Can someone direct me to the documentation about the client side global functions, like ew.isMobile()?
I've searched the available docs but can't find it anywhere...
Thanks!
Client side global functions
-
- User
- Posts: 148
Client side global functions
-
- User
- Posts: 1031
Actually many server-side global functions are also undocumented. It's impossible to documenting them all.
To get all available server-side global functions that you can use in a page, try:
// Page Data Rendering event
public function pageDataRendering(&$header)
{
// Example:
//$header = "your header";
// Get an array of all defined functions
$functions = get_defined_functions();
// internal (built-in PHP) functions
$internalFunctions = $functions['internal'];
// user-defined functions
$userFunctions = $functions['user'];
$header = "";
foreach ($userFunctions as $function) {
$header .= $function . "<br/>";
}
}
For client-side global functions, try:
// Startup script
function isStandardObject(obj) {
return obj instanceof Object || obj instanceof Array || obj instanceof Function ||
obj instanceof Date || obj instanceof RegExp || obj instanceof Set ||
obj instanceof Map || obj instanceof WeakSet || obj instanceof WeakMap ||
obj instanceof Promise || obj instanceof Symbol;
}
function findFunctions(obj) {
let functions = [];
function recursiveSearch(obj) {
for (const key in obj) {
if (isStandardObject(obj)) {
if (obj.hasOwnProperty(key)) {
if (typeof obj[key] === 'function') {
functions.push({ key, func: obj[key] });
} else if (typeof obj[key] === 'object' && obj[key] !== null) {
recursiveSearch(obj[key]);
}
}
}
}
}
recursiveSearch(obj);
return functions;
}
const functions = findFunctions(ew);
console.log(functions);
For server-side, you have to "Find in Files" to locate the functions.
For client-side, you can expand the object and go to [[FunctionLocation]].
-
- User
- Posts: 148
Thanks for the code, sangnandar, that is very helpful!
I do agree that it's impossible to document all the functions, but my contention is that it would be very helpful if the most important client functions were, as are the most relevant server functions (more than 40 of those are documented, actually).