mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-12-28 02:59:04 +00:00
* Deprecate some utility functions * Drop IE support * Update two function * Update comment * Further simplify with arrow function * Fix node error * Deprecate logTable * Deprecate class functions * Attempt to fix error * Deprecate two functions * Remove deprecation for getLocationPath * Deprecate stringifyNumber, domContains, domMatchesSelector * Deprecate $tw.utils.each * Revert "Deprecate $tw.utils.each" This reverts commit650df1d575. * Simplify getFullScreenApis * Replace LLMap with Map * Revert "Replace LLMap with Map" This reverts commit4410ac194a. * Move some deprecated functions to deprecated.js * Remove Opera & MS prefix * Deprecate getLocationPath * Fix code style * Revert "Remove Opera & MS prefix" This reverts commite5771c00be. * Revert "Simplify getFullScreenApis" This reverts commit894cb479ea. * Further simplify toggleClass * Second attempt to simplify $tw.utils.each * Revert "Second attempt to simplify $tw.utils.each" This reverts commit74cb4f766e. * Third attempt to simplify $tw.utils.each * Add missing comma * Update comments * Deprecate hopArray Since it is easy to implement it with some method * Update change notes * Deprecate tagToCssSelector Since tc-tagged-* classes are deprecated
58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
/*\
|
|
title: $:/core/modules/utils/deprecated.js
|
|
type: application/javascript
|
|
module-type: utils
|
|
|
|
Deprecated util functions
|
|
|
|
\*/
|
|
|
|
exports.logTable = data => console.table(data);
|
|
|
|
exports.repeat = (str,count) => str.repeat(count);
|
|
|
|
exports.startsWith = (str,search) => str.startsWith(search);
|
|
|
|
exports.endsWith = (str,search) => str.endsWith(search);
|
|
|
|
exports.trim = function(str) {
|
|
if(typeof str === "string") {
|
|
return str.trim();
|
|
} else {
|
|
return str;
|
|
}
|
|
};
|
|
|
|
exports.hopArray = (object,array) => array.some(element => $tw.utils.hop(object,element));
|
|
|
|
exports.sign = Math.sign;
|
|
|
|
exports.strEndsWith = (str,ending,position) => str.endsWith(ending,position);
|
|
|
|
exports.stringifyNumber = num => num.toString();
|
|
|
|
exports.tagToCssSelector = function(tagName) {
|
|
return "tc-tagged-" + encodeURIComponent(tagName).replace(/[!"#$%&'()*+,\-./:;<=>?@[\\\]^`{\|}~,]/mg,function(c) {
|
|
return "\\" + c;
|
|
});
|
|
};
|
|
|
|
exports.domContains = (a,b) => a.compareDocumentPosition(b) & 16;
|
|
|
|
exports.domMatchesSelector = (node,selector) => node.matches(selector);
|
|
|
|
exports.hasClass = (el,className) => el.classList && el.classList.contains(className);
|
|
|
|
exports.addClass = function(el,className) {
|
|
el.classList && el.classList.add(className);
|
|
};
|
|
|
|
exports.removeClass = function(el,className) {
|
|
el.classList && el.classList.remove(className);
|
|
};
|
|
|
|
exports.toggleClass = function(el,className,status) {
|
|
el.classList && el.classList.toggle(className, status);
|
|
};
|
|
|
|
exports.getLocationPath = () => window.location.origin + window.location.pathname; |