1
0
mirror of https://tt-rss.org/git/tt-rss.git synced 2024-06-26 11:59:02 +02:00

move stuff in common.js around a bit

This commit is contained in:
Andrew Dolgov 2021-02-19 06:40:35 +03:00
parent 5475eed452
commit d57e7eaa98

View File

@ -27,8 +27,6 @@ Element.prototype.removeClassName = function(className) {
}; };
Element.prototype.toggleClassName = function(className) { Element.prototype.toggleClassName = function(className) {
console.log(this, className);
if (this.hasClassName(className)) if (this.hasClassName(className))
return this.removeClassName(className); return this.removeClassName(className);
else else
@ -97,6 +95,20 @@ Element.hasClassName = function (elem, className) {
return elem.hasClassName(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 */ /* xhr shorthand helpers */
/* exported xhrPost */ /* 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 */ /* exported xhrJson */
function xhrJson(url, params = {}, complete = undefined) { function xhrJson(url, params = {}, complete = undefined) {
return new Promise((resolve, reject) => return new Promise((resolve, reject) =>