Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision |
custom:javascript [2019/05/06 02:05] – [See Also] digital man | custom:javascript [2019/07/26 16:32] – [Output] mention the limited @-code support in console.print() digital man |
---|
Modified stock ''.js'' files should be placed in your Synchronet ''[[dir:mods]]'' directory to prevent over-writing by future upgrades. | Modified stock ''.js'' files should be placed in your Synchronet ''[[dir:mods]]'' directory to prevent over-writing by future upgrades. |
| |
===== Integration ===== | ===== Invocation ===== |
| |
JavaScript files can be executed from: | JavaScript files can be executed / invoked from: |
* [[:server:terminal|Terminal Server]] | * [[:server:terminal|Terminal Server]] |
as a timed event, external program (door), login/logon/newuser module, | as a timed event, external program (door), login/logon/newuser module, via the ''EXEC'' sysop command |
basically anywhere a Baja module or executable can be launched | ((basically anywhere a Baja module or native or MS-DOS executable can be launched)) |
* [[:server:web|Web Server]] | * [[:server:web|Web Server]] |
dynamically generates HTML files, | dynamically generates HTTP responses (e.g. HTML/CSS content), |
see ''[[dir:web]]/root/*.ssjs'' | see ''[[dir:web]]/root/*.ssjs'' |
* [[:server:ftp|FTP Server]] | * [[:server:ftp|FTP Server]] |
inbound mail processors may be written in JavaScript, | inbound mail processors may be written in JavaScript, |
see ''[[dir:exec]]/[[module:mailproc_example]].js'' and ''[[dir:ctrl]]/[[config:mailproc.ini]]'' | see ''[[dir:exec]]/[[module:mailproc_example]].js'' and ''[[dir:ctrl]]/[[config:mailproc.ini]]'' |
* [[:util:jsexec|JSexec]] | * [[:util:JSexec]] |
some script files may be executed outside of Synchronet (e.g. as a CGI script or daemon) using jsexec, | some script files may be executed outside of Synchronet (e.g. as a CGI script or daemon) using [[util:JSexec]], |
examples: ''ircd.js'', ''newslink.js'' | examples: ''ircd.js'', ''newslink.js'' |
| |
From the Terminal Server, a JavaScript file is executed on a native command-line by placing a question mark (''?'') at the beginning of the command-line before the JavaScript file name (in [[util:scfg]]). It is not necessary to specify the ''.js'' portion of the file name on the command-line. For example, the command-line to execute the file ''[[dir:exec]]/newslink.js'' would be "''?newslink''" or "''?newslink.js''". | From the Terminal Server, a JavaScript file is executed on a native command-line by placing a question mark (''?'') or asterisk (''*'') at the beginning of the command-line before the JavaScript file name (in [[util:SCFG]]). It is not necessary to specify the ''.js'' portion of the file name on the command-line. For example, the command-line to execute the file ''[[dir:exec]]/newslink.js'' would be "''?newslink''" or "''*newslink''". |
| |
From within a Baja module, a JavaScript file may be executed using the following Baja code: | From within a Baja module, a JavaScript file may be executed using the following Baja code: |
<code baja> | <code baja> |
exec "?modname" # where modname is the JavaScript file. | exec "?modname" # where modname is the JavaScript filename or base filename. |
| </code> |
| or: |
| <code baja> |
| exec "*modname" # where modname is the JavaScript filename or base filename. |
| </code> |
| or: |
| <code baja> |
| exec_bin "modname" # where modname is the JavaScript filename or base filename. |
</code> | </code> |
| |
===== Object Model ===== | ===== Object Model ===== |
| |
| ''alert()'' | Yes | Yes | Yes | Yes | Telnet-IAC, Ctrl-A | No | If user not online, same as ''log(LOG_WARNING, ...)'' | | | ''alert()'' | Yes | Yes | Yes | Yes | Telnet-IAC, Ctrl-A | No | If user not online, same as ''log(LOG_WARNING, ...)'' | |
| ''log()'' | Yes | Yes | N/A | N/A | | Yes((following the log-level argument)) | Displayed/logged on the server only | | | ''log()'' | Yes | Yes | N/A | N/A | | Yes((following the log-level argument)) | Displayed/logged on the server only | |
| ''console.print()'' | Yes | No | No | Yes | Telnet-IAC, Ctrl-A | Yes | | | | ''console.print()'' | Yes | No | No | Yes | Telnet-IAC, Ctrl-A, [[custom:atcodes|@-Codes]] | Yes | @-Codes only supported within''[[text.dat]]'' strings and mnemonics| |
| ''console.write()'' | Yes | No | No | PETSCII only | Telnet-IAC | Yes | No line-counting/auto-pause | | | ''console.write()'' | Yes | No | No | Yes | Telnet-IAC | Yes | No line-counting/auto-pause | |
| ''console.writeln()'' | Yes | No | Yes | PETSCII only | Telnet-IAC | Yes | No line-counting/auto-pause | | | ''console.writeln()'' | Yes | No | Yes | Yes | Telnet-IAC | Yes | No line-counting/auto-pause | |
| ''console.putmsg()'' | Yes | No | No | Yes | Telnet-IAC, Ctrl-A, [[custom:atcodes|@-Codes]], [[custom:colors|Extra Attributes]] | No | Typically used for displaying text/menu files | | | ''console.putmsg()'' | Yes | No | No | Yes | Telnet-IAC, Ctrl-A, [[custom:atcodes|@-Codes]], [[custom:colors|Extra Attributes]] | No | Typically used for displaying text/menu files | |
| ''console.center()'' | Yes | No | Yes | Yes | Telnet-IAC, Ctrl-A | No | Text centered on screen | | | ''console.center()'' | Yes | No | Yes | Yes | Telnet-IAC, Ctrl-A | No | Text centered on screen | |