• webv4 add menu items

    From Mortifis@VERT/ALLEYCAT to echicken on Fri Apr 3 19:44:48 2020
    ... been diggin in yer webv4 and got lost lol ... how to I add a menu drop on the top navbar ... or under the more drop down?

    Thanks, hope yer well!

    ---
    þ Synchronet þ AlleyCat! BBS Lake Echo, NS Canada
  • From echicken@VERT/ECBBS to Mortifis on Fri Apr 3 23:08:02 2020
    Re: webv4 add menu items
    By: Mortifis to echicken on Fri Apr 03 2020 19:44:48

    ... been diggin in yer webv4 and got lost lol ... how to I add a menu drop on
    the top navbar ... or under the more drop down?

    https://github.com/echicken/synchronet-web-v4/wiki/Customization#pages

    Just create a subdirectory of webv4/pages/ and put more stuff in there. Those subdirectories can have their own subdirectories, etc. (I think).

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
  • From Mortifis@VERT/ALLEYCAT to echicken on Sat Apr 4 17:02:20 2020
    Re: webv4 add menu items
    By: Mortifis to echicken on Fri Apr 03 2020 19:44:48

    https://github.com/echicken/synchronet-web-v4/wiki/Customization#pages

    Just create a subdirectory of webv4/pages/ and put more stuff in there. Those subdirectories can have their own subdirectories, etc. (I think).

    ---
    echicken


    Hmmm ... 1st I created a script 001-own.xjs page in webv4/pages and when I load webv4 it throws an error
    !JavaScript /sbbs/webv4/lib/pages.js line 62: TypeError: f.readln() is null

    also tied putting it in more/004-owm.xjs throws the same error ... apparently I do not know how to add pages or sidebars :'

    ---
    ­ Synchronet ­ AlleyCat! BBS Lake Echo, NS Canada
  • From echicken@VERT/ECBBS to Mortifis on Sat Apr 4 16:30:13 2020
    Re: webv4 add menu items
    By: Mortifis to echicken on Sat Apr 04 2020 17:02:20

    Hmmm ... 1st I created a script 001-own.xjs page in webv4/pages and when I load webv4 it throws an error
    !JavaScript /sbbs/webv4/lib/pages.js line 62: TypeError: f.readln() is null

    also tied putting it in more/004-owm.xjs throws the same error ... apparently I
    do not know how to add pages or sidebars :'

    Is 001-own.xjs empty? If not, can you put its contents somewhere (pastebin, etc.) where I can see them?

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
  • From Mortifis@VERT/ALLEYCAT to echicken on Sat Apr 4 17:39:59 2020
    Re: webv4 add menu items
    By: Mortifis to echicken on Sat Apr 04 2020 17:02:20

    Is 001-own.xjs empty? If not, can you put its contents somewhere (pastebin, etc.) where I can see them?

    ---
    echicken

    It's not empty but I changed the externsion to .ssjs and it is working now ... thanks echicken, I'll slowly figure it out ... then I will try to figure out how to change the css colors ...

    ---
    ­ Synchronet ­ AlleyCat! BBS Lake Echo, NS Canada
  • From echicken@VERT/ECBBS to Mortifis on Sat Apr 4 17:09:47 2020
    Re: webv4 add menu items
    By: Mortifis to echicken on Sat Apr 04 2020 17:39:59

    It's not empty but I changed the externsion to .ssjs and it is working now ...
    thanks echicken, I'll slowly figure it out ... then I will try to figure out

    That's confusing. At a glance I can't see why that alone would resolve the error you got. Did you make any other changes while you were at it?

    Also, XJS and SSJS files are subtly different, and XJS is almost always preferable for front-end / user-facing stuff. I'm sure you get the general idea of <?xjs ... ?> from your PHP experience. Did you change the extension as an experiment, or is this actually an SSJS file?

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
  • From Mortifis@VERT/ALLEYCAT to echicken on Sat Apr 4 19:26:08 2020
    Re: webv4 add menu items
    By: Mortifis to echicken on Sat Apr 04 2020 17:39:59

    That's confusing. At a glance I can't see why that alone would resolve the error you got. Did you make any other changes while you were at it?

    Also, XJS and SSJS files are subtly different, and XJS is almost always preferable for front-end / user-facing stuff. I'm sure you get the general idea of <?xjs ... ?> from your PHP experience. Did you change the extension as an experiment, or is this actually an SSJS file?

    ---
    echicken

    it was orinally an .xjs file, I stripped the <?xjs ?> tags and changed the extension to ssjs. I was getting the same error with the sbbslist.xjs so I did the same to that both work ... no worries, thanks for the help, I'll keep playing with it

    (Nice web interface btw :-)

    ~Mortifis

    ---
    ­ Synchronet ­ AlleyCat! BBS Lake Echo, NS Canada
  • From echicken@VERT/ECBBS to Mortifis on Sat Apr 4 20:06:58 2020
    Re: webv4 add menu items
    By: Mortifis to echicken on Sat Apr 04 2020 19:26:08

    it was orinally an .xjs file, I stripped the <?xjs ?> tags and changed the extension to ssjs. I was getting the same error with the sbbslist.xjs so I did
    the same to that both work ... no worries, thanks for the help, I'll keep

    When doing this, you'd also need to convert any non-js stuff into printed JS strings:

    <div>hi</div>

    becomes:

    write('<div>hi</div>');

    but that's a huge pain. I'd rather figure out the cause of the problem than engage in that kind of workaround.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
  • From Mortifis@VERT/ALLEYCAT to echicken on Sun Apr 5 03:54:51 2020
    ... been huntin' n' peckin' ... which webv4 file has the function emit(...) please ?

    ---
    ­ Synchronet ­ AlleyCat! BBS Lake Echo, NS Canada
  • From echicken@VERT/ECBBS to Mortifis on Sun Apr 5 12:42:32 2020
    Re: webv4 add menu items
    By: Mortifis to echicken on Sun Apr 05 2020 03:54:51

    ... been huntin' n' peckin' ... which webv4 file has the function emit(...)
    please ?

    The file root/api/events.ssjs is an HTTP EventSource and has the emit() function in it.

    The client requests this page and remains connected. Events are streamed to tbe browser as they happen. This was a change I introduced in a move away from having the browser poll the server at intervals for updates (new telegrams, who's online, etc.).

    The event emitters are in lib/events/. Clients can subscribe to any of the event types in there.

    An event emitter must expose a 'cycle' function. events.ssjs will call this function during its loop. The 'cycle' function should check for new data to send, and then push it to the client.

    Pushing an event to the client is a matter of calling 'emit', as in:

    emit({ event: 'my_event', data: 'some data' });

    or:

    emit({ event: 'an_event', data: { an: 'object' } });

    'data' can be a string or an object.

    On the client side, there's a function included in (I think) every page called registerEventListener, so you would need to do something like this, client-side, in JS:

    registerEventListener('my_event', function (e) {
    const data = JSON.parse(e.data);
    });

    Now whenever the server pushes a 'my_event' to the client, this function will be called. You can do whatever you need to with 'e', which is the object that your event emitter passed to emit().

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
  • From Roxanne@VERT/ALLEYCAT to echicken on Sun Apr 5 19:32:54 2020
    Re: webv4 add menu items
    By: Mortifis to echicken on Sun Apr 05 2020 03:54:51

    The file root/api/events.ssjs is an HTTP EventSource and has the emit() function in it.

    The client requests this page and remains connected. Events are streamed to tbe browser as they happen. This was a change I introduced in a move away from having the browser poll the server at intervals for updates (new telegrams, who's online, etc.).

    The event emitters are in lib/events/. Clients can subscribe to any of the event types in there.

    An event emitter must expose a 'cycle' function. events.ssjs will call this function during its loop. The 'cycle' function should check for new data to send, and then push it to the client.

    Pushing an event to the client is a matter of calling 'emit', as in:

    emit({ event: 'my_event', data: 'some data' });

    or:

    emit({ event: 'an_event', data: { an: 'object' } });

    'data' can be a string or an object.

    On the client side, there's a function included in (I think) every page called registerEventListener, so you would need to do something like this, client-side, in JS:

    registerEventListener('my_event', function (e) {
    const data = JSON.parse(e.data);
    });

    Now whenever the server pushes a 'my_event' to the client, this function will be called. You can do whatever you need to with 'e', which is the object that your event emitter passed to emit().

    ---
    echicken

    excellent explaination, thank you!

    ---
    ­ Synchronet ­ AlleyCat! BBS Lake Echo, NS Canada
  • From Mortifis@VERT/ALLEYCAT to echicken on Sun Apr 5 23:12:04 2020
    Sorry to keep troubling you ...
    I have a line is a script:

    writeln('<a href="?pages/More/telegram.ssjs&to='+sys.host+'@'+sys.users[j].name +'"'>+sys.users[j].name+'</a>');

    Throwing error:

    !JavaScript SyntaxError: invalid XML attribute value

    is that because of the &=to portion?

    Thanks,

    ~Mortifis

    ---
    ­ Synchronet ­ AlleyCat! BBS Lake Echo, NS Canada
  • From echicken@VERT/ECBBS to Mortifis on Sun Apr 5 22:31:39 2020
    Re: webv4 add menu items
    By: Mortifis to echicken on Sun Apr 05 2020 23:12:04

    writeln('<a href="?pages/More/telegram.ssjs&to='+sys.host+'@'+sys.users[j].name
    +'"'>+sys.users[j].name+'</a>');

    !JavaScript SyntaxError: invalid XML attribute value

    is that because of the &=to portion?

    No, that's fine. You've got a misplaced apostrophe/single-quote:

    +'"'>+sys.users[j].name+'</a>');

    Should be:

    +'">'+sys.users[j].name+'</a>');

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com