<% osm = @trans.t.osm misc = @trans.t.misc taginfo = @trans.t.taginfo page = @trans.t.pages.tag %> function link_to_key_or_tag(key, value) { var link = link_to_key(key) + '='; if (value && value != '') { link += link_to_value(key, value, { 'class': 'pref' }); } else { link += '*'; } return link; } var create_flexigrid_for = { overview: function(key, value, filter_type) { create_flexigrid('grid-overview', { url: '/api/4/tag/stats?key=' + encodeURIComponent(key) + '&value=' + encodeURIComponent(value), colModel: [ { display: '<%= h(misc.object_type) %>', name: 'type', width: 100, sortable: true }, { display: '<%= h(page.number_objects) %>', name: 'count', width: 260, sortable: true, align: 'center' } ], usepager: false, useRp: false, preProcess: function(data) { return { total: 4, page: 1, rows: jQuery.map(data.data, function(row, i) { return { 'cell': [ fmt_type_image(row.type), fmt_value_with_percent(row.count, row.count_fraction) ]}; }) }; } }); }, combinations: function(key, value, filter_type) { create_flexigrid('grid-combinations', { url: '/api/4/tag/combinations?key=' + encodeURIComponent(key) + '&value=' + encodeURIComponent(value) + '&filter=' + encodeURIComponent(filter_type), colModel: [ { display: '<%= h(misc.count) %> →', name: 'to_count', width: 260, sortable: true, align: 'center' }, { display: '<%= h(page.other_tags_used.other) %>', name: 'other_tag', width: 400, sortable: true }, { display: '→ <%= h(misc.count) %>', name: 'from_count', width: 260, sortable: true, align: 'center' } ], searchitems: [ { display: '<%= h(page.other_tags_used.other) %>', name: 'other_tag' } ], sortname: 'to_count', sortorder: 'desc', preProcess: function(data) { data.rows = jQuery.map(data.data, function(row, i) { return { 'cell': [ fmt_value_with_percent(row.together_count, row.to_fraction), link_to_key_or_tag(row.other_key, row.other_value), fmt_value_with_percent(row.together_count, row.from_fraction), ] }; }); return data; } }); }, wiki: function(key, value) { create_flexigrid('grid-wiki', { url: '/api/4/tag/wiki_pages?key=' + encodeURIComponent(key) + '&value=' + encodeURIComponent(value), colModel: [ { display: '<%= h(misc.language) %>', name: 'lang', width: 150, sortable: false }, { display: '<%= h(page.wiki_pages.wiki_page) %>', name: 'title', width: 200, sortable: false, align: 'right' }, { display: '<%= h(misc.description) %>', name: 'description', width: 400, sortable: false }, { display: '<%= h(misc.image) %>', name: 'image', width: 120, sortable: false }, { display: '<%= h(osm.objects) %>', name: 'objects', width: 80, sortable: false }, { display: '<%= h(page.wiki_pages.implied_tags) %>', name: 'tags_implied', width: 120, sortable: false }, { display: '<%= h(page.wiki_pages.combined_tags) %>', name: 'tags_combination', width: 120, sortable: false }, { display: '<%= h(page.wiki_pages.linked_tags) %>', name: 'tags_linked', width: 220, sortable: false } ], usepager: false, useRp: false, preProcess: function(data) { return { total: data.size, page: 1, rows: jQuery.map(data, function(row, i) { return { 'cell': [ fmt_language(row.lang, row.language, row.language_en), link_to_wiki(row.title), html_escape(row.description), fmt_wiki_image_popup(row.image), fmt_type_icon('node', row.on_node) + fmt_type_icon('way', row.on_way) + fmt_type_icon('area', row.on_area) + fmt_type_icon('relation', row.on_relation), fmt_key_or_tag_list(row.tags_implies), fmt_key_or_tag_list(row.tags_combination), fmt_key_or_tag_list(row.tags_linked) ]}; }) }; } }); }, projects: function(key, value, filter_type) { create_flexigrid('grid-projects', { url: '/api/4/tag/projects?key=' + encodeURIComponent(key) + '&value=' + encodeURIComponent(value) + '&filter=' + encodeURIComponent(filter_type), colModel: [ { display: '<%= h(taginfo.project) %>', name: 'project_name', width: 280, sortable: true }, { display: '<%= h(osm.tag) %>', name: 'tag', width: 220, sortable: true }, { display: '<%= h(osm.objects) %>', name: 'objects', width: 80, sortable: false }, { display: '<%= h(page.projects.description) %>', name: 'description', width: 600, sortable: false, align: 'left' } ], searchitems: [ { display: '<%= h(taginfo.project) %>/<%= h(osm.value) %>', name: 'project_value' } ], sortname: 'tag', sortorder: 'asc', preProcess: function(data) { data.rows = jQuery.map(data.data, function(row, i) { return { 'cell': [ link_to_project(row.project_id, row.project_name, row.project_icon_url), row.value ? link_to_tag(row.key, row.value) : (link_to_key(row.key) + '=*'), fmt_type_icon('node', row.on_node) + fmt_type_icon('way', row.on_way) + fmt_type_icon('area', row.on_area) + fmt_type_icon('relation', row.on_relation), project_tag_desc(row.description, row.icon_url, row.doc_url) ] }; }); return data; } }); } }; function page_init() { activate_josm_button(); jQuery('#filter').bind('change', function() { var value = this.value; var qs = jQuery.getQueryString; qs['filter'] = value; window.location.search = jQuery.param(qs); }); page_init2(); }