From c5428074f4380471e2da6f17c6f7a2375f262bca Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Fri, 18 Jan 2013 18:08:32 +0100 Subject: Add XAPI and JOSM buttons to relations page --- web/lib/ui/relation.rb | 2 ++ web/views/relation.erb | 9 +++++++++ web/viewsjs/relation.js.erb | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/web/lib/ui/relation.rb b/web/lib/ui/relation.rb index e55d02b..1e1fe71 100644 --- a/web/lib/ui/relation.rb +++ b/web/lib/ui/relation.rb @@ -11,6 +11,8 @@ class Taginfo < Sinatra::Base @title = [escape_html(@rtype), t.osm.relations] section :relations + @count_all_values = @db.select("SELECT count_relations FROM db.keys").condition('key = ?', @rtype).get_first_value().to_i + @desc = h(@db.select("SELECT description FROM wiki.relation_pages WHERE lang=? AND rtype=?", r18n.locale.code, @rtype).get_first_value()) @desc = h(@db.select("SELECT description FROM wiki.relation_pages WHERE lang='en' AND rtype=?", @rtype).get_first_value()) if @desc == '' if @desc == '' diff --git a/web/views/relation.erb b/web/views/relation.erb index bf0044b..d1aea0d 100644 --- a/web/views/relation.erb +++ b/web/views/relation.erb @@ -1,4 +1,12 @@
+
+ <% if @count_all_values < TaginfoConfig.get('xapi.max_results', 1000) %> + <%= xapi_link('relation', 'type', @rtype) %> <%= josm_link('relation', 'type', @rtype) %> + <% else %> + XAPI + JOSM + <% end %> +

<%= @desc %>

@@ -23,6 +31,7 @@ <% end %> + <% javascript do JS.raw(<<"JAVASCRIPT") function page_init2() { diff --git a/web/viewsjs/relation.js.erb b/web/viewsjs/relation.js.erb index 931f33c..6c4ad7e 100644 --- a/web/viewsjs/relation.js.erb +++ b/web/viewsjs/relation.js.erb @@ -58,6 +58,11 @@ var create_flexigrid_for = { }; function page_init() { + jQuery('#josm_button').bind('click', function() { + jQuery('#josmiframe')[0].src = jQuery('#josm_button')[0].href; + return false; + }); + up = function() { window.location = '/relations'; }; page_init2(); } -- cgit v1.2.3