Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

21 May, 2024: Computers section is temporarily disabled for maintenance. It will take several days before it's back.


dovenet / Synchronet Javascript / Getting number of active nodes

SubjectAuthor
* Couple of JS QuestionsApam
+- Re: Couple of JS Questionspoindexter FORTRAN
`* Couple of JS QuestionsDigital Man
 +- Couple of JS QuestionsApam
 `* Couple of JS QuestionsApam
  `* Couple of JS QuestionsDigital Man
   +- Couple of JS QuestionsApam
   `* Getting number of active nodesnolageek
    `- Getting number of active nodesDigital Man

1
Couple of JS Questions

<628B5524.6.dove-syncjs@positronic.ddns.net>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=780&group=DOVE-Net.Synchronet_Javascript#780

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: apam@VERT/POSITRON (Apam)
To: All
Subject: Couple of JS Questions
Message-ID: <628B5524.6.dove-syncjs@positronic.ddns.net>
Date: Mon, 23 May 2022 12:34:28 +1000
X-Comment-To: All
Path: rocksolidbbs.com!not-for-mail
Organization: The Positronic Brain
Newsgroups: DOVE-Net.Synchronet_Javascript
X-FTN-PID: Synchronet 3.19c-Linux master/94ea4bf4e May 18 2022 GCC 10.2.1
X-FTN-CHRS: CP437 2
WhenImported: 20220523024333-0700 c1e0
WhenExported: 20220523055762-0700 c1e0
ExportedFrom: VERT sync-js 3699
WhenImported: 20220523193428+1000 1258
WhenExported: 20220523194324+1000 1258
ExportedFrom: POSITRON dove-syncjs 6
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: Apam - Mon, 23 May 2022 02:34 UTC

Hi

I'm mucking around in JS, and am creating a gemini service for synchronet. It serves files in /sbbs/text/gemini/ (not exactly hard coded, i'm using system.text_dir + "gemini".)

First question, is it possible in synchronet javascript to determine the mime-type of a file?

At present I'm just using a switch statement based on the extension - is this the best way to do things?

The second question, I'd like to add cgi type interface, which would load javascript files from the gemini root. I'm unsure how to execute another javascript file from within a service javascript file (or at all).

Andrew

---
■ Synchronet ■ The Positronic Brain

Re: Couple of JS Questions

<628B9BB8.3548.dove.sync_js@realitycheckbbs.org>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=781&group=DOVE-Net.Synchronet_Javascript#781

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: poindexter.fortran@VERT/REALITY (poindexter FORTRAN)
To: Apam
Subject: Re: Couple of JS Questions
Message-ID: <628B9BB8.3548.dove.sync_js@realitycheckbbs.org>
Date: Sun, 22 May 2022 23:36:00 -0700
X-Comment-To: Apam
Path: rocksolidbbs.com!not-for-mail
Organization: realitycheckBBS
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <628B5524.6.dove-syncjs@positronic.ddns.net>
References: <628B5524.6.dove-syncjs@positronic.ddns.net>
X-FTN-PID: Synchronet 3.19c-Win32 master/94ea4bf4e May 18 2022 MSC 1929
X-FTN-CHRS: ASCII 1
WhenImported: 20220523095120-0700 c1e0
WhenExported: 20220523115762-0700 c1e0
ExportedFrom: VERT sync-js 3700
WhenImported: 20220523073536-0700 c1e0
WhenExported: 20220523095114-0700 c1e0
ExportedFrom: REALITY dove.sync_js 3548
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
 by: poindexter FORTRAN - Mon, 23 May 2022 06:36 UTC

-=> Apam wrote to All <=-

Ap> I'm mucking around in JS, and am creating a gemini service for
Ap> synchronet. It serves files in /sbbs/text/gemini/ (not exactly hard
Ap> coded, i'm using system.text_dir + "gemini".)

<ears perked in Apam's direction>

.... Are there sections? Consider transitions
--- MultiMail/DOS v0.52
� Synchronet � .: realitycheckbbs.org :: scientia potentia est :.

Couple of JS Questions

<628BD720.3701.sync-js@vert.synchro.net>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=782&group=DOVE-Net.Synchronet_Javascript#782

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: digital.man@VERT (Digital Man)
To: Apam
Subject: Couple of JS Questions
Message-ID: <628BD720.3701.sync-js@vert.synchro.net>
Date: Mon, 23 May 2022 04:49:04 -0700
X-Comment-To: Apam
Path: rocksolidbbs.com!not-for-mail
Organization: Vertrauen
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <628B5524.6.dove-syncjs@positronic.ddns.net>
References: <628B5524.6.dove-syncjs@positronic.ddns.net>
X-FTN-PID: Synchronet 3.19c-Win32 master/65e938974 May 18 2022 MSC 1929
X-FTN-CHRS: CP437 2
WhenImported: 20220523114904-0700 c1e0
WhenExported: 20220523115762-0700 c1e0
ExportedFrom: VERT sync-js 3701
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: Digital Man - Mon, 23 May 2022 11:49 UTC

Re: Couple of JS Questions
By: Apam to All on Mon May 23 2022 07:34 pm

> Hi
>
> I'm mucking around in JS, and am creating a gemini service for synchronet.
> It serves files in /sbbs/text/gemini/ (not exactly hard coded, i'm using
> system.text_dir + "gemini".)
>
> First question, is it possible in synchronet javascript to determine the
> mime-type of a file?

You could load ctrl/mime_types.ini using the File class and compare the extension.

> At present I'm just using a switch statement based on the extension - is
> this the best way to do things?

Ideally, you'd use the same mime_types.ini file used by the web server.

> The second question, I'd like to add cgi type interface, which would load
> javascript files from the gemini root. I'm unsure how to execute another
> javascript file from within a service javascript file (or at all).

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

Synchronet/BBS Terminology Definition #90:
UTF-8 = 8-bit Unicode Transformation Format
Norco, CA WX: 66.8°F, 69.0% humidity, 8 mph SSE wind, 0.00 inches rain/24hrs
---
■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net

Couple of JS Questions

<628C21CB.9.dove-syncjs@positronic.ddns.net>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=783&group=DOVE-Net.Synchronet_Javascript#783

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: apam@VERT/POSITRON (Apam)
To: Digital Man
Subject: Couple of JS Questions
Message-ID: <628C21CB.9.dove-syncjs@positronic.ddns.net>
Date: Tue, 24 May 2022 02:54:00 +1000
X-Comment-To: Digital Man
Path: rocksolidbbs.com!not-for-mail
Organization: The Positronic Brain
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <628BD720.3701.sync-js@vert.synchro.net>
References: <628BD720.3701.sync-js@vert.synchro.net>
X-FTN-PID: Synchronet 3.19c-Linux master/94ea4bf4e May 18 2022 GCC 10.2.1
X-FTN-CHRS: ASCII 1
WhenImported: 20220523204335-0700 c1e0
WhenExported: 20220523235762-0700 c1e0
ExportedFrom: VERT sync-js 3702
WhenImported: 20220524100739+1000 1258
WhenExported: 20220524134333+1000 1258
ExportedFrom: POSITRON dove-syncjs 9
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
 by: Apam - Mon, 23 May 2022 16:54 UTC

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

> > First question, is it possible in synchronet javascript to determine the
> > mime-type of a file?
>
> You could load ctrl/mime_types.ini using the File class and compare the extension.
Great. That's what I'm now doing.

> > The second question, I'd like to add cgi type interface, which would load
> > javascript files from the gemini root. I'm unsure how to execute another
> > javascript file from within a service javascript file (or at all).
>
> load(), require() and js.exec() are used to execute a JS file from a JS file.

Thanks! I've not done this yet, but will soon.

If anyone is interested in looking at it, I put it up here:

https://github.com/apamment/geminiserv

Andrew

--
Andrew Pamment (apam)

=== TitanMail/linux v1.1.5

---
� Synchronet � The Positronic Brain

Couple of JS Questions

<628C245F.10.dove-syncjs@positronic.ddns.net>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=784&group=DOVE-Net.Synchronet_Javascript#784

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: apam@VERT/POSITRON (Apam)
To: Digital Man
Subject: Couple of JS Questions
Message-ID: <628C245F.10.dove-syncjs@positronic.ddns.net>
Date: Tue, 24 May 2022 03:18:00 +1000
X-Comment-To: Digital Man
Path: rocksolidbbs.com!not-for-mail
Organization: The Positronic Brain
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <628BD720.3701.sync-js@vert.synchro.net>
References: <628BD720.3701.sync-js@vert.synchro.net>
X-FTN-PID: Synchronet 3.19c-Linux master/94ea4bf4e May 18 2022 GCC 10.2.1
X-FTN-CHRS: ASCII 1
WhenImported: 20220523204335-0700 c1e0
WhenExported: 20220523235762-0700 c1e0
ExportedFrom: VERT sync-js 3703
WhenImported: 20220524101839+1000 1258
WhenExported: 20220524134333+1000 1258
ExportedFrom: POSITRON dove-syncjs 10
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
 by: Apam - Mon, 23 May 2022 17:18 UTC

-=> 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

Couple of JS Questions

<628C6655.3704.sync-js@vert.synchro.net>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=785&group=DOVE-Net.Synchronet_Javascript#785

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: digital.man@VERT (Digital Man)
To: Apam
Subject: Couple of JS Questions
Message-ID: <628C6655.3704.sync-js@vert.synchro.net>
Date: Mon, 23 May 2022 15:00:05 -0700
X-Comment-To: Apam
Path: rocksolidbbs.com!not-for-mail
Organization: Vertrauen
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <628C245F.10.dove-syncjs@positronic.ddns.net>
References: <628C245F.10.dove-syncjs@positronic.ddns.net>
X-FTN-PID: Synchronet 3.19c-Win32 master/65e938974 May 18 2022 MSC 1929
X-FTN-CHRS: CP437 2
WhenImported: 20220523220005-0700 c1e0
WhenExported: 20220523235762-0700 c1e0
ExportedFrom: VERT sync-js 3704
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: Digital Man - Mon, 23 May 2022 22:00 UTC

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

Couple of JS Questions

<628D5944.12.dove-syncjs@positronic.ddns.net>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=786&group=DOVE-Net.Synchronet_Javascript#786

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: apam@VERT/POSITRON (Apam)
To: Digital Man
Subject: Couple of JS Questions
Message-ID: <628D5944.12.dove-syncjs@positronic.ddns.net>
Date: Wed, 25 May 2022 01:16:36 +1000
X-Comment-To: Digital Man
Path: rocksolidbbs.com!not-for-mail
Organization: The Positronic Brain
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <628C6655.3704.sync-js@vert.synchro.net>
References: <628C6655.3704.sync-js@vert.synchro.net>
X-FTN-PID: Synchronet 3.19c-Linux master/94ea4bf4e May 18 2022 GCC 10.2.1
X-FTN-CHRS: CP437 2
WhenImported: 20220524204334-0700 c1e0
WhenExported: 20220524235812-0700 c1e0
ExportedFrom: VERT sync-js 3705
WhenImported: 20220525081636+1000 1258
WhenExported: 20220525134326+1000 1258
ExportedFrom: POSITRON dove-syncjs 12
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: Apam - Tue, 24 May 2022 15:16 UTC

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

DM> js.exec() is a function, so:
DM> 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

Getting number of active nodes

<62A958AB.3495.sync_js@capitolshrill.com>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=790&group=DOVE-Net.Synchronet_Javascript#790

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: nolageek@VERT/CAPSHRIL (nolageek)
To: Digital Man
Subject: Getting number of active nodes
Message-ID: <62A958AB.3495.sync_js@capitolshrill.com>
Date: Tue, 14 Jun 2022 16:57:31 -0400
X-Comment-To: Digital Man
Path: rocksolidbbs.com!not-for-mail
Organization: Capitol Shrill BBS
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <628C6655.3704.sync-js@vert.synchro.net>
References: <628C6655.3704.sync-js@vert.synchro.net>
X-FTN-PID: Synchronet 3.19c-Win32 master/59200e330 Mar 30 2022 MSC 1929
X-FTN-CHRS: CP437 2
WhenImported: 20220614222217-0700 c1e0
WhenExported: 20220619211848-0700 c1e0
ExportedFrom: VERT sync-js 3717
WhenImported: 20220614235731-0400 c12c
WhenExported: 20220615012200-0400 c12c
ExportedFrom: CAPSHRIL sync_js 3495
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: nolageek - Tue, 14 Jun 2022 20:57 UTC

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?

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

---
■ Synchronet ■ Capitol Shrill BBS - Washington, DC - capitolshrill.com

Getting number of active nodes

<62A97537.3719.sync-js@vert.synchro.net>

  copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=792&group=DOVE-Net.Synchronet_Javascript#792

  copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: digital.man@VERT (Digital Man)
To: nolageek
Subject: Getting number of active nodes
Message-ID: <62A97537.3719.sync-js@vert.synchro.net>
Date: Tue, 14 Jun 2022 15:59:19 -0700
X-Comment-To: nolageek
Path: rocksolidbbs.com!not-for-mail
Organization: Vertrauen
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <62A958AB.3495.sync_js@capitolshrill.com>
References: <62A958AB.3495.sync_js@capitolshrill.com>
X-FTN-PID: Synchronet 3.19c-Linux master/d3e4c4edb Jun 7 2022 GCC 8.3.0
X-FTN-CHRS: CP437 2
WhenImported: 20220614225919-0700 c1e0
WhenExported: 20220619211848-0700 c1e0
ExportedFrom: VERT sync-js 3719
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: Digital Man - Tue, 14 Jun 2022 22:59 UTC

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


dovenet / Synchronet Javascript / Getting number of active nodes

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor