Page 191 of 216 FirstFirst ... 91141181189190191192193201 ... LastLast
Results 3,801 to 3,820 of 4318

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


Thread: Widget Weather

  1. #3801
    Code Dependent NewD's Avatar
    Join Date
    Jan 2012
    Location
    Northeast US
    Posts
    5,733
    Thanks
    8,351
    Thanked 16,485 Times in 7,705 Posts

    Okay - Coding gurus, Dacal,RKO, Marty, King, bombmom, MJ.....

    Is there a simple line of code that allows me to search within multiple objects for a certain string?

    obj.a[1] = "cars";
    obj.a[2] = "boats";
    obj.a[3] = "trucks";
    obj.a[4] = "busses";
    obj.a[5] = "places";

    I need syntax to say <<Look for the string 'busses' from within obj.a[1-5] -- if it's in ANY of those objects -- then do { }

    In know the the long way around -----
    Code:
    if ((obj.a[1].indexOf('busses') > -1) ||
    (obj.a[2].indexOf('busses') > -1) ||
    (obj.a[3].indexOf('busses') > -1) ||
    (obj.a[4].indexOf('busses') > -1) ||
    (obj.a[5].indexOf('busses') > -1))  {  do this    ;}
    Is that the only code available to me?

    I've done a lot of searching on W3 Schools and other code sites.. Not finding what I think should be possible..

    TIA
    Last edited by NewD; 2014-06-20 at 03:17 AM.

  2. #3802
    Quote Originally Posted by NewdestinyX View Post
    Okay - Coding gurus, Dacal,RKO, Marty, King, bombmom, MJ.....

    Is there a simple line of code that allows me to search within multiple objects for a certain string?

    obj.a[1] = "cars";
    obj.a[2] = "boats";
    obj.a[3] = "trucks";
    obj.a[4] = "busses";
    obj.a[5] = "places";

    I need syntax to say <<Look for the string 'busses' from within obj.a[1-5] -- if it's in ANY of those objects -- then do { }

    In know the the long way around -----
    Code:
    if ((obj.a[1].indexOf('busses') > -1) ||
    (obj.a[2].indexOf('busses') > -1) ||
    (obj.a[3].indexOf('busses') > -1) ||
    (obj.a[4].indexOf('busses') > -1) ||
    (obj.a[5].indexOf('busses') > -1))  {  do this    ;}
    Is that the only code available to me?

    I've done a lot of searching on W3 Schools and other code sites.. Not finding what I think should be possible..

    TIA
    Use a for loop to loop over the array within the object.

    Code:
    var a, obj = {a: a = ["cars", "boats", "trucks","busses","places"]}; //your array in the object
    
      for (i = 0; i < obj.a.length; i++) { //how to find the index of busses
        if(obj.a[i]=="busses"){
       	alert(i);
        }
      }
    Whipped up a jsfiddle
    Edit fiddle - JSFiddle


    If you wanted it as a reusable function.

    Code:
    var a, obj = {a: a = ["cars", "boats", "trucks","busses","places"]};
    
    function findname(length,name){
      for (i = 0; i < length; i++) { 
        if(obj.a[i]==name){
       	return i;
        }
      }
    }
    
    var busses=findname(obj.a.length,"busses");
    var cars=findname(obj.a.length,"cars");
    alert(busses);
    alert(cars);
    There are many ways to achieve this, here is just one.
    Last edited by June'sIphone; 2014-06-20 at 03:59 AM.

  3. The Following 2 Users Say Thank You to June'sIphone For This Useful Post:

    lostinthemes (2014-06-20), NewD (2014-06-20)

  4. #3803
    Code Dependent NewD's Avatar
    Join Date
    Jan 2012
    Location
    Northeast US
    Posts
    5,733
    Thanks
    8,351
    Thanked 16,485 Times in 7,705 Posts

    Quote Originally Posted by June'sIphone View Post
    Use a for loop to loop over the array within the object.

    Code:
    var a, obj = {a: a = ["cars", "boats", "trucks","busses","places"]}; //your array in the object
    
      for (i = 0; i < obj.a.length; i++) { //how to find the index of busses
        if(obj.a[i]=="busses"){
       	alert(i);
        }
      }
    Whipped up a jsfiddle
    Edit fiddle - JSFiddle


    If you wanted it as a reusable function.

    Code:
    var a, obj = {a: a = ["cars", "boats", "trucks","busses","places"]};
    
    function findname(length,name){
      for (i = 0; i < length; i++) { 
        if(obj.a[i]==name){
       	return i;
        }
      }
    }
    
    var busses=findname(obj.a.length,"busses");
    var cars=findname(obj.a.length,"cars");
    alert(busses);
    alert(cars);
    There are many ways to achieve this, here is just one.
    Thanks, June. Very helpful! Now let's see if I can understand it enough to adapt to my exact variables.

    Is LENGTH part of the equation? I want it to be able to find one specific string of text whether 2 or 18 characters..

    In the precise case I'm working on.. I need find out if the string "Fairbanks North Shore" exists in any of the objects' parsed data from GoogleMaps API..

    Right now - the formatted address fields from Google are returning this:
    obj.add[1] = "Fairbanks";
    obj.add[2] = "Fairbanks";
    obj.add[3] = "Fairbanks";
    obj.add[4] = "Fairbanks";
    obj.add[5] = "Fairbanks North Shore";
    obj.add[6] = "Fairbanks";

    Sometimes Google returns Fairbanks North Shore in obj.add[3] and still other times the coordinates I send to the API returns Fairbanks Northshore in obj.add[6]. It jumps around. I need the equivalent of:

    if ("Fairbanks North Shore" exists in any of the object formatted address output fields [1]-[6]) {obj.county = "Fairbanks North Shore";}

    So..... each 'county' name I'm looking for from within the six obj. fields could be anything from 3-4 characters up to 20 characters. So that's why I need to know if 'length' matters..

    So I'm essentially searching for a certain string of text that could exists in any one of 6 objects. if my text string exists - I want the condition to return TRUE.

    Thanks for taking a look for me.
    Last edited by NewD; 2014-06-20 at 04:47 AM.

  5. #3804
    Quote Originally Posted by NewdestinyX View Post
    Thanks, June. Very helpful! Now let's see if I can understand it enough to adapt to my exact variables.

    Is LENGTH part of the equation? I want it to be able to find one specific string of text whether 2 or 18 characters..

    In the precise case I'm working on.. I need find out if the string "Fairbanks North Shore" exists in any of the objects' parsed data from GoogleMaps API..

    Right now - the formatted address fields from Google are returning this:
    obj.add[1] = "Fairbanks";
    obj.add[2] = "Fairbanks";
    obj.add[3] = "Fairbanks";
    obj.add[4] = "Fairbanks";
    obj.add[5] = "Fairbanks North Shore";
    obj.add[6] = "Fairbanks";

    Sometimes Google returns Fairbanks North Shore in obj.add[3] and still other times the coordinates I send to the API returns Fairbanks Northshore in obj.add[6]. It jumps around. I need the equivalent of:

    if ("Fairbanks North Shore" exists in any of the object formatted address output fields [1]-[6]) {obj.county = "Fairbanks North Shore";}

    So..... each 'county' name I'm looking for from within the six obj. fields could be anything from 3-4 characters up to 20 characters. So that's why I need to know if 'length' matters..

    Thanks for taking a look for me.
    From the looks of it there is only one object. The rest is an array nested within the object. In this case your array is add. (in the code above) So what you are doing with obj.add[1-6] is going through the array.

    Example: add = ["cars", "boats", "trucks","busses","places"]

    here is an array. Now if you go add[0], you will get cars. add[1] boats so on an so forth. Since it is nested in an object its like this.

    Example: var add, obj = {add: add = ["cars", "boats", "trucks","busses","places"]}; Therefore to get to your array you first have to go through the object. So obj.add[0] will give you cars. obj.a[1] boats so on an so forth.

    The use of length, in the function I listed was to get the number of items in that array. This is used for the for loop.

    for (i=0; i< obj.a.length; i++)

    What this for loop does is it takes i then compares it to the length of the array. Say if there is 5 it will loop through each one until it reaches 5. Meaning every time i is less than the length it adds one number to i. Inside the brackets you can add anything really, but this case you are looking for a certain name so you can go if(obj.a[i]=="YourName") then do this {//do something}

    example if you do
    for (i=0; i< obj.add.length; i++){
    alert("test");
    }

    It will alert("test"); as many times until i is equal to the length of the array.

    It loops through each one because i is now really a number, but it is a number that goes through the entire array. It does this because it adds 1 over and over until i is equal to the length of the array. To answer your question .length is needed in this particular function.



    Code:
    <div id="neighborhood"></div>
    
    <script>
    var add, obj = {add: add = ["Fairbanks", "Fairbanks", "Fairbanks North Shore","Fairbanks","Fairbanks"]}; 
    
      for (i = 0; i < obj.add.length; i++) {
        if(obj.add[i]=="Fairbanks North Shores"){
       	document.getElementById("neighborhood").innerHTML=obj.add[i];
        }
      }
    </script>
    With this you will always get Fairbanks North Shores to the div no matter where it is in the array.
    Hope that helps.
    Last edited by June'sIphone; 2014-06-20 at 05:10 AM.

  6. The Following 2 Users Say Thank You to June'sIphone For This Useful Post:

    lostinthemes (2014-06-20), NewD (2014-06-20)

  7. #3805
    Code Dependent NewD's Avatar
    Join Date
    Jan 2012
    Location
    Northeast US
    Posts
    5,733
    Thanks
    8,351
    Thanked 16,485 Times in 7,705 Posts

    Quote Originally Posted by June'sIphone View Post
    Code:
    <div id="neighborhood"></div>
    
    <script>
    var add, obj = {add: add = ["Fairbanks", "Fairbanks", "Fairbanks North Star","Fairbanks","Fairbanks"]}; 
    
      for (i = 0; i < obj.add.length; i++) {
        if(obj.add[i]=="Fairbanks North Star"){
       document.getElementById("neighborhood").innerHTML=obj.add[i];
        }
      }
    </script>
    With this you will always get Fairbanks North Star to the div no matter where it is in the array.
    Hope that helps.
    Fabulous, June. For the first time I think I've understood loops and arrays. Thanks for taking the time to help take my coding to the next level. I won't forget it.

    Peace..

    EDITED:
    Here's the final code that accomplished what I needed - based on my tutorial from June about looping. I had several other special case Alaskan Borough names I needed to do different boolean tests for with <else if> after this special case with the "Fairbanks North Star Borough".. So after the loop looked for "Fairbanks North Star", instead of simply reporting obj.add[i] to the <div> I needed to set a variable and then test for that variable if the first <if> -- followed by the other <else if>

    Additionally --> [i] was a variable Dacal had used in a loop he created for me earlier in the code to parse the formatted address data from the Google API in a more efficient way than I had been doing it.. So I chose the variable [s] in this loop June showed me. Early on King_O_Hill taught me you don't duplicate variables that are gonna do different things. So the final result for this section where I'm dealing with the special way Alaska does counties.
    Code:
    var AKdivide = "";
    if (obj.statecode == 'AK') {
      var AKcensusA = ["Yukon-Koyukuk", "Nome", "Aleutians West", "Bethel", "Dillingham",
      "Skagway-Hoonah-Angoon", "Prince of Wales-Outer Ketchikan", "Southeast Fairbanks",
      "Valdez-Cordova", "Wade Hampton"]; //list of Alaskan Census Areas
      if (AKcensusA.indexOf(obj.add[3]) > -1) {var AKdivide = " Census Area";} else {var AKdivide = " Borough";}
      
    //SPECIAL CASE AK BOROUGH NAMING
      for (s = 0; s < obj.add.length; s++) {
         if(obj.add[s] == "Fairbanks North Star") {var FairbanksNS = true;}
      }
      if (FairbanksNS == true) {obj.county = "Fairbanks North Star" + AKdivide;}
      else if (....) {.....}
      else if (......) {.....}
      ........
      else {obj.county = obj.add[3] + AKdivide;}//these are normal cases
    }
    Last edited by NewD; 2014-06-20 at 07:43 AM.

  8. The Following 2 Users Say Thank You to NewD For This Useful Post:

    June'sIphone (2014-06-20), lostinthemes (2014-06-20)

  9. #3806
    Wow. Thank you June. Good stuff here, guys.


    Sent from my iPhone 5S

  10. The Following User Says Thank You to MamaJaay For This Useful Post:

    June'sIphone (2014-06-20)

  11. #3807
    Ok i am having a senior moment. I cannot find where I can fix the wind as seen in screen shot. 3mph wind no wind.

    Can someone point out where I am missing it.

    Thanks

    ImageUploadedByModMyi1403296593.103646.jpg

  12. #3808
    It's got to do with the wind direction, not the speed. Look in the main.js for //WINDSPEED the error is in there. I can't remember what the exact fix was, post if you need further help.

    Check out WW3 for iOS 9/10 - Widget-Weather 3.0

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

    bliken (2014-06-21)

  14. #3809
    Quote Originally Posted by bliken View Post
    Ok i am having a senior moment. I cannot find where I can fix the wind as seen in screen shot. 3mph wind no wind.

    Can someone point out where I am missing it.

    Thanks
    Delete this line in main.js...

    if (direction == 0) var winddir = "No wind";

  15. The Following 4 Users Say Thank You to Marty McFly For This Useful Post:

    bliken (2014-06-21), King_O_Hill (2014-06-21), lostinthemes (2014-06-26), NewD (2014-06-21)

  16. #3810
    Quote Originally Posted by Marty McFly View Post
    Delete this line in main.js...
    Thanks G.....that worked.

    I was missing it when I was looking on my phone....had to wait until I got home and used WINSCP and found it.

    Thanks again.

  17. The Following User Says Thank You to bliken For This Useful Post:

    Marty McFly (2014-06-22)

  18. #3811

  19. The Following 7 Users Say Thank You to Smitbeat For This Useful Post:

    Dacal (2014-06-22), Destan (2014-06-23), King_O_Hill (2014-06-23), lostinthemes (2014-06-26), Marty McFly (2014-06-25), Mary48336 (2014-06-23), RKO1195 (2014-06-22)

  20. #3812
    iPhone? More like MyPhone Enmedi00's Avatar
    Join Date
    Feb 2014
    Location
    Ruskin, Florida, United States
    Posts
    216
    Thanks
    52
    Thanked 43 Times in 36 Posts

    ImageUploadedByModMyi1403822728.190391.jpg
    Is this normal? I don't remember seeing this warning when I was JB on 7.06

  21. #3813
    It's normal now with the latest version of cydia installer.

    Check out WW3 for iOS 9/10 - Widget-Weather 3.0

  22. The Following 2 Users Say Thank You to King_O_Hill For This Useful Post:

    Marty McFly (2014-06-27), NewD (2014-06-27)

  23. #3814
    iPhone? More like MyPhone Enmedi00's Avatar
    Join Date
    Feb 2014
    Location
    Ruskin, Florida, United States
    Posts
    216
    Thanks
    52
    Thanked 43 Times in 36 Posts

    Quote Originally Posted by King_O_Hill View Post
    It's normal now with the latest version of cydia installer.
    But the widgets are not working when I set them to read the weather info thru widget weather tweak

  24. #3815
    Code Dependent NewD's Avatar
    Join Date
    Jan 2012
    Location
    Northeast US
    Posts
    5,733
    Thanks
    8,351
    Thanked 16,485 Times in 7,705 Posts

    Quote Originally Posted by Enmedi00 View Post
    But the widgets are not working when I set them to read the weather info thru widget weather tweak
    Did you set it from Manual to Constant mode? And did you turn on the myLocation switch?

  25. #3816
    iPhone? More like MyPhone Enmedi00's Avatar
    Join Date
    Feb 2014
    Location
    Ruskin, Florida, United States
    Posts
    216
    Thanks
    52
    Thanked 43 Times in 36 Posts

    Quote Originally Posted by NewdestinyX View Post
    Did you set it from Manual to Constant mode? And did you turn on the myLocation switch?
    I did but it's not even showing on the location services section ImageUploadedByModMyi1403828566.065570.jpg

  26. #3817
    Livin the iPhone Life oldskoolsk8r's Avatar
    Join Date
    Dec 2010
    Location
    Orem, UT
    Posts
    1,174
    Thanks
    1,896
    Thanked 1,970 Times in 725 Posts

    Mine is not working either


    Sent from my iPhone using Tapatalk

  27. #3818
    Code Dependent NewD's Avatar
    Join Date
    Jan 2012
    Location
    Northeast US
    Posts
    5,733
    Thanks
    8,351
    Thanked 16,485 Times in 7,705 Posts

    Quote Originally Posted by oldskoolsk8r View Post
    Mine is not working either


    Sent from my iPhone using Tapatalk
    Full Reboot after installing is needed in most cases with WW.

  28. #3819
    Livin the iPhone Life oldskoolsk8r's Avatar
    Join Date
    Dec 2010
    Location
    Orem, UT
    Posts
    1,174
    Thanks
    1,896
    Thanked 1,970 Times in 725 Posts

    Nope reboot still doesn't work


    Sent from my iPhone using Tapatalk

  29. #3820
    Code Dependent NewD's Avatar
    Join Date
    Jan 2012
    Location
    Northeast US
    Posts
    5,733
    Thanks
    8,351
    Thanked 16,485 Times in 7,705 Posts

    Quote Originally Posted by oldskoolsk8r View Post
    Nope reboot still doesn't work
    It won't work until you see the Widget Weather switch in Location Services. I had this problem once and it just took a combination of a couple of re-installs and reboots. Lots of people have WW running on 7.1.1 and the Pangu Jailbreak. So it's nothing wrong with WW itself.

Page 191 of 216 FirstFirst ... 91141181189190191192193201 ... LastLast
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •