• Couple of JS Questions

    From Apam@VERT/POSITRON to Digital Man on Tue May 24 10:18:00 2022
    On Mon May 23 11:49:00 2022, Digital Man wrote to Apam <=-

    load(), require() and js.exec() are used to execute a JS file from a JS file.

    I think I need to use js.exec.apply() so I can pass the query argument.. but can't seem to find any information on it..

    I see it's used in install-xtrn

    var result = js.exec.apply(null
    ,[js_file, item.startup_dir, {}].concat(js_args));

    but unsure what that first null is.

    Andrew

    --
    Andrew Pamment (apam)

    === TitanMail/linux v1.1.5

    ---
    þ Synchronet þ The Positronic Brain
  • From Digital Man@VERT to Apam on Mon May 23 22:00:05 2022
    Re: Couple of JS Questions
    By: Apam to Digital Man on Tue May 24 2022 10:18 am

    On Mon May 23 11:49:00 2022, Digital Man wrote to Apam <=-

    load(), require() and js.exec() are used to execute a JS file from a JS file.

    I think I need to use js.exec.apply() so I can pass the query argument.. but can't seem to find any information on it..

    I see it's used in install-xtrn

    var result = js.exec.apply(null
    ,[js_file, item.startup_dir, {}].concat(js_args));

    but unsure what that first null is.

    js.exec() is a function, so: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply
    --
    digital man (rob)

    Rush quote #19:
    Rebel without a conscience, martyr without a cause
    Norco, CA WX: 57.6øF, 87.0% humidity, 2 mph SE wind, 0.00 inches rain/24hrs
    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Apam@VERT/POSITRON to Digital Man on Wed May 25 08:16:36 2022
    Re: Couple of JS Questions
    By: Digital Man to Apam on Mon May 23 2022 10:00 pm

    js.exec() is a function, so: https://developer.mozilla.org/en-US/docs/Web/JavaS

    Thanks! I feel like such a newbie lol I had assumed it was a synchronet command and was going through the synchronet javascript stuff on the wiki.

    Andrew

    ---
    þ Synchronet þ The Positronic Brain
  • From nolageek@VERT/CAPSHRIL to Digital Man on Tue Jun 14 23:57:31 2022
    Re: Couple of JS Questions
    By: Digital Man to Apam on Mon May 23 2022 10:00 pm

    I'm working on a mod to turn on a light when I have active nodes - however sometimes the light will stay on after someone logs off, even when no one else is logged in - but there is a active connection by a bot, scanner, or network call of some kind. I'm currently using server.clients to get this number but it's leaving the light on (and not in a good Motel 6 kind of way)

    Is there a better way to get the number of actual nodes with a user actually logged in?

    |15n|03ola|15g|03eek |10<|02phenom|10>|07
    |12C|04APiT0L |12S|04HRiLL|07

    ---
    þ Synchronet þ Capitol Shrill BBS - Washington, DC - capitolshrill.com
  • From Digital Man@VERT to nolageek on Tue Jun 14 22:59:19 2022
    Re: Getting number of active nodes
    By: nolageek to Digital Man on Tue Jun 14 2022 11:57 pm

    Re: Couple of JS Questions
    By: Digital Man to Apam on Mon May 23 2022 10:00 pm

    I'm working on a mod to turn on a light when I have active nodes - however sometimes the light will stay on after someone logs off, even when no one else is logged in - but there is a active connection by a bot, scanner, or network call of some kind. I'm currently using server.clients to get this number but it's leaving the light on (and not in a good Motel 6 kind of way)

    Is there a better way to get the number of actual nodes with a user actually logged in?

    Iterate through the system.node_list array and count up how many have a status property value of NODE_INUSE (defined in load/nodedefs.js). Or just simply set/return true if *any* of them are in-use (you don't need the actual total).

    That should leave the light on for ya only when there's an actual rent-paying customer. :-)
    --
    digital man (rob)

    Rush quote #70:
    He's got a problem with his power, with weapons on patrol .. New World Man Norco, CA WX: 66.4øF, 78.0% humidity, 1 mph SE wind, 0.00 inches rain/24hrs
    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net