Add php functions

This commit is contained in:
Dennis Eichhorn 2017-12-17 14:29:47 +01:00
parent 0d17a93d66
commit 05ab8502bf
3 changed files with 68 additions and 0 deletions

View File

@ -74,4 +74,9 @@
{
return obj;
};
jsOMS.isset = function (variable)
{
return typeof variable !== 'undefined' && variable !== null;
};
}(window.jsOMS = window.jsOMS || {}));

View File

@ -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 = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#039;'
};
if (quotes) {
map['"'] = '"';
map["'"] = "'";
}
return text.replace(/[&<>"']/g, function(m) { return map[m]; });
};
}(window.jsOMS = window.jsOMS || {}));

View File

@ -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 = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#039;'
};
if (quotes) {
map['"'] = '"';
map["'"] = "'";
}
return text.replace(/[&<>"']/g, function(m) { return map[m]; });
};
}(window.jsOMS = window.jsOMS || {}));