diff --git a/Utils/GeneralUtils.js b/Utils/GeneralUtils.js index 8664336..2cb1676 100644 --- a/Utils/GeneralUtils.js +++ b/Utils/GeneralUtils.js @@ -74,4 +74,9 @@ { return obj; }; + + jsOMS.isset = function (variable) + { + return typeof variable !== 'undefined' && variable !== null; + }; }(window.jsOMS = window.jsOMS || {})); diff --git a/Utils/StringUtils.js b/Utils/StringUtils.js index a38c3ea..9a64fe2 100644 --- a/Utils/StringUtils.js +++ b/Utils/StringUtils.js @@ -129,4 +129,33 @@ return res; }; + + jsOMS.strpbrk = function (haystack, chars) + { + const length = haystack.length; + for (let i = 0; i < length; ++i) { + if (chars.indexOf(haystack.charAt(i)) >= 0) { + return haystack.slice(i); + } + } + + return false; + }; + + jsOMS.htmlspecialchars = function (text, quotes) { + let map = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''' + }; + + if (quotes) { + map['"'] = '"'; + map["'"] = "'"; + } + + return text.replace(/[&<>"']/g, function(m) { return map[m]; }); + }; }(window.jsOMS = window.jsOMS || {})); diff --git a/Utils/oLib.js b/Utils/oLib.js index cfc8f31..21dbc87 100644 --- a/Utils/oLib.js +++ b/Utils/oLib.js @@ -437,4 +437,38 @@ { return obj; }; + + jsOMS.isset = function (variable) + { + return typeof variable !== 'undefined' && variable !== null; + }; + + jsOMS.strpbrk = function (haystack, char_list) + { + const length = haystack.length; + for (let i = 0; i < length; ++i) { + if (char_list.indexOf(haystack.charAt(i)) >= 0) { + return haystack.slice(i); + } + } + + return false; + }; + + jsOMS.htmlspecialchars = function (text, quotes) { + let map = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''' + }; + + if (quotes) { + map['"'] = '"'; + map["'"] = "'"; + } + + return text.replace(/[&<>"']/g, function(m) { return map[m]; }); + }; }(window.jsOMS = window.jsOMS || {}));