aboutsummaryrefslogtreecommitdiff
path: root/web/viewsjs
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2013-01-18 19:16:40 +0100
committerJochen Topf <jochen@topf.org>2013-01-18 19:16:40 +0100
commit71e774e39117dc51e27902d64ee8a70341a08ef3 (patch)
tree5a214d90dbfdb65585cc64fd8ca768dbd026b643 /web/viewsjs
parentee83b7feeca5e0bf0d2e29275ee73919f28bdb60 (diff)
downloadtaginfo-71e774e39117dc51e27902d64ee8a70341a08ef3.tar
taginfo-71e774e39117dc51e27902d64ee8a70341a08ef3.tar.gz
Add role search
Diffstat (limited to 'web/viewsjs')
-rw-r--r--web/viewsjs/search.js.erb35
1 files changed, 31 insertions, 4 deletions
diff --git a/web/viewsjs/search.js.erb b/web/viewsjs/search.js.erb
index 5ce7e72..9dcafa2 100644
--- a/web/viewsjs/search.js.erb
+++ b/web/viewsjs/search.js.erb
@@ -3,17 +3,22 @@
misc = @trans.t.misc
search = @trans.t.pages.search
%>
-function link_to_key_with_highlight(key, highlight) {
+
+function highlight(str, query) {
+ return str.replace(new RegExp('(' + query + ')', 'gi'), "<b>$1</b>")
+}
+
+function link_to_key_with_highlight(key, query) {
return link(
url_for_key(key),
- key.replace(new RegExp('(' + highlight + ')', 'gi'), "<b>$1</b>")
+ highlight(key, query)
);
}
-function link_to_value_with_highlight(key, value, highlight) {
+function link_to_value_with_highlight(key, value, query) {
return link(
url_for_tag(key, value),
- value.replace(new RegExp('(' + highlight + ')', 'gi'), "<b>$1</b>")
+ highlight(value, query)
);
}
@@ -60,6 +65,28 @@ var create_flexigrid_for = {
}
});
},
+ roles: function(query) {
+ create_flexigrid('grid-roles', {
+ url: '/api/4/search/by_role?query=' + encodeURIComponent(query),
+ colModel: [
+ { display: '<%= misc.count %>', name: 'count_all', width: 80, sortable: true, align: 'right' },
+ { display: '<%= osm.relation_types %>', name: 'rtype', width: 250, sortable: true },
+ { display: '<%= osm.relation_member_roles %>', name: 'role', width: 500, sortable: true }
+ ],
+ sortname: 'count_all',
+ sortorder: 'desc',
+ preProcess: function(data) {
+ data.rows = jQuery.map(data.data, function(row, i) {
+ return { 'cell': [
+ fmt_with_ts(row.count_all),
+ link_to_rtype(row.rtype),
+ highlight(html_escape(row.role), query)
+ ] };
+ });
+ return data;
+ }
+ });
+ },
tags: function(query) {
var q = query.split('=', 2);
create_flexigrid('grid-tags', {