Subj : Replacing a text string to execute JS code directly
To : Digital Man
From : Nightfox
Date : Wed Jan 29 2025 04:20 pm
Re: Replacing a text string to execute JS code directly
By: Digital Man to Nightfox on Wed Jan 29 2025 02:43 pm
>> Not exactly as @-codes are pretty restrictive as to the contents (e.g. no
>> space characters), so it'be pretty hard to put a code block within an
>> @-code. One possibility is to define a JS property with a getter function
>> and then you can invoke that getter function with the JS:propname @-code:
>>
https://wiki.synchro.net/custom:atcodes#external_content
DM> Here's an example:
DM> Object.defineProperty(js.global, "prop", {
DM> get : function () {
DM> return "hello, world";
DM> }
DM> });
DM> bbs.replace_text("Pause", "@JS:" + "prop@"); // @-code split for posting
DM> console.pause(); // will invoke the global 'prop' getter function
DM> In this example, the "prop" getter function could do more stuff and just
DM> return an empty string if that's what's desired. --
That's working. Thanks for the response and the example.
Nightfox
---
� Synchronet � Digital Distortion: digitaldistortionbbs.com