update the design a bit
This commit is contained in:
parent
89dbd6532a
commit
35d9a0e910
3 changed files with 42 additions and 6 deletions
25
app.rb
25
app.rb
|
@ -5,8 +5,9 @@ require './environments'
|
|||
|
||||
set :public_folder, 'public'
|
||||
|
||||
# CONTROLLER
|
||||
get '/' do
|
||||
@raids = Raid.all
|
||||
@raids = Raid.all.reverse
|
||||
erb :index
|
||||
end
|
||||
|
||||
|
@ -24,6 +25,28 @@ post '/' do
|
|||
end
|
||||
end
|
||||
|
||||
#HELPERS
|
||||
def readable_number(value)
|
||||
numbers.each do |number, symbol|
|
||||
if value.to_f / number.to_f > 1
|
||||
return (value.to_f / number.to_f).to_s + symbol
|
||||
end
|
||||
end
|
||||
|
||||
return value
|
||||
end
|
||||
|
||||
def numbers
|
||||
{
|
||||
'1000000000000000' => 'Q',
|
||||
'1000000000000' => 'T',
|
||||
'1000000000' => 'B',
|
||||
'1000000' => 'M',
|
||||
'1000' => 'K'
|
||||
}
|
||||
end
|
||||
|
||||
# MODEL
|
||||
class Raid < ActiveRecord::Base
|
||||
def money=(value)
|
||||
value = value.to_s.gsub(/[$,]/, '').to_f
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<h2>Index</h2>
|
||||
|
||||
<table border="1">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Attacker</td>
|
||||
|
@ -15,8 +15,8 @@
|
|||
<tr>
|
||||
<td><%= raid.attacker %></td>
|
||||
<td><%= raid.defender %></td>
|
||||
<td><%= raid.soldiers.to_f / 1000000000000.0 %>T</td>
|
||||
<td><%= raid.money.to_f / 1000000000000.0 %>T</td>
|
||||
<td><%= readable_number(raid.soldiers) %></td>
|
||||
<td><%= readable_number(raid.money) %></td>
|
||||
<td><%= raid.created_at %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
|
|
@ -1,10 +1,23 @@
|
|||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta http-equiv="refresh" content="30" />
|
||||
<title>Raids</title>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%= yield %>
|
||||
<div class="container">
|
||||
<nav class="navbar navbar-default">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header"><a class="navbar-brand" href="#">ClickClickMafia Raids</a></div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<%= yield %>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue