1. Dacal's Avatar
    Yeah M8, as soon as all the little niggles are ironed out.



    So this just updates the location right?, if there is no change in location the weather doesn't refresh. Where does it set the time to refresh the weather if there is no change in location?

    Thanks again pal.
    In original widget, in the UpdateLocation, you find this

    GetWeather(woeid); setInterval('GetWeather(woeid)', 1000*20*60 );

    So 20s for location update, no change on weather if same place.
    20 min for a refresh of the weather at the same place.

    We can do the same things, Just to have a look on battery draining but i think not to much. For me, it's a little useless, no ? Perhaps better to wait for a refresh rate all 15 minutes.
    2012-03-08 07:50 PM
  2. The_Durben's Avatar
    Thanks Dacal.

    To Dacal, rasputin, crazy & The_Durben (or anybody who knows)

    Coming home in the taxi tonight I set 20 second lock screen to 20 minutes and tested the original "GPSweather.theme" and it did not update when moving through the various towns. The LS (and the UniAW (PerPage)) are only updating the location after the weather "UpdateInterval" refreshes, (currently set at 20 minutes).

    But from what I gather from "The_Durben" and others it is supposed to update more or less as soon as you move to another district as this is when the "myLocation.txt" file gets updated.

    How often does the GPS app check our location, or is it continuously monitoring and does it update the .txt file immediately?

    And.. (sorry) If the text file coordinates change does the weather widgets immediately change too, or do they only change after the 20 minutes set in the "UpdateInterval" as mine are doing.

    Thanks guys.
    Hey Ian
    So I tested the original lock theme ( restyled that's all and it updates as you move.
    The uniaw however (same one I sent you) must have had a well timed refresh last night as I changed the interval this morning to 60mins and drove through two different locales to work today and it did not update.
    I'm not overly concerned at that as 15-20 interval will do the trick. I think if the uniaw is changed to keep looking consistently for a change in the location.txt it will have a negative impact on battery.

    Edit** I see why the original updates after reading Dacals post.
    I'll test mine tomorrow while I'm working from home with a faster refresh rate as well as location check rate and see the impact on battery with normal use of the phone.
    Last edited by The_Durben; 2012-03-08 at 08:00 PM.
    2012-03-08 07:52 PM
  3. <Ian Nicoll/>'s Avatar
    Thanks guys, but I would like to try it updating the UpdateLocation function every 20 seconds, so maybe Chevy can also try this, it works on my mac but cant test it on the road till tomorrow when I go to work.

    In the Widget.html file of the UniAW add this to body section Or maybe it should be in the head section!, anyway, it works like this on the Mac, just stick it wherever you want .).


    <script language="JavaScript">UpdateLocation(); setInterval('UpdateLocation()', 20000 )</script>

    We will see how the battery goes.

    I know it's not important but would just like to see it change while driving!! (I'm a big kid really lol..)

    Ian, rather than making UniAW 5 work with GPS code, would it not be easier to make the GPS widget by Crazy into UniAW?
    Hi bud,

    I already went through that headache, because the original uses the var locale="CAXX0677 and the UniAW uses the woeid code in "123456" format it didn't work.

    UniAW with GPS is now working, just still in beta LOL..
    Last edited by <Ian Nicoll/>; 2012-03-08 at 08:27 PM.
    2012-03-08 08:08 PM
  4. chevymusclecar's Avatar
    lmao!! I'm a big kid also Ian and I have added the script code! Will be able to test in a couple of hours!

    Thanks you guys for your diligence!
    2012-03-08 08:33 PM
  5. The_Durben's Avatar
    Thanks guys, but I would like to try it updating the UpdateLocation function every 20 seconds, so maybe Chevy can also try this, it works on my mac but cant test it on the road till tomorrow when I go to work.

    In the Widget.html file of the UniAW add this to body section Or maybe it should be in the head section!, anyway, it works like this on the Mac, just stick it wherever you want .).


    <script language="JavaScript">UpdateLocation(); setInterval('UpdateLocation()', 20000 )</script>

    We will see how the battery goes.

    I know it's not important but would just like to see it change while driving!! (I'm a big kid really lol..)



    Hi bud,

    I already went through that headache, because the original uses the var locale="CAXX0677 and the UniAW uses the woeid code in "123456" format it didn't work.

    UniAW with GPS is now working, just still in beta LOL..
    I added that script to my lock and will test in my way home in about 6hrs.
    Thanks again Ian
    2012-03-08 08:39 PM
  6. Dacal's Avatar
    You're all big kids. LMAO !

    Before GPS, no problem to update weather all 15/20 minutes (i don't remember the number of time where i saw rain outside and my widget show a partly cloudy day, but i don't care about this... Just a respring if necessary ).

    Now, you want an update every 20 secondes .

    LOL.

    PS : i also a big kid... I think i'll test this tomorrow....
    2012-03-08 08:52 PM
  7. <Ian Nicoll/>'s Avatar
    ^^ LOL
    Well this big kid is going nite nite, see ya's tomorrow guys.

    Oh man, I need a 50" MacbookPro, 17" is just not big enough for this theming stuff.

    Attached Thumbnails GPS Based HTML Lockscreen Weather Theme-screen-shot-2012-03-09-3.20.53-am.png  
    Last edited by <Ian Nicoll/>; 2012-03-08 at 09:24 PM.
    2012-03-08 09:03 PM
  8. poofster1's Avatar
    I'm a big kid with small toys (ipod 2g kids have 4g haha) anyway if someone was to jump in rite now as a newbie...where would they start? What's the latest download they should use to get the latest tweaks here? Or is that still being worked on? Kids want this now.
    2012-03-08 09:23 PM
  9. crazyvivek's Avatar
    But this is not what other people are telling us, it changes as they drive, not on the updateInterval!! (Unless they all have their UpdateInterval set to like 2 minutes, which I hope not LOL)

    When I have it running on My Mac with "Live View", I can edit the text file in the theme folder (not in the HTML editor) and the widget changes, I can put the txt file on my desktop and point the widget to it, and again if I edit the coordinates in the text file the widget updates immediately, so I'm wondering why it doesn't do it on the phone!
    It uses the deviceís cellular radio to determine the userís location.

    https://developer.apple.com/library/...eLocation.html

    In iOS 4.0 and later, you can use the significant-change location service to receive location events. This service offers a significant power savings and provides accuracy that is good enough for most applications. It uses the deviceís cellular radio to determine the userís location and report changes in that location, allowing the system to manage power usage much more aggressively than it could otherwise. This service is also capable of waking up an application that is currently suspended or not running in order to deliver new location data.
    --------
    If you like "GPS weather theme" http://modmyi.com/forums/iphone-4-ne...her-theme.html donate via paypal to [email protected]
    --------
    2012-03-08 10:20 PM
  10. Schnedi's Avatar
    where start?

    first page, first post...

    you should read the full thread to understand what these amazing kids are doing!!
    2012-03-08 10:22 PM
  11. King_O_Hill's Avatar
    It uses the device’s cellular radio to determine the user’s location.

    https://developer.apple.com/library/...eLocation.html

    In iOS 4.0 and later, you can use the significant-change location service to receive location events. This service offers a significant power savings and provides accuracy that is good enough for most applications. It uses the device’s cellular radio to determine the user’s location and report changes in that location, allowing the system to manage power usage much more aggressively than it could otherwise. This service is also capable of waking up an application that is currently suspended or not running in order to deliver new location data.
    Ah Yes! Now it makes sense! I do remember reading that.

    Thanks Crazy!
    2012-03-08 10:24 PM
  12. The_Durben's Avatar
    Thanks for that info crazy

    To everyone else, crazyvivek has a donation link up in his signature if you're in a giving back kinda mood
    2012-03-08 10:24 PM
  13. nik1975's Avatar
    mine today ....

    UniAW works well for me too,but sometimes like without animated as well


    Nice job man..Can you do this also for the homescreen, without the photo of car?Only hour, weather??
    Thank you..
    2012-03-08 10:26 PM
  14. Dacal's Avatar
    Mmmm...

    Rework the code to reduce the load in case of location check every 20s... I think (but need to test) that will be better (no need to modify the line in HTML) :

    //-----------------------------------------------------------------------------------------------------------
    //-----------------------------------------------------------------------------------------------------------
    // Author : Vivek Thakur
    // Date : 25 Feb 2012
    //-----------------------------------------------------------------------------------------------------------
    //-----------------------------------------------------------------------------------------------------------
    // Modified by Dacal for BaSalt HD theme.
    //-----------------------------------------------------------------------------------------------------------
    //-----------------------------------------------------------------------------------------------------------

    var prevlatitude = "";
    var prevlongitude = "";
    var textLat;
    var textLong;
    var refreshWeatherTimer;
    var get_location = false;

    function trimString (text) {
    return text.replace(/^\s+/g,'').replace(/\s+$/g,'');
    }

    function UpdateLocation() {
    var file="../../../../var/mobile/Documents/myLocation.txt";
    var txt_request = new XMLHttpRequest();
    txt_request.overrideMimeType("text/xml");
    var LocationTimer = setTimeout(function() {
    txt_request.abort();
    dealWithWeather({error:true});
    }, 10000);
    txt_request.onload = function(e) {
    clearTimeout(LocationTimer);
    getCoordinates(txt_request.responseText);
    }
    txt_request.open("GET", file, false);
    txt_request.setRequestHeader("Cache-Control", "no-cache");
    txt_request.send(null);
    setTimeout("UpdateLocation();", 20000); // Refresh location every 20s
    }

    function getCoordinates(request) {
    var substr = request.split('\n');
    var templatitude=(substr[0]).split('=');
    var templongitude=(substr[1]).split('=');
    latitude = trimString(templatitude[1]);
    longitude = trimString(templongitude[1]);

    if (prevlatitude != latitude || prevlongitude != longitude) {
    prevlatitude = latitude;
    prevlongitude = longitude;
    getWoeid ();
    }
    }

    function getWoeid() {
    var url = "http://where.yahooapis.com/geocode?location=" + latitude + "+" + longitude + "&gflags=R";
    var xml_request = new XMLHttpRequest();
    var WoeidTimer = setTimeout(function() {
    xml_request.abort();
    if (get_location == true) { document.getElementById("Offline").innerHTML = "Offline"; }
    else { dealWithWeather({error:true, errorString:null}); }
    }, 10000);
    xml_request.onload = function(e) {
    clearTimeout(WoeidTimer);
    woeid_loaded(xml_request);
    }
    xml_request.overrideMimeType("text/xml");
    xml_request.open("GET", url+"&antiCache="+Math.floor(Math.random()*1001), false);
    xml_request.setRequestHeader("Cache-Control", "no-cache");
    xml_request.send(null);
    }

    function woeid_loaded(request) {
    if (get_location == true) { clearTimeout(refreshWeatherTimer); }
    var effectiveRoot = findChild(request.responseXML, "ResultSet");
    postal = parseInt(findChild(effectiveRoot, "Result").getElementsByTagName("woeid")[0].childNodes[0].nodeValue);

    if (latitude < 0) { textLat = Math.round(latitude*100)/100 + "\u00B0" + "S"; }
    else if (latitude > 0){ textLat = Math.round(latitude*100)/100 + "\u00B0" + "N"; }
    else { textLat = Math.round(latitude*100)/100 + "\u00B0"; }

    if (longitude < 0) { textLong = Math.round(longitude*100)/100 + "\u00B0" + "W"; }
    else if (longitude > 0) { textLong = Math.round(longitude*100)/100 + "\u00B0" + "E"; }
    else { textLong = Math.round(longitude*100)/100 + "\u00B0"; }

    get_location = true;
    refreshWeather();
    }

    function refreshWeather() {
    fetchWeatherData(dealWithWeather,postal);
    var refreshWeatherTimer = setTimeout("refreshWeather()", updateWeatherEvery); // Refresh weather as specified in Config.js
    }
    In fact, i don't like let a timer which is not specified. Sometimes, timer (define by setInterval or setTimeout) will not stop correctly and will continue to do its job. I prefer assign a variable and stop it when no need anymore.

    In some widget, it's a cause of bug and/or fast battery draining.

    To everyone else, crazyvivek has a donation link up in his signature if you're in a giving back kinda mood
    Done . Thx man, i appreciate the work. No big money, but it's a start

    Question (and i must also check that !) : What is the precision of the GPS ? Imagine you have the phone in your pocket, and you move from kitchen to bedroom => Is it a significant change for update the weather ? Oh god, my battery...
    Last edited by Dacal; 2012-03-08 at 11:11 PM.
    2012-03-08 10:54 PM
  15. chevymusclecar's Avatar
    So Dacal will not need to add this line....

    <script language="JavaScript">UpdateLocation(); setInterval('UpdateLocation()', 20000 )</script>

    In HTML?
    2012-03-08 11:18 PM
  16. Dacal's Avatar
    Guys, during your tests, if you drive don't forget to look the road... Don't focalize on you phone .

    So Dacal will not need to add this line....

    <script language="JavaScript">UpdateLocation(); setInterval('UpdateLocation()', 20000 )</script>

    In HTML?
    No. I'm trying to make a all-in-one script for modders. The change to an existing widget must be minor. For now, need only 4 things.

    1) Include a line in the HTML (be careful must point to the right location for js) :

    <script type="text/javascript" charset="utf-8" src="Resources/JavaScript/Main/GetLocation_Weather.js"/></script>
    2) Copy the "GetLocation_Weather.js" (code in previous post) in the place above

    3) Slightly modify the main javascript of your theme (for my widget, i call an init function in main.js) and must replace (for exemple ) :

    validateWeatherLocation(escape(locale).replace(/^%u/g, "%"), setPostal
    by :

    if (locale == 0) { UpdateLocation(); }
    else { validateWeatherLocation(escape(locale).replace(/^%u/g, "%"), setPostal); }
    4) Put the locale variable to 0. For my widget (and a lot now, as a many are based on my code), edit the ../Setup/Config.js.

    I think i didn't forget anything....
    Last edited by Dacal; 2012-03-08 at 11:34 PM.
    2012-03-08 11:20 PM
  17. The_Durben's Avatar
    So Dacal will not need to add this line....

    <script language="JavaScript">UpdateLocation(); setInterval('UpdateLocation()', 20000 )</script>

    In HTML?
    I added Ian's script and it's kicking my phone batteries azz. 35% in 3hrs
    Id like to know the same thing Chevy
    2012-03-08 11:23 PM
  18. Dacal's Avatar
    I added Ian's script and it's kicking my phone batteries azz. 35% in 3hrs
    Id like to know the same thing Chevy
    Try my code (think it's better, Ian it's not a critic !), but i'm scare that battery draining is more intensive than an update in same time of "classic" weather.
    2012-03-08 11:39 PM
  19. KraXik's Avatar
    I'm confused as to why the update thing has to change? It works amazingly well with Crazys lockscreen. Why do we need to change it? Me = confused. :s
    2012-03-08 11:43 PM
  20. Dacal's Avatar
    I'm confused as to why the update thing has to change? It works amazingly well with Crazys lockscreen. Why do we need to change it? Me = confused. :s
    The crazy LS work very well ! It's the implementation in others widgets which need to be more easy. The main goal (i think) is to make a easy add-on for existing widget.
    2012-03-08 11:47 PM
2,706 ... 1624252627283676126 ...
LINK TO POST COPIED TO CLIPBOARD
We have updated our Privacy Policy and Terms & Conditions. Please check them out.