• Synchronet Javascript..

    From Ktulu@VERT/ROI to All on Mon Apr 14 21:46:00 2008
    How do I go about checking if a user has a certain security level and / or a certain age? I mean what's the syntax of it?
    Thanks!!!

    --
    Ktulu
    ---
    þ Synchronet þ Realm of Insanity telnet://roi.synchro.net
  • From Tracker1@VERT/TRN to Ktulu on Tue Apr 15 07:13:00 2008
    On 04/14/2008 06:46 PM, Ktulu wrote:
    How do I go about checking if a user has a certain security level and
    / or a certain age? I mean what's the syntax of it? Thanks!!!

    There's actually a couple ways... the current user, is usually "user" as an instance... otherwise...

    for the JS object model used in sync, see http://www.synchro.net/docs/jsobjs.html
    also... http://www.synchro.net/docs/js.html

    var u = new User(#); //where # is the user number... forward, expecting "user"

    if (user.age >= 18) {
    //do something...
    }

    if (user.security.level > 60) {
    //do something
    }

    alternatively

    if (user.compare_ars("AGE 18 OR LEVEL 60")) {
    //do something
    }

    If you need some books on Javascript in general, let me know...

    NOTE: when you are doing multiple security checks, compare_ars uses the same format as other ARS strings in SCFG, and is generally an easier syntax, than longer JS evaluations, though probably a little longer to parse/execute, but it shouldn't be a huge deal... look at the .js files in the exec/ directory for tons of examples... you can find more information on ARS strings here http://www.synchro.net/docs/security.html

    --
    Michael J. Ryan - tracker1(at)theroughnecks(dot)net - www.theroughnecks.net icq: 4935386 - AIM/AOL: azTracker1 - Y!: azTracker1 - MSN/Win: (email)

    ... FRA #255: A wife is a luxury ... a smart accountant is a necessity.

    ---
    þ Synchronet þ theroughnecks.net - you know you want it
  • From Ktulu@VERT/ROI to Tracker1 on Tue Apr 15 21:14:00 2008
    Re: Re: Synchronet Javascript
    By: Tracker1 to Ktulu on Tue Apr 15 2008 11:13 am

    Hey thanks a lot for the pointers, I appreciate it. I guess if I would have poked around enough and RTFM I woudl have found out how to do it. Thanks again!!!!

    --
    Jim
    ---
    þ Synchronet þ Realm of Insanity telnet://roi.synchro.net
  • From Zero Reader@VERT/ALKY to KenDB3 on Thu Jul 28 04:22:00 2016
    On 07/27/16, KenDB3 said the following...

    For reference, I am trying to grab the data found here: http://www.hamqsl.com/solarxml.php

    I made a mod for my board using that very same feed. I did it in Python with the xmltodict module and just have it outputting an ANSI file that I then display on the board. Piece of cake!

    --- Mystic BBS v1.12 A30 (Raspberry Pi)
    * Origin: Alcoholiday / Est. 1995 / alco.bbs.io
  • From Zero Reader@VERT/ALKY to KenDB3 on Thu Jul 28 05:47:00 2016
    On 07/27/16, KenDB3 said the following...

    For reference, I am trying to grab the data found here: http://www.hamqsl.com/solarxml.php

    I didn't do this with java, but I thought you might get a kick out of the output:

    .-----------------------------------------------------------------------------. | Current Solar-Terrestrial Data, Updated: 28 Jul 2016 1424 GMT | +-----------------------------------------------------------------------------+ | Solar Flux Index : 71 Electron Flux : 4.41e+01 | | A Index : 4 Aurora : 1/n=1.99 | | K Index : 2 Mag. Field (Bz) : 1.8 | | X-ray : A5.8 Solar Wind : 393.8 | | Sunspot Number : 0 Geomagnetic Field : QUIET | | Helium Line (304A) : 110.6 @ SEM Signal Noise : S1-S2 | | Proton Flux : 2.10e-01 MUF @ Boulder, CO : 11.01 | +-----------------------------.----------------------------.------------------+ | HF Conditions | VHF Conditions |`. \ ' / .'| | --------------------------- | | `. .-*""*-. .' | | Bands Day Night | Aurora Lat : 67.5 |-._ /.*. .*.\ _.-| | --------------------------- | Aurora : Band Closed | : <x> <x> ; __| | 80m - 40m Fair Good | 6m EsEU : 50MHz ES |""': .. ; | | 30m - 20m Fair Fair | 4m EsEU : Band Closed |-*" \ ____ / "*-| | 17m - 15m Poor Poor | 2m EsEU : High MUF | .' `-.__.-' `. | | 12m - 10m Poor Poor | 2m EsNA : Band Closed |.hamqsl.com/solar.| `-----------------------------^----------------------------^------------------'
    ALCO-SOLAR v. 1.0 / by zERO rEADER / data from N0NBH

    Everything is colorized "Amiga" style. The band conditions are colorized
    the exact same way you see them on hamqsl.com. The sun graphic in the bottom right corner goes from "sad" to "happy" depending on the SFI. You can see
    right now he's "dead" as the flux is very low.

    The basic idea was to get the data from the feed, and just append it to the bottom of the template. ANSI positional codes (in this case, Mystic's MCI codes) are used to move the data to the right place in the template.

    --- Mystic BBS v1.12 A30 (Raspberry Pi)
    * Origin: Alcoholiday / Est. 1995 / alco.bbs.io
  • From KenDB3@VERT/KD3NET to Zero Reader on Thu Jul 28 17:14:00 2016
    On 07/27/16, KenDB3 said the following...

    For reference, I am trying to grab the data found here: http://www.hamqsl.com/solarxml.php

    I didn't do this with java, but I thought you might get a kick out of the output:

    .--------------------------------------------------------------------------- --. | Current Solar-Terrestrial Data, Updated: 28 Jul 2016 1424 GMT
    | +------------------------------------------------------------------------- ----+ | Solar Flux Index : 71 Electron Flux : 4.41e+01 | | A Index : 4 Aurora
    : 1/n=1.99 | | K Index : 2 Mag. Field (Bz)
    : 1.8 | | X-ray : A5.8 Solar Wind
    : 393.8 | | Sunspot Number : 0 Geomagnetic Field : QUIET | | Helium Line (304A) : 110.6 @ SEM Signal Noise
    : S1-S2 | | Proton Flux : 2.10e-01 MUF @ Boulder, CO : 11.01 | +-----------------------------.---------------------------- .------------------+ | HF Conditions | VHF Conditions |`. \ ' / .'| | --------------------------- |
    | `. .-*""*-. .' | | Bands Day Night | Aurora Lat : 67.5
    |-._ /.*. .*.\ _.-| | --------------------------- | Aurora : Band Closed | : <x> <x> ; __| | 80m - 40m Fair Good | 6m EsEU : 50MHz ES |""': .. ; | | 30m - 20m Fair Fair | 4m EsEU
    : Band Closed |-*" \ ____ / "*-| | 17m - 15m Poor Poor | 2m EsEU : High MUF | .' `-.__.-' `. | | 12m - 10m Poor Poor | 2m EsNA : Band Closed |.hamqsl.com/solar.| `-----------------------------^--------- -------------------^------------------'
    ALCO-SOLAR v. 1.0 / by zERO rEADER / data from N0NBH

    Everything is colorized "Amiga" style. The band conditions are colorized
    the exact same way you see them on hamqsl.com. The sun graphic in the bottom right corner goes from "sad" to "happy" depending on the SFI. You can see right now he's "dead" as the flux is very low.

    The basic idea was to get the data from the feed, and just append it to the bottom of the template. ANSI positional codes (in this case, Mystic's MCI codes) are used to move the data to the right place in the template.

    Aha! So, you are the one who wrote that! Someone showed me a screen shot of it and asked if I could do something like it for Synchronet. I'm honestly not sure I can, lol.

    You did a really great job, I wanted to say kudos. Would you mind if I tried to emulate what you did? Or, if your work is open source, would you mind if tried to rewrite the whole thing from Python into Javascript and credit you with the module?

    My post was basically because I was tinkering around to see if I could even play with the data before I started attempting to write anything else.

    ~KenDB3

    ---
    þ Synchronet þ KD3net-Rhode Island's only BBS about nothing. http://bbs.kd3.us
  • From Mro@VERT/BBSESINF to Zero Reader on Thu Jul 28 18:35:00 2016
    Re: Re: Synchronet Javascript
    By: Zero Reader to KenDB3 on Thu Jul 28 2016 09:47 am

    The basic idea was to get the data from the feed, and just append it to the bottom of the template. ANSI positional codes (in this case, Mystic's MCI codes) are used to move the data to the right place in the template.


    you can also use ansi positioning codes.

    i would first dump the 'art' for the template and at the ass end of the file tack on the position codes with the data.
    ---
    þ Synchronet þ ::: BBSES.info - free BBS services :::
  • From Zero Reader@VERT/ALKY to KenDB3 on Thu Jul 28 21:02:00 2016
    On 07/28/16, KenDB3 said the following...

    You did a really great job, I wanted to say kudos. Would you mind if I tried to emulate what you did? Or, if your work is open source, would
    you mind if tried to rewrite the whole thing from Python into Javascript and credit you with the module?

    Thanks! I'm not a coder or anything and this was the first thing I ever did
    in Python. It started out just outputting the data like a list, and then I
    just started adding onto it, making that template for it, etc. I originally wrote it for DayDream BBS, but I re-did it and started using mystic's MCI
    codes rather than ANSI positioning.

    I run the script as a door from the BBS, or it could be a timed event, and it just generates a text file which is then displayed to the user.

    The module that does the heavy lifting is xmltodict, which I'm told is very similar to JSON. I use it for some other stuff like a Top 10 Box Office listing, and I had a Summits on the Air spot lister once upon a time also.

    You're free to use whatever you like. I was basically just riffing off the solar widgets from hamqsl. I actually sent him a screenshot of it in action
    and he loved it.

    My post was basically because I was tinkering around to see if I could even play with the data before I started attempting to write anything else.

    Good luck with it! Let me know if you want to see the Python and I'll try to figure out a way to make it available. I never really released anything
    because my code is so bad I didn't want to get ridiculed for it, heheh.

    In the meantime, I hope this solar flux index goes back up. I can't make any magic happen on the airwaves...

    --- Mystic BBS v1.12 A30 (Raspberry Pi)
    * Origin: Alcoholiday / Est. 1995 / alco.bbs.io
  • From Zero Reader@VERT/ALKY to Mro on Thu Jul 28 21:07:00 2016
    On 07/28/16, Mro said the following...

    you can also use ansi positioning codes.

    i would first dump the 'art' for the template and at the ass end of the file tack on the position codes with the data.

    That's exactly what it does. It makes a copy of the template and appends positional codes with the respective data at the bottom. My first version
    used ANSI codes, when I made a version for Mystic, I used Mystic's MCI positional codes, and I'm sure Synchronet's positional codes would also work.

    It also looks pretty decent with a good Amiga font... Like Topaz or Microknight, heheh.

    --- Mystic BBS v1.12 A30 (Raspberry Pi)
    * Origin: Alcoholiday / Est. 1995 / alco.bbs.io
  • From KenDB3@VERT/KD3NET to Zero Reader on Fri Jul 29 03:56:00 2016
    On 07/28/16, KenDB3 said the following...

    You did a really great job, I wanted to say kudos. Would you mind if I tried to emulate what you did? Or, if your work is open source, would you mind if tried to rewrite the whole thing from Python into Javascript and credit you with the module?

    Thanks! I'm not a coder or anything and this was the first thing I ever did in Python. It started out just outputting the data like a list, and then I just started adding onto it, making that template for it, etc. I originally wrote it for DayDream BBS, but I re-did it and started using mystic's MCI codes rather than ANSI positioning.

    I run the script as a door from the BBS, or it could be a timed event, and it just generates a text file which is then displayed to the user.

    The module that does the heavy lifting is xmltodict, which I'm told is very similar to JSON. I use it for some other stuff like a Top 10 Box Office listing, and I had a Summits on the Air spot lister once upon a time also.

    You're free to use whatever you like. I was basically just riffing off the solar widgets from hamqsl. I actually sent him a screenshot of it in action and he loved it.

    My post was basically because I was tinkering around to see if I could even play with the data before I started attempting to write anything else.

    Good luck with it! Let me know if you want to see the Python and I'll try to figure out a way to make it available. I never really released anything because my code is so bad I didn't want to get ridiculed for it, heheh.

    In the meantime, I hope this solar flux index goes back up. I can't make any magic happen on the airwaves...


    Thanks Man! I really appreciate it!

    ~KenDB3

    ---
    þ Synchronet þ KD3net-Rhode Island's only BBS about nothing. http://bbs.kd3.us
  • From KenDB3@VERT/KD3NET to echicken on Fri Jul 29 12:49:00 2016
    There's already some code for dealing with this exact feed, but it's embedded in an IRC bot. You might be able to find something useful in: '/exec/ircbots/ham/ham.js', however this should work:

    load('http.js');
    try {
    var solardata = new XML(
    (new HTTPRequest()).Get(
    'http://www.hamqsl.com/solarxml.php'
    ).replace(
    /<\?[^?]*\?>/g, ''
    )
    ).solardata;
    } catch (err) {
    log('Shit done borked! ' + err);
    }

    (See https://bbs.electronicchicken.com/temp/solar.txt if that didn't come through okay.)

    You should then be able to get at the values from the feed like so:

    print(solardata.sunspots);
    print(solardata.solarwind);

    And so on.

    The IRC bot code mentioned above has examples of how to deal with the nested 'calculated(vhf)conditions' values, which gets deeper into E4X than I care to do right now.


    EC, I have another question (or anyone that feels they can answer).

    I notice in the IRC bot code that you can get banned for hitting the web page too often.

    Would there be a way to bring in the XML data without an HTTPRequest from a local file? Say something I saved from the last successful pull from the live file and defined as:
    var localfile = js.exec_dir + "solar.php";
    where solar.php was saved from a previous lookup less than an hour ago?

    My awful attempt to do this currently looks like this:

    if((time() - last_solar_update) > 60*60) {
    try {
    var solardata = new XML(
    (new HTTPRequest()).Get(
    'http://bbs.kd3.us/sol/solarxml.php.xml'
    ).replace(
    /<\?[^?]*\?>/g, ''
    )
    ).solardata;
    } catch (err) {
    log('Shit done borked! ' + err);
    }
    } else {
    try {
    var localfile = js.exec_dir + "solar.php";
    var localPHPfile = new File(localfile);
    localPHPfile.open("r"); // open file with read access
    var localXMLfile = localPHPfile.readAll();
    var fixedXMLfile = localXMLfile.replace(
    /<\?[^?]*\?>/g, ''
    );
    var solardata = new XML(
    fixedXMLfile.solardata);
    } catch (err) {
    log('Shit done borked! ' + err);
    }
    localPHPfile.close();
    }

    Also, if this is simply a crazy thing to try and do, feel free to let me know. localXMLfile keeps coming back as null and I'm not sure where I've gone wrong anymore.

    ~KenDB3

    ---
    þ Synchronet þ KD3net-Rhode Island's only BBS about nothing. http://bbs.kd3.us
  • From echicken@VERT/ECBBS to KenDB3 on Fri Jul 29 13:36:00 2016
    I notice in the IRC bot code that you can get banned for hitting the web page too often.

    Yes, this is something that I recall hearing about in the past. I guess you get x number of hits per day.

    Would there be a way to bring in the XML data without an HTTPRequest from a local file? Say

    Sure. I would do something like this:

    load('http.js');

    var url = 'http://www.hamqsl.com/solarxml.php';
    var file = system.data_dir + 'solardata.xml';
    var age = 43200; // Seconds

    // Fetch data via HTTP and write to file specified above
    function getSolarData() {
    var sd = (new HTTPRequest()).Get(url);
    var f = new File(file);
    f.open('w');
    f.write(sd);
    f.close();
    }

    // Read data from local file and return parsed XML object
    function readSolarData() {
    var f = new File(file);
    f.open('r');
    var sd = new XML(f.read().replace(/<\?[^?]*\?>/g, ''));
    f.close();
    return sd;
    }

    // Fetch new data if local file timestamp less than file age specified above
    if (!file_exists(file) || time() - file_utime(file) > 43200) getSolarData();

    // Read the current data on hand
    var sd = readSolarData();

    // Now start printing out that fascinating solar data and your happy/sad sun face

    It would be worth throwing in some try ... catch blocks somewhere in there, because the HTTP load or XML parsing portions may fail for a variety of reasons.

    You could also move the data-fetching part into a separate script and run it on a schedule once, twice, or however many times per day that you want, then the user facing script just loads whatever data is in the file that the other script writes to.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-273-7230
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
  • From KenDB3@VERT/KD3NET to echicken on Fri Jul 29 21:01:00 2016
    I notice in the IRC bot code that you can get banned for hitting the web page too often.

    Yes, this is something that I recall hearing about in the past. I guess you get x number of hits per day.

    Would there be a way to bring in the XML data without an HTTPRequest from a local file? Say

    Sure. I would do something like this:

    load('http.js');

    var url = 'http://www.hamqsl.com/solarxml.php';
    var file = system.data_dir + 'solardata.xml';
    var age = 43200; // Seconds

    // Fetch data via HTTP and write to file specified above
    function getSolarData() {
    var sd = (new HTTPRequest()).Get(url);
    var f = new File(file);
    f.open('w');
    f.write(sd);
    f.close();
    }

    // Read data from local file and return parsed XML object
    function readSolarData() {
    var f = new File(file);
    f.open('r');
    var sd = new XML(f.read().replace(/<\?[^?]*\?>/g, ''));
    f.close();
    return sd;
    }

    // Fetch new data if local file timestamp less than file age specified above if (!file_exists(file) || time() - file_utime(file) > 43200) getSolarData();

    // Read the current data on hand
    var sd = readSolarData();

    // Now start printing out that fascinating solar data and your happy/sad sun face

    It would be worth throwing in some try ... catch blocks somewhere in there, because the HTTP load or XML parsing portions may fail for a variety of reasons.

    You could also move the data-fetching part into a separate script and run it on a schedule once, twice, or however many times per day that you want, then the user facing script just loads whatever data is in the file that the other script writes to.



    Thanks again EC, it is much appreciated. :-)

    ~KenDB3

    ---
    þ Synchronet þ KD3net-Rhode Island's only BBS about nothing. http://bbs.kd3.us
  • From KenDB3@VERT/KD3NET to Kirkman on Fri Aug 5 08:09:00 2016
    I faced the same quandary when I was putting together Sports Stats. Ultimately I decided to use Python to write my data scraper. It pulls in the XML and converts it to JSON. Once the data is in JSON, then I can parse it using Sync's JS.


    I was very close to doing that if I couldn't get the data a different way. I was hoping to make the script more portable for Sync sysops though. So, thanks to echicken, it turned out pretty well.

    ~KenDB3

    ---
    þ Synchronet þ KD3net-Rhode Island's only BBS about nothing. http://bbs.kd3.us