diff options
-rw-r--r-- | web/lib/ui/taginfo.rb | 1 | ||||
-rw-r--r-- | web/views/key.erb | 43 | ||||
-rw-r--r-- | web/views/reports/frequently_used_keys_without_wiki_page.erb | 6 | ||||
-rw-r--r-- | web/views/taginfo/i18n.erb | 14 | ||||
-rw-r--r-- | web/viewsjs/key.js.erb | 38 | ||||
-rw-r--r-- | web/viewsjs/reports/frequently_used_keys_without_wiki_page.js.erb | 6 | ||||
-rw-r--r-- | web/viewsjs/taginfo/i18n.js.erb | 6 |
7 files changed, 58 insertions, 56 deletions
diff --git a/web/lib/ui/taginfo.rb b/web/lib/ui/taginfo.rb index deca152..b995735 100644 --- a/web/lib/ui/taginfo.rb +++ b/web/lib/ui/taginfo.rb @@ -46,6 +46,7 @@ class Taginfo < Sinatra::Base "<tr><td class='#{c}' style='padding-left: #{ level * 16 + 6 }px;'><span title='#{ name }'>#{ key }</span></td><td class='#{c}'>#{ en }</td><td class='#{c}'>#{ other }</td></tr>" } + javascript "#{ r18n.locale.code }/taginfo/i18n" erb :'taginfo/i18n' end diff --git a/web/views/key.erb b/web/views/key.erb index d42eeb8..8833eb6 100644 --- a/web/views/key.erb +++ b/web/views/key.erb @@ -97,44 +97,13 @@ function page_init2() { var key = #{ @key.to_json }; init_tabs([key, #{ @filter_type.to_json }, #{ r18n.locale.code.to_json }]); - - var w = 160, h = 440, max = #{ @count_all_values }, data = #{ @prevalent_values.to_json() }; - - var y = 0; - data.forEach(function(d) { - d['y'] = y; - y += d['count']; + create_chart({ + key: key, + width: 160, + height: 440, + max: #{ @count_all_values }, + data: #{ @prevalent_values.to_json() } }); - - var scale = d3.scale.linear() - .domain([0, max]) - .range([0, h]); - - var color = d3.scale.ordinal() - .range(d3_colors()); - - var chart = d3.select('#canvas-values').append('svg') - .attr("width", w) - .attr("height", h); - - chart.selectAll("rect") - .data(data) - .enter() - .append("svg:a") - .attr('xlink:href', function(d) { return url_for_tag(key, d['value']); }) - .attr('transform', function(d) { return 'translate(10, ' + scale(d['y']) + ')'; }) - .call(function(c) { - c.append("rect") - .attr('width', 20) - .attr('height', function(d) { return scale(d['count']); }) - .style('fill', function(d, i) { return color(i); }); - }) - .append("text") - .attr('x', 25) - .attr('y', function(d) { return scale(d['count'] / 2); }) - .attr('dy', '0.5em') - .text(function(d) { return d['value']; }); - } JAVASCRIPT end diff --git a/web/views/reports/frequently_used_keys_without_wiki_page.erb b/web/views/reports/frequently_used_keys_without_wiki_page.erb index d510f70..7b92dd5 100644 --- a/web/views/reports/frequently_used_keys_without_wiki_page.erb +++ b/web/views/reports/frequently_used_keys_without_wiki_page.erb @@ -16,12 +16,6 @@ JS.raw(<<"JAVASCRIPT") function page_init2() { create_flexigrid_with_option(#{ params[:english] == '1' ? '1' : '0' }); - jQuery('#english').bind('click', function() { - jQuery('#grid-keys').flexOptions({ - url: '/api/4/keys/without_wiki_page?english=' + (jQuery('#english')[0].checked ? '1' : '0') - }); - jQuery('#grid-keys').flexReload(); - }); } JAVASCRIPT end diff --git a/web/views/taginfo/i18n.erb b/web/views/taginfo/i18n.erb index 8445efa..a381724 100644 --- a/web/views/taginfo/i18n.erb +++ b/web/views/taginfo/i18n.erb @@ -20,16 +20,4 @@ <%= i18n_walk(@line, 0, '', @i18n_en, @i18n_lang) %> </table> </div> -<% -end -javascript do - JS.raw(<<"JAVASCRIPT") -function page_init() { - jQuery('span[title]').tipsy({ opacity: 1, delayIn: 500, gravity: 'w' }); - jQuery('#lang').bind('change', function() { - jQuery('form').submit(); - }); -} -JAVASCRIPT -end -%> +<% end %> diff --git a/web/viewsjs/key.js.erb b/web/viewsjs/key.js.erb index e83bbdd..e8db21f 100644 --- a/web/viewsjs/key.js.erb +++ b/web/viewsjs/key.js.erb @@ -145,6 +145,44 @@ var create_flexigrid_for = { } }; +function create_chart(params) { + var y = 0; + params.data.forEach(function(d) { + d['y'] = y; + y += d['count']; + }); + + var scale = d3.scale.linear() + .domain([0, params.max]) + .range([0, params.height]); + + var color = d3.scale.ordinal() + .range(d3_colors()); + + var chart = d3.select('#canvas-values').append('svg') + .attr("width", params.width) + .attr("height", params.height); + + chart.selectAll("rect") + .data(params.data) + .enter() + .append("svg:a") + .attr('xlink:href', function(d) { return url_for_tag(params.key, d['value']); }) + .attr('transform', function(d) { return 'translate(10, ' + scale(d['y']) + ')'; }) + .call(function(c) { + c.append("rect") + .attr('width', 20) + .attr('height', function(d) { return scale(d['count']); }) + .style('fill', function(d, i) { return color(i); }); + }) + .append("text") + .attr('x', 25) + .attr('y', function(d) { return scale(d['count'] / 2); }) + .attr('dy', '0.5em') + .text(function(d) { return d['value']; }); + +} + function page_init() { jQuery('#josm_button').bind('click', function() { jQuery('#josmiframe')[0].src = jQuery('#josm_button')[0].href; 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 a31bb0d..680ba5d 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 @@ -37,4 +37,10 @@ function create_flexigrid_with_option(english) { function page_init() { page_init2(); + jQuery('#english').bind('click', function() { + jQuery('#grid-keys').flexOptions({ + url: '/api/4/keys/without_wiki_page?english=' + (jQuery('#english')[0].checked ? '1' : '0') + }); + jQuery('#grid-keys').flexReload(); + }); } diff --git a/web/viewsjs/taginfo/i18n.js.erb b/web/viewsjs/taginfo/i18n.js.erb new file mode 100644 index 0000000..38200ae --- /dev/null +++ b/web/viewsjs/taginfo/i18n.js.erb @@ -0,0 +1,6 @@ +function page_init() { + jQuery('span[title]').tipsy({ opacity: 1, delayIn: 500, gravity: 'w' }); + jQuery('#lang').bind('change', function() { + jQuery('form').submit(); + }); +} |