mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-05-24 10:28:39 +00:00
Add php functions
This commit is contained in:
parent
0d17a93d66
commit
05ab8502bf
|
|
@ -74,4 +74,9 @@
|
||||||
{
|
{
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
jsOMS.isset = function (variable)
|
||||||
|
{
|
||||||
|
return typeof variable !== 'undefined' && variable !== null;
|
||||||
|
};
|
||||||
}(window.jsOMS = window.jsOMS || {}));
|
}(window.jsOMS = window.jsOMS || {}));
|
||||||
|
|
|
||||||
|
|
@ -129,4 +129,33 @@
|
||||||
|
|
||||||
return res;
|
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 || {}));
|
}(window.jsOMS = window.jsOMS || {}));
|
||||||
|
|
|
||||||
|
|
@ -437,4 +437,38 @@
|
||||||
{
|
{
|
||||||
return obj;
|
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 || {}));
|
}(window.jsOMS = window.jsOMS || {}));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user