From d57e7eaa98b8669837d6ccb98d6f7d0d739f52e8 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Feb 2021 06:40:35 +0300 Subject: [PATCH] move stuff in common.js around a bit --- js/common.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/js/common.js b/js/common.js index 9275bd09f..1adf5d56e 100755 --- a/js/common.js +++ b/js/common.js @@ -27,8 +27,6 @@ Element.prototype.removeClassName = function(className) { }; Element.prototype.toggleClassName = function(className) { - console.log(this, className); - if (this.hasClassName(className)) return this.removeClassName(className); else @@ -97,6 +95,20 @@ Element.hasClassName = function (elem, className) { return elem.hasClassName(className); } +Array.prototype.remove = function(s) { + for (let i=0; i < this.length; i++) { + if (s == this[i]) this.splice(i, 1); + } +}; + +Array.prototype.uniq = function() { + return this.filter((v, i, a) => a.indexOf(v) === i); +}; + +String.prototype.stripTags = function() { + return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?(\/)?>|<\/\w+>/gi, ''); +} + /* xhr shorthand helpers */ /* exported xhrPost */ @@ -122,20 +134,6 @@ function xhrPost(url, params = {}, complete = undefined) { }); } -Array.prototype.remove = function(s) { - for (let i=0; i < this.length; i++) { - if (s == this[i]) this.splice(i, 1); - } -}; - -Array.prototype.uniq = function() { - return this.filter((v, i, a) => a.indexOf(v) === i); -}; - -String.prototype.stripTags = function() { - return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?(\/)?>|<\/\w+>/gi, ''); -} - /* exported xhrJson */ function xhrJson(url, params = {}, complete = undefined) { return new Promise((resolve, reject) =>