home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2004 June
/
PCWorld_2004-06_cd.bin
/
software
/
vyzkuste
/
problemy
/
problemy.exe
/
M2Combo.exe
/
Plugin
/
weather2.js
< prev
next >
Wrap
Text File
|
2003-10-21
|
5KB
|
170 lines
// JavaScript Document
var nowflag = 1;
var todayflag = 1;
var futureflag = 1;
var objwords;
var swn = "www.msnbc.com";
var arrdetail = new Array();
function getCookie(Name) {
var search = Name + "=";
if(document.cookie.length > 0) {
offset = document.cookie.indexOf(search);
if(offset != -1) {
offset += search.length;
end = document.cookie.indexOf(";", offset);
if(end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(offset, end));
}
else return('');
}
else return('');
}
var locid = getCookie("WT_loc_id");
var cityname = getCookie("WT_loc_text");
var tempunit = getCookie("WT_T_unit");
var windunit = getCookie("WT_Wind_unit");
var presunit = getCookie("WT_P_unit");
var visbunit = getCookie("WT_Visb_unit");
var lan = getCookie("WT_Lan");
if(locid == '') {
location.replace("config.htm");
}
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
if(lan == "1") xmlDoc.load("language/lan_cn.xml"); else xmlDoc.load("language/lan_en.xml");
function translate(WTwords) {
objwords = xmlDoc.getElementsByTagName(WTwords);
document.write(objwords.item(0).text);
}
function translateonly(WTwords) {
objwords = xmlDoc.getElementsByTagName(WTwords);
if(objwords.length > 0) {
rewords = objwords.item(0).text;
} else {
rewords = WTwords;
}
return rewords;
}
if(tempunit == '') { tempunit = 1; }
if(windunit == '') { windunit = 1; }
if(presunit == '') { presunit = 1; }
if(visbunit == '') { visbunit = 1; }
var urlstr = "http://"+swn+"/m/chnk/d/weather_d_src.asp?acid="+locid;
document.all["objscript"].src = urlstr;
function transUnit(name, value) {
switch (name) {
case "temp":
returnvalue = Math.round((5/9)*(value-32));
break;
case "wind":
returnvalue = value*1.609334;
break;
case "pres":
returnvalue = value*33.86389;
break;
case "visb":
if(value == 999) {
value = "inf. "
return value;
}
else returnvalue = value*1.609334;
break;
}
return Math.round(returnvalue);
}
function checkinf(value) {
if(value == 999) {
value = "inf. "
return value;
}
}
function expclp(item) {
switch (item) {
case "titlenow" :
if(nowflag == 1) {
document.all["titlenow"].src = "images/expand.gif";
document.all["contentnow"].style.display = "none";
nowflag = 0;
} else {
document.all["titlenow"].src = "images/collapse.gif";
document.all["contentnow"].style.display = "block";
nowflag = 1;
}
break;
case "titletoday" :
if(todayflag == 1) {
document.all["titletoday"].src = "images/expand.gif";
document.all["contenttoday"].style.display = "none";
todayflag = 0;
} else {
document.all["titletoday"].src = "images/collapse.gif";
document.all["contenttoday"].style.display = "block";
todayflag = 1;
}
break;
case "titlefuture" :
if(futureflag == 1) {
document.all["titlefuture"].src = "images/expand.gif";
document.all["contentfuture"].style.display = "none";
futureflag = 0;
} else {
document.all["titlefuture"].src = "images/collapse.gif";
document.all["contentfuture"].style.display = "block";
futureflag = 1;
}
break;
}
}
function getWeekday(n) {
var Wday='';
switch (n) {
case "1":
Wday = "WT_Sunday";
break;
case "2":
Wday = "WT_Monday";
break;
case "3":
Wday = "WT_Tuesday";
break;
case "4":
Wday = "WT_Wednesday";
break;
case "5":
Wday = "WT_Thursday";
break;
case "6":
Wday = "WT_Friday";
break;
case "7":
Wday = "WT_Saturday";
break;
}
return translateonly(Wday);
}
function futurehead (idx) {
document.write(getWeekday(aFore[idx])+"<br><img src='http://image.weather.com/web/common/wxicons/25/"+aFore[10+idx]+".gif'>");
}
function futurebody (idx) {
if(tempunit == 1)
document.write(translateonly("WT_Thighabbre")+": "+transUnit("temp",aFore[20+idx])+"°C</span><br><span class=lowT>"+translateonly("WT_Tlowabbre")+": "+transUnit("temp",aFore[40+idx])+"°C<BR>"+translateonly("WT_Precipabbre")+": "+aFore[15+idx]+"%");
else
document.write(translateonly("WT_Thighabbre")+": "+aFore[20+idx]+"°F</span><br><span class=lowT>"+translateonly("WT_Tlowabbre")+": "+aFore[40+idx]+"°F<BR>"+translateonly("WT_Precipabbre")+": "+aFore[15+idx]+"%");
}