I'm exploring the scripts for my favorite Windows gadget wondering if I can port it to DesktopX (plus I really want to change some variables) I've found a select call for the drop-down box where you choose what magnitude you want, but I be darned I cannot find the actual bit where it pulls the data from the web using the selected data. I've looked through 15 files for hours. XML, HTML, JS, CSS. I cannot figure out what I am looking for nor finding it. Here is the starting call, I can link the rest of the files if anyone wants to practice their code analysis.
<select id="data" style="width:196;font-size:12px;"> <option value="1">Magnitude 0+ (Past Day)</option> <option value="2">Magnitude 2+ (Past 7 Day)</option> <option value="3">Magnitude 3+ (Past 7 Day)</option> <option value="4">Magnitude 5+ (Past 7 Day)</option> <option value="5">Magnitude 7+ (Past 7 Day)</option> </select>
The original numbers were 0+,1+(Past Day),2.5+,5+,7+ There has to be some place that is feeding two variables into the gadget (magnitude and number of days). It has become more a learning experience than simply changing 2.5+ to 3+.
I don't intend to use the code for anything but my own. I want to figure out how it draws information from USGS and then make my own code. Probably some available variables that I would use besides what he has. I just want to understand how this is used to set the size and period. Right now I have it populating the drop down, but that is no good.
I know that USGS probably publishes a SDK. I find that trying to understand those things just makes me frustrated and I quit. For me it is easier to see how it is used then investigate how it works from there.
Which gadget? What is USGS? What does the gadget do?
If it's a Microsoft gadget I believe they have functions built into a dll which are called to retrieve information.
It displays earthquake data from the USGS. Just a little column whose data rolls down as it is updated. Twice now I have learned about earthquakes before the news agencies have (like today) They need one of these. It is a Microsoft Sidebar gadget that is still supported by its creator (who has several gadgets) I'd like simply to chage the variables. I already know how to change the width and font and such. I'd really like to learn the API so I can make my own - using DesktopX. I can't see the API call either in this thing.
http://addgadget.com/earthquakes_meter/
I'd hazard a guess that he's tapping into the RSS Atom feeds listed on this page: http://earthquake.usgs.gov/earthquakes/catalogs/
It looks like the feeds are already grouped into the days and magnitude categories.
I assume that the list 'expands' if there are earthquakes in each magnitude category e.g. right now there are only 0, 1, and 2.5 groups for the 'past day', but if a 7 occurs suddenly there would be a new 7+ listing for 'past hour' and eventually 'past day'.
Because the atom feeds are 'filename based' - you could poll for each possible xml file, each hour, and update a gadget or whatever accordingly. There is no way to know what files (and therefore what magnitudes and periods) exist until you ask the server for them.
*edit* Actually http://earthquake.usgs.gov/earthquakes/feed/ seems a better choice as it just has a 'All earthquakes' feed for each period.
You could then filter the data according to your desired magnitude.
*edit* I might also say that the gadget maker says it provides alerts within a minute - I think that might not always be correct as the feed source website states that for international alerts it can be up to 30 minutes.
I didn't think of that when I was looking. I saw there was daily, weekly, and thirty day groupings and some variety of strengths. I wonder if the 1,2,3 etc match up to those feeds. I was looking a bit at that Atom feed that they replaced RSS with. I was just getting used to RSS...
So I guess at first I'm going to be limited by the existing sets and create a format I like better. The interface on the current one is too narrow, too scrunched up, and I would like the ability to scroll back. I wonder if a person could add some more of those data sets? Like have 8 of them rather than just five. I think I shall change 1-5 to mix it up a little and see what I get. I still don't see where it is using that call to get the data. More looking I guess.
Now this is a gadget worth having. I usually resort to hitting up the USGS and get an image that shows the location and magnitude of earthquakes but the red dots are all over the place. It lists all of the quakes, major and minor, for a given period. An RSS feed is just what I need.
I have the gadget that is just the map too, but I like my IRIS bookmark better. With it you can gently click the little ring you want and have the data show up, and then use the "last thirty days" option to get some good data to play with. If I ever teach an Excel class again I'm going to give them weather or earthquake data to learn with. The hardest part about teaching Excel is to get enough interesting data to really play with the features with.
So many toys.....so little time. Oh well
It seems he has gone to some trouble to prevent exactly what you are trying to do (but I could be wrong and you could try emailing him).
If you cannot find what you are looking for then modifying this gadget's scripts may involve a steep learning curve.
I would encourage you to make your own gadget. Use search to find examples from which to learn.
But if you really must look at his scripts then you will have to use something like the Web Developer extension in Firefox.
Open the relevant html file in Firefox and then from the Web Developer toolbar select "Information" and then from the drop down list click on "View Javascript" and all scripts loaded by the html file will be displayed in a new tab/page. Copy everything and paste into your editor. There will be quite a lot of white space...
Oh, btw, I would like to change the Windowblinds UI...perhaps you could be of assistance in decompiling the exe for me and sending me the source...
I am trying to wean from Windows Sidebar. The thing is a memory hog and this is the only gadget I really care about. The rest I use are weather ones and I can survive with the available ones even though they do not have all the data I like to have at my fingertips (and use less than my favorite provider) I will investigate eventually to see if I can get the data and provider I want with the weather gadget because it does have good documentation. As for the earthquake gadget, I really want to learn how those calls work. The color and window size are easy to figure out, but the key one is not. At first I thought that it refers to data on his web site, but I can't find that call either. The USGS site doesn't seem to have anything resembling a SDK and I'm not knowledgeable enough to translate web pages to desktop use. It's OK, I'll figure something out.
You don't need a "SDK". Just set a timer to load the ATOM files (which are XML) feeds every so many minutes and then parse them into a display.
Look into MSXML vbscript examples on the web - you'll learn how to create an 'in memory' XML object - load in an external xml file (like the ATOM files) and then read information from them.
I can probably give you a hand if noone else wants to jump in - but I'm a bit busy with a house move at the moment.
First step is to set up an object which retrieves the atom file, and then set a DX Text object to display the contents - it'll all be xml code, but you have a basic proof of concept - then work on manipulating the atom file to only put the information you want into the DX Text object.
Parsing is where you face the most programming - pulling the information out that you want without all the XML code tags - this is where learning about MSXML object in vbscript will come into play.
ok....
I'm glad I am not hurrying. But it sure sounds like fun. I should have something I like by fall I think
Don't worry about helping me until I've messed myself up thoroughly. I estimate that to be about May as it will be a side line of a couple other projects.
You can look at an example of how to download and parse an xml file with jscript here :
http://social.msdn.microsoft.com/Forums/en/sidebargadfetdevelopment/thread/5c313c0e-0a3e-4cf6-9e4e-e0d701a834d6
That looks very complicated.
Well, it's about as basic as I know how to make it - and apart from the gadget.xml file (which is fairly generic) it is a complete working gadget. Still if anyone can provide that OP with an easier or less complicated working solution it would make me very happy. Him too, I suppose.
I gotta find my pencil and print that out. My mind is running in circles trying to keep track of all the small things. Sure looks like fun! Thanks. Funny how you were listening to two very similar threads in two forums.
It is fun but if you have never made a gadget before, please consider following the advice in this thread
Gadget Newbie
and start by making a "Hello World" gadget. The thread also contains a few other useful links but please note that these do not cover the properties and methods of the IXMLDOMDocument and IXMLHTTPRequest objects (which besides script examples also contain code examples.)
There are also many other links possible to give for jscript. Think of it as a superset of javascript. A very big one. Also, if you can write jscript you will have little trouble learning how to write vbscript (and vice-versa).
Any suggestions on something to read about using that select command for outside data? I have used similar before as it has for colors and such. I still want to learn the one above.
What you have above is just an HTML element or object - a way of adding a drop down list to the page.
There are no commands.
But a select object can be manipulated through script via it's properties, methods and events.
You can change or read it's displayed value for example with the value property.
The "Gadget Newbie thread" mentioned above contains this link :
HTML and DHTML reference
which in turn includes these links :
DHTML Objects
(you will find the select link on this page)
DHTML Properties
DHTML Methods
DHTML Events
I assumed that you already knew how to write HTML/CSS (ie can make a web page) which is a necessary skill for making gadgets but if this is not the case then you should perhaps start elsewhere - for example :
Search for How to write HTML
bearing in mind that with gadgets you are writing your pages for one client/browser only.
There is a lot you can learn about this stuff and not too many shortcuts which is why I would suggest starting at the beginning.
Knowing how to make a gadget that downloads and parses an xml file with a script I would put more towards the advanced side of things.
(Likewise the first gadget I tried to make was a network gadget which was a very bad choice - I ended up rewriting it five times from scratch over five months before I published it. And I was pretty handy with HTML/CSS before I started.)
Hum. I know that much about select. With that one I never could tell just WHAT the selection was used for. I guess I need to make my own and try to debug it.
That's right - make your own !!
If you are trying to make gadgets, this is where the "Hello World" gadget becomes very handy. You can make the simplest example possible and experiment with it.
For example here is a fairly average example that changes the content above the select depending on the option that is selected (and please note that this is an Sidebar/Internet Explorer specific example)
And above all - be prepared to use Search.
It has not been uncommon for me to do a hundred or more searches a day when I've been trying to learn to do new things.
btw...
In a normal web page a select is a form element and the select value will be sent to the server when the form is submitted - when the submit/send button is clicked.
There are many great features available to you once you register, including:
Sign in or Create Account