• syncWXremix and Dial-up

    From KenDB3@VERT/KD3NET to Digital Man on Wed Jan 6 22:23:46 2016
    Re: Re: Sync Weather App - syncWXremix
    By: KenDB3 to tbirdsradio on Fri Jan 01 2016 08:11 am

    Re: Re: Sync Weather App - syncWXremix
    By: tbirdsradio to KenDB3 on Thu Dec 31 2015 09:34 am

    Once again i got ahead of myself. Dial up user phoned in and
    received this error:

    "Error in weather.js api.underground.com returned a
    'querynotfound' error with this description. 'No cities match your
    search query'."
    Do i have the above right?

    That's all correct. I just didn't account for dial-up users. Mainly
    because I don't have any dial-up access, it didn't really dawn on me.

    Can anyone shed some light on how I might test for this scenario? I'm
    guessing the user's IP comes up as undefined in this case?

    Assuming the BBS is using SEXPOTS, the user's IP address should be the IP address of the BBS computer, or possibly 127.0.0.1 (I forget which). You can programatically detect a SEXPOTS/dial-up connection by checking if user.connection is a number (e.g. "28800") rather than a protocol string (e.g. "Telnet").

    Something like this:
    var dialup = (parseInt(user.connection) > 0);

    At least, I think would work (without actually trying it). Let me know how it works for you,

    DM, I was hoping you might be able to help point me in the right direction on this. tbirdsradio had a chance to try out the new version from GitHub that used
    this bit of code (but had no luck):

    var dialup = (parseInt(user.connection) > 0);

    function getQuerySuffix() {
    var qs;
    if (dialup === 'true')
    {
    if (fallback_type == 'nonip') {
    qs = fallback + '.json';
    } else {
    qs = 'autoip.json?geo_ip=' + resolve_ip(system.inet_addr);
    }
    } else if (user.ip_address.search( /(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]
    \.)|(^169\.254\.)|(^::1$)|(^[fF][cCdD])/
    ) > -1
    ) {
    if (fallback_type == 'nonip') {
    qs = fallback + '.json';
    } else {
    if (client.protocol === 'Telnet') {
    qs = wstsGetIPAddress();
    } else if (bbs.sys_status&SS_RLOGIN) {
    qs = wsrsGetIPAddress();
    }
    if (typeof qs === 'undefined') qs = resolve_ip(system.inet_addr);
    qs = 'autoip.json?geo_ip=' + qs;
    }
    } else {
    qs = 'autoip.json?geo_ip=' + user.ip_address;
    }
    return qs;
    }

    var wungrndQuery = getQuerySuffix();

    **********

    However, tbird is still seeing an error when the app is launched at Logon and also as a Door/External for his dial-up user.

    DEBUG for weather.js API call looked like this at the time of error: http://api.wunderground.com/api/XXXXXXXXXXXXXXXX/conditions/forecast/astronomy/
    alerts/q/autoip.json?geo_ip=812XXXXXXX

    (Blocked out API and last 7 of phone number).

    Any thoughts as to why I am missing catching this scenario? It's got me boggled
    and I can't really see it.

    Thanks for any help you can lend (and sorry for the long post).

    ~KenDB3

    ---
    þ Synchronet þ KD3net-Rhode Island's only BBS about nothing. http://bbs.kd3.us
  • From echicken@VERT/ECBBS to KenDB3 on Wed Jan 6 23:33:28 2016
    Re: syncWXremix and Dial-up
    By: KenDB3 to Digital Man on Wed Jan 06 2016 22:23:46

    var dialup = (parseInt(user.connection) > 0);

    However, tbird is still seeing an error when the app is launched at Logon and also as a Door/External for his dial-up user.

    parseInt() is probably the wrong thing for this particular case, because it tries to pull a number out of a string that may contain non-digit characters.

    parseInt('192.168.1.1'); // returns 192
    parseInt('4162737230'); // returns 4162737230

    Assuming that phone numbers will always be strings of digits, you could do:

    if(user.connection.search(/[^\d]/) < 0) {
    // Probably a phone number
    } else {
    // Probably not a phone number
    }

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-273-7230
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
  • From Digital Man@VERT to echicken on Wed Jan 6 22:06:46 2016
    Re: syncWXremix and Dial-up
    By: echicken to KenDB3 on Wed Jan 06 2016 11:33 pm

    Re: syncWXremix and Dial-up
    By: KenDB3 to Digital Man on Wed Jan 06 2016 22:23:46

    var dialup = (parseInt(user.connection) > 0);

    However, tbird is still seeing an error when the app is launched at Logon and also as a Door/External for his dial-up user.

    parseInt() is probably the wrong thing for this particular case, because it tries to pull a number out of a string that may contain non-digit characters.

    parseInt('192.168.1.1'); // returns 192
    parseInt('4162737230'); // returns 4162737230

    Assuming that phone numbers will always be strings of digits, you could do:

    if(user.connection.search(/[^\d]/) < 0) {
    // Probably a phone number
    } else {
    // Probably not a phone number
    }

    He's using parseInt() on the user.connection property, which should either be a terminal-protocol string (e.g. "Telnet", "Rlogin", "SSH") or a modem DCE (connect) rate (e.g. "28800"). There should not ever be an IP address or a phone number in the user.connection property.

    Or maybe I missed this other use of parseInt()?

    digital man

    Synchronet "Real Fact" #42:
    Synchronet added Baja/PCMS support with v2.00a (1994).
    Norco, CA WX: 47.9øF, 91.0% humidity, 3 mph WNW wind, 0.60 inches rain/24hrs

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From KenDB3@VERT/KD3NET to echicken on Thu Jan 7 01:11:30 2016
    Re: syncWXremix and Dial-up
    By: echicken to KenDB3 on Wed Jan 06 2016 11:33 pm

    Re: syncWXremix and Dial-up
    By: KenDB3 to Digital Man on Wed Jan 06 2016 22:23:46

    var dialup = (parseInt(user.connection) > 0);

    However, tbird is still seeing an error when the app is launched at
    Logon and also as a Door/External for his dial-up user.

    parseInt() is probably the wrong thing for this particular case, because it tries to pull a number out of a string that may contain non-digit characters.

    parseInt('192.168.1.1'); // returns 192
    parseInt('4162737230'); // returns 4162737230

    Assuming that phone numbers will always be strings of digits, you could do:

    if(user.connection.search(/[^\d]/) < 0) {
    // Probably a phone number
    } else {
    // Probably not a phone number
    }

    According to DM, user.connection should return a connection speed for a dialup user (e.g. "28800") rather than a protocol string (e.g. "Telnet"). So the > 0 made sense. I gave it some mock data, and it returned "true" if I fed it 28800, and "false" if I fed it the word Telnet.

    I don't know SEXPOTS (or any dialup to telnet bridge) well enough to know if the Caller ID was going to come back with 10-digit (4162737230), 11-digit (14162737230), +1 format, or even the short 7-digit pattern. So, I was avoiding testing the user.ip_address field even though the phone number was ending up there. I'm not sure if that behavior is predictable across the board. If the sysop had dialup but not Caller ID from thier telco, what does SEXPOTS drop into the user.ip_address? Does it work in Europe? Tricky tricky. :-/

    Quick question, do I have too many "=" when trying to match if "dialup" is "true"? I suddenly thought of it 30 minutes ago. (Maybe go from === to ==)

    ~KenDB3

    ---
    þ Synchronet þ KD3net-Rhode Island's only BBS about nothing. http://bbs.kd3.us
  • From Digital Man@VERT to KenDB3 on Wed Jan 6 22:12:59 2016
    Re: syncWXremix and Dial-up
    By: KenDB3 to Digital Man on Wed Jan 06 2016 10:23 pm

    Re: Re: Sync Weather App - syncWXremix
    By: KenDB3 to tbirdsradio on Fri Jan 01 2016 08:11 am

    Re: Re: Sync Weather App - syncWXremix
    By: tbirdsradio to KenDB3 on Thu Dec 31 2015 09:34 am

    Once again i got ahead of myself. Dial up user phoned in and
    received this error:

    "Error in weather.js api.underground.com returned a
    'querynotfound' error with this description. 'No cities match your
    search query'."
    Do i have the above right?

    That's all correct. I just didn't account for dial-up users. Mainly
    because I don't have any dial-up access, it didn't really dawn on me.

    Can anyone shed some light on how I might test for this scenario? I'm
    guessing the user's IP comes up as undefined in this case?

    Assuming the BBS is using SEXPOTS, the user's IP address should be the IP address of the BBS computer, or possibly 127.0.0.1 (I forget which). You can programatically detect a SEXPOTS/dial-up connection by checking if user.connection is a number (e.g. "28800") rather than a protocol string (e.g. "Telnet").

    Something like this:
    var dialup = (parseInt(user.connection) > 0);

    At least, I think would work (without actually trying it). Let me know how it works for you,

    DM, I was hoping you might be able to help point me in the right direction on this. tbirdsradio had a chance to try out the new version from GitHub that used
    this bit of code (but had no luck):

    var dialup = (parseInt(user.connection) > 0);

    function getQuerySuffix() {
    var qs;
    if (dialup === 'true')
    {
    if (fallback_type == 'nonip') {
    qs = fallback + '.json';
    } else {
    qs = 'autoip.json?geo_ip=' + resolve_ip(system.inet_addr);
    }
    } else if (user.ip_address.search( /(^127\.)|(^192\.168\.)|(^10\.)|(^172 \.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1] \.)|(^169\.254\.)|(^::1$)|(^[fF][cCdD])/
    ) > -1
    ) {
    if (fallback_type == 'nonip') {
    qs = fallback + '.json';
    } else {
    if (client.protocol === 'Telnet') {
    qs = wstsGetIPAddress();
    } else if (bbs.sys_status&SS_RLOGIN) {
    qs = wsrsGetIPAddress();
    }
    if (typeof qs === 'undefined') qs = resolve_ip(system.inet_addr);
    qs = 'autoip.json?geo_ip=' + qs;
    }
    } else {
    qs = 'autoip.json?geo_ip=' + user.ip_address;
    }
    return qs;
    }

    var wungrndQuery = getQuerySuffix();

    **********

    However, tbird is still seeing an error when the app is launched at Logon and also as a Door/External for his dial-up user.

    DEBUG for weather.js API call looked like this at the time of error: http:// api.wunderground.com/api/XXXXXXXXXXXXXXXX/conditions/forecast/astronomy/ alerts/q/autoip.json?geo_ip=812XXXXXXX

    (Blocked out API and last 7 of phone number).

    Any thoughts as to why I am missing catching this scenario? It's got me boggled
    and I can't really see it.

    Thanks for any help you can lend (and sorry for the long post).

    For a dial-up connection (via SEXPOTS), the user.ip_address property could either the caller-ID information (if provided by the modem) or the IP address of the SEXPOTS proxy (e.g. 127.0.0.1).

    Is dialup not being set to true (in your code) for the dial-up connection?

    Some more debug-level log output could help identify exactly what's happening here.

    digital man

    Synchronet "Real Fact" #66:
    SEXYZ is as a 32-bit replacement for [F]DSZ, CE-XYZ and other protocol drivers. Norco, CA WX: 48.0øF, 92.0% humidity, 0 mph WNW wind, 0.60 inches rain/24hrs

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From KenDB3@VERT/KD3NET to Digital Man on Thu Jan 7 01:22:43 2016
    Re: syncWXremix and Dial-up
    By: Digital Man to KenDB3 on Wed Jan 06 2016 10:12 pm

    Re: syncWXremix and Dial-up
    By: KenDB3 to Digital Man on Wed Jan 06 2016 10:23 pm

    Re: Re: Sync Weather App - syncWXremix
    By: KenDB3 to tbirdsradio on Fri Jan 01 2016 08:11 am

    Re: Re: Sync Weather App - syncWXremix
    By: tbirdsradio to KenDB3 on Thu Dec 31 2015 09:34 am

    Once again i got ahead of myself. Dial up user phoned in and
    received this error:

    "Error in weather.js api.underground.com returned a
    'querynotfound' error with this description. 'No cities match
    your
    search query'."
    Do i have the above right?

    That's all correct. I just didn't account for dial-up users. Mainly
    because I don't have any dial-up access, it didn't really dawn on
    me.
    Can anyone shed some light on how I might test for this scenario?
    I'm guessing the user's IP comes up as undefined in this case?

    Assuming the BBS is using SEXPOTS, the user's IP address should be
    the IP address of the BBS computer, or possibly 127.0.0.1 (I
    forget which). You can programatically detect a SEXPOTS/dial-up
    connection by checking if user.connection is a number (e.g.
    "28800") rather than a protocol string (e.g. "Telnet").

    Something like this:
    var dialup = (parseInt(user.connection) > 0);

    At least, I think would work (without actually trying it). Let me
    know how it works for you,

    DM, I was hoping you might be able to help point me in the right
    direction on this. tbirdsradio had a chance to try out the new
    version from GitHub that used
    this bit of code (but had no luck):

    var dialup = (parseInt(user.connection) > 0);

    function getQuerySuffix() {
    var qs;
    if (dialup === 'true')
    {
    if (fallback_type == 'nonip') {
    qs = fallback + '.json';
    } else {
    qs = 'autoip.json?geo_ip=' + resolve_ip(system.inet_addr);
    }
    } else if (user.ip_address.search(
    /(^127\.)|(^192\.168\.)|(^10\.)|(^172
    \.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]
    \.)|(^169\.254\.)|(^::1$)|(^[fF][cCdD])/ ) > -1
    ) {
    if (fallback_type == 'nonip') {
    qs = fallback + '.json';
    } else {
    if (client.protocol === 'Telnet') {
    qs = wstsGetIPAddress();
    } else if (bbs.sys_status&SS_RLOGIN) {
    qs = wsrsGetIPAddress();
    }
    if (typeof qs === 'undefined') qs = resolve_ip(system.inet_addr);
    qs = 'autoip.json?geo_ip=' + qs;
    }
    } else {
    qs = 'autoip.json?geo_ip=' + user.ip_address;
    }
    return qs;
    }

    var wungrndQuery = getQuerySuffix();

    **********

    However, tbird is still seeing an error when the app is launched at
    Logon and also as a Door/External for his dial-up user.

    DEBUG for weather.js API call looked like this at the time of error:
    http://
    api.wunderground.com/api/XXXXXXXXXXXXXXXX/conditions/forecast/astronom
    y/ alerts/q/autoip.json?geo_ip=812XXXXXXX
    (Blocked out API and last 7 of phone number).

    Any thoughts as to why I am missing catching this scenario? It's got
    me boggled
    and I can't really see it.

    Thanks for any help you can lend (and sorry for the long post).

    For a dial-up connection (via SEXPOTS), the user.ip_address property could either the caller-ID information (if provided by the modem) or the IP address of the SEXPOTS proxy (e.g. 127.0.0.1).

    Is dialup not being set to true (in your code) for the dial-up connection?

    Some more debug-level log output could help identify exactly what's happening here.

    Good point, I don't know what's happening to "dialup" during this process. I
    do know that the phone number is being dropped into user.ip_address and that's where the query string is failing. I'm just not catching it. I'll add some DEBUG to grab "dialup" and I think user.connection as well.

    Thanks DM!

    ~KenDB3

    ---
    þ Synchronet þ KD3net-Rhode Island's only BBS about nothing. http://bbs.kd3.us
  • From echicken@VERT/ECBBS to Digital Man on Thu Jan 7 01:37:53 2016
    Re: syncWXremix and Dial-up
    By: Digital Man to echicken on Wed Jan 06 2016 22:06:46

    He's using parseInt() on the user.connection property, which should either be a terminal-protocol string (e.g. "Telnet", "Rlogin", "SSH") or a modem DCE (connect) rate (e.g. "28800"). There should not ever be an IP address or a phone number in the user.connection property.

    Or maybe I missed this other use of parseInt()?

    Nah, I just wasn't paying close enough attention.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-273-7230
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
  • From echicken@VERT/ECBBS to KenDB3 on Thu Jan 7 01:42:39 2016
    Re: syncWXremix and Dial-up
    By: KenDB3 to echicken on Thu Jan 07 2016 01:11:30

    According to DM, user.connection should return a connection speed for a dialup user (e.g. "28800") rather than a protocol string (e.g. "Telnet"). So the > 0 made sense. I gave it some mock data, and it returned "true" if I fed it 28800, and "false" if I fed it the word Telnet.

    Yes - I was wrong, and that makes sense.

    I don't know SEXPOTS (or any dialup to telnet bridge) well enough to know if the Caller ID was going to come back with 10-digit (4162737230), 11-digit (14162737230), +1 format, or even the short 7-digit pattern. So,

    It depends entirely on what caller-ID data the modem gives to the BBS, if any. There may also be international numbers, which would be entirely different. Not worth trying to do a pattern-match, I wouldn't think.

    I was avoiding testing the user.ip_address field even though the phone number was ending up there. I'm not sure if that behavior is predictable

    I think that's where I got confused (I forgot you were using user.connection.)

    across the board. If the sysop had dialup but not Caller ID from thier telco, what does SEXPOTS drop into the user.ip_address? Does it work in

    I think that DM mentioned that the fallback user.ip_address for SEXPOTS connections lacking caller-ID info would be the SEXPOTS proxy's IP address. This won't always be on the local network - in my case, I run SEXPOTS at home, but my BBS is elsewhere.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-273-7230
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
  • From KenDB3@VERT/KD3NET to Digital Man on Thu Jan 7 11:33:47 2016
    Re: syncWXremix and Dial-up
    By: KenDB3 to Digital Man on Thu Jan 07 2016 01:22 am

    var dialup = (parseInt(user.connection) > 0);

    function getQuerySuffix() {
    var qs;
    if (dialup === 'true')
    {
    if (fallback_type == 'nonip') {
    qs = fallback + '.json';
    } else {
    qs = 'autoip.json?geo_ip=' + resolve_ip(system.inet_addr);
    }
    } else if (user.ip_address.search(
    /(^127\.)|(^192\.168\.)|(^10\.)|(^172
    \.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]
    \.)|(^169\.254\.)|(^::1$)|(^[fF][cCdD])/ ) > -1
    ) {
    if (fallback_type == 'nonip') {
    qs = fallback + '.json';
    } else {
    if (client.protocol === 'Telnet') {
    qs = wstsGetIPAddress();
    } else if (bbs.sys_status&SS_RLOGIN) {
    qs = wsrsGetIPAddress();
    }
    if (typeof qs === 'undefined') qs = resolve_ip(system.inet_addr);
    qs = 'autoip.json?geo_ip=' + qs;
    }
    } else {
    qs = 'autoip.json?geo_ip=' + user.ip_address;
    }
    return qs;
    }

    var wungrndQuery = getQuerySuffix();

    **********

    However, tbird is still seeing an error when the app is launched at
    Logon and also as a Door/External for his dial-up user.

    DEBUG for weather.js API call looked like this at the time of error:
    http://
    api.wunderground.com/api/XXXXXXXXXXXXXXXX/conditions/forecast/astrono
    m
    y/ alerts/q/autoip.json?geo_ip=812XXXXXXX
    (Blocked out API and last 7 of phone number).

    Any thoughts as to why I am missing catching this scenario? It's got
    me boggled
    and I can't really see it.

    Thanks for any help you can lend (and sorry for the long post).

    For a dial-up connection (via SEXPOTS), the user.ip_address property
    could either the caller-ID information (if provided by the modem) or
    the IP address of the SEXPOTS proxy (e.g. 127.0.0.1).

    Is dialup not being set to true (in your code) for the dial-up connection?
    Some more debug-level log output could help identify exactly what's
    happening here.

    Good point, I don't know what's happening to "dialup" during this process. I do know that the phone number is being dropped into user.ip_address and that's where the query string is failing. I'm just not catching it. I'll add some DEBUG to grab "dialup" and I think user.connection as well.

    I started using some mock data (since I don't have dialup to test with). I think I figured this out.

    function getQuerySuffix() {
    var qs;
    if (dialup === 'true')

    ...should be...

    function getQuerySuffix() {
    var qs;
    if (dialup === true)

    This makes it through the function by grabbing the correct fallback lookup.

    Triple Equals works... At some point I tried Double Equals instead (stil works). Should I stick with Triple? I read up on the difference, but not sure if one might be better than the other in this particular case.

    Thank you so much for the help (DM and EC)! More Debug was certainly the difference this time.

    ~KenDB3

    ---
    þ Synchronet þ KD3net-Rhode Island's only BBS about nothing. http://bbs.kd3.us
  • From echicken@VERT/ECBBS to KenDB3 on Thu Jan 7 13:31:40 2016
    Re: syncWXremix and Dial-up
    By: KenDB3 to Digital Man on Thu Jan 07 2016 11:33:47

    var dialup = (parseInt(user.connection) > 0);

    if (dialup === 'true')
    ...should be...
    if (dialup === true)

    Triple Equals works... At some point I tried Double Equals instead (stil works). Should I stick with Triple? I read up on the difference, but not sure if one might be better than the other in this particular case.

    The difference between == and === can be pretty big in some situations. See here for a lot of info:

    http://tinyurl.com/paz96fe

    But ultimately you can just do this:

    if (dialup) {
    // If dialup is true, then this happens
    } else {
    // Otherwise this happens
    }

    I'd still recommend reading up on == vs. ===, because using both without knowing the difference would probably lead to much confusion.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-273-7230
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
  • From KenDB3@VERT/KD3NET to echicken on Thu Jan 7 13:54:59 2016
    Re: syncWXremix and Dial-up
    By: echicken to KenDB3 on Thu Jan 07 2016 01:31 pm

    var dialup = (parseInt(user.connection) > 0);

    if (dialup === 'true')
    ...should be...
    if (dialup === true)

    Triple Equals works... At some point I tried Double Equals instead
    (stil works). Should I stick with Triple? I read up on the
    difference, but not sure if one might be better than the other in
    this particular case.

    The difference between == and === can be pretty big in some situations. See here for a lot of info:

    http://tinyurl.com/paz96fe

    But ultimately you can just do this:

    if (dialup) {
    // If dialup is true, then this happens
    } else {
    // Otherwise this happens
    }

    I'd still recommend reading up on == vs. ===, because using both without knowing the difference would probably lead to much confusion.

    That link is incredibly helpful, and I'll read through it more in depth. I appreciate it, thank you! I tested with your suggestion, works like a champ. I'm curious to see tbirdsradio try out the new code.

    ~KenDB3

    ---
    þ Synchronet þ KD3net-Rhode Island's only BBS about nothing. http://bbs.kd3.us
  • From Nightfox@VERT/DIGDIST to KenDB3 on Thu Jan 7 12:52:43 2016
    I started using some mock data (since I don't have dialup to test with). I think I figured this out.

    function getQuerySuffix() {
    var qs;
    if (dialup === 'true')

    ...should be...

    function getQuerySuffix() {
    var qs;
    if (dialup === true)

    This makes it through the function by grabbing the correct fallback lookup.

    Triple Equals works... At some point I tried Double Equals instead (stil works). Should I stick with Triple? I read up on the difference, but not sure if one might be better than the other in this particular case.

    Isn't the "=== true" redundant? Saying "if (dialup)" should be enough, and it's just as clear as saying "if (dialup === true)", since that has the same meaning.

    Nightfox

    ---
    þ Synchronet þ Digital Distortion: digitaldistortionbbs.com
  • From KenDB3@VERT/KD3NET to Nightfox on Thu Jan 7 23:39:01 2016
    Re: syncWXremix and Dial-up
    By: Nightfox to KenDB3 on Thu Jan 07 2016 12:52 pm

    I started using some mock data (since I don't have dialup to test
    with). I think I figured this out.

    function getQuerySuffix() {
    var qs;
    if (dialup === 'true')

    ...should be...

    function getQuerySuffix() {
    var qs;
    if (dialup === true)

    This makes it through the function by grabbing the correct fallback
    lookup.
    Triple Equals works... At some point I tried Double Equals instead
    (stil works). Should I stick with Triple? I read up on the difference,
    but not sure if one might be better than the other in this particular
    case.

    Isn't the "=== true" redundant? Saying "if (dialup)" should be enough, and it's just as clear as saying "if (dialup === true)", since that has the same meaning.

    Thanks Nightfox, that is what echicken suggested too, and I think I get the concept a bit more now. That is what I ended up using in the code.

    After I hear back on if it fixed the issue with tbirdsradio, who has a dialup user, I'll know if I've covered my bases a bit better now. I'll probably package whats on GitHub right now as the next iteration at that point.

    ~KenDB3

    ---
    þ Synchronet þ KD3net-Rhode Island's only BBS about nothing. http://bbs.kd3.us
  • From Deuce@VERT/SYNCNIX to Nightfox on Fri Jan 8 13:05:43 2016
    Re: syncWXremix and Dial-up
    By: Nightfox to KenDB3 on Thu Jan 07 2016 12:52 pm

    Isn't the "=== true" redundant? Saying "if (dialup)" should be enough, and it's just as clear as saying "if (dialup === true)", since that has the same meaning.

    No, they're different meanings.

    dialup = "Yes"
    if (dialup)
    print("Yessir!")
    if (dialip===true)
    print("Fosho!");

    Would only print "Yessir!".

    ---
    http://DuckDuckGo.com/ a better search engine that respects your privacy.
    Mro is an idiot. Please ignore him, we keep hoping he'll go away.
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From Digital Man@VERT to Nightfox on Sat Jan 9 19:59:22 2016
    Re: syncWXremix and Dial-up
    By: Nightfox to KenDB3 on Thu Jan 07 2016 12:52 pm

    I started using some mock data (since I don't have dialup to test with). I think I figured this out.

    function getQuerySuffix() {
    var qs;
    if (dialup === 'true')

    ...should be...

    function getQuerySuffix() {
    var qs;
    if (dialup === true)

    This makes it through the function by grabbing the correct fallback lookup.

    Triple Equals works... At some point I tried Double Equals instead (stil works). Should I stick with Triple? I read up on the difference, but not sure if one might be better than the other in this particular case.

    Isn't the "=== true" redundant? Saying "if (dialup)" should be enough, and it's just as clear as saying "if (dialup === true)", since that has the same meaning.

    Usually, and in the case of this particular script, if(dialup) and if(dialup == true) and if(dialup === true) are all functionally equivalent.

    However, technically if(dialup) is the equivalent of: if(dialup != false), because if dialup = 2, let's say, then if(dialup == true) or if(dialup === true) would not execute the if-block while if(dialup) would still execute the if-block. if(Boolean(dialup) == true) is the equivalent of if(dialup). :-)

    digital man

    Synchronet "Real Fact" #82:
    Donations to the Synchronet project are welcome @ http://wiki.synchro.net/donate
    Norco, CA WX: 51.8øF, 81.0% humidity, 1 mph SSE wind, 0.00 inches rain/24hrs

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Nightfox@VERT/DIGDIST to Digital Man on Sat Jan 9 21:27:20 2016
    Re: syncWXremix and Dial-up
    By: Digital Man to Nightfox on Sat Jan 09 2016 19:59:22

    Isn't the "=== true" redundant? Saying "if (dialup)" should be
    enough, and it's just as clear as saying "if (dialup === true)", since
    that has the same meaning.

    Usually, and in the case of this particular script, if(dialup) and if(dialup == true) and if(dialup === true) are all functionally equivalent.

    However, technically if(dialup) is the equivalent of: if(dialup != false), because if dialup = 2, let's say, then if(dialup == true) or if(dialup === true) would not execute the if-block while if(dialup) would still execute the if-block. if(Boolean(dialup) == true) is the equivalent of if(dialup). :-)

    :) Makes sense. I'm still getting to know all the cases of how variables behave in JavaScript. Logically, though, it seemed redundant to check for equivalence to true in an if check. :)

    Nightfox

    ---
    þ Synchronet þ Digital Distortion: digitaldistortionbbs.com
  • From KenDB3@VERT/KD3NET to Digital Man on Sun Jan 10 15:06:19 2016
    This makes it through the function by grabbing the correct fallback lookup.

    Triple Equals works... At some point I tried Double Equals instead (stil works). Should I stick with Triple? I read up on the difference, but not sure if one might be better than the other in this particular case.

    Isn't the "=== true" redundant? Saying "if (dialup)" should be enough, and it's just as clear as saying "if (dialup === true)", since that has the same meaning.

    Usually, and in the case of this particular script, if(dialup) and if(dialup == true) and if(dialup === true) are all functionally equivalent.

    However, technically if(dialup) is the equivalent of: if(dialup != false), because if dialup = 2, let's say, then if(dialup == true) or if(dialup === true) would not execute the if-block while if(dialup) would still execute the if-block. if(Boolean(dialup) == true) is the equivalent of if(dialup). :-)

    digital man

    Really great and helpful explanation. +1 ;-)

    ~KenDB3

    ---
    þ Synchronet þ KD3net-Rhode Island's only BBS about nothing. http://bbs.kd3.us
  • From tracker1@VERT/TRNTEST to Deuce on Sun Jan 10 15:14:52 2016
    dialup = "Yes"
    if (dialup)
    print("Yessir!")
    if (dialip===true)
    print("Fosho!");

    Would only print "Yessir!".

    The following values evaluate as false in JS:
    0, undefined, mull, NaN, false, empty string

    Everything else is true.
    --
    Michael J. Ryan
    tracker1(at)gmail.com
    +o Roughneck BBS

    ---
    þ Synchronet þ RoughneckBBS - http://www.roughneckbbs.com/
  • From Digital Man@VERT to tracker1 on Sun Jan 10 14:54:39 2016
    Re: Re: syncWXremix and Dial-up
    By: tracker1 to Deuce on Sun Jan 10 2016 03:14 pm

    dialup = "Yes"
    if (dialup)
    print("Yessir!")
    if (dialip===true)
    print("Fosho!");

    Would only print "Yessir!".

    The following values evaluate as false in JS:
    0, undefined, mull, NaN, false, empty string

    Everything else is true.

    Not when testing for equality (and that was the original question). For example: print(2==true), prints 'false'.

    digital man

    Synchronet "Real Fact" #40:
    Synchronet's cross-platform library is called XPDEV (named before Windows XP). Norco, CA WX: 58.8øF, 65.0% humidity, 1 mph E wind, 0.00 inches rain/24hrs

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuce@VERT/SYNCNIX to tracker1 on Sun Jan 10 17:59:39 2016
    Re: Re: syncWXremix and Dial-up
    By: tracker1 to Deuce on Sun Jan 10 2016 03:14 pm

    The following values evaluate as false in JS:
    0, undefined, mull, NaN, false, empty string

    Everything else is true.

    To expand that... all of the above would == false, but only false would === false.

    ---
    http://DuckDuckGo.com/ a better search engine that respects your privacy.
    Mro is an idiot. Please ignore him, we keep hoping he'll go away.
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From Deuce@VERT/SYNCNIX to Digital Man on Sun Jan 10 18:14:49 2016
    Re: Re: syncWXremix and Dial-up
    By: Digital Man to tracker1 on Sun Jan 10 2016 02:54 pm

    The following values evaluate as false in JS:
    0, undefined, mull, NaN, false, empty string

    Everything else is true.

    Not when testing for equality (and that was the original question). For example: print(2==true), prints 'false'.

    But print('0x01'==true) prints 'true'.

    So here's a super-duper example...
    [1, '1', '0x01', 2, '2', "true", true].forEach(function (x)
    {
    print("X="+x+' '+(typeof x));
    if (x)
    print("Is");
    if (x==true)
    print("True");
    if (x===true)
    print("Truth");
    print('');
    });

    Which results in:
    X=1 number
    Is
    True

    X=1 string
    Is
    True

    X=0x01 string
    Is
    True

    X=2 number
    Is

    X=2 string
    Is

    X=true string
    Is

    X=true boolean
    Is
    True
    Truth


    ---
    http://DuckDuckGo.com/ a better search engine that respects your privacy.
    Mro is an idiot. Please ignore him, we keep hoping he'll go away.
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)