1. NewD's Avatar
    Thanks Ras.. That helps!! So where is the OPENING ' ( ' near the JSON request? That's where I'm lost.

    Look with a HTML/JS editor like Notepad++ .
    I do, Dacal. I only use TextWrangler and TacoHTMLEdit; two GREAT editors for Mac. I just don't see the opening '(' for the JSON function. And don't understand why a ' ; ' would be needed after a ' )}. '. Usually all ' ; ' are contained WITHIN { }.

    Thanks! VERY helpful!!
    Last edited by NewD; 2013-09-11 at 10:51 PM.
    2013-09-11 10:48 PM
  2. rasputin007's Avatar
    Yepp, I have colored all the bracket pairs (opening and closing), each pair has their own color.

    Here is an idea for later
    Once you have the address from Google, why don't you add a Touch event on the address, which will open a Google Map with the location given by the latitude and longitude. This Google Map would be fully interactive on the Lockscreen, like street view etc. Make it 400x400 or so and place it BELOW the touch event area, so that another touch would close the Google Map. That way you can always check if the actual coordinates from the xml file are where you are.
    Here is an old screenshot from Swipe that uses Google Maps (fully interactive) to check that the latitude and longitude (and therefore the address) are where I am. Sometimes the GPS positioning is figured out by signal masts and that is not very accurate, certainly not here in the UK and can place you miles away, which of course will give you a wrong location name.

    Nothing is impossible only miracles take a bit longer!
    2013-09-11 11:12 PM
  3. NewD's Avatar
    VERY COOL, RAS!!! LOVE IT! I love the specificity of Google. Though I've noticed the odd behavior that what it outputs for 'formatted[1] and [2] will often swap on one call to the next. So one time I'm a in a town and I call on [1] it will give me [2]'s info and then switch back the next time I'm in that town. So there's some inconsistency in what it outputs in its formatted output options [0]-[7].

    Hey can you PM me the way to obtain a Weather Underground free API and then the JSON request for them and their output forms.. thanks!
    2013-09-11 11:34 PM
  4. King_O_Hill's Avatar
    Thanks Ras.. That helps!! So where is the OPENING ' ( ' near the JSON request? That's where I'm lost.
    $.getJSON(

    If your editor is not showing you the different brackets in different colors, you should consider changing!
    Last edited by King_O_Hill; 2013-09-11 at 11:50 PM.

    Check out WW3 for iOS 9/10 - Widget-Weather 3.0
    2013-09-11 11:48 PM
  5. NewD's Avatar
    $.getJSON(

    If your editor is not showing you the different brackets in different colors, you should consider changing!
    Thanks, Brian! I see it now. All the colors can be assigned. I just need to do it. Now I will.

    Thanks!!

    Next question..

    How do I create an IF statement that checks for text CONTAINED within data? From searching around I got this syntax but it broken the widget.

    if (!obj.county.contains("County")) {cityname = obj.county + " County";}

    I wish to check the XML for whether the obj.county object contains the word "County" or not. In Canada extraLocCounty does NOT contain the word County after the County name.

    I want my if statement to say:
    If obj.county does NOT contain "County" --- cityname = object county + "County"

    TIA!
    Last edited by NewD; 2013-09-12 at 12:00 AM.
    2013-09-11 11:56 PM
  6. Dacal's Avatar
    Thanks, Brian! I see it now. All the colors can be assigned. I just need to do it. Now I will.

    Thanks!!

    Next question..

    How do I create an IF statement that checks for text CONTAINED within data? From searching around I got this syntax but it broken the widget.

    if (!obj.county.contains("County")) {cityname = obj.county + " County";}

    I wish to check the XML for whether the obj.county object contains the word "County" or not. In Canada extraLocCounty does NOT contain the word County after the County name.

    I want my if statement to say:
    If obj.county does NOT contain "County" --- cityname = object county + " County"

    TIA!
    indexOf

    if (obj.county.indexOf('County') == -1) { cityname = obj.county + " County"; }

    This function returns -1 if the value to search for never occurs. Be careful, it's case sensitive (good to convert the chaine to lower or upper case before searching...).
    Last edited by Dacal; 2013-09-12 at 12:17 AM.


    My themes : Jade HD, Silex HD, BaSalt HD,ToPaz
    All are on Cydia and/or Theme It.
    2013-09-12 12:06 AM
  7. NewD's Avatar
    indexOf

    if (obj.county.indexOf('County') == -1) { cityname = obj.county + " County"; }

    This function returns -1 if the value to search for never occurs. Be careful, it's case sensitive (good to convert the chaine to lower or upper case before searching...).
    Perfect, Dacal!! THANKS!!!
    2013-09-12 01:00 AM
  8. rasputin007's Avatar
    Weather Underground details

    Go to API | Weather Underground, register with email and password, next go to pricing page,API | Weather Underground select the Anvil plan and Developer. That should come to $0 cost, now purchase your key. Your API key will be emailed to you, but also is in your account and will be automatically used when you click on example urls.
    See the documentation page for all the goodies you can use and on how to use them.
    I have used this now for month and it did not cost me any penny so far. I have currently 25 raindrops (you'll find out what they do!). Even when testing I never came over the 500 uses per day limit.

    Ask Drifter or King, they should have the javascript that pulls the info from the JSON response file.
    Last edited by rasputin007; 2013-09-12 at 09:13 AM.
    Nothing is impossible only miracles take a bit longer!
    2013-09-12 09:02 AM
  9. Dacal's Avatar
    Weather Underground details

    Go to API | Weather Underground, register with email and password, next go to pricing page,API | Weather Underground select the Anvil plan and Developer. That should come to $0 cost, now purchase your key. Your API key will be emailed to you, but also is in your account and will be automatically used when you click on example urls.
    See the documentation page for all the goodies you can use and on how to use them.
    I have used this now for month and it did not cost me any penny so far. I have currently 25 raindrops (you'll find out what they do!). Even when testing I never came over the 500 uses per day limit.

    Ask Drifter or King, they should have the javascript that pulls the info from the JSON response file.
    I have look in the past. It's a very good feed.


    My themes : Jade HD, Silex HD, BaSalt HD,ToPaz
    All are on Cydia and/or Theme It.
    2013-09-12 09:31 AM
  10. NewD's Avatar
    Ask Drifter or King, they should have the javascript that pulls the info from the JSON response file.
    Thanks, Ras! It was very impressive on my trip back from New York. I hope it has good "additional" location naming. Not just main City. I want to see those township and neighborhood names too in addition to main city. Not to mention I want more accurate weather info for my small town near big city locations.

    Thanks!!
    Grant
    2013-09-12 02:40 PM
  11. King_O_Hill's Avatar
    You got PM!

    Check out WW3 for iOS 9/10 - Widget-Weather 3.0
    2013-09-12 04:25 PM
  12. NewD's Avatar
    You got PM!
    THANKS SIR!.. Great site.. Lot to learn.. But things are coming more quickly to me - the more I dive in....

    DACAL or anyone...

    You gave me this syntax:
    //obj.coords =$(this).find('extraLocName').text().replace(/ /g,"");
    ......to split a coordinate format with a ',' and a ' ' (comma and space).. WU uses JUST a comma. SO what would be the split syntax to turn this:
    41.057987, -75.085708
    into this:
    41.057987,-75.085708 (no space)??

    Thanks!!
    Grant
    2013-09-12 08:14 PM
  13. rasputin007's Avatar
    There often is more then one way to achieve what you want to do, very nice feature of javascript.
    Actually both methods give the same result.
    I split obj.coords into obj.lati and obj.longi, then used ....."+obj.lati+","+obj.longi+" in the url
    Dacal used obj.coords =$(this).find('extraLocName').text().replace(/ /g,""), see JavaScript replace() Method, will replace the empty space with nothing (no space), so you only need the obj.coords in the url.

    My "+obj.lati+","+obj.longi+" is equal to Dacal's "+obj.coords+".
    Nothing is impossible only miracles take a bit longer!
    2013-09-12 09:28 PM
  14. NewD's Avatar
    There often is more then one way to achieve what you want to do, very nice feature of javascript.
    Actually both methods give the same result.
    I split obj.coords into obj.lati and obj.longi, then used ....."+obj.lati+","+obj.longi+" in the url
    Dacal used obj.coords =$(this).find('extraLocName').text().replace(/ /g,""), see JavaScript replace() Method, will replace the empty space with nothing (no space), so you only need the obj.coords in the url.

    My "+obj.lati+","+obj.longi+" is equal to Dacal's "+obj.coords+".
    Thanks, Ras.. Very helpful! Would you be willing to add me to your contacts that I might ask a question or two in PM specifically about the Weather Underground output from the JSON request? I'm having a little trouble retrieving the info. The call format isn't like Yahoo or Google.

    Thanks..
    2013-09-12 09:54 PM
  15. The_Durben's Avatar
    Subscribed
    2013-09-13 06:53 PM
  16. NewD's Avatar
    Subscribed
    Wonderful, sir. Thanks!!
    2013-09-13 07:29 PM
  17. rasputin007's Avatar
    Thanks, Ras.. Very helpful! Would you be willing to add me to your contacts that I might ask a question or two in PM specifically about the Weather Underground output from the JSON request? I'm having a little trouble retrieving the info. The call format isn't like Yahoo or Google.

    Thanks..
    THIS is better then PM, as it might benefit others as well, apart from the fact that I have dumped all iOS stuff onto an spare HDD, to have enough free space for playing with Ubuntu Touch. So no easy "Oh, I have a quick look" any more and I have not upgraded my own memory to remember all that stuff.
    Nothing is impossible only miracles take a bit longer!
    2013-09-13 10:39 PM
  18. RKO1195's Avatar
    Thanks Grant for making this thread! its a great idea for people wanting to learn and for guys that already know stuff that can help others and learn something new too.. This is cool I love to learn more and more everyday
    Last edited by RKO1195; 2013-09-14 at 02:07 PM.
    2013-09-14 10:01 AM
  19. NewD's Avatar
    A few lessons learned added to post #1. Enjoy!!
    post 1
    2013-09-16 12:00 AM
  20. RKO1195's Avatar
    Dam I'm proud of you
    2013-09-16 01:36 AM
141 1234 ...
LINK TO POST COPIED TO CLIPBOARD