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