diff options
author | Jochen Topf <jochen@topf.org> | 2013-01-17 10:02:46 +0100 |
---|---|---|
committer | Jochen Topf <jochen@topf.org> | 2013-01-17 10:02:46 +0100 |
commit | dc789ec05a0870123c9c7550251de5a5d48f3788 (patch) | |
tree | 24af94c2a2e954b88df2e699997c32618589b3ca /web | |
parent | 5d4abbc9e3a634afa0ee18d8ea55c3dd6cd1a8cd (diff) | |
download | taginfo-dc789ec05a0870123c9c7550251de5a5d48f3788.tar taginfo-dc789ec05a0870123c9c7550251de5a5d48f3788.tar.gz |
Cleanup batch of print_* functions
Diffstat (limited to 'web')
-rw-r--r-- | web/public/js/taginfo.js | 55 | ||||
-rw-r--r-- | web/viewsjs/key.js.erb | 14 | ||||
-rw-r--r-- | web/viewsjs/reports/frequently_used_keys_without_wiki_page.js.erb | 2 | ||||
-rw-r--r-- | web/viewsjs/reports/wiki_pages_about_non_existing_keys.js.erb | 2 | ||||
-rw-r--r-- | web/viewsjs/tag.js.erb | 14 |
5 files changed, 47 insertions, 40 deletions
diff --git a/web/public/js/taginfo.js b/web/public/js/taginfo.js index ec79458..42058bd 100644 --- a/web/public/js/taginfo.js +++ b/web/public/js/taginfo.js @@ -217,11 +217,32 @@ function span(text, c) { return tag('span', text, { 'class': c }); } +function empty(text) { + return span(text, 'empty'); +} + function hover_expand(text) { return span(text, 'overflow'); } -function img_popup(image) { +/* ============================ */ + +function fmt_wiki_link(title, options) { + if (title == '') { + return ''; + } + + var path; + if (options && options.edit) { + path = 'w/index.php?action=edit&title=' + title; + } else { + path = 'wiki/' + title; + } + + return link('http://wiki.openstreetmap.org/' + path, title, { target: '_blank', 'class': 'extlink' }); +} + +function fmt_img_popup(image) { var w = image.width, h = image.height, max_size = 180, @@ -233,36 +254,22 @@ function img_popup(image) { if (w < max_size) { title = html_escape('<div class="img_popup" style="width: ' + w + 'px; height:' + h + 'px;"><img src="' + image.image_url + '"/></div>'); } else { - title = html_escape('<div class="img_popup" style="width: ' + thumb_size + 'px; height:' + other_size + 'px;"><img src="' + url + '"/></div>'); - } - - return '<span class="overflow" tipsy_html="s" title="' + title + '">' + print_wiki_link(image.title) + '</span>'; -} - -function empty(text) { - return span(text, 'empty'); -} - -function print_wiki_link(title, options) { - if (title == '') { - return ''; - } - - if (options && options.edit) { - path = 'w/index.php?action=edit&title=' + title; - } else { - path = 'wiki/' + title; + title = html_escape('<div class="img_popup" style="width: ' + thumb_size + 'px; height:' + other_size + 'px;"><img src="' + url + '"/></div>'); } - return link('http://wiki.openstreetmap.org/' + path, title, { target: '_blank', 'class': 'extlink' }); + return '<span class="overflow" tipsy_html="s" title="' + title + '">' + fmt_wiki_link(image.title) + '</span>'; } -function print_language(code, native_name, english_name) { +function fmt_language(code, native_name, english_name) { return tag('span', code, { 'class': 'lang', title: native_name + ' (' + english_name + ')' }) + ' ' + native_name; } -function print_type_icon(type, on_or_off) { - return on_or_off ? '<img src="/img/types/' + type + '.16.png" alt="yes" width="16" height="16"/> ' : '<img src="/img/types/none.16.png" alt="no" width="16" height="16"/> '; +function fmt_type_icon(type, on_or_off) { + return '<img src="/img/types/' + + (on_or_off ? type : 'none') + + '.16.png" alt="' + + (on_or_off ? 'yes' : 'no') + + '" width="16" height="16"/> '; } function print_josm_value(key, value, value_bool) { diff --git a/web/viewsjs/key.js.erb b/web/viewsjs/key.js.erb index b0a67e4..8bbf631 100644 --- a/web/viewsjs/key.js.erb +++ b/web/viewsjs/key.js.erb @@ -101,14 +101,14 @@ var create_flexigrid_for = { page: 1, rows: jQuery.map(data, function(row, i) { return { 'cell': [ - print_language(row.lang, row.language, row.language_en), - print_wiki_link(row.title), + fmt_language(row.lang, row.language, row.language_en), + fmt_wiki_link(row.title), row.description, - row.image.title ? img_popup(row.image) : empty('<%= misc.no_image %>'), - print_type_icon('node', row.on_node) + - print_type_icon('way', row.on_way) + - print_type_icon('area', row.on_area) + - print_type_icon('relation', row.on_relation), + row.image.title ? fmt_img_popup(row.image) : empty('<%= misc.no_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), print_key_or_tag_list(row.tags_implies), print_key_or_tag_list(row.tags_combination), print_key_or_tag_list(row.tags_linked) diff --git a/web/viewsjs/reports/frequently_used_keys_without_wiki_page.js.erb b/web/viewsjs/reports/frequently_used_keys_without_wiki_page.js.erb index d405fe5..ead154c 100644 --- a/web/viewsjs/reports/frequently_used_keys_without_wiki_page.js.erb +++ b/web/viewsjs/reports/frequently_used_keys_without_wiki_page.js.erb @@ -22,7 +22,7 @@ function create_flexigrid_with_option(english) { preProcess: function(data) { data.rows = jQuery.map(data.data, function(row, i) { return { 'cell': [ - print_wiki_link('Key:' + row.key, { edit: true }), + fmt_wiki_link('Key:' + row.key, { edit: true }), link_to_key(row.key), print_with_ts(row.count_all), print_with_ts(row.users_all), diff --git a/web/viewsjs/reports/wiki_pages_about_non_existing_keys.js.erb b/web/viewsjs/reports/wiki_pages_about_non_existing_keys.js.erb index 54d1d14..b19ab94 100644 --- a/web/viewsjs/reports/wiki_pages_about_non_existing_keys.js.erb +++ b/web/viewsjs/reports/wiki_pages_about_non_existing_keys.js.erb @@ -21,7 +21,7 @@ function page_init() { data.rows = jQuery.map(data.data, function(row, i) { var wikilinks = []; jQuery(row.wikipages).each(function(i, wikipage) { - var w = print_wiki_link(wikipage.title); + var w = fmt_wiki_link(wikipage.title); if (wikipage.type == 'redirect') { w += ' (REDIRECT)'; } diff --git a/web/viewsjs/tag.js.erb b/web/viewsjs/tag.js.erb index a58d8f0..d04a200 100644 --- a/web/viewsjs/tag.js.erb +++ b/web/viewsjs/tag.js.erb @@ -83,14 +83,14 @@ var create_flexigrid_for = { page: 1, rows: jQuery.map(data, function(row, i) { return { 'cell': [ - print_language(row.lang, row.language, row.language_en), - print_wiki_link(row.title), + fmt_language(row.lang, row.language, row.language_en), + fmt_wiki_link(row.title), row.description, - row.image.title ? img_popup(row.image) : empty('<%= misc.no_image %>'), - print_type_icon('node', row.on_node) + - print_type_icon('way', row.on_way) + - print_type_icon('area', row.on_area) + - print_type_icon('relation', row.on_relation), + row.image.title ? fmt_img_popup(row.image) : empty('<%= misc.no_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), print_key_or_tag_list(row.tags_implies), print_key_or_tag_list(row.tags_combination), print_key_or_tag_list(row.tags_linked) |