summaryrefslogtreecommitdiff
path: root/web/views/key.erb
blob: 98e28e911d257a789d15a055dfb73ec247b9b5f2 (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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<div class="pre">
    <div id="tools">
        <% if @count_all_values < 1000 %>
            <%= xapi_link('*', @key) %> <%= josm_link('*', @key) %>
        <% else %>
            <span class="button disabled" title="Button disabled, because there are too many objects with this key"><img src="/img/link-extern-disabled.gif" width="14" height="10" alt=""/>XAPI</span>
            <span class="button disabled" title="Button disabled, because there are too many objects with this key"><img src="/img/link-extern-disabled.gif" width="14" height="10" alt=""/>JOSM</span>
        <% end %>
    </div>
    <form id="filter-form">
        <label for="filter"><%= t.pages.key.filter.label %></label>
        <select id="filter" name="filter">
            <option value="all"<%=       @sel['all']       %>><%= t.pages.key.filter.none %></option>
            <option value="nodes"<%=     @sel['nodes']     %>><%= t.pages.key.filter.nodes %></option>
            <option value="ways"<%=      @sel['ways']      %>><%= t.pages.key.filter.ways %></option>
            <option value="relations"<%= @sel['relations'] %>><%= t.pages.key.filter.relations %></option>
        </select>
    </form>
    <h1><%= @key_pp %></h1>
    <p><%= @desc %></p>
</div>
<div id="tabs">
    <ul>
        <li><a href="#overview"><%= t.taginfo.overview %></a></li>
        <li><a href="#values"><%= t.osm.values %></a></li>
        <li><a href="#keys"><%= t.taginfo.key_combinations %></a></li>
        <li><a href="#map"><%= t.taginfo.map %></a></li>
        <li><a href="#wiki"><%= t.sources.wiki.name %></a></li>
        <li><a href="#josm"><%= t.sources.josm.name %></a></li>
    </ul>
    <div id="overview">
        <h2><%= t.taginfo.overview %></h2>
        <table id="grid-overview">
        </table>
        <p>Objects with this key are owned by <%= @user_count %> different users.</p>
    </div>
    <div id="values">
        <h2><%= t.pages.key.values_used %></h2>
        <div class="canvas" id="canvas-values" style="float: right;"></div>
        <div>
            <table id="grid-values">
            </table>
        </div>
    </div>
    <div id="keys">
        <h2><%= t.pages.key.other_keys_used.title %></h2>
        <table id="grid-keys">
        </table>
    </div>
    <div id="map">
        <h2><%= 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;"/>
                <img src="/api/3/db/keys/distribution/nodes?key=<%= @key_uri %>" alt="" width="<%= @img_width %>" height="<%= @img_height %>" style="position: absolute;"/>
                <img src="/api/3/db/keys/distribution/ways?key=<%= @key_uri %>" alt="" width="<%= @img_width %>" height="<%= @img_height %>"/>
            </div>
        <% elsif @filter_type == 'nodes' %>
            <div style="background-image: url(<%= TaginfoConfig.get('geodistribution.background_image') %>); background-repeat: no-repeat;"/>
                <img src="/api/3/db/keys/distribution/nodes?key=<%= @key_uri %>" alt="" width="<%= @img_width %>" height="<%= @img_height %>"/>
            </div>
        <% elsif @filter_type == 'ways' %>
            <div style="background-image: url(<%= TaginfoConfig.get('geodistribution.background_image') %>); background-repeat: no-repeat;"/>
                <img src="/api/3/db/keys/distribution/ways?key=<%= @key_uri %>" alt="" width="<%= @img_width %>" height="<%= @img_height %>"/>
            </div>
        <% elsif @filter_type == 'relations' %>
            <p><i><%= t.pages.key.geographic_distribution.relations %></i></p>
        <% end %>
    </div>
    <div id="wiki">
        <h2><%= t.pages.key.wiki_pages.title %></h2>
        <% if @wiki_count > 0 %>
            <table id="grid-wiki">
            </table>
        <% else %>
            <p><i><%= t.pages.key.wiki_pages.none_found %>.</i></p>
            <p>[<a href="http://wiki.openstreetmap.org/w/index.php?action=edit&title=Key:<%= @key_uri %>">Create wiki page</a>]</p>
        <% end %>
    </div>
    <div id="josm">
        <h2><%= t.pages.key.josm_rules.title %></h2>
<!--        <form>
            <label for="josm-style"><%= t.pages.key.josm_rules.choice %></label>
            <select id="josm-style" name="josm-style">
                <option>Standard</option>
            </select>
        </form>-->
       <table id="grid-josm">
       </table>
    </div>
<!--    <div id="merkaartor">
        <p>Type: <%= @merkaartor_type %></p>
        <% if @merkaartor_link %>
            <p>Link: XXX</p>
        <% end %>
        <p>
            <%= @merkaartor_images %>
        </p>
        <h3>Values</h3>
        <%= @merkaartor_values.map{ |value| link_to_value(@key, value) }.join(', ') %>
        <h3>Descriptions</h3>
        <table>
            <% @merkaartor_desc.each do |desc| %>
                <tr><td><%= desc['lang'] %></td><td><%= desc['description'] %></td></tr>
            <% end %>
        </table>
    </div>-->
</div>
<iframe id="josmiframe" name="josmiframe"></iframe>
<% javascript do
    JQuery.ready do
        JS.raw(<<"JAVASCRIPT")

jQuery('#josm_button').bind('click', function() {
    jQuery('#josmiframe')[0].src = jQuery('#josm_button')[0].href;
    return false;
});

jQuery('#filter').bind('change', function() {
    var value = this.value;

    var qs = jQuery.getQueryString;
    qs['filter'] = value;

    window.location.search = jQuery.param(qs);
});

var tabs = jQuery('#tabs').tabs({
    show: function(event, ui) { 
        resize_wrapper();
        window.location.hash = ui.tab.hash;
        if (ui.tab.hash.substring(1) in create_flexigrid_for.key) {
            create_flexigrid_for.key[ui.tab.hash.substring(1)](#{ @key.to_json }, #{ @filter_type.to_json });
        }
    }
});

var data = #{ @prevalent_values.to_json() };

var w=160, h=440;

var vis = new pv.Panel()
    .canvas('canvas-values')
    .width(w)
    .height(h + 20);

var scale = pv.Scale.linear(0, #{ @count_all_values }).range(0, h);

vis.add(pv.Layout.Stack)
    .bottom(10)
    .order('reverse')
    .layers(data)
    .x(10)
    .y(function(d) { return scale(d.count); })
  .layer.add(pv.Bar)
    .width(20)
    .cursor(function() {
        return this.data().value == '(other)' ? 'default' : 'pointer';
    })
    .event('click', function() {
        if (this.data().value != '(other)') {
            window.location = url_to_value(#{ @key_json }, this.data().value);
        }
    })
  .anchor('left')
    .add(pv.Label)
    .left(30)
    .text(function(d) { return d.value; });

vis.render();

JAVASCRIPT
    end
end
%>