Script investigating, extra eyes needed

Wednesday, April 11, 2012 by LizMarr | Discussion: DesktopX

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.

 

First Previous Page 2 of 2 Next Last
LizMarr
Reply #21 Friday, April 13, 2012 8:12 PM

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.

mystifeid
Reply #22 Friday, April 13, 2012 9:37 PM

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)

Code: html
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>Hello World</title>
  5. <style type="text/css">
  6. body {margin:0;width:130px;height:60px;background-color:#444;padding:5px;font:bold 12px/14px "Segoe UI";}
  7. select, #resultDiv {width:120px;}
  8. #resultDiv {color:#f66;margin-bottom:10px}
  9. </style>
  10. <script type="text/jscript">
  11. function showOptionChoice(){
  12.  resultDiv.innerText=mySelect.value;
  13.     //or
  14.     //resultDiv.innerText=mySelect.options(mySelect.selectedIndex).value;
  15.     if(resultDiv.innerText!=="Choose an option"){
  16.      resultDiv.style.color="#0f0";
  17.     }
  18.     else{
  19.      resultDiv.style.color="#f66";
  20.     }
  21. }
  22. function fx(){
  23.  mySelect.onchange=showOptionChoice;
  24. }
  25. </script>
  26. </head>
  27. <body onload="fx();">
  28. <div id="resultDiv">Choose an option</div>
  29. <select id="mySelect">
  30.  <option value="Choose an option">Options</option>
  31.  <option value="1st option selected">First Option</option>
  32.  <option value="2nd option selected">Second Option</option>
  33.  <option value="3rd option selected">Third Option</option>
  34. </select>
  35. </body>
  36. </html>
mystifeid
Reply #23 Friday, April 13, 2012 9:52 PM

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.

Please login to comment and/or vote for this skin.

Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:

  • Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
  • Access to a great community, with a massive database of many, many areas of interest.
  • Access to contests & subscription offers like exclusive emails.
  • It's simple, and FREE!



web-wc01