home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GameStar 2006 February
/
Gamestar_81_2006-02_dvd.iso
/
Programy
/
mcombo152.exe
/
Plugin
/
Weather
/
script
/
writeData.js
< prev
Wrap
Text File
|
2005-10-31
|
20KB
|
428 lines
/*************************************************************************************
=== Weather 4.41 ===
By Neo101
Previous versions by crino, Arkim, mdlist, seidenj and Tara
Created for Maxthon Tabbed Browser (www.maxthon.com)
=== License ===
Please contact Neo10 on forum.maxthon.com or www.neo101.nl if you would like to make any changes!
This plugin is for Maxthon only. You are not allowed to use it for any other program without permission.
Do not remove these comments/credits.
You are allowed to use/copy the icons. I did not create them.
Copyright 2005
Last modified 09-10-2005
=== Description of writeData.js ===
Here are the functions that write the weather data to the HTML page.
***************************************************************************************/
function SummaryWeatherHTML(weatherData){
var text=
'<table cellpadding="0" cellspacing="0">'+
'<tr><td class="content">'+
//Now
'<table cellpadding="0" cellspacing="0"> '+
'<tr class="title"><td class="titleleft" title="'+dateToday+'">'+trans(sNow)+
((showTodayDate==1)?' '+dateToday:'')+'</td> '+
'<td class="titleright"> '+
'<img src="images/plus.gif" class="expclpimg" id="titlenow" onClick="switchstate(\'titlenow\')"></td></tr> '+
'<tr id="contentnow"> '+
'<td colspan=2> '+
'<table cellpadding="0" cellspacing="0"> '+
'<tr><td> '+
'<table class="obsInfo"> '+
'<tr><td>'+
((weatherData.swCIcon!='')?'<img src="images/'+imageLocation+weatherData.swCIcon+iconExtension+'">':'')+
'</td></tr> '+
'<tr><td> '+
'<B> '+transW(weatherData.swConText)+'<br>'+transUnit(weatherData.swTemp,"temp")+
'</B></td></tr> '+
'<tr><td><B> '+
((details==1)?trans("WT_Feellkie")+"<br>"+transUnit(weatherData.swReal,"temp"):'')+'</B> '+
'</table> '+
'</td>'+((design==1)?'</tr><tr>':'')+' '+
'<td class="obsInfo"> '+
((details==1)?t=trans("WT_UV",1)+((weatherData.swUV&&weatherData.swUV!='')?weatherData.swUV:'0')+"<br>":'')+
trans("WT_Humd",1)+weatherData.swHumid+"%<br>"+
trans("WT_Visb",1)+transUnit(weatherData.swVis,"visb")+unitsSym[2]+"<br>"+
((details==1)?trans("WT_Pres",1)+transUnit(weatherData.swBaro,"pres")+unitsSym[3]+"<br>":'')+
trans("WT_Wind",1)+transUnit(weatherData.swWindS,"wind")+unitsSym[1]+
' <span title="'+transWind3(weatherData.swWindD)+
'">'+transWind(weatherData.swWindD)+'</span>'+
'</td></tr> '+
'</table></td></tr> '+
'</table></td></tr> <tr><td height="3"></td></tr> <tr><td class="content"> '+
//Today
'<table cellpadding="0" cellspacing="0"> '+
'<tr class="title"><td class="titleleft" width="50%">'+trans(sDay)+'</td> '+
'<td class="titleright"> '+
' <img src="images/plus.gif" class="expclpimg" id="titletoday" onClick="switchstate(\'titletoday\')">'+
'</td></tr> '+
'<tr id="contenttoday"><td colspan=2>'+
'<table class="obsInfo"><tr><td '+((design==1)?'colspan=2':'')+' width="50%"> '+
"<b>"+trans("WT_Wday")+"</b><br>"+
"<img src='images/"+imageLocation+forecastArray[10]+iconExtension+"'><br>"+
trans("WT_Hight",1)+" "+transUnit(forecastArray[20],"temp")+"<br>"+
((design==0)?'</td><td valign="top" width="50%">':trans("WT_Precip",1)+
" "+forecastArray[25]+"%<br>")+
"<b>"+trans("WT_Wnight")+"</b><br><img src='images/"+imageLocation+forecastArray[30]+iconExtension+"'><br>"+
trans("WT_Lowt",1)+" "+transUnit(forecastArray[40],"temp")+
((design==0)?'</tr><tr><td colSpan=2>'+
trans("WT_Precip",1)+" "+forecastArray[25]+"%":'')+
'</td><tr>'+
'</table>'+
'</td></tr> '+
'</table></td></tr> <tr><td height="3"></td></tr> '+
'<tr><td class="content"> '+
//Future
'<table cellpadding="0" cellspacing="0"> '+
'<tr class="title"><td class="titleleft" width="50%">'+trans("WT_Future")+'</td> '+
'<td class="titleright"> '+
'<img src="images/plus.gif" class="expclpimg" id="titlefuture" onClick="switchstate(\'titlefuture\')">'+
'</td></tr>'+
'<tr id="contentfuture"> '+
'<td colspan="2">'+
'<table cellspacing="0" cellpadding="0" class="obsInfo"> '
return text
}
function FutureWeatherHTML(){
var text =
'<table cellpadding="0" cellspacing="0" id="main">'+
'<tr><td class="content">'+
//Today /Tonight
'<table cellpadding="0" cellspacing="0"> '+
'<tr class="title"><td class="titleleft" title="'+dateToday+'">'+trans(sNow)+
((showTodayDate==1)?' '+dateToday:'')+'</td> '+
'<td class="titleright"> '+
'<img src="images/plus.gif" class="expclpimg" id="titlenow" onClick="switchstate(\'titlenow\')"></td></tr> '+
'<tr id="contentnow"> '+
'<td colspan=2><table class="obsInfo"> '+
'<tr><td>'+
'<table class="obsInfo"><tr><td> '+
"<img src='images/"+imageLocation+data[0][5]+iconExtension+"'><br>"
+'</td></tr><tr><td><b>'+
transW(data[0][6])+'<br>'+
((data[0][2]!='N/A')?transUnit(data[0][2],'temp'):trans("WT_Lowt",1)+transUnit(data[0][3],'temp'))+
'</b></td></tr></table> '+
'</td>'+((design==1)?'</tr><tr>':'')+'<td>'+
((data[0][2]!='N/A')?trans("WT_Lowt",1)+" "+transUnit(data[0][3],'temp')+"<br>":'')+
((details==1&&data[0][2]!='N/A')?trans("WT_UV",1)+data[0][4]+"<br>":'')+
trans("WT_Humd",1)+data[0][11]+"%<br>"+
trans("WT_Precip",1)+data[0][10]+"%<br>"+
trans("WT_Wind",1)+transUnit(data[0][7],'wind')+
unitsSym[1]+" <span title='"+transWind2(data[0][8])+"'>"+transWind(data[0][9])+'</span>'
+'</td></tr> '+
'</table></td></tr> '+
'</table>'+
'</td></tr> <tr><td height="3"></td></tr> <tr><td class="content"> '+
//Future
'<table cellpadding="0" cellspacing="0"> '+
'<tr class="title"><td class="titleleft">'+trans("WT_Future")+'</td> '+
'<td class="titleright"> '+
'<img src="images/plus.gif" class="expclpimg" id="titlefuture" onClick="switchstate(\'titlefuture\')"></td></tr> '+
'<tr id="contentfuture"><td class="obsInfo" colspan="2"> '+
'<table cellspacing="0" cellpadding="0"><tr><td> '+
'<table '+((design==1)?'style="width:50%"':'')+
'><tr><td class="futureD" width=50%><span title="'+data[1][12]+'">'+getWeekday(data[1][0])
+"</span></td>"+
"<td><img alt='"+transW(data[1][6])+"' src='images/"+imageLocation+data[1][5]+iconExtension+
"' align=absmiddle></table>"+((design==1)?'<tr>':'')
+'</td><td class="futureTDBody" > '+
'<span class="highT"> '
if(compactDisplay!=1){
text+=trans("WT_Hight",1)+
transUnit(data[1][2],'temp')+"</span><br><span class=lowT>"+
trans("WT_Lowt",1)+transUnit(data[1][3],'temp')+"<br>"+
trans("WT_Precip",1)+data[1][10]+"%<br>"
if(type=='Future'&&details==1) text+=trans("WT_Wind",1)+transUnit(data[1][7],'wind')+
unitsSym[1]+" <span title='"+transWind2(data[1][8])+"'>"+transWind(data[1][9],1)+'</span>'
+'</span></td></tr> '
}
else{
text+='<table class=lowT style="width:'+((design==1)?'80':'100')+
'%"><tr><td class="highT" width="40%" title="'+trans("WT_Hight")+'"><b>'+
transUnit(data[1][2],'temp')+
'</b></td><td width="30%" title="'+trans("WT_Lowt")+'">'+transUnit(data[1][3],'temp')+
'</td><td width="30%" title="'+trans("WT_Precip")+'">'+data[1][10]+'%</td></tr>'
+((type=='Future'&&details==1)?'<tr><td colspan=3 title="'+trans("WT_Wind")+'">'+transUnit(data[1][7],'wind')+
unitsSym[1]+" <span title='"+transWind2(data[1][8])+"'>"+transWind(data[1][9]):'')+'</td></tr></table>'
}
return text
}
function TodayWeatherHTML(){
var text='<table cellpadding="0" cellspacing="0" id="main">'
if(top.todayData==null) return
if(todayData[0]!='N/A') //After 2pm the "today" weather isn't available anymore. It will be hidden then.
text+='<tr><td class="content">'+
//Today
'<table cellspacing="0"> '+
'<tr class="title"><td class="titleleft" title="'+dateToday+'">'+trans(sNow)+
((showTodayDate==1)?' '+dateToday:'')+'</td> '+
'<td class="titleright"> '+
'<img src="images/plus.gif" class="expclpimg" id="titlenow" onClick="switchstate(\'titlenow\')"></td></tr> '+
'<tr id="contentnow"> '+
'<td colspan=2> '+
'<table class="obsInfo"><tr><td><table class="obsInfo"> '+
'<tr><td><img src="images/'+imageLocation+todayData[2]+iconExtension+'"><br></td></tr>'+
'<tr><td><B>'+
transW(todayData[3])+'<br>'+
transUnit(todayData[0],'temp')+
'</B></td></tr></table> '+
'</td>'+((design==1)?'</tr><tr>':'')+' '+
'<td class="obsInfo"> '+
((details==1)?trans("WT_UV",1)+todayData[1]+"<br>":'')+
trans("WT_Humd",1)+todayData[8]+"%<br>"+
trans("WT_Precip",1)+todayData[7]+"%<br>"+
trans("WT_Wind",1)+transUnit(todayData[4],'wind')+
unitsSym[1]+" <span title='"+transWind2(todayData[5])+"'>"+transWind(todayData[6])+'</span><br>'
+trans("WT_SunUp",1)+sunUp
+'</td></tr> '+
'</table></td></tr> '+
'</table></td></tr> <tr><td height="3"></td></tr>'
//Tonight
text+='<tr><td class="content"> '+
'<table cellpadding="0" cellspacing="0"> '+
'<tr class="title"><td class="titleleft" title="'+dateToday+'">'+trans("WT_Tonight")+
((showTodayDate==1&&todayData[0]=='N/A')?' '+dateToday:'')+'</td> '+
'<td class="titleright"> '+
'<img src="images/plus.gif" class="expclpimg" id="titletoday" onClick="switchstate(\'titletoday\')"></td></tr> '+
'<tr id="contenttoday"><td colspan=2> '+
'<table cellpadding="0" cellspacing="0"> '+
'<tr><td>'+
'<table class="obsInfo"><tr><td> '+
"<img src='images/"+imageLocation+tonightData[1]+iconExtension+"'><br>"
+'</td></tr><tr><td> '+
'<B class="obsTextA"> '+
transW(tonightData[2])+'<br>'+
transUnit(tonightData[0],'temp')+
'</B></td></tr></table> '+
'</td>'+((design==1)?'</tr><tr>':'')+' '+
'<td class="obsInfo" width="70%" '+((design==1)?'colspan=2':'')+'> '+
trans("WT_Humd",1)+tonightData[7]+"%<br>"+
trans("WT_Precip",1)+tonightData[6]+"%<br>"+
trans("WT_Wind",1)+transUnit(tonightData[3],'wind')+
unitsSym[1]+" <span title='"+transWind2(tonightData[4])+"'>"+transWind(tonightData[5])+'</span><br>'
+trans("WT_SunDown",1)+sunDown
+'</td></tr> '+
'</table></td></tr> '+
'</table></td></tr> <tr><td height="3"></td></tr> <tr><td class="content"> '+
//Future
'<table cellpadding="0" cellspacing="0"> '+
'<tr class="title"><td class="titleleft" width="50%">'+trans("WT_Details2")+'</td> '+
'<td class="titleright"> '+
'<img src="images/plus.gif" class="expclpimg" id="titlefuture" onClick="switchstate(\'titlefuture\')"></td></tr>'+
'<tr id="contentfuture"> '+
'<td colspan="2"><table cellspacing="0" cellpadding="0" class="obsInfo"> '
return text
}
function ModalDialogHTML(weatherData){
var text,textBody;
text='<html>'+
'<head><title>Weather </title>'+
'<base href="'+pluginfolder+'">'+
'<link href="style/common.css" rel="stylesheet" type="text/css">'+
'<link href="style/'+FONT_SIZE_MODDIALOG+'" rel="stylesheet" type="text/css">'+
'<link href="style/'+style+'" rel="stylesheet" type="text/css">'+
'</head>'+
'<body onunload="dialogArguments.saveCurrentPosition(window.screenLeft,window.screenTop,window.dialogHeight,window.dialogWidth)">'
if(type=='Summary')
var textBody="<table class='obsInfo'><tr><td>"+trans(sNow+'_short')+"</td><td colspan=2>"+trans(sDay+'_short')+
"</td></tr>"+
"<tr><td>"+
"<img alt='"+transW(weatherData.swConText)+"' src='images/"+IMG_LOCATION_MODDIALOG+weatherData.swCIcon+iconExtension+"'></td>"+
"<td><img src='images/"+IMG_LOCATION_MODDIALOG+forecastArray[10]+iconExtension+"'></td>"+
"<td><img src='images/"+IMG_LOCATION_MODDIALOG+forecastArray[30]+iconExtension+"'></td>"+
"</tr>"+
"<tr><td>"+transUnit(weatherData.swTemp,"temp")+"</td>"+
"<td>"+transUnit(forecastArray[20],"temp")+"</td><td>"+
transUnit(forecastArray[40],"temp")+"</td></tr></table>"
else if(type=='Future')
textBody="<table class='obsInfo'>"+
"<tr><td>"+trans(sNow+'_short')+"</td><td>"+trans(sDay+'_short')+
"</td><td>"+trans("WT_Future_short")+"</td></tr><tr>"+
"<td><img alt='"+transW(data[0][6])+"' src='images/"+IMG_LOCATION_MODDIALOG+data[0][5]+iconExtension+"'></td><td>"+
"<img alt='"+transW(data[1][6])+"' src='images/"+IMG_LOCATION_MODDIALOG+data[1][5]+iconExtension+"'></td><td>"+
"<img alt='"+transW(data[2][6])+"' src='images/"+IMG_LOCATION_MODDIALOG+data[2][5]+iconExtension+"'></td></tr>"+
"<tr><td>"+((data[0][2]!='N/A')?transUnit(data[0][2],'temp'):transUnit(data[0][3],'temp'))+
"</td><td>"+transUnit(data[1][2],'temp')+"</td><td>"+
transUnit(data[2][2],'temp')+"</td></tr>"+
"</table>"
else if(type=='Today'&&todayData[0]!='N/A')
textBody="<table class='obsInfo'>"+
"<tr><td>"+trans('WT_Today_short')+"</td><td>"+
trans('WT_Tonight_short')+'</td><td>'+data[0][0]+".00</td></tr><tr>"+
"<td><img alt='"+transW(todayData[3])+"' src='images/"+IMG_LOCATION_MODDIALOG+todayData[2]+iconExtension+"'></td><td>"+
"<img alt='"+transW(tonightData[2])+"' src='images/"+IMG_LOCATION_MODDIALOG+tonightData[1]+iconExtension+"'></td><td>"+
"<img alt='"+transW(data[0][2])+"' src='images/"+IMG_LOCATION_MODDIALOG+data[0][1]+iconExtension+"'></td></tr>"+
"<tr><td>"+transUnit(todayData[0],'temp')+
"</td><td>"+transUnit(tonightData[0],'temp')+"</td><td>"+
transUnit(data[0][3],'temp')+"</td></tr>"+
"</table>"
else if(type=='Today')
textBody="<table class='obsInfo'>"+
"<tr><td>"+trans('WT_Tonight_short')+
'</td><td>'+data[0][0]+'.00</td><td>'+data[1][0]+".00</td></tr><tr>"+
"<td><img alt='"+transW(tonightData[2])+"' src='images/"+IMG_LOCATION_MODDIALOG+tonightData[1]+iconExtension+"'></td><td>"+
"<img alt='"+transW(data[0][2])+"' src='images/"+IMG_LOCATION_MODDIALOG+data[0][1]+iconExtension+"'></td><td>"+
"<img alt='"+transW(data[1][2])+"' src='images/"+IMG_LOCATION_MODDIALOG+data[1][1]+iconExtension+"'></td></tr>"+
"<tr><td>"+transUnit(tonightData[0],'temp')+
"</td><td>"+transUnit(data[0][3],'temp')+"</td><td>"+
transUnit(data[1][3],'temp')+"</td></tr>"+
"</table>"
return text+textBody
}
/* This will load the weather info into the webpage. */
function loadPage(){
t=''
var weatherData
if(type=='Summary'){ //summary
futdays = eval(readIni("FutureDays"));
if(futdays>3) futdays = 3
sDay = "WT_Tomorrow";
try{
weatherData = new makeWeatherObj()
}
catch(err) {
showErrorMessage(errorMsg1)
}
if(weatherData.swFore&&weatherData.swFore!=''){
forecastArray = weatherData.swFore.split('|')
for(i=1; i<6; i++){
data[i]=[forecastArray[(i-1)],'',forecastArray[(19+i)],forecastArray[(39+i)],
'',forecastArray[(9+i)],'','','','',forecastArray[(24+i)],'','']
}
curDate = new Date();
if((forecastArray[0] - 1)==curDate.getDay()) sDay = "WT_Today"
showDate(weatherData.swLastUp.split(' ')[0].replace(/\//g,','))
setClock(weatherData.swLastUp.split(' ')[1])
}
else {
document.all['mainBody'].innerHTML=''
showErrorMessage(errorMsg2)
window.onerror=nothing
document.all['lastUpdate'].innerHTML=''
}
if(activeCityName=='unknown') {
activeCityName=weatherData.swCity+', '+weatherData.swCountry
writeIni("LocationTxt"+activeLocation,activeCityName)
document.all['cityNameDisp'].innerHTML=activeCityName
}
var mainText = SummaryWeatherHTML(weatherData)
}
else if(type=='Future'){ //future forecast
sDay = "WT_Tomorrow"
sNow = (data[0][2]!='N/A')?"WT_Today":"WT_Tonight";
futdays = eval(readIni("FutureDays"))-1;
if(a==0) showErrorMessage(errorMsg1)
var mainText = FutureWeatherHTML()
}
else if(type=='Today'){ //today's weather
futdays = readIni("FutureDays");
if(futdays>6) futdays=6
sDay = "WT_Tomorrow";
if(a==0) showErrorMessage(errorMsg1)
var mainText = TodayWeatherHTML()
}
/* Create the Future / Details part */
if(type=='Summary'||type=='Future') {
for(i=2;i<(futdays+2);i++){
if(data[i]==null||data[i][6]=='N/A') continue
mainText+='<tr><td > '+
'<table '+((design==1)?'style="width:50%"':'')+'>'+
'<tr><td class="futureD" width=50%><span title="'+data[i][12]+'">'+getWeekday(data[i][0])
+"</span></td>"+
"<td><img alt='"+transW(data[i][6])+"' src='images/"+imageLocation+data[i][5]+iconExtension+
"' align=absmiddle>"+
"</table>"+((design==1)?'<tr>':'')
+'</td> '+
'<td class="futureTDBody" > '+
'<span class="highT">'
if(compactDisplay!=1){
mainText+=trans("WT_Hight",1)+
transUnit(data[i][2],'temp')+"</span><br><span class=lowT>"+
trans("WT_Lowt",1)+transUnit(data[i][3],'temp')+"<br>"+
trans("WT_Precip",1)+data[i][10]+"%<br>"
if(type=='Future'&&details==1) mainText+=trans("WT_Wind",1)+transUnit(data[i][7],'wind')+
unitsSym[1]+" <span title='"+transWind2(data[i][8])+"'>"+transWind(data[i][9])+'</span>'
} else{
mainText+='<table class=lowT style="width:'+((design==1)?'80':'100')+'%"><tr>'+
'<td class="highT" width="40%" title="'+trans("WT_Hight")+'"><b>'+transUnit(data[i][2],'temp')+
'</b></td>'+
'<td width="30%" title="'+trans("WT_Lowt")+'">'+transUnit(data[i][3],'temp')+
'</td><td width="30%" title="'+trans("WT_Precip")+'">'+data[i][10]+'%</td></tr>'
+((type=='Future'&&details==1)?'<tr><td colspan=3 title="'+trans("WT_Wind")+'">'+
transUnit(data[i][7],'wind')+unitsSym[1]+" <span title='"+transWind2(data[i][8])+
"'>"+transWind(data[i][9],1):'')+'</td></tr>'+
'</table>'
}
mainText+='</span></td></tr> '
}
}
else{//data0, icon1 ,weather type2, temp3, feel like temp4, percip5 , dew point (whatever that is...)6, humid7, wind direction8 speed9
for(var i=0;i<futdays;i++){
if(data[i]==null||data[i][6]=='N/A') continue
mainText+='<tr><td > '+
'<table '+((design==1)?'style="width:50%"':'')+'>'+
'<tr><td class="futureD" width=50%><span>'+data[i][0]
+data[i][10]+"</span></td>"+
"<td><img alt='"+transW(data[i][2])+"' src='images/"+imageLocation+data[i][1]+iconExtension+
"' align=absmiddle>"+
"</table>"+((design==1)?'</td></tr><tr>':'</td>')+
'<td class="futureTDBody" > '+
'<span class="highT"> '
if(compactDisplay!=1){
mainText+=trans("WT_Temperature",1)+
transUnit(data[i][3],'temp')+"</span><br><span class=lowT>"+
trans("WT_Precip",1)+data[i][5]+"%"+
((details==1)?'<br>'+trans("WT_Wind",1)+
transUnit(data[i][9],'wind')+unitsSym[1]+' <span title="'+
transWind3(data[i][8])+'">'+transWind(data[i][8])+'</span>':'')
+'</span></td></tr> '
}
else {
mainText+='<table style="width:'+((design==1)?'50':'100')+'%" class=lowT>'+
'<tr><td class="highT" width="50%" title="'+trans("WT_Temperature")+'"><b>'+
transUnit(data[i][3],'temp')+
'</b></td><td width="50%" title="'+trans("WT_Precip")+'">'+
data[i][5]+'%</td></tr><tr><td colspan=2 title="'+trans("WT_Wind")+'" >'+
((details==1)?transUnit(data[i][9],'wind')+unitsSym[1]+' <span title="'+
transWind3(data[i][8])+'">'+transWind(data[i][8],1)+'</span>':'')
+'</td></tr></table></td></tr> '
}
}
}
mainText+='</table>'
document.all['mainBody'].innerHTML=mainText //print the data
/* The Small Window code*/
modalDialogText = ModalDialogHTML(weatherData)
writeFile("script/Dialog.htm",modalDialogText)
if(smallWindow && smallWindow!='') smallWindow.document.body.innerHTML=modalDialogText
if(showWinAlways==1 && smallWindow=='') window.setTimeout('showFloatingWindow()',200)
}