Weather widget

Talk about YBoxen, widgets, Propeller hacking, etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
irritantno9
 
Posts: 22
Joined: Thu Jun 05, 2008 4:12 pm

Weather widget

Post by irritantno9 »

I initially bought the Ybox2 just for the weather widget. I'm a terrible programmer. How difficult would it be to have the weather widget cycle through a number of zip codes. Like change every 2 minutes or so?

magician13134
 
Posts: 1119
Joined: Wed Jun 13, 2007 9:17 am

Post by magician13134 »

I don't have a YBox2, so this is pretty much guesswork, but from the Widgets page, it looks like the zip code is simply adjusted via your web browser, so you may want to try some simple javascript injection.
For example, go to the Google homepage, once it's loaded, paste this into the URL bar:

Code: Select all

javascript:void(setTimeout("document.f.q.value='Hello, World';document.f.submit()", 1000));
hit enter and wait for once second.

Notice what happened. You'll need to take over from here, since I can't experiment on my own with that page, but I'll break down what's going on.

Code: Select all

javascript: - Tells your browser to accept a script

void( - Makes sure you stay where you are, otherwise, you will lose your page when it returns a value

setTimeout( - This function will sleep for the number in the second argument, then do what's in the first argument

"document.f.q.value='Hello, World!';document.f.submit();" - This is the first argument, it tells Firefox (or IE) to look in the document for a form named "f" (you'll need to view the page source and see what your form is named), then in that form, look for a control named "q" (again, find the name of you zip code input box) and set its value to "Hello, World!" and submit the form

, 1000)); - This tells the function to sleep for 1000mS, for 2 minutes, you would do 60 * 2 = 120 * 1000 = 120000
If you can edit the page source, it would be easy add this:

Code: Select all

<script>
function func1(){
<!-- insert code to change zip code to whatever -->
<!-- insert a setTimeout to call func2 -->
}

function func2(){
<!-- insert code to change zip code to whatever else -->
<!-- insert a setTimeout to call func1 -->
}
</script>
That should get you started :)

User avatar
irritantno9
 
Posts: 22
Joined: Thu Jun 05, 2008 4:12 pm

ORLY

Post by irritantno9 »

Sounds like Dr. Sbaitso:

Dr. Sbaitso: The answer is asdhjfkldsfjhklasdfhkjsdhfkjshdfkjshdfjhsdkjf.

OK I think I understand......
Last edited by irritantno9 on Sat Jun 28, 2008 4:57 pm, edited 1 time in total.

User avatar
irritantno9
 
Posts: 22
Joined: Thu Jun 05, 2008 4:12 pm

no actually

Post by irritantno9 »

I take that back!

HUH!

I think I plateaued at

10 print "hello world" ;
20 goto 10

Locked
Please be positive and constructive with your questions and comments.

Return to “YBox2 (discontinued)”