summaryrefslogtreecommitdiff
path: root/web/views/key.erb
blob: 42434d5484b4dacaf008ab9f15bdc536a1e7a3c1 (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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<div class="pre">
    <form id="filter-form">
        <label for="filter"><%= h(t.pages.key.filter.label) %></label>
        <select id="filter" name="filter">
            <option value="all"<%=       @sel['all']       %>><%= h(t.pages.key.filter.none) %></option>
            <option value="nodes"<%=     @sel['nodes']     %>><%= h(t.pages.key.filter.nodes) %></option>
            <option value="ways"<%=      @sel['ways']      %>><%= h(t.pages.key.filter.ways) %></option>
            <option value="relations"<%= @sel['relations'] %>><%= h(t.pages.key.filter.relations) %></option>
        </select>
    </form>
    <form id="list-form">
        <select id="list" name="list">
            <option value="title" selected="selected" style="color: #000000"><%= h(t.comparison.list) %> (0 <%= h(t.comparison.items) %>)</option>
            <option value="add"><%= h(t.comparison.add_key) %></option>
            <option value="clear"><%= h(t.comparison.clear) %></option>
            <option value="compare"><%= h(t.comparison.compare) %></option>
        </select>
    </form>
    <div id="tools" class="no-print">
        <% if @count_all_values <= TaginfoConfig.get('xapi.max_results', 1000) %>
            <%= xapi_link(@filter_xapi, @key) %> <%= josm_link(@filter_xapi, @key) %>
        <% else %>
            <span class="button disabled" title="<%= h(t.pages.key.button_disabled) %>">XAPI</span>
            <span class="button disabled" title="<%= h(t.pages.key.button_disabled) %>">JOSM</span>
        <% end %>
        <% if @count_all_values <= TaginfoConfig.get('level0.max_results', 10) %>
            <%= level0_link() %>
        <% else %>
            <span class="button disabled" title="<%= h(t.pages.key.button_disabled) %>">Level0 Editor</span>
        <% end %>
        <%= turbo_link(@count_all_values, @filter_type, @key) %>
    </div>
    <h1></h1>
    <p><%= @desc %></p>
</div>
<div id="tabs">
    <ul class="no-print">
        <li><a href="#overview"><%= h(t.taginfo.overview) %></a></li>
        <li><a href="#values"><%= h(t.osm.values) %></a></li>
        <li><a href="#combinations"><%= h(t.taginfo.key_combinations) %></a></li>
<% if TaginfoConfig.get('user_interface.key_page.show_tab_similar', false) %>
        <li><a href="#similar"><%= h(t.pages.key.similar.tab) %></a></li>
<% end %>
        <li><a href="#map"><%= h(t.taginfo.map) %></a></li>
        <li><a href="#wiki"><%= h(t.sources.wiki.name) %></a></li>
        <li><a href="#projects"><%= h(t.taginfo.projects) %></a></li>
    </ul>
    <div id="overview">
        <div style="float: right; text-align: center; padding-left: 20px;">
            <p><%= h(t.pages.key.overview.distribution_of_values) %></p>
            <div class="canvas" id="canvas-values"></div>
        </div>
<% if @image_url %>
        <div class="wiki_image">
            <img src="<%= @image_url.sub(/^http:/, '') %>" alt=""/>
        </div>
<% end %>
        <h2><%= h(t.taginfo.overview) %></h2>
        <table id="grid-overview">
        </table>
        <p><span title="<%= h(t.pages.key.overview.no_endorsement) %>" tipsy="n"><%= t.pages.key.overview.objects_last_edited_by(@user_count.to_s_with_ts) %></span></p>
    </div>
    <div id="values">
        <h2><%= h(t.pages.key.values_used) %></h2>
        <div>
            <table id="grid-values">
            </table>
        </div>
    </div>
    <div id="combinations">
        <h2><%= h(t.pages.key.other_keys_used.title) %></h2>
        <table id="grid-keys">
        </table>
    </div>
<% if TaginfoConfig.get('user_interface.key_page.show_tab_similar', false) %>
    <div id="similar">
        <h2><%= h(t.pages.key.similar.title) %></h2>
        <table id="grid-similar">
        </table>
    </div>
<% end %>
    <div id="map">
        <h2><%= h(t.pages.key.geographic_distribution.title) %></h2>
        <% if @filter_type == 'all' %>
            <div style="background-image: url(<%= TaginfoConfig.get('geodistribution.background_image') %>); background-repeat: no-repeat; background-position: 1px 1px;"/>
                <img class="map" src="/api/4/key/distribution/nodes?key=<%= @key_uri %>" alt="" width="<%= @img_width %>" height="<%= @img_height %>" style="position: absolute;"/>
                <img class="map" src="/api/4/key/distribution/ways?key=<%= @key_uri %>" alt="" width="<%= @img_width %>" height="<%= @img_height %>"/>
                <div class="note"><%= TaginfoConfig.get('geodistribution.image_attribution') %></div>
            </div>
        <% elsif @filter_type == 'nodes' %>
            <div style="background-image: url(<%= TaginfoConfig.get('geodistribution.background_image') %>); background-repeat: no-repeat; background-position: 1px 1px;"/>
                <img class="map" src="/api/4/key/distribution/nodes?key=<%= @key_uri %>" alt="" width="<%= @img_width %>" height="<%= @img_height %>"/>
                <div class="note"><%= TaginfoConfig.get('geodistribution.image_attribution') %></div>
            </div>
        <% elsif @filter_type == 'ways' %>
            <div style="background-image: url(<%= TaginfoConfig.get('geodistribution.background_image') %>); background-repeat: no-repeat; background-position: 1px 1px;"/>
                <img class="map" src="/api/4/key/distribution/ways?key=<%= @key_uri %>" alt="" width="<%= @img_width %>" height="<%= @img_height %>"/>
                <div class="note"><%= TaginfoConfig.get('geodistribution.image_attribution') %></div>
            </div>
        <% elsif @filter_type == 'relations' %>
            <p class="empty"><%= h(t.pages.key.geographic_distribution.relations) %></p>
        <% end %>
    </div>
    <div id="wiki">
        <h2><%= h(t.pages.key.wiki_pages.title) %></h2>
        <% if @wiki_count > 0 %>
            <table id="grid-wiki">
            </table>
        <% else %>
            <p class="empty"><%= h(t.pages.key.wiki_pages.none_found) %></p>
            <p><a class="extlink" target="_blank" rel="nofollow" href="//wiki.openstreetmap.org/w/index.php?action=edit&title=Key:<%= @key_uri %>"><%= h(t.pages.key.wiki_pages.create) %></a></p>
        <% end %>
    </div>
    <div id="projects">
        <h2><%= h(t.pages.key.projects.title) %></h2>
        <table id="grid-projects">
        </table>
    </div>
</div>
<% javascript do
    JS.raw(<<"JAVASCRIPT")
function redraw_chart() {
    jQuery('#canvas-values').html('');
    var max_height = jQuery(window).height() - 300;
    create_chart({
        key: #{ @key.to_json },
        width: 160,
        height: Math.min(440, max_height),
        max: #{ @count_all_values },
        data: #{ @prevalent_values.to_json() }
    });
}
function page_init2() {
    var filter = #{ @filter_type.to_json },
        key = #{ @key.to_json };
    jQuery('h1').html(fmt_key(key));

    if (cookies_enabled()) {
        comparison_list_update(key);
        jQuery('#list').bind('change', function() {
            comparison_list_change(key);
        });
    } else {
        jQuery('#list-form').html('<span class="empty" style="position: relative; top: 1px;">Enable cookies for comparison function!</span>');
    }

    jQuery('#level0_button').bind('click', function() {
        return level0_editor('#{ TaginfoConfig.get('level0.overpass_url_prefix') }', '#{ TaginfoConfig.get('level0.level0_url_prefix') }', filter, key, undefined);
    });

    init_tabs([key, filter, #{ r18n.locale.code.to_json }]);

    redraw_chart();
    jQuery(window).resize(redraw_chart);
}
JAVASCRIPT
end
%>