Downloading File
Filename: Google Weather Toolbar
;Google ToolBar Weather by Ford_Lawnmower irc.GeekShed.net #Script-Help alias GweatherTBInit { ;;;;;Setup;;;;; ;;Change %MyLocation to the location you want to monitor. ;;**Note** This does NOT accept airport codes. City,State-City,Country or ZipCode. var %MyLocation Hamilton,Ohio ;;Change %ForC to F or C for the Measurement Unit you want to use. var %ForC F ;;Change %MPHorKPH to KPH if you want to view the wind in KPH. var %MPHorKPH MPH ;;;End Setup;;; if (!$isdir(GoogleWeatherTB)) mkdir GoogleWeatherTB writeini GoogleWeatherTB\GoogleWeatherTB.ini Settings MeasurementUnit %ForC writeini GoogleWeatherTB\GoogleWeatherTB.ini Settings Location %MyLocation writeini GoogleWeatherTB\GoogleWeatherTB.ini Settings WindMeasurement %MPHorKPH window -hp +d @GoogleWeather 535 0 63 22 drawfill -r @GoogleWeather $rgb(240,240,230) $rgb(240,240,240) 0 0 GetGoogleWeather Window 0 %MyLocation .timerGoogleWeatherTB -o 0 100 GetGoogleWeather Window 0 %MyLocation } on *:Start: { if ($readini(GoogleWeatherTB\GoogleWeatherTB.ini,Settings,Status) != Off) GweatherTBInit } On *:Unload: .timerGoogleWeatherTB off alias -l GetGoogleWeather { if (!$window(@GoogleWeather)) window -hp +d @GoogleWeather 535 0 63 22 .sockclose G.o.o.gleWeatherTB sockopen G.o.o.gleWeatherTB www.google.com 80 sockmark G.o.o.gleWeatherTB $1 $+(/ig/api?weather=,$urlencode($3-)) $2 } On *:sockopen:G.o.o.gleWeatherTB: { if (!$sockerr) { sockwrite -nt $sockname GET $gettok($sock($sockname).mark,2,32) HTTP/1.1 sockwrite -n $sockname User-Agent: Opera 9.6 sockwrite -n $sockname Host: $sock($sockname).addr sockwrite -n $sockname $crlf } else { sockclose $sockname | return } } On *:sockread:G.o.o.gleWeatherTB: { if ($sockerr) { sockclose $sockname | return } else { var %GoogleWeather | sockread %GoogleWeather var %OutputMethod $gettok($sock($sockname).mark,1,32) if (<problem_cause data=""/> isin %GoogleWeather && %OutputMethod == Dialog) { did -ra GoogleWeather 2 $did(GoogleWeather,28) :: No Data found for $did(GoogleWeather,28) } if ($regex(%GoogleWeather,/<city data="(.*?)"\/>/i)) { if (%OutputMethod == Dialog) { dialog $iif($dialog(GoogleWeather),-v,-m GoogleWeather) GoogleWeather did -ra GoogleWeather 2 $regml(1) on $fulldate } else sockmark $sockname $addtok($sock($sockname).mark,$regml(1),13) } if ($regex(%GoogleWeather,/<humidity data="[^:]*:(.*?)"\/>/i)) { if (%OutputMethod == Dialog) did -ra GoogleWeather 32 $regml(1) else sockmark $sockname $addtok($sock($sockname).mark,$regml(1),13) } if ($regex(%GoogleWeather,/<wind_condition data="[^:]*:(.*?)"\/>/i)) { var %wind $MPH-KPH($regml(1)) if (%OutputMethod == Dialog) did -ra GoogleWeather 33 %wind else sockmark $sockname $addtok($sock($sockname).mark,%wind,13) } if ($regex(%GoogleWeather,/<day_of_week data="(.*?)"\/>/gi) && %OutputMethod == Dialog) { var %count 1 while (%count <= $regml(0)) { did -ra GoogleWeather $calc(%count + 6) $regml(%count) inc %count } } if ($regex(%GoogleWeather,/<low data="(.*?)"\/>/gi) && %OutputMethod == Dialog) { var %count 1 while (%count <= $regml(0)) { did -ra GoogleWeather $calc(%count + 14) $+(Low:,$forc($regml(%count))) inc %count } } if ($regex(%GoogleWeather,/<high data="(.*?)"\/>/gi) && %OutputMethod == Dialog) { var %count 1 while (%count <= $regml(0)) { did -ra GoogleWeather $calc(%count + 18) $+(High:,$forc($regml(%count))) inc %count } } if ($regex(%GoogleWeather,/<condition data="(.*?)"\/>/gi)) { if (%OutputMethod == Window) { clear @GoogleWeather drawfill -r @GoogleWeather $rgb(240,240,230) $rgb(240,240,240) 0 0 sockmark $sockname $addtok($sock($sockname).mark,$regml(1),13) } elseif (%OutputMethod == Dialog) { did -ra GoogleWeather 31,23 $regml(1) var %count 2 while (%count <= $regml(0)) { if ($regml(%count)) did -ra GoogleWeather $calc(21 + %count) $v1 inc %count } } } if ($regex(%GoogleWeather,/<temp_f\sdata="(.*?)"\/>/)) { if (%OutputMethod == Window) { drawtext -np @GoogleWeather 1 arial 14 30 4 $+($chr(2),$forc($regml(1)),$chr(186)) sockmark $sockname $addtok($sock($sockname).mark,$+($forc($regml(1)),$chr(186)),13) } elseif (%OutputMethod == Dialog) did -ra GoogleWeather 34 $+($forc($regml(1)),$chr(186)) } if ($regex(%GoogleWeather,/<icon\sdata="(.*?)"\/>/gi)) { GetGoogleWeatherIcon www.google.com $regml(1) GoogleWeatherTB $nopath($regml(1)) %OutputMethod 0 if ($window(@GoogleWeather) && %OutputMethod == Window) { tokenize 13 $sock($sockname).mark UpdateToolBar -tp Location: $2 $+(Humidity:,$3) $+(Wind:,$4) Conditon: $5 Temp: $6 } elseif (%OutputMethod == Dialog) { var %c $regml(0), %cc 5 while (%c > 1) { GetGoogleWeatherIcon www.google.com $regml(%c) GoogleWeatherTB $nopath($regml(%c)) %OutputMethod %cc dec %c dec %cc } } } } } alias -l UpdateToolBar { drawsave @GoogleWeather GoogleWeatherTB\GoogleWeather.jpg if ($toolbar(GoogleWeather)) { toolbar $1 GoogleWeather $qt($2-) "GoogleWeatherTB\GoogleWeather.jpg" $& $qt(/GetGoogleWeather Dialog 0 $readini(GoogleWeatherTB\GoogleWeatherTB.ini,Settings,Location)) @GoogleWeather } else { toolbar -as GoogleWeather| toolbar -a GoogleWeather $qt($2-) "GoogleWeatherTB\GoogleWeather.jpg" $& $qt(/GetGoogleWeather Dialog 0 $readini(GoogleWeatherTB\GoogleWeatherTB.ini,Settings,Location)) @GoogleWeather } } alias -l GetGoogleWeatherIcon { if ($isfile($qt($+($3,\,$4)))) { if ($5 == Window) drawpic -ns @GoogleWeather 0 0 25 22 $+(GoogleWeatherTB/,$4) elseif (($5 == Dialog)) did -g GoogleWeather $iif($6,$calc($6 + 9),$+(3,$chr(44),11)) $qt($+(GoogleWeatherTB/,$4)) } else { var %sockname $+(GetGoogleWeatherIcon,$ticks,$r(1,$ticks)) if (!$isdir($qt($3))) { mkdir $qt($3) } sockopen %sockname $1 80 sockmark %sockname $1- } } On *:sockopen:GetGoogleWeatherIcon*:{ sockwrite -nt $sockname GET $+(/,$gettok($sock($sockname).mark,2,32)) HTTP/1.0 sockwrite -n $sockname Host: $gettok($sock($sockname).mark,1,32) $+ $crlf $+ $crlf } On *:sockread:GetGoogleWeatherIcon*:{ if (!$gettok($sock($sockname).mark,7,32)) { var %GetGoogleWeatherIcon | sockread %GetGoogleWeatherIcon if (!%GetGoogleWeatherIcon) { sockmark $sockname $addtok($sock($sockname).mark,1,32) } } else { sockread &GetGoogleWeatherIcon bwrite -s $qt($+($gettok($sock($sockname).mark,3,32),\,$gettok($sock($sockname).mark,4,32))) -1 -1 &GetGoogleWeatherIcon } } On *:sockclose:GetGoogleWeatherIcon*:{ tokenize 32 $sock($sockname).mark if ($exists($qt($+($3,/,$4)))) { if ($5 == Window) { drawpic -s @GoogleWeather 0 0 25 22 $qt($+($3,/,$4)) } elseif ($5 == Dialog) { if (!$6) did -g GoogleWeather 3,11 $qt($+($3,/,$4)) else did -g GoogleWeather $calc(9 + $6) $qt($+($3,/,$4)) } } } alias -l MPH-KPH { if ($readini(GoogleWeatherTB\GoogleWeatherTB.ini,Settings,WindMeasurement) == KPH) { return $replace($regsubex($1-,/([\d]+)/,$round($calc(\t * 1.609344),0)),mph,kph) } else return $1- } alias -l ForC { if ($readini(GoogleWeatherTB\GoogleWeatherTB.ini,Settings,MeasurementUnit) == C) { return $round($calc((5 / 9) * ($1 - 32)),0) } else return $1 } alias -l urlencode return $replace($regsubex($1-,/([^a-z0-9\s])/ig,% $+ $base($asc(\t),10,16,2)),$chr(32),+) menu @GoogleWeather { Google Weather .$iif($timer(GoogleWeatherTB),$style(3)) On:{ writeini GoogleWeatherTB\GoogleWeatherTB.ini Settings Status On GweatherTBInit } .$iif(!$timer(GoogleWeatherTB),$style(3)) Off:{ .timerGoogleWeatherTB off window -c @GoogleWeather if ($toolbar(GoogleWeather)) toolbar -d GoogleWeather if ($toolbar(GoogleWeather|)) toolbar -d GoogleWeather| writeini GoogleWeatherTB\GoogleWeatherTB.ini Settings Status Off } .Dialogs:dialog $iif($dialog(GoogleWeather),-v,-m GoogleWeather) GoogleWeather } menu channel,status,menubar { - Google Weather .$iif($timer(GoogleWeatherTB),$style(3)) On:{ writeini GoogleWeatherTB\GoogleWeatherTB.ini Settings Status On GweatherTBInit } .$iif(!$timer(GoogleWeatherTB),$style(3)) Off:{ .timerGoogleWeatherTB off window -c @GoogleWeather if ($toolbar(GoogleWeather)) toolbar -d GoogleWeather if ($toolbar(GoogleWeather|)) toolbar -d GoogleWeather| writeini GoogleWeatherTB\GoogleWeatherTB.ini Settings Status Off } .Dialogs:dialog $iif($dialog(GoogleWeather),-v,-m GoogleWeather) GoogleWeather } On *:dialog:GoogleWeather:Sclick:29: { if ($did(28)) getgoogleweather dialog 0 $v1 } dialog GoogleWeather { title "Google Weather" size -1 -1 232 129 option dbu text "Current Weather for", 1, 5 2 52 8 text "", 2, 57 2 168 8 icon 3, 6 17 20 20 text "Condition:", 4, 34 14 27 8 text "Humidity:", 5, 34 24 27 8 text "Wind:", 6, 34 34 27 8 text "", 7, 9 54 54 8, center text "", 8, 63 54 54 8, center text "", 9, 117 54 54 8, center text "", 10, 171 54 54 8, center icon 11, 26 63 20 20 icon 12, 80 63 20 20 icon 13, 134 63 20 20 icon 14, 186 63 20 20 text "", 15, 9 87 25 8 text "", 16, 63 87 25 8 text "", 17, 117 87 25 8 text "", 18, 171 87 25 8 text "", 19, 34 87 29 8 text "", 20, 88 87 29 8 text "", 21, 142 87 29 8 text "", 22, 196 87 29 8 text "", 23, 9 96 54 16, center text "", 24, 63 96 54 16, center text "", 25, 117 96 54 16, center text "", 26, 171 96 54 16, center text "Location:", 27, 9 116 24 8 edit "", 28, 33 115 110 10, autohs button "Check", 29, 148 114 37 12 button "Close", 30, 188 114 37 12, cancel text "", 31, 61 14 164 8 text "", 32, 61 24 163 8 text "", 33, 61 34 163 8 text "", 34, 5 39 25 8, center box "", 35, 170 49 54 64 box "", 36, 62 49 54 64 box "", 37, 116 49 54 64 box "", 38, 8 49 54 64 }
Related Files
by [Domino]
by SplitFire aka X-System
by FroggieDaFrog