XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently May 7th, 2025, 11:39 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: January 24th, 2014, 12:05 pm 
Offline

Joined: January 24th, 2014, 11:41 am
Posts: 2
Would it be possible to add a pollen tag for extracting the pollen data from this "core"?

I noticed that the the "AccuWeatherCore2*" cached file appears to already have the pollen data; however, I'm unable to locate a "pollen" tag in the XWidget Designer tool (under Add tag).

JSON Snippet with Pollen data:
Code:
"AirAndPollen":[{"Name":"AirQuality","Value":25,"Category":"Good","CategoryValue":1,"Type":"Ozone"},{"Name":"Grass","Value":0,"Category":"Low","CategoryValue":1},{"Name":"Mold","Value":400,"Category":"Low","CategoryValue":1},{"Name":"Ragweed","Value":0,"Category":"Low","CategoryValue":1},{"Name":"Tree","Value":50,"Category":"Moderate","CategoryValue":2}


File Location: C:\Users\..\Documents\xwidget\Cache

Thanks,
Matt


Top
 Profile  
 
PostPosted: January 25th, 2014, 7:42 pm 
Offline
User avatar

Joined: March 8th, 2013, 10:27 pm
Posts: 353
There is lots of candid stuff that Accuweather sends but unfortunately not all are exposed through the tags. One solution is to load the json and get the objects manually.

_________________
Life is a myriad game... Just play it!


Top
 Profile  
 
PostPosted: January 25th, 2014, 9:55 pm 
Offline

Joined: January 24th, 2014, 11:41 am
Posts: 2
digigamer wrote:
There is lots of candid stuff that Accuweather sends but unfortunately not all are exposed through the tags. One solution is to load the json and get the objects manually.


Thanks!

Is there a way to pull back the raw JSON via the native JavaScript API in XWidget instead of retrieving it from the local cached file?


Code:
  ...
    //file_get_contents_async('http://api.vkontakte.ru/method/users.get?uids=1&fields=photo_200',
    file_get_contents_async('C:\\Users\\user123\\Desktop\\test.json',
        function(response)
    {
       //get the json.. lets say that is stored in a obj
       //response is the downloaded string...
        var obj = JSON.parse(response);
        //var uid = obj.response[0].uid;
        //var firstName = obj.response[0].first_name;
        //var lastName = obj.response[0].last_name;
        //var avatar = obj.response[0].photo_200;
        //alert(lastName);
        var name = obj.DailyForecasts[0].AirAndPollen[2].Name;
        var value = obj.DailyForecasts[0].AirAndPollen[2].Value;
        var category = obj.DailyForecasts[0].AirAndPollen[2].Category;
        var categoryVal = obj.DailyForecasts[0].AirAndPollen[2].CategoryValue;

        alert(categoryVal);
    });


Code:
function file_get_contents_async( url ,callback) {
var req = null;
 try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {
 try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {
 try { req = new XMLHttpRequest(); } catch(e) {}
 }
 }
 if (req == null) throw new Error('XMLHttpRequest not supported');

req.open("GET",url,true);
req.onreadystatechange=function() {
 if (req.readyState==4) {
 var response = req.responseText;
 callback(response);
 }};
req.send(null);
}


Attachments:
File comment: Cached Accuweather JSON Files
Screenshot - 1_25_2014 , 9_50_53 PM.jpg
Screenshot - 1_25_2014 , 9_50_53 PM.jpg [ 18.97 KiB | Viewed 4115 times ]
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 26 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB® Forum Software © phpBB Group