1. Simon's Avatar
    Cool, well glad you did. Been meaning to ask that question for a while but kept forgetting.
    2015-02-06 08:08 PM
  2. michaelrw's Avatar
    Yes, Michael. You're a quick study! Mostly everything you've said is correct there. Except watch your naming.. It's BatteryStats.txt and not 'batterystats.txt',etc.. And the groovyAPI.do ({ read:.... call only looks into the Documents folder for a file. The BatteryStats.txt and RAMStats.txt files reside in var/mobile/Library/Stats folder. So you'd need the syntax:
    Code:
    groovyAPI.do ( { read: '../Library/Stats/BatteryStats.txt' }, function(appdata) {
    Now here is the kicker.. Several of the widgets that have function(appdata).. are likely older myLocation.txt-based widgets which are accessing the simple pair of coordinates in the myLocation.txt file.. And - though groovyAPI+ is able to gain us access to the myLocation.txt file locally in the Documents folder - WKWebView, on iOS 8 running on our phones, is incompatible with the older RSS feed calls made to yahoo.. ... Those forecastRSS feeds are not YQL-compliant and Apple seems to have dropped support for them, at least in the iOS8.1.2 implementation of WKWebView.. So the incompatible yahoo feed syntax renders the older dBar (based on WOEID only) and myLocation.txt mods completely useless to us in GL+ and GB+..

    So I don't want you to go through all of your attempts at conversion for nothing. In my tutorials I make clear that the simple fix method only works for WidgetWeather.xml based mods.

    Now I've been working on a way around this limitation and have had my first breakthrough.. But more testing to do. Too early for the victory lap..
    Thanks so much. I'm at work atm and will read this thoroughly and reply when I get home later tonight. Thanks again!
    2015-02-07 12:56 AM
  3. michaelrw's Avatar
    Yes, Michael. You're a quick study! Mostly everything you've said is correct there. Except watch your naming.. It's BatteryStats.txt and not 'batterystats.txt',etc.. And the groovyAPI.do ({ read:.... call only looks into the Documents folder for a file. The BatteryStats.txt and RAMStats.txt files reside in var/mobile/Library/Stats folder. So you'd need the syntax:
    Code:
    groovyAPI.do ( { read: '../Library/Stats/BatteryStats.txt' }, function(appdata) {
    Now here is the kicker.. Several of the widgets that have function(appdata).. are likely older myLocation.txt-based widgets which are accessing the simple pair of coordinates in the myLocation.txt file.. And - though groovyAPI+ is able to gain us access to the myLocation.txt file locally in the Documents folder - WKWebView, on iOS 8 running on our phones, is incompatible with the older RSS feed calls made to yahoo.. ... Those forecastRSS feeds are not YQL-compliant and Apple seems to have dropped support for them, at least in the iOS8.1.2 implementation of WKWebView.. So the incompatible yahoo feed syntax renders the older dBar (based on WOEID only) and myLocation.txt mods completely useless to us in GL+ and GB+..

    So I don't want you to go through all of your attempts at conversion for nothing. In my tutorials I make clear that the simple fix method only works for WidgetWeather.xml based mods.

    Now I've been working on a way around this limitation and have had my first breakthrough.. But more testing to do. Too early for the victory lap..
    Ok, so.. I will start by saying, all of the syntax for the groovyAPI.do calls makes sense to me, I will implement this into my code. I was using full paths in my code, which obv didnt work. So, good to know I need to use paths that are relative to Documents directory.

    You also said "It's BatteryStats.txt and not 'batterystats.txt' " .. youre basically saying that filenames are case-sensitive?

    All of the technical stuff about ios8 and wkwebview and compatibility and blah blah makes no sense to me really, just bc it's over my head. Is the major point there that some html themes are worth converting, while others are not? I dont think my theme works on MyLocation, but rather uses a woeid, directly in the main.js (there is no config.js). On the other hand, I have the exact same theme that Marty converted to WW2, which reworked a lot of the scripting (obviously) and also added a config.js, and also rewrote/condensed/made-more-efficient a lot of the html and Css. The problem that I am finding, aside from the Battery and RAM not working (Which will now work because we have resolved that above), there are a few other parts of the theme that arent working with gAPI+. However, there are no other jQuery that need replacing, so i dont know what the problem is. When I have more time I will isolate the function and post it here/somewhere and see if we can figure out why it doesnt work well on gAPI+
    2015-02-07 10:24 PM
  4. King_O_Hill's Avatar
    Yes, when referencing any external file, image etc, it is always case sensitive.

    Check out WW3 for iOS 9/10 - Widget-Weather 3.0
    2015-02-07 10:38 PM
  5. NewD's Avatar
    Michael, the remaining problem you're having with GL+/GB+/gAPI+ and widgets that use WOEID, is that WKWeView-based HTML players, like GL+, etc, can't make calls to RSS-based Yahoo feeds any longer. Only YQL compliant feeds will work in WKWebView (GL+, etc). The good news is that Yahoo does have free YQL compliant apis to use in your older widgets. Just finding the right one is the trick.
    Last edited by NewD; 2015-02-08 at 03:24 AM.
    2015-02-08 03:21 AM
  6. undersea's Avatar
    What you're asking is beyond the scope of this particular thread, Undersea.. You need to learn a certain level of coding on your own to even speak a language we both can understand.. Please ask a more specific question about one function you want to add/delete.. and maybe we can help you with that on thing.

    But what you describe there is a massive rewrite. Maybe Dacal or Chevy can help you in the WidgetWeather 2.0 thread.. since they are the original creators/modders of the 02_WidgetWeather_Base.
    Okay. I see. Thanks man

    Any chance for add only the Weather read API from widget weather xml into the old code HTML ? Just replace the weather with new GroovyAPI.
    2015-02-09 12:26 PM
  7. NewD's Avatar
    Okay. I see. Thanks man

    Any chance for add only the Weather read API from widget weather xml into the old code HTML ? Just replace the weather with new GroovyAPI.
    Converting an old myLocation.txt or WOEID-only widget (like those from dBar) to WidgetWeather xml format IS possible - just very difficult and time-consuming. You need to find a coder willing to put in the time (which will be hard to find) or learn how to do it yourself. I wish I had better news.
    2015-02-09 02:36 PM
  8. undersea's Avatar
    Converting an old myLocation.txt or WOEID-only widget (like those from dBar) to WidgetWeather xml format IS possible - just very difficult and time-consuming. You need to find a coder willing to put in the time (which will be hard to find) or learn how to do it yourself. I wish I had better news.
    I think so. I saw someone recoded widget from WW2 chevy. I just follow that way. Thank so much for your time. I Appreciated.
    Maybe I will back here and ask u something new
    2015-02-09 03:34 PM
  9. michaelrw's Avatar
    so, i have a functioning ww2 gb+ theme ive been modding for the past few days..
    Today I wanted to finally add some new code to the script (main.js), to add a battery bar that uses BatteryStats.txt. So, i wrote the appropriate html and css, then cut and paste the modified script to work with gAPI+ (replaced jQuery), and evberything worked out just fine. That is, the battery bar worked fine. However, it knocked out everything else. Pretty much every other major function of the script was killed.. So, i dont know why, what i did wrong, or where to go to fix it.

    Code:
    var Level = "";
    var State = "";
    
    $.ajaxSetup({
    cache: false,
    headers: {'Cache-Control': 'no-cache'}
    });
    
    function battery() {
    	refreshLocationTimer = setTimeout(battery, 10*1000);
    //	jQuery.get('file:///private/var/mobile/Library/BatteryStats.txt', function(appdata) {
    	groovyAPI.do ( { read: "../Library/BatteryStats.txt" }, function(appdata) {
    		var myvar = appdata;
    		var substr = appdata.split('\n');
    		Level=substr[0].split(':')[1];
    		State=substr[1].split(':')[1];
    		if( Level > 0  && Level <= 2 )	document.getElementById("BatteryImage").src="Images/Battery/[email protected]";
    		if( Level > 2  && Level <= 4 )	document.getElementById("BatteryImage").src="Images/Battery/[email protected]";
    
    ...
    ...
    ...
    
    		if( Level > 98 && Level <= 100 ) document.getElementById("BatteryImage").src="Images/Battery/[email protected]";
    
    		// Replace the Level variable ranges if you want a less, or more, accurate battery bar. Replace the array of  images, such that they are representative of the defined range.
    
    		document.getElementById("LevelDisplay").innerHTML = Level + "%";
    		document.getElementById("StateDisplay").innerHTML = State;
    		if( Level > 0 ) {
     			$(function() {
    				$("h1#StateDisplay").lettering();
    			});
    		}
    	});
    }
    I basically just pasted this after the last function in the main script,
    function Translate(translate){

    originally my battery bar function was
    Code:
    function init() {
    but i changed it to a different name because there is already a function init() somewhere else in the main.js, so i wasnt sure if that was a problem. Either way, both produced the same result.. the battery bar worked, but knocked out the rest of the script.

    Maybe I just keep the battery script in its own script file and then link to it from the Wallpaper.html ?? Not sure if that will help.. Im sure this is just something simple that im not doing correctly, but i dont know how to write JS, I can only manipulate it to a certain degree.

    Ideas?
    Last edited by michaelrw; 2015-02-10 at 12:30 AM.
    2015-02-09 11:31 PM
  10. undersea's Avatar
    so, i have a functioning ww2 gb+ theme ive been modding for the past few days..
    Today I wanted to finally add some new code to the script (main.js), to add a battery bar that uses BatteryStats.txt. So, i wrote the appropriate html and css, then cut and paste the modified script to work with gAPI+ (replaced jQuery), and evberything worked out just fine. That is, the battery bar worked fine. However, it knocked out everything else. Pretty much every other major function of the script was killed.. So, i dont know why, what i did wrong, or where to go to fix it.

    Code:
    var Level = "";
    var State = "";
    
    $.ajaxSetup({
    cache: false,
    headers: {'Cache-Control': 'no-cache'}
    });
    
    function battery() {
    	refreshLocationTimer = setTimeout(battery, 10*1000);
    //	jQuery.get('file:///private/var/mobile/Library/BatteryStats.txt', function(appdata) {
    	groovyAPI.do ( { read: "../Library/BatteryStats.txt" }, function(appdata) {
    		var myvar = appdata;
    		var substr = appdata.split('\n');
    		Level=substr[0].split(':')[1];
    		State=substr[1].split(':')[1];
    		if( Level > 0  && Level <= 2 )	document.getElementById("BatteryImage").src="Images/Battery/[email protected]";
    		if( Level > 2  && Level <= 4 )	document.getElementById("BatteryImage").src="Images/Battery/[email protected]";
    
    ...
    ...
    ...
    
    		if( Level > 98 && Level <= 100 ) document.getElementById("BatteryImage").src="Images/Battery/[email protected]";
    
    		// Replace the Level variable ranges if you want a less, or more, accurate battery bar. Replace the array of  images, such that they are representative of the defined range.
    
    		document.getElementById("LevelDisplay").innerHTML = Level + "%";
    		document.getElementById("StateDisplay").innerHTML = State;
    		if( Level > 0 ) {
     			$(function() {
    				$("h1#StateDisplay").lettering();
    			});
    		}
    	});
    }
    I basically just pasted this after the last function in the main script,
    function Translate(translate){

    originally my battery bar function was
    Code:
    function init() {
    but i changed it to a different name because there is already a function init() somewhere else in the main.js, so i wasnt sure if that was a problem. Either way, both produced the same result.. the battery bar worked, but knocked out the rest of the script.

    Maybe I just keep the battery script in its own script file and then link to it from the Wallpaper.html ?? Not sure if that will help.. Im sure this is just something simple that im not doing correctly, but i dont know how to write JS, I can only manipulate it to a certain degree.

    Ideas?
    I think you just put the Battery script in a seperate js and link it to HTML. It'll easy to fix or combine with any html use GL+, GB+.
    2015-02-10 10:45 AM
  11. rasputin007's Avatar
    originally my battery bar function was
    Code:
    function init() {
    but i changed it to a different name because there is already a function init() somewhere else in the main.js, so i wasnt sure if that was a problem. Either way, both produced the same result.. the battery bar worked, but knocked out the rest of the script.

    Maybe I just keep the battery script in its own script file and then link to it from the Wallpaper.html ?? Not sure if that will help.. Im sure this is just something simple that im not doing correctly, but i dont know how to write JS, I can only manipulate it to a certain degree.

    Ideas?
    Never a good idea to have 2 functions with the same name. Pot luck which will be executed. LOL
    Either follow undersea's suggestion with external js file and script link in html. (Still would need a battery() call somewhere else).
    Or
    Leave where it is in main.js and just add a function call, e.g. into init
    Code:
    function init() {
    
    //all the usual code to be executed by function init()
    
    //before closing function bracket just add the function call
    
    battery();
    }
    That means the init function does all the usual stuff it does and the last thing is it will call the battery function.
    Alternative, as you use jquey, you could rename
    Code:
    function battery() {
    //your battery function content in here
    }
    as
    Code:
    $(function(){ 
    //your battery function content in here
    });
    This way this $ function will be executed automatically and no need to be called!
    Last edited by rasputin007; 2015-02-10 at 03:36 PM.
    Nothing is impossible only miracles take a bit longer!
    2015-02-10 03:27 PM
  12. NewD's Avatar
    Excellent, Ras! That's exactly how I'd code it.. Just call the battery function from the init.. People should know that 'where' functions are set up 'function myFunction () {................}' in terms of order of the code does NOT matter... BUT -- where the 'call' for the function 'myFunction ();' is place - DOES matter.. And a 'function init ();' is the first function to run when called from the HTML. via onload init or other conventional init calls.
    2015-02-10 04:49 PM
  13. rasputin007's Avatar
    I used this
    Code:
    $(function(){ 
    myFirstFunction();// will read database and place values in global variables
    mySecondFunction();// will get GPS coordinates, time and date to calculate sunrise, sunset, moonrise and moonset
    });
    instead of init function or "body onload=..." to start the javascript execution.
    Jquery will execute any $(function) automatically, no need for a function call or an "body onload=..." tag.
    Nothing is impossible only miracles take a bit longer!
    2015-02-10 09:34 PM
  14. michaelrw's Avatar
    I got the function working in the main.js
    I kept the unique name I gave to the function, then replaced the 'appdata' parameter with 'data', and changed the other 2 occurrences of appdata into data, as well. So the relevant part of the function now reads:
    Code:
    groovyAPI.do ( { read: "../Library/BatteryStats.txt" }, function(data) {
                    var myvar = data;
                    var substr = data.split('\n');
    Then I added "battery ()" at the very end of the script, outside of the battery function. Now it is working fine. I would like to add a switch in the config file for users who may want to disable it. If I declare a variable called showBatteryBar and set it to false in config.js, then I just need to find a good place in the function to put the conditional. Actually, could I just wrap the "battery ()" at the end of the script in a conditional? Something like:
    Code:
     if (showBatteryBar == true) { battery () }
    2015-02-11 08:38 AM
  15. NewD's Avatar
    I got the function working in the main.js
    I kept the unique name I gave to the function, then replaced the 'appdata' parameter with 'data', and changed the other 2 occurrences of appdata into data, as well. So the relevant part of the function now reads:
    Code:
    groovyAPI.do ( { read: "../Library/BatteryStats.txt" }, function(data) {
                    var myvar = data;
                    var substr = data.split('\n');
    Then I added "battery ()" at the very end of the script, outside of the battery function. Now it is working fine. I would like to add a switch in the config file for users who may want to disable it. If I declare a variable called showBatteryBar and set it to false in config.js, then I just need to find a good place in the function to put the conditional. Actually, could I just wrap the "battery ()" at the end of the script in a conditional? Something like:
    Code:
     if (showBatteryBar == true) { battery () }
    Precisely!
    Don't forget a semi colon after ().
    Is the work you're doing for a widget running in GL+?
    2015-02-11 02:00 PM
  16. undersea's Avatar
    Hi all,
    Because I have a problem with SBHTML, it made my 6+ Respring alot, even on Simple Sbhtml. So i begin change to GroovyBoard+ and GL+.
    The first time, thanks to WidgetWeather team have a super tweak for everyone. And also thanks @chevymusclecar @Simon for remade widgets.

    One pic than thousand words


    I recode and bring something on Springboard. Depend on WW_Base_chevymusclecar and Simon's DCL_Slideshow_mod. All information you want to make sbhtml. Easy add or remove info for your own. This one help you convert some old widgets to the new GroovyAPI widgets.
    I also added Switch on/off GroovyAPIplus.

    I already remade some my widgets:




    New Lockscreen and SBHTML will coming....

    Should I make a new thread for this ?
    Last edited by undersea; 2015-02-11 at 06:07 PM. Reason: credit to authors
    2015-02-11 04:06 PM
  17. NewD's Avatar
    New Lockscreen and SBHTML will coming....

    Should I make a new thread for this ?
    Yes, please. Please put them in this thread: CLICK HERE

    And nice job!
    2015-02-11 04:40 PM
  18. Simon's Avatar
    Hi all,
    Because I have a problem with SBHTML, it made my 6+ Respring alot, even on Simple Sbhtml. So i begin change to GroovyBoard+ and GL+.
    The first time, thanks to WidgetWeather team have a super tweak for everyone. And also thanks @chevymusclecar for remake widget.

    One pic than thousand words


    I recode and bring something on Springboard. Depend on WW_Base_chevymusclecar. All information you want to make sbhtml. Easy add or remove info for your own. This one help you convert some old widgets to the new GroovyAPI widgets.
    I also add Switch on/off GroovyAPIplus.

    I already remade some my widgets:


    New Lockscreen and SBHTML will coming....

    Should I make a new thread for this ?
    That first pic looks like my dcl slideshow mod, not Chevy's. I did one for GL+ from first WW base and WW2 base.
    Workaround Stategies for iOS8 respringing using GroovyAPI+-imageuploadedbymodmyi1423672853.084056.jpg
    Last edited by Simon; 2015-02-11 at 05:42 PM.
    2015-02-11 05:35 PM
  19. undersea's Avatar
    That first pic looks like my dcl slideshow mod, not Chevy's. I did one for GL+ from first WW base and WW2 base.
    Workaround Stategies for iOS8 respringing using GroovyAPI+-imageuploadedbymodmyi1423672853.084056.jpg
    You're right Simon. Apology for my mistake. I will edit topic and credit to you.
    If not your mod, i couldn't made this fast. Thank you.
    2015-02-11 06:04 PM
  20. Simon's Avatar
    You're right Simon. Apology for my mistake. I will edit topic and credit to you.
    If not your mod, i couldn't made this fast. Thank you.
    Lol, no prob. Don't forget Dacal too. None of our mods would be possible without him
    2015-02-11 06:12 PM
831 ... 10181920212230 ...
LINK TO POST COPIED TO CLIPBOARD