BS-Harou

Just another blog about the best browser - Opera!

Weather in Speed dial

, ,

[UPDATE 2012-01-26]
The post below is related to old version of my speed dial weather and still might be useful to someone who uses old versions of Opera. For Opera 11.50+ there is a new Opera extension:

https://addons.opera.com/en/addons/extensions/details/weather-by-wundergound/

______________________________________________________________________


Were you thinking about some alternative way how to use speed dial? Here is one way how you can do that. I've created site with big weather images and description.

So how it works? Very simple.

First part is the URL of the site:
http://speeddial.operacesky.net/weather.php

Put this URL into some speed dial window

Second part is query string. There are five (all optional) parameters that you can use.
1 - Language: lang=en or cs/fr - default is "cs" (Czech language)
2 - Area: area=London - default is Prague (Capital of Czech Republic)
3 - Top: top=100 - this parameter sets margin-top css property of images and description, thank to this parameter you can align the main parts to center of your speeddial window.
4 - Redirect: redirect=http://www.wunderground.com/ - Site to which you get redirected when you click on speed dial window. Default is http://www.wunderground.com/. You can also type: no - this means that you won't be redirected anywhere. If you want to use site with query string you will have to encode this URL, or use some site like http://bit.ly/ (that's what I do).

[NEW] 5 - Degrees: deg=F - Use Fahrenheit instead of Celsius

Thanks for Frenzie who gave me the idea of speed dial vs. real window detection.

So here is one completed example:
http://speeddial.operacesky.net/weather.php?lang=en&area=Oslo&top=100&redirect=http://is.gd/eoCvi

And here is screen of the result:


I hope you like it =)

BTW you should set time interval to reload this speed dial window (I use 30 minutes)

UserJS - External scripts v1.1Autocomplete for Opera

Comments

z@h3kZAHEK Wednesday, August 18, 2010 8:53:12 PM

yikes

FransFrenzie Wednesday, August 18, 2010 10:36:38 PM

Interesting thought. You should open up the source so others can play around with it too. smile

At any rate, I'll be posting some improvement suggestions in a few minutes.

BS-Harou Wednesday, August 18, 2010 10:39:47 PM

well there isn't actually a lots of code. I just use XML file from google and print the information to the page =)

I'm ready for your suggestions =)

lucideer Wednesday, August 18, 2010 11:34:31 PM

Originally posted by BS-Harou:

your suggestions


Unite "speed-dial" app - it could start out with just weather, and then add other pages serving useful info to the speed-dial thumbs.... I'm not sure what exactly though... just an idea.

dapxin Wednesday, August 18, 2010 11:36:13 PM

9ice Idea.

QuHno Thursday, August 19, 2010 6:04:18 AM

Originally posted by BS-Harou:

I just use XML file from google


What's the syntax for the request to Google to receive the XML file? Is it open or do you have to subscribe somewhere?

FransFrenzie Thursday, August 19, 2010 8:27:39 AM

For the record, before other people waste time duplicating effort, this was my suggestion (you might need to disable Javascript to actually see it properly).

BS-Harou pointed out that vertical-align wasn't chosen in case of smaller speed dials, upon which I suggested to use vertical-align unless a top offset were specifically specified, and that the horizontal part of the speed dial doesn't seem to be affected by such so that no left offset is required.

If someone can think of a better way to detect whether something's a speed dial than what I came up with after seeing this idea, I'd be glad to hear it.

Also, QuHNo, I don't know about Google, but Weather Underground offers RSS from which one could easily extract such information. That's one of the reasons I'd like the source, since I'd prefer to host it myself as well as avoid Google (of course it shouldn't be too hard to replicate, but heck, an original idea is an original idea!).

BS-Harou Thursday, August 19, 2010 9:27:54 AM

Originally posted by QuHno:

What's the syntax for the request to Google to receive the XML file? Is it open or do you have to subscribe somewhere?



Everything is here: http://www.google.com/ig/api?weather=YOUR_CITY

BTW I do plan do give you the source after week or two)

BS-Harou Thursday, August 19, 2010 9:41:34 AM

add 4 parameter for redirect.

metude Thursday, August 19, 2010 10:02:34 AM

It looks there's no Turkish (tr) support.

BS-Harou Thursday, August 19, 2010 10:30:23 AM

Originally posted by metude:

It looks there's no Turkish (tr) support.



http://speeddial.operacesky.net/weather.php?lang=en&area=Ankara

this works, can you give me name of the city you want?

EDIT: you mean probably alnguage. No it's not (yet). There is only en, cs and fr, but if you want I can send you list of things for translation =)

BS-Harou Thursday, August 19, 2010 11:43:29 AM

added "fr" to languages

docThe-Doc Thursday, August 19, 2010 11:59:30 AM

Thanks again for supporting [fr] yes

QuHno Thursday, August 19, 2010 12:26:44 PM

Originally posted by BS-Harou:

Everything is here: (...)

Ah! Via the iGoogle API and the response from Google is valid, too. I didn't think about that. Thank You.

edit:

I believe most of the Opera users have set their native language as first in thr language settings so you could use this for an automatic UI language detection for the hl= part of the query string:
if ( isset( $_SERVER["HTTP_ACCEPT_LANGUAGE"] ) ){
	$languages = strtolower( $_SERVER["HTTP_ACCEPT_LANGUAGE"] );
	$pos = strpos(';',$languages);
	if ($pos !== false){
		$languages = substr( $languages, 0, pos-1 );
	}
	$pos = strpos(',',$languages);
	if ($pos !== false){
		$languages = substr( $languages, 0, pos-1 );
	}
}
The double strpos is needed because of the °C,km/h | °F,mph (SI|US) switch.
You get °C when using British English or any other language:
http://www.google.com/ig/api?weather=Oslo&hl=en-gb
in comparison to the assumed US setting with °F and mph when using plain English:
http://www.google.com/ig/api?weather=Oslo&hl=en

If the set language is not supported by Google, it defaults to US English, so no harm done:
http://www.google.com/ig/api?weather=Oslo&hl=XX

Most of the world (except USA) use SI instead of US values so may be you should prefer en-gb to get the SI units if the first "Accept Language" is en like it is in my string: en,de;q=0.9,de-DE;q=0.8 ... wink

@metude: Would work with tr too, see here smile

Aleksander AasAleksander Friday, August 20, 2010 11:30:01 AM

Awesome work!

BS-Harou Friday, August 20, 2010 11:50:39 AM

QuHno: get the language from $_SERVER["HTTP_ACCEPT_LANGUAGE"] is very good idea I will implemented as soon as I can =) I've also forgot that in US they use F instead of F, thanks for that)

However I'm working now on one new userJS so I'll update this after I finish at least "pre-alpha" of this new userJS =)

Originally posted by QuHno:

@metude: Would work with tr too, see here



the problem is that I need word "Weather" and sentence "We don't have information for this city" bigsmile ... I will probably combine days in selected language with those two words in English)

Sami Serolaserola Friday, August 20, 2010 12:18:27 PM

yikes cool Amazing! I need to try this up

Abhinavdecodedthought Friday, August 20, 2010 2:05:34 PM

very nice got to try this one smile up

QuHno Friday, August 20, 2010 2:48:38 PM

Originally posted by BS-Harou:

the problem is that I need word "Weather" and sentence "We don't have information for this city"

Why not just check for the existence of the Element. Primitive but quite complete snippet (without language detection or GET request check):
<?php 

function getWeather() {

  $requestAddress = "http://www.google.com/ig/api?weather=Oslo&hl=fi";
  // Downloads weather data based on location - where is Oslo? :D
  $xml_str = file_get_contents($requestAddress,0);
  // Parses XML 
  $xml = new SimplexmlElement($xml_str);

  // Loops XML
  $count = 0;
  echo '<div id="weather">';
  if ($xml->problem_cause && ($xml->problem_cause['data'] != '')){
    echo '<div>Damn! No Weather!</div>';
  } else {
    foreach($xml->weather as $item) {
      foreach($item->forecast_conditions as $new) {
        echo '<div class="weatherIcon">';
        echo '<img src="http://www.google.com/' .$new->icon['data'] . '"/><br />';
        echo $new->day_of_week['data'];
        echo '</div>';
      }

    }
  }
  echo '</div>';
}

getWeather();
?>

metude Friday, August 20, 2010 2:52:52 PM

Originally posted by BS-Harou:

this works, can you give me name of the city you want?


I was mean language support.

Monday > Pazartesi
Tuesday > Salı
Wednesday > Çarşamba
Thursday> Perşembe
Friday > Cuma
Saturday > Cumartesi
Sunday > Pazar

Sorry i have limited time for now, i didn't read other comments.

BS-Harou Friday, August 20, 2010 2:56:25 PM

metude: thanks, but days are finally only thing I don't need. p

I need those two:
- "Weather"
- "We don't have any information for this city"

PengePenge4 Friday, August 20, 2010 4:14:06 PM

Originally posted by BS-Harou:

I need those two:
- "Weather"
- "We don't have any information for this city"



Hungarian translation:

Weather = Időjárás
We don't have any information for this city = Nincs semmilyen információnk erről a városról

Furthermore:

Monday > Hétfő
Tuesday > Kedd
Wednesday > Szerda
Thursday> Csütörtök
Friday > Péntek
Saturday > Szombat
Sunday > Vasárnap

----------------

In the city names, that contains accent, works with the encoded format.
Just enter the name to the Google Search and copy the encoded format.
For example: Győr = Gy%C5%91r

BS-Harou Friday, August 20, 2010 4:18:32 PM

Penge:

Thank you.

I want tonight add support for all languages that google supports, but there is translation only for days, so if anyone else want the "weather" word in his language he has to send me the translation.

Dacotah Friday, August 20, 2010 4:25:05 PM

cool

QuHno Friday, August 20, 2010 5:36:46 PM

German, de, de-DE, de-AT, de-CH,: Wetter - Die Information ist vorübergehend nicht verfügbar.
Dutch, nl: Weer - Informatie is tijdelijk niet beschikbaar.

Sn3ipen Friday, August 20, 2010 5:44:13 PM

Norwegian: Vær

Im not sure if you should use no, nb or nn.

Just add them all to be safe, because the word for weather is the same in both Norwegian main languages(nb and nn).

Adonis @ my.opera /friendspartyworld Adonisali Friday, August 20, 2010 5:46:13 PM

I loaded the script in Opera mini 4.2 and it worked in dutch by default. up Great but now i only need a way to bookmark it, because i do not have visual speeddials. Also i would like to have a bookmarklet like These. to bookmark links in a page direct. for you, it should be a piece of cake.

BS-Harou Friday, August 20, 2010 5:46:40 PM

QuHno & Joachim: Thank you, I'll implemented very soon.

WildEnte Friday, August 20, 2010 6:09:31 PM

very cool!

Mitthaodp Friday, August 20, 2010 6:18:37 PM

Vietnamese:
- Thời tiết
- Chúng tôi không có thông tin về thành phố này.

BS-Harou Friday, August 20, 2010 7:21:27 PM

Originally posted by thaodp:

Vietnamese:
- Thời tiết
- Chúng tôi không có thông tin về thành phố này.



what is the abbreviation for Vietnamese? "vi"?

Sn3ipen Friday, August 20, 2010 7:49:13 PM

This gave me a few ideas. idea

What about making a Unite app out of this so people can host their own script?

Or using the same kind of technique to show a custom speed dial image. I believe someone could make a Unite App of that?

QuHno Friday, August 20, 2010 7:58:04 PM

Originally posted by BS-Harou:

what is the abbreviation for Vietnamese? "vi"?


Nope, "vn"

see Wikipedia smile

BS-Harou Friday, August 20, 2010 8:02:36 PM

Originally posted by QuHno:

Nope, "vn"

see Wikipedia



but google show english translation for "vn" but probably Vietnamese translation for "vi" p

EDIT: ok it's probably not Vietnamese, but it doesn't look like "Virgin Islands" too bigsmile

FransFrenzie Friday, August 20, 2010 8:24:54 PM

Originally posted by QuHno:

Nope, "vn"

see Wikipedia


The language codes and Internet domains are unrelated. You need the ISO 639-1 standard for this kind of thing.

ISO 639-1 vi
ISO 639-2 vie
ISO 639-3 vie
http://en.wikipedia.org/wiki/Vietnamese_language



Also see this nice list.

random414 Friday, August 20, 2010 8:27:02 PM

Great! wink

QuHno Friday, August 20, 2010 8:31:56 PM

Uups... Sorry! doh

See also here smile

BS-Harou Friday, August 20, 2010 8:32:07 PM

Originally posted by Frenzie:

The language codes and Internet domains are unrelated. You need the ISO 639-1 standard for this kind of thing.



thanks

btw I've got problem with Russian: http://speeddial.operacesky.net/weather.php?lang=ru&top=100&area=Praha&redirect=no

it shows wrong characters, but I can't figure out hy. Everywhere is UTF-8, I tried dozens of conversions but still without success. Any ideas?

FransFrenzie Friday, August 20, 2010 8:39:25 PM

Originally posted by BS-Harou:

it shows wrong characters, but I can't figure out hy. Everywhere is UTF-8, I tried dozens of conversions but still without success. Any ideas?


Do the PHP files have the BOM? That could cause problems. See for example here. If you save it as UTF-8 cookie (no BOM, but still UTF-8), it could potentially solve issues created by this PHP bug.

If that's not it, no idea. You're getting the names of the days from Google?

BS-Harou Friday, August 20, 2010 8:48:23 PM

Originally posted by Frenzie:

If that's not it, no idea. You're getting the names of the days from Google?



Yes, from Google. And it doesn't look like there is the BOM bug (at least as far as I was able to understand it).

FransFrenzie Friday, August 20, 2010 8:56:07 PM

Are you doing anything other than echoing the names of the days? Generally speaking the PHP parser just stupidly passes bytes through, so that shouldn't cause an issue.

In the end it comes down to the good old proverb that without seeing some code, it's like trying to operate on a patient in a dark. p

BS-Harou Friday, August 20, 2010 9:00:08 PM

Originally posted by Frenzie:

In the end it comes down to the good old proverb that without seeing some code, it's like trying to operate on a patient in a dark.



ok, you've got the code in PM

lucideer Friday, August 20, 2010 9:28:36 PM

Originally posted by Sn3ipen:

What about making a Unite app out of this so people can host their own script?


I've done up a quick and dirty one - if anyone wants to take it further and add features, help yourselves.
http://files.myopera.com/lucideer/files/Speeddial.ua

I haven't added a redirect to it (yet) like BS-Harou's version, and you can't customise the top-margin either - as I said, it's just a quick proof-of-concept. I have however set it up with the possibility of adding more (non-weather) speed-dials, if anyone has any suggestions.

BS-Harou Friday, August 20, 2010 9:31:43 PM

Originally posted by lucideer:

I've done up a quick and dirty one - if anyone wants to take it further and add features, help yourselves.
http://files.myopera.com/lucideer/files/Speeddial.ua



very nice =)

lucideer Friday, August 20, 2010 10:06:26 PM

Originally posted by BS-Harou:

very nice =)


Aha - approval, great stuff.

I've a question - I was trying to figure out the Goog api. Do you know if there's any way to set Celcius/Fahrenheit explicitly or is it always set by language code (and annoyingly defaults to F for en sad )?

BS-Harou Friday, August 20, 2010 10:08:39 PM

Originally posted by lucideer:

o you know if there's any way to set Celcius/Fahrenheit explicitly or is it always set by language code (and annoyingly defaults to F for en :( )?



sad (nope)

tom tkr1 Saturday, August 21, 2010 2:10:34 AM

for the C/F degrees option, for lang= choose of one the two

en - Celsius
us - Fahrenheit

metude Saturday, August 21, 2010 5:38:50 AM

Originally posted by BS-Harou:

- "Weather"
- "We don't have any information for this city"


Weather = Hava Durumu (But if this too long, you can use just "Hava")
- Bu şehir için bilgi yok. (

Originally posted by BS-Harou:

it shows wrong characters, but I can't figure out hy. Everywhere is UTF-8, I tried dozens of conversions but still without success. Any ideas?


Did you tried this. Open page Notepad++, Encoding > Convert to UTF8. Someone faster than me.

Tip: Set Automatic reload time with 1440 minutes. Your weather info will update every. (I'm not sure "page default" option working.)

d4rkn1ght Saturday, August 21, 2010 6:14:38 AM

This is fantastic! Thanks! cool up

BS-Harou Saturday, August 21, 2010 7:32:42 AM

Originally posted by metude:

Did you tried this. Open page Notepad++, Encoding > Convert to UTF8. Someone faster than me.



It was much more complicated than that, but it's fixed now =)

I'll add Turkish later (but still today) =) - but you should have already at least days in Turkish.

Write a comment

You must be logged in to write a comment. If you're not a registered member, please sign up.