+ Reply
Page 2 of 7 FirstFirst 1234 ... LastLast
Results 21 to 40 of 138

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: Improving our Coding Skills

is a discussion within the

File Mods

forums, a part of the

iPhone Modding

section;
Thanks Ras.. That helps!! So where is the OPENING ' ( ' near the JSON request? That's where I'm lost. Originally Posted by Dacal Look with a HTML/ JS editor
...
  1. #21
    The Big D NewdestinyX's Avatar
    Join Date
    Jan 2012
    Posts
    9,378
    Thanks
    3,626
    Thanked 8,437 Times in 4,285 Posts

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

    Quote Originally Posted by Dacal View Post
    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 NewdestinyX; 09-11-2013 at 02:51 PM.
    Here to help if I can. If I can't I know someone who can!

  2. The Following User Says Thank You to NewdestinyX For This Useful Post:

    Dacal (09-11-2013)

  3. #22
    My iPhone is a Part of Me
    Join Date
    Aug 2009
    Posts
    666
    Thanks
    325
    Thanked 2,140 Times in 490 Posts

    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.


  4. The Following 3 Users Say Thank You to rasputin007 For This Useful Post:

    Dacal (09-11-2013), NewdestinyX (09-11-2013), RKO1195 (09-14-2013)

  5. #23
    The Big D NewdestinyX's Avatar
    Join Date
    Jan 2012
    Posts
    9,378
    Thanks
    3,626
    Thanked 8,437 Times in 4,285 Posts

    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!
    Here to help if I can. If I can't I know someone who can!

  6. #24
    King Kong ain't got nothing on me! King_O_Hill's Avatar
    Join Date
    Apr 2011
    Location
    USA
    Posts
    8,806
    Thanks
    38,956
    Thanked 16,303 Times in 5,968 Posts

    Quote Originally Posted by NewdestinyX View Post
    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; 09-11-2013 at 03:50 PM.
    Widget-Weather App Now Available! Also with MyLocation Support!
    Check out the thread here - Widget-Weather
    To install the Widget-Weather app, just go to Cydia and install. This will also remove MyLocation, as it is built in!
    Want to protect your JailBreak! Add this repo http://cydia.myrepospace.com/iLEXiNFO/ & Install "iLEX R.A.T."
    It will allow you to bring your phone back to a fresh jailbroken state!

  7. The Following 3 Users Say Thank You to King_O_Hill For This Useful Post:

    Dacal (09-11-2013), NewdestinyX (09-11-2013), RKO1195 (09-14-2013)

  8. #25
    The Big D NewdestinyX's Avatar
    Join Date
    Jan 2012
    Posts
    9,378
    Thanks
    3,626
    Thanked 8,437 Times in 4,285 Posts

    Default Syntax for "DOES NOT CONTAIN"
    Quote Originally Posted by King_O_Hill View Post
    $.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 NewdestinyX; 09-11-2013 at 04:00 PM.
    Here to help if I can. If I can't I know someone who can!

  9. The Following User Says Thank You to NewdestinyX For This Useful Post:

    King_O_Hill (09-11-2013)

  10. #26
    Addicted to Code Dacal's Avatar
    Join Date
    Nov 2010
    Posts
    1,889
    Thanks
    2,885
    Thanked 8,475 Times in 1,496 Posts

    Quote Originally Posted by NewdestinyX View Post
    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; 09-11-2013 at 04:17 PM.


    My themes : Jade HD, Silex HD, BaSalt HD,ToPaz
    All are on Cydia and/or Theme It.

  11. The Following 3 Users Say Thank You to Dacal For This Useful Post:

    King_O_Hill (09-11-2013), NewdestinyX (09-11-2013), RKO1195 (09-14-2013)

  12. #27
    The Big D NewdestinyX's Avatar
    Join Date
    Jan 2012
    Posts
    9,378
    Thanks
    3,626
    Thanked 8,437 Times in 4,285 Posts

    Quote Originally Posted by Dacal View Post
    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!!!
    Here to help if I can. If I can't I know someone who can!

  13. The Following 2 Users Say Thank You to NewdestinyX For This Useful Post:

    Dacal (09-11-2013), King_O_Hill (09-11-2013)

  14. #28
    My iPhone is a Part of Me
    Join Date
    Aug 2009
    Posts
    666
    Thanks
    325
    Thanked 2,140 Times in 490 Posts

    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; 09-12-2013 at 01:13 AM.

  15. The Following 3 Users Say Thank You to rasputin007 For This Useful Post:

    King_O_Hill (09-12-2013), NewdestinyX (09-12-2013), RKO1195 (09-14-2013)

  16. #29
    Addicted to Code Dacal's Avatar
    Join Date
    Nov 2010
    Posts
    1,889
    Thanks
    2,885
    Thanked 8,475 Times in 1,496 Posts

    Quote Originally Posted by rasputin007 View Post
    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.

  17. The Following 2 Users Say Thank You to Dacal For This Useful Post:

    King_O_Hill (09-12-2013), rasputin007 (09-12-2013)

  18. #30
    The Big D NewdestinyX's Avatar
    Join Date
    Jan 2012
    Posts
    9,378
    Thanks
    3,626
    Thanked 8,437 Times in 4,285 Posts

    Quote Originally Posted by rasputin007 View Post
    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
    Here to help if I can. If I can't I know someone who can!

  19. The Following User Says Thank You to NewdestinyX For This Useful Post:

    King_O_Hill (09-12-2013)

  20. #31
    King Kong ain't got nothing on me! King_O_Hill's Avatar
    Join Date
    Apr 2011
    Location
    USA
    Posts
    8,806
    Thanks
    38,956
    Thanked 16,303 Times in 5,968 Posts

    You got PM!
    Widget-Weather App Now Available! Also with MyLocation Support!
    Check out the thread here - Widget-Weather
    To install the Widget-Weather app, just go to Cydia and install. This will also remove MyLocation, as it is built in!
    Want to protect your JailBreak! Add this repo http://cydia.myrepospace.com/iLEXiNFO/ & Install "iLEX R.A.T."
    It will allow you to bring your phone back to a fresh jailbroken state!

  21. The Following User Says Thank You to King_O_Hill For This Useful Post:

    NewdestinyX (09-12-2013)

  22. #32
    The Big D NewdestinyX's Avatar
    Join Date
    Jan 2012
    Posts
    9,378
    Thanks
    3,626
    Thanked 8,437 Times in 4,285 Posts

    Quote Originally Posted by King_O_Hill View Post
    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
    Here to help if I can. If I can't I know someone who can!

  23. #33
    My iPhone is a Part of Me
    Join Date
    Aug 2009
    Posts
    666
    Thanks
    325
    Thanked 2,140 Times in 490 Posts

    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+".

  24. The Following 3 Users Say Thank You to rasputin007 For This Useful Post:

    Dacal (09-12-2013), King_O_Hill (09-12-2013), RKO1195 (09-14-2013)

  25. #34
    The Big D NewdestinyX's Avatar
    Join Date
    Jan 2012
    Posts
    9,378
    Thanks
    3,626
    Thanked 8,437 Times in 4,285 Posts

    Quote Originally Posted by rasputin007 View Post
    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..
    Here to help if I can. If I can't I know someone who can!

  26. The Following User Says Thank You to NewdestinyX For This Useful Post:

    King_O_Hill (09-12-2013)

  27. #35
    The Mechanic The_Durben's Avatar
    Join Date
    Aug 2010
    Location
    Vancouver Canada
    Posts
    8,424
    Thanks
    34,944
    Thanked 40,559 Times in 7,513 Posts

    Subscribed

  28. The Following 3 Users Say Thank You to The_Durben For This Useful Post:

    King_O_Hill (09-13-2013), NewdestinyX (09-13-2013), RKO1195 (09-14-2013)

  29. #36
    The Big D NewdestinyX's Avatar
    Join Date
    Jan 2012
    Posts
    9,378
    Thanks
    3,626
    Thanked 8,437 Times in 4,285 Posts

    Quote Originally Posted by The_Durben View Post
    Subscribed
    Wonderful, sir. Thanks!!
    Here to help if I can. If I can't I know someone who can!

  30. The Following User Says Thank You to NewdestinyX For This Useful Post:

    King_O_Hill (09-13-2013)

  31. #37
    My iPhone is a Part of Me
    Join Date
    Aug 2009
    Posts
    666
    Thanks
    325
    Thanked 2,140 Times in 490 Posts

    Quote Originally Posted by NewdestinyX View Post
    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.

  32. The Following 4 Users Say Thank You to rasputin007 For This Useful Post:

    King_O_Hill (09-13-2013), NewdestinyX (09-14-2013), RKO1195 (09-14-2013), The_Durben (09-15-2013)

  33. #38
    widget modder RKO1195's Avatar
    Join Date
    Aug 2010
    Location
    Alabama
    Posts
    2,208
    Thanks
    9,796
    Thanked 5,003 Times in 1,708 Posts

    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; 09-14-2013 at 06:07 AM.
    WidgetWeather ​Thread

  34. The Following 4 Users Say Thank You to RKO1195 For This Useful Post:

    King_O_Hill (09-14-2013), Krima (09-14-2013), NewdestinyX (09-14-2013), rasputin007 (09-14-2013)

  35. #39
    The Big D NewdestinyX's Avatar
    Join Date
    Jan 2012
    Posts
    9,378
    Thanks
    3,626
    Thanked 8,437 Times in 4,285 Posts

    A few lessons learned added to post #1. Enjoy!!
    post 1
    Here to help if I can. If I can't I know someone who can!

  36. The Following 2 Users Say Thank You to NewdestinyX For This Useful Post:

    King_O_Hill (09-18-2013), RKO1195 (09-15-2013)

  37. #40
    widget modder RKO1195's Avatar
    Join Date
    Aug 2010
    Location
    Alabama
    Posts
    2,208
    Thanks
    9,796
    Thanked 5,003 Times in 1,708 Posts

    Dam I'm proud of you
    WidgetWeather ​Thread

  38. The Following 2 Users Say Thank You to RKO1195 For This Useful Post:

    King_O_Hill (09-18-2013), NewdestinyX (09-15-2013)

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts