Global variables and methods
Console
console.log()
console.log(...)
Prints log message to either application configured debug output stream or to inspector's log view.
console.log("format", ...)
Prints log message using C-style printf conventions.
console.warn()
console.error()
Same as console.log() but prints messages using different meta type.
console.reportException(err,isPromise)
Unhandled exceptions handler, all not handled exceptions go here. This function can be overriden to implement custom handler:
console.reportException = function(err,isPromise) {
Window.this.modal(<alert>{err.toString()}</alert>);
return "";
}
Timers and intervals
setTimeout()
setTimeout(func:function,milliseconds:int): timerId
Calls the func after milliseconds timeout.
The function returns timer id value that can be used with clearTimeout()
clearTimeout()
clearTimeout(timerId)
The function cancels previously created timer.
tip::: Sciter provides also element timers that can work as timeouts and intervals:
document.timer(500ms, ()=>{ ... });
In some cases they are more flexible as they also support auto cancelling to implement effective call throttling. :::
setInterval()
setInterval(func,milliseconds): intId
Calls the func periodically with milliseconds interval. Retuns interval ID.
clearInterval()
clearInterval(intId)
Stops interval by its intId.
requestAnimationFrame()
requestAnimationFrame(func): animId
Schedules func to be executed at next paint event (<= 16ms - 60 FPS usually).
The function gets executed once, so for periodic calls it needs to be called inside that func again.
cancelAnimationFrame(a)
cancelAnimationFrame(animId)
HTTP client
fetch()
fetch(url:string | Request [, options:object]): Response
see Fetch
Sciter specific
printf()
printf(format:string, ...):string
This function does formatting of arguments using C-style printf conventions.
Returns formatted string.
In Sciter list of standard formatting types is extended by these two:
%v- takes argument and prints it asJSON.stringify(arg);%V- takes argument and prints it asJSON.stringify(arg, null, " ");
scanf()
scanf(format:string, input: string) : [...]
Takes input string and parses it according the format specification using C-style scanf conventions.
Returns list (array) of successfully parsed values.
evalModule()
evalModule(text:string [,url:string]):object
"module" version of JS stock eval() function - evaluates the text as a module body.
If the url is provided it is used as a base URL for resolving relative paths in import ... from "relpath" statements inside.
The function returns module's exported data as an object.
loadScript()
loadScript(url:string);
Loads and executes JavaScript at url synchronously.
That's an equivalent of
document.append(<script src=url />);
but without physical DOM update.
loadScriptModule()
loadScriptModule(url:string): object
Loads and executes JavaScript module at url synchronously. Returns modules export object.
That's an equivalent of
document.append(<script src=url />);
but without physical DOM update.
global properties
globalThis
object, global namespace, aliased as window for compatibility with browsers.
devicePixelRatio
float, number of physical screen pixels in logical CSS px (dip).