aboutsummaryrefslogtreecommitdiff
path: root/web/views/compare.erb
blob: aae10651e8c8ef4d0e331d1ed3e214f0e41edb19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<div class="pre">
    <h1 class="section"><%= h(t.taginfo.comparison) %></h1>
</div>
<% if @data.size == 0 %>
<p class="empty"><%= h(t.pages.compare.nothing_to_compare) %></p>
<% else %>
<table class="comparison">
    <tr>
        <% @data.each_with_index do |data, num| %>
        <td class="data first item<%= num %>" style="width: <%= 100/@data.size %>%">
            <a class="close ui-icon ui-icon-closethick" href="#"></a>
            <h2></h2>
            <p><%= data[:desc] %></p>
        </td>
        <% end %>
    </tr>
    <tr>
        <% @data.each_with_index do |data, num| %>
        <td class="data item<%= num %>">
            <table class="compstat">
                <tr>
                    <td class="spacer"></td>
                    <th><img width="16" height="16" alt="" src="/img/types/all.16.png"/> <%= h(t.osm.all) %></th>
                    <td><%= data[:count_all].to_s_with_ts %></td>
                    <td class="spacer"></td>
                </tr>
                <tr>
                    <td class="spacer"></td>
                    <th><img width="16" height="16" alt="" src="/img/types/node.16.png"/> <%= h(t.osm.nodes) %></th>
                    <td><%= data[:count_nodes].to_s_with_ts %></td>
                    <td class="spacer"></td>
                </tr>
                <tr>
                    <td class="spacer"></td>
                    <th><img width="16" height="16" alt="" src="/img/types/way.16.png"/> <%= h(t.osm.ways) %></th>
                    <td><%= data[:count_ways].to_s_with_ts %></td>
                    <td class="spacer"></td>
                </tr>
                <tr>
                    <td class="spacer"></td>
                    <th><img width="16" height="16" alt="" src="/img/types/relation.16.png"/> <%= h(t.osm.relations) %></th>
                    <td><%= data[:count_relations].to_s_with_ts %></td>
                    <td class="spacer"></td>
                </tr>
            </table>
        </td>
        <% end %>
    </tr>
    <tr>
        <% @data.each_with_index do |data, num| %>
        <td class="data item<%= num %> prevalent_values">
            <p><b></b></p>
            <div></div>
        </td>
        <% end %>
    </tr>
    <tr>
        <% @data.each_with_index do |data, num| %>
        <td class="data item<%= num %> wiki">
            <p><b><%= data[:value].nil? ? h(t.pages.key.wiki_pages.title) : h(t.pages.tag.wiki_pages.title) %>:</b></p>
            <%= data[:wiki_pages].map{ |lang| '<span class="lang" title="' + ::Language[lang].native_name.to_s + '">' + lang + '</span>' }.join(' ') %>
        </td>
        <% end %>
    </tr>
    <tr>
        <% @data.each_with_index do |data, num| %>
        <td class="data item<%= num %> map">
            <% if data[:has_map] %>
            <div style="background-image: url(<%= TaginfoConfig.get('geodistribution.background_image') %>); background-repeat: no-repeat; background-position: center 4px; background-size: <%= @img_width %>px <%= @img_height %>px; position: relative;"/>
                <% key_or_tag = data[:value].nil? ? 'key' : 'tag' %>
                <img class="map" src="/api/4/<%= key_or_tag %>/distribution/nodes?key=<%= data[:key] %><%= data[:value].nil? ? '' : ('&amp;value=' + data[:value]) %>" alt="" width="<%= @img_width %>" height="<%= @img_height %>" style="position: absolute;"/>
                <img class="map" src="/api/4/<%= key_or_tag %>/distribution/ways?key=<%= data[:key] %><%= data[:value].nil? ? '' : ('&amp;value=' + data[:value]) %>" alt="" width="<%= @img_width %>" height="<%= @img_height %>"/>
                <div class="note"><%= TaginfoConfig.get('geodistribution.image_attribution') %></div>
            </div>
            <% end %>
        </td>
        <% end %>
    </tr>
    <tr>
        <% @data.each_with_index do |data, num| %>
        <td class="data last"></td>
        <% end %>
    </tr>
</table>
<% end %>
<% javascript do
    JS.raw(<<"JAVASCRIPT")
function page_init2() {
    var data = #{ @data.to_json };
    var items = []
    jQuery.each(data, function(index, item) {
        items.push([ item.key, (item.value === null ? undefined : item.value) ]);
    });
    set_comparison_list(items);
    jQuery.each(data, function(index, item) {
        var datac = [];
        jQuery.each(data, function(i, item) {
            if (i != index) {
                datac.push([item['key'], item['value']]);
            }
        });
        jQuery('.item' + index + ' a.close').attr('href', comparison_list_url(datac));
        if (item.value) {
            jQuery('.item' + index + ' h2').html(link_to_tag(item.key, item.value));
        } else {
            jQuery('.item' + index + ' h2').html(link_to_key(item.key));
            jQuery('.item' + index + '.prevalent_values p b').html('#{ h(t.misc.prevalent_values)}:');
            jQuery('.item' + index + '.prevalent_values div').html(fmt_prevalent_value_list(item.key, item.prevalent_values));
        }
    });
    jQuery('div.prevalent_values a').tipsy({ opacity: 1, delayIn: 500, gravity: 'w' });
    jQuery('span.lang').tipsy({ opacity: 1, delayIn: 500, gravity: 'n' });
}
JAVASCRIPT
end
%>