aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2015-02-26 15:43:36 +0100
committerJochen Topf <jochen@topf.org>2015-02-26 15:43:36 +0100
commit6d3e4dd166439a00df5898dd4c7151ee1c524638 (patch)
treee6c2d070313a401e8afae7369a540a0ca73610c9
parent4a2073856b3ca10b61c158a12cc36aaaf8842f46 (diff)
downloadtaginfo-6d3e4dd166439a00df5898dd4c7151ee1c524638.tar
taginfo-6d3e4dd166439a00df5898dd4c7151ee1c524638.tar.gz
Move some functions from search.js.erb into taginfo.js.
These functions are generally useful and will be used in other parts of the taginfo ui soon.
-rw-r--r--web/public/js/taginfo.js25
-rw-r--r--web/viewsjs/search.js.erb25
2 files changed, 25 insertions, 25 deletions
diff --git a/web/public/js/taginfo.js b/web/public/js/taginfo.js
index 5a06361..c8b7a25 100644
--- a/web/public/js/taginfo.js
+++ b/web/public/js/taginfo.js
@@ -228,6 +228,31 @@ function link_to_url(url) {
);
}
+function highlight(str, query) {
+ return html_escape(str).replace(new RegExp('(' + html_escape(query) + ')', 'gi'), "<b>$1</b>");
+}
+
+function link_to_key_with_highlight(key, query) {
+ return link(
+ url_for_key(key),
+ highlight(key, query)
+ );
+}
+
+function link_to_value_with_highlight(key, value, query) {
+ return link(
+ url_for_tag(key, value),
+ highlight(value, query)
+ );
+}
+
+function link_to_rtype_with_highlight(rtype, query) {
+ return link(
+ url_for_rtype(rtype),
+ highlight(rtype, query)
+ );
+}
+
/* ============================ */
function html_escape(text) {
diff --git a/web/viewsjs/search.js.erb b/web/viewsjs/search.js.erb
index 0dd3fdb..b47509b 100644
--- a/web/viewsjs/search.js.erb
+++ b/web/viewsjs/search.js.erb
@@ -4,31 +4,6 @@
search = @trans.t.pages.search
%>
-function highlight(str, query) {
- return html_escape(str).replace(new RegExp('(' + html_escape(query) + ')', 'gi'), "<b>$1</b>");
-}
-
-function link_to_key_with_highlight(key, query) {
- return link(
- url_for_key(key),
- highlight(key, query)
- );
-}
-
-function link_to_value_with_highlight(key, value, query) {
- return link(
- url_for_tag(key, value),
- highlight(value, query)
- );
-}
-
-function link_to_rtype_with_highlight(rtype, query) {
- return link(
- url_for_rtype(rtype),
- highlight(rtype, query)
- );
-}
-
var create_flexigrid_for = {
keys: function(query) {
create_flexigrid('grid-keys', {