feat: add weather forecasting
This commit is contained in:
parent
6eea0dc29f
commit
705e7b1dc0
20 changed files with 181 additions and 19 deletions
|
@ -1,4 +1,4 @@
|
|||
<main id="nm-list">
|
||||
<div id="nm-list">
|
||||
<% APP_DATA[instance.zone.to_sym][:nms].each do |nm| %>
|
||||
<% is_popped = instance.pops.filter { |pop| (Time.current - 120.minutes) <= pop.created_at }.any? { |pop| pop.name == nm[:name].parameterize } %>
|
||||
<section class="<%= class_names(popped: is_popped) %>">
|
||||
|
@ -10,7 +10,7 @@
|
|||
<span class="badge">LV<%= nm[:level].to_s.rjust(2, "0") %></span>
|
||||
<%= nm[:name] %>
|
||||
<% if nm[:weather] %>
|
||||
<img src="/<%= nm[:weather] %>.png" title="during <%= nm[:weather] %> only" width="15" />
|
||||
<img src="/weather/<%= nm[:weather] %>.png" title="during <%= nm[:weather] %> only" width="15" />
|
||||
<% end %>
|
||||
</h3>
|
||||
<div class="spawn-info">
|
||||
|
@ -20,7 +20,7 @@
|
|||
<span title="only at night">🌙</span>
|
||||
<% end %>
|
||||
<% if nm[:spawned_by][:weather] %>
|
||||
<img src="/<%= nm[:spawned_by][:weather] %>.png" title="during <%= nm[:spawned_by][:weather] %> only" width="15" />
|
||||
<img src="/weather/<%= nm[:spawned_by][:weather] %>.png" title="during <%= nm[:spawned_by][:weather] %> only" width="15" />
|
||||
<% end %>
|
||||
<small class="badge">LV<%= nm[:spawned_by][:level].to_s.rjust(2, "0") %></small>
|
||||
</div>
|
||||
|
@ -52,4 +52,4 @@
|
|||
</div>
|
||||
</section>
|
||||
<% end %>
|
||||
</main>
|
||||
</div>
|
||||
|
|
|
@ -22,7 +22,26 @@
|
|||
</div>
|
||||
</header>
|
||||
|
||||
<%= render partial: "list", locals: { instance: @instance } %>
|
||||
<main>
|
||||
<%= render partial: "list", locals: { instance: @instance } %>
|
||||
|
||||
<div class="sidebar">
|
||||
<div class="weather-list">
|
||||
<% forecast = Weather.forecast(@instance.zone.to_sym) %>
|
||||
<div class="weather">
|
||||
<img src="/weather/<%= forecast[0][:curr_weather] %>.png" width="25" title="<%= forecast[0][:weather_name] %>" />
|
||||
<div>now</div>
|
||||
</div>
|
||||
<% 4.times do |i| %>
|
||||
»
|
||||
<div class="weather">
|
||||
<img src="/weather/<%= forecast[i + 1][:curr_weather] %>.png" width="25" title="<%= forecast[i + 1][:weather_name] %>" />
|
||||
<div><%= ((forecast[i + 1][:time] - Time.now.utc) / 1.minutes).floor %>m</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<%= javascript_include_tag "list" %>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue