summaryrefslogtreecommitdiffstats
path: root/data/js/util.js
diff options
context:
space:
mode:
authorJoakim Reinert <mail@jreinert.com>2015-04-18 23:09:44 +0200
committerFlorian Pritz <bluewind@xinu.at>2015-05-05 12:21:26 +0200
commit9f1fb6e1c8fbe2c54b5d9a7f0755557acd7ea84a (patch)
tree0f748b6d74d70dc6668ec6055aa4313f42f2230e /data/js/util.js
parente9a248f9e9ff9a5b816338a634a0ace1d4883471 (diff)
Refactor line higlighting functionality
Diffstat (limited to 'data/js/util.js')
-rw-r--r--data/js/util.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/data/js/util.js b/data/js/util.js
new file mode 100644
index 000000000..810bc4167
--- /dev/null
+++ b/data/js/util.js
@@ -0,0 +1,34 @@
+(function () {
+'use strict';
+define(['jquery'], function () {
+ var PrivateFunctions = {
+ highlightLine: function (id) {
+ this.clearLineHighlights();
+ var line = $(id).parents('.table-row');
+ line.addClass("highlight_line");
+ },
+ clearLineHighlights: function () {
+ $('.highlight_line').removeClass('highlight_line');
+ }
+ };
+ var Util = {
+ fixedEncodeURIComponent: function (string) {
+ var encodedString = encodeURIComponent(string);
+ encodedString = encodedString.replace(/[!'()]/g, escape);
+ encodedString = encodedString.replace(/\*/g, "%2A");
+
+ return encodedString;
+ },
+ highlightLineFromHash: function () {
+ var hash = window.location.hash;
+ if (hash.match(/^#n(?:-.+-)?\d+$/) === null) {
+ PrivateFunctions.clearLineHighlights();
+ return;
+ }
+
+ PrivateFunctions.highlightLine(hash);
+ }
+ };
+ return Util;
+});
+})();