]> git.openstreetmap.org Git - rails.git/blob - app/views/layouts/_banner.html.erb
a1091c887acdc0c0971756ec122ffa29d668e93b
[rails.git] / app / views / layouts / _banner.html.erb
1 <% active_banners = {
2   :sotmus2016 => {
3     :alt => 'State of the Map US 2016',
4     :link => 'http://stateofthemap.us/',
5     :img => 'banners/sotmus-2016.jpg'
6   },
7   :sotm2016 => {
8     :alt => 'State of the Map 2016',
9     :link => 'http://2016.stateofthemap.org/',
10     :img => 'banners/sotm-2016.jpg'
11   }
12 }
13
14 bannerSym = nil
15 cookieStr = nil
16 queuePos = 9999
17
18 # pick least recently seen banner that is not hidden
19 active_banners.each_key do |k|
20   c = '_osm_banner_' + k.to_s
21   val = cookies[c.to_sym] || 0
22   next if val == 'hide'
23
24   if val.to_i > 0
25     cookies[c.to_sym] = val.to_i - 1
26   end
27
28   if val.to_i <= queuePos
29     bannerSym = k
30     cookieStr = c
31     queuePos = val.to_i
32   end
33 end
34
35 unless bannerSym.nil?
36   banner = active_banners[bannerSym]
37   cookies[cookieStr.to_sym] = active_banners.length   # bump to end of queue
38 %>
39 <%= link_to (image_tag banner[:img], :alt => banner[:alt], :title => banner[:alt]), banner[:link] %>
40 <div class="close-wrap" id="<%= cookieStr %>"><span class="icon close"></span></div>
41 <% end %>