diff options
author | Florian Pritz <bluewind@xinu.at> | 2015-06-04 23:10:31 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2015-06-05 21:23:49 +0200 |
commit | d088234d67f3aa422796d922e08a07949dc53d83 (patch) | |
tree | a964821b6b725dd26becbb3e91acf8d7dd5e0014 /public_html/data/js/util.js | |
parent | 048410164d2a17bbb588e43351e44eeb81610960 (diff) |
Move public files to ./public_html
./data/local is not moved because it contains likely untracked files
and moving it would throw an error when updating.
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'public_html/data/js/util.js')
-rw-r--r-- | public_html/data/js/util.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/public_html/data/js/util.js b/public_html/data/js/util.js new file mode 100644 index 000000000..af3635673 --- /dev/null +++ b/public_html/data/js/util.js @@ -0,0 +1,60 @@ +(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); + }, + focusDropdownInput: function (target) { + setTimeout(function () { + var dropDown = $(target).siblings('.dropdown-menu'); + dropDown.find('input').trigger('focus'); + }, 0); + }, + setTabwidth: function (value) { + value = value || 8; + $('span.tabwidth-value').html(value); + $('.tabwidth-form input').val(value); + $('.highlight pre').css('tab-size', value); + localStorage.setItem('tabwidth', value); + }, + setTabwidthFromLocalStorage: function () { + this.setTabwidth(localStorage.getItem('tabwidth')); + }, + setLineWrap: function (lines_wrapped) { + var whitespaceMode = lines_wrapped ? 'pre-wrap' : 'pre'; + $('.highlight > pre').css('white-space', whitespaceMode); + localStorage.setItem('lines_wrapped', lines_wrapped); + }, + toggleLineWrap: function() { + this.setLineWrap( + localStorage.getItem('lines_wrapped') !== 'true' + ); + } + }; + return Util; +}); +})(); |