首頁 / 玩玩手機 / HTC One Weather widget@iPhone5
Logo

HTC One Weather widget@iPhone5

今天看到一個很簡潔的HTC One版本的天氣預報待機畫面,裝上去比HTC Weather Widget 1.75的還省記憶體,印象中裝HTC Weather Widget 1.75時,重開機好只有4XXMB記憶體,現在用這個,重開機完有553MB記憶體,效果也很不錯,修改也簡單~! 😋

htc_one_01htc_one_02

*********檔案來源*********
原文:Release – HTC One Weather widget LIVE ON CYDIA
分流下載點:http://db.tt/QiuNHUok

*********必備工具*********

1. 已JB而且能上網的哀鳳5 – 不懂JB的看這→【小胖教學】6.1.2 JB evasi0n 1.5.3 (4/18更新)
2. 已在Cydia安裝WinterBoard佈景主題工具
3. NotePad++ – 免費文字編輯軟體阿榮牌免安裝中文版
4. iTools或是i-FunBox
5. 一顆勇敢又不怕出錯的心 :er

本佈景主題使用的天氣代碼是Y!的,查詢網頁是:http://weather.yahoo.com/

台灣地區 – http://weather.yahoo.com/taiwan/

Changhua 彰化 – 2306183
Chiayi 嘉義 – 2296315
Chungli 中壢 – 2306184
Hsinchu 新竹 – 2306185
Hualien 花蓮 – 2306187
Kaohsiung 高雄 – 2306180
Keelung 基隆 – 2306188
Miaoli 苗栗 – 2301128
Nantou 南投 – 2306204
New Taipei 新北市 – 20070569
Pingtung 屏東 – 2306189
Taichung 台中 – 2306181
Tainan 台南 – 2306182
Taipei 台北 – 2306179
Taitung 台東 – 2306190
Taoyuan 桃園 – 2298866
Yilan 宜蘭 – 2306198
Yunlin 雲林 – 2347346

中國地區 – http://weather.yahoo.com/china/
Beijing 北京 – 2151330
Hong Kong 香港 – 2165352
Macau 澳門 – 1887901
Shanghai 上海 – 2151849
Shenzhen 深圳 – 2161853

*********安裝說明*********

1. 首先把下列四個資料夾複製到手機上的LibraryThemes

HTC One EU Light springboard.theme ← 白色適用的鎖屏畫面佈景主題
HTC One EU Light Lockscreen.theme ← 白色適用的主畫面佈景主題
HTC One EU Dark springboard.theme ← 黑色適用的鎖屏畫面佈景主題
HTC One EU Dark Lockscreen.theme ← 黑色適用的主畫面佈景主題

EU跟US版本差異點在美制預設是12小時制,溫度單位是華氏;歐版是24小時制,溫度單位是攝氏。 🤔

2. 依照個人喜好挑選Light或Dark版本的佈景主題資料夾進去修改兩個檔案

Lockscreen.theme資料夾底下的LockBackground.html從第253行開始修改
springboard.theme資料夾底下的Wallpaper.html是從第252行開始修改

var locale = "12798581" // 地區天氣代碼
var isCelsius = true // 溫度使用攝氏,false則會使用華氏
var useRealFeel = false // 啟用體感溫度
var enableWallpaper = true; // 啟用桌布
var enableLockScreen = true; // 啟用鎖屏
var updateInterval = 60 // 更新頻率

3. 到Cydia點下方的搜尋來找Lockscreen Clock Hide,這個小工具是用來隱藏鎖屏畫面用的時鐘。 😉

4. 在Cydia繼續搜尋Gridlock,需要安裝此工具來自訂桌面的圖示位置。 👫

最後回WinterBoard啟用再Respring即可。 😎

*********備註*********

更換背景圖需要進去Light或Dark版本的佈景主題資料夾找到

Lockscreen.theme資料夾底下的LockBackground.png ← 鎖屏畫面背景圖
springboard.theme資料夾底下的Wallpaper.png ← 主畫面背景圖

注意圖片尺寸是寬640*長1136 :O

LockBackground.html範例

<style>
<p>@font-face {<br />
font-family: Default1;<br />
src: url(Default1.otf);<br />
}</p>
<p>#Layer {<br />
width: 321px;<br />
height: 569px;<br />
position: absolute;<br />
top: -1px;<br />
right: 0px;<br />
down: 0px;<br />
left: -1px;<br />
}</p>
<p>.stretch {<br />
width:100%;<br />
height:100%;<br />
}</p>
<p>/* -------------------------------------------------------------------------------------- Digital Clock ------------------- */</p>
<p>	SPAN#clock {<br />
font-family: Default1;<br />
color: #1d1d1d;<br />
//	letter-spacing: 0.06em;<br />
//	text-shadow: 1px 4px 4px rgba(0,0,0,0.5);<br />
font-size: 75px;<br />
//	opacity: 0.8;<br />
}</p>
<p>	SPAN#ampm {<br />
// display: none;<br />
font-family: Default1;<br />
color: #1d1d1d;<br />
//	letter-spacing: 0.06em;<br />
//	text-shadow: 1px 4px 4px rgba(0,0,0,0.5);<br />
font-size: 14px;<br />
//	opacity: 0.8;<br />
}</p>
<p>/* -------------------------------------------------------------------------------------- Calendar ------------------- */</p>
<p>	TD#date {<br />
font-family: Default1;<br />
text-align: right;<br />
color: #1d1d1d;<br />
//	letter-spacing: 0.06em;<br />
//	text-shadow: 1px 4px 4px rgba(0,0,0,0.5);<br />
font-size: 12px;<br />
text-transform: uppercase;<br />
//	opacity: 0.8;<br />
}</p>
<p>	TD#season {<br />
font-family: Default1;<br />
text-align: center;<br />
color: #1d1d1d;<br />
letter-spacing: 0.06em;<br />
text-shadow: 1px 4px 4px rgba(0,0,0,0.5);<br />
font-size: 20px;<br />
text-transform: none;<br />
opacity: 0.8;<br />
display: none;<br />
}</p>
<p>/* -------------------------------------------------------------------------------------- Weather ------------------- */</p>
<p>	#WeatherContainer {<br />
background-color: rgba(0,0,0,0);<br />
}</p>
<p>	#TextContainer {<br />
font-size:55px;<br />
font-family: Default1;<br />
//	font-weight: bold;<br />
color:#1d1d1d;<br />
}</p>
<p>	#city {<br />
position: absolute; top: 113px; right: 0px; down: 0px; left: 92px; width: 320px; height: 481px;<br />
//	display: none;<br />
text-align: left;<br />
font-family: Default1;<br />
font-size: 12px;<br />
//	text-shadow: 1px 4px 4px rgba(0,0,0,0.5);<br />
color: #1d1d1d;<br />
text-transform: uppercase;<br />
}</p>
<p>	#temp {<br />
position: absolute; top: 100px; right: 0px; down: 0px; left: -23px; width: 320px; height: 481px;<br />
margin-top:0px;<br />
text-align: center;<br />
font-family: Default1;<br />
font-size: 14px;<br />
color: #1d1d1d;<br />
text-shadow: 1px 4px 4px rgba(0,0,0,0.5);<br />
opacity: 0.8;<br />
letter-spacing: 0.06em;<br />
display:none;<br />
}</p>
<p>	#desc{<br />
position: absolute; top: 200px; right: 0px; down: 0px; left: 0px; width: 320px; height: 461px;<br />
display: none;<br />
text-align: center;<br />
font-family: Default1;<br />
font-size: 14px;<br />
text-shadow: 1px 4px 4px rgba(0,0,0,0.5);<br />
color: #1d1d1d;<br />
}</p>
<p>	#TextContainer p{<br />
margin:0;<br />
}</p>
<p>	#weatherIcon{</p>
<p>		position: absolute; top: 43px; left: 220px; width: 320px; height: 461px;<br />
height:90;<br />
width:90;<br />
}</p>
</style>
</p>
<p><!----------------------------------------------------------------------------------------------------------------></p>
<p><!-- Display Wallpaper (LockBackground.png) here --></p>
<div id="Layer"><img class="stretch" src="LockBackground.png" /></div>
<p> </p>
<p><!----------------------------------------------------------------------------------------------------------------></p>
<p><!-- Clock and Calendar Script --></p>
<p><script type="text/javascript">

function init ( )
{
	timeDisplay = document.createTextNode ( "" );
	document.getElementById("clock").appendChild ( timeDisplay );
}

function updateClock ( )
{
	var currentTime = new Date ( );
	var currentHours = currentTime.getHours ( );
	var currentMinutes = currentTime.getMinutes ( );
	var currentSeconds = currentTime.getSeconds ( );

<!-- Pad the minutes and seconds with leading zeros, if required -->

	currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
	currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

<!-- Defines either "AM" or "PM" as appropriate -->
	var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

<!-- Convert hours component of "12" to "24" -->
	//currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

<!-- Convert hours component from "0" to "12 at Midnight-->
	currentHours = ( currentHours == 0 ) ? 12 : currentHours;

<!-- Compose the string for display-->
	currentHours = ( currentHours < 10 ? "0" : "" ) + currentHours;
	var currentTimeString = currentHours + ":" + currentMinutes;

	<!-- Update the time display-->
	document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}

function init2 ( )
{
	timeDisplay = document.createTextNode ( "" );
	document.getElementById("ampm").appendChild ( timeDisplay );
}

function amPm ( )
{
	var currentTime = new Date ( );
	var currentHours = currentTime.getHours ( );

<!-- Defines either "AM" or "PM" as appropriate -->
	var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

<!-- Convert hours component of "12" to "24" -->
	//currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

<!-- Convert hours component from "0" to "12 at Midnight-->
	//currentHours = ( currentHours == 0 ) ? 12 : currentHours;

<!-- Compose the string for display-->
	var currentTimeString = timeOfDay;

<!-- Update the string for display of AM/PM-->
	document.getElementById("ampm").firstChild.nodeValue = currentTimeString;
}

function init3 ( )
{
	timeDisplay = document.createTextNode ( "" );

	document.getElementById("date").appendChild ( timeDisplay );

	document.getElementById("season").appendChild ( timeDisplay );
}

function calendarDate ( )
{
	var this_weekday_name_array = new Array("周日","周一","周二","周三","周四","周五","周六")
	//var this_weekday_name_array = new Array("sun","mon","tue","wed","thu","fri","sat")



    var this_month_name_array = new Array("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月")
    //var this_month_name_array = new Array("jan","feb","mar","apr","may","jun","jul","augus","sep","oct","nov","dec")

	var this_season_name_array = new Array("冬","冬","春","春","春","夏","夏","夏","秋","秋","秋","冬")
	//var this_season_name_array = new Array("Winter","Winter","Spring","Spring","Spring","Summer","Summer","Summer","Autumn","Autumn","Autumn","Winter")

	var this_date_timestamp = new Date()
	var this_weekday = this_date_timestamp.getDay()
	var this_date = this_date_timestamp.getDate()
	var this_month = this_date_timestamp.getMonth()
	var this_season = this_date_timestamp.getMonth()


	document.getElementById("date").firstChild.nodeValue = this_weekday_name_array[this_weekday] + ", " + this_month_name_array[this_month] + " " + this_date + ", "
	//document.getElementById("date").firstChild.nodeValue = this_weekday_name_array[this_weekday] + ", " +this_month_name_array[this_month] + " " + this_date + " | "

document.getElementById("season").firstChild.nodeValue = this_season_name_array[this_season]

}

<!----------------------------------------------------------------------------------------------------------------><!-- Weather Script -->

	var locale = "2306184"
	var isCelsius = true
	var useRealFeel = false
	var enableWallpaper = true;
	var enableLockScreen = true;
	var stylesheetWall = 'mini'
	var stylesheetLock = 'mini'
	var stylesheet = 'mini'
	var iconSetWall = 'stardock'
	var iconExtWall = ".png"
	var iconSetLock = 'stardock'
	var iconExtLock = '.png'
	var source = 'yahooWeather'
	var updateInterval = 60
	var postal;
	var demoMode = false;
	var enabled;

if (location.href.indexOf("LockBackground")  == -1){
	stylesheet = stylesheetWall;
	iconSet = iconSetWall;
	iconExt = iconExtWall;
	enabled = enableWallpaper;
}else{
	stylesheet = stylesheetLock;
	iconSet = iconSetLock;
	iconExt = iconExtLock;
	enabled = enableLockScreen;
}

if(enabled == true){
if(iconSet == null || iconSet == 'null' || iconSet == ""){
	var iconSet = stylesheet;
}

var headID = document.getElementsByTagName("head")[0];
var styleNode = document.createElement('link');
styleNode.type = 'text/css';
styleNode.rel = 'stylesheet';
styleNode.href = 'Stylesheets/'+stylesheet+'.css';
headID.appendChild(styleNode);

var scriptNode = document.createElement('script');
scriptNode.type = 'text/javascript';
scriptNode.src = 'Sources/'+source+'.js';
headID.appendChild(scriptNode);
}

function onLoad(){
	if (enabled == true){
	if (demoMode == true){
		document.getElementById("weatherIcon").src="Icon Sets/"+iconSet+"/"+"cloudy1"+iconExt;
		document.getElementById("city").innerText="Somewhere";
		document.getElementById("desc").innerText="Partly Cloudy";
		document.getElementById("temp").innerText="100º";

	}else{
	document.getElementById("weatherIcon").src="Icon Sets/"+iconSet+"/"+"dunno"+iconExt;
	validateWeatherLocation(escape(locale).replace(/^%u/g, "%"), setPostal)
	}
	}else{
		document.getElementsByTagName("body")[0].innerText='';
	}
}

function convertTemp(num)
{
	if (isCelsius == true)
		return Math.round ((num - 32) * 5 / 9);
	else
		return num;
}

function setPostal(obj){

	if (obj.error == false){
		if(obj.cities.length > 0){
			postal = escape(obj.cities[0].zip).replace(/^%u/g, "%")
			document.getElementById("WeatherContainer").className = "";
			weatherRefresherTemp();
		}else{
			document.getElementById("city").innerText="Not Found";
			document.getElementById("WeatherContainer").className = "errorLocaleNotFound";
		}
	}else{
		document.getElementById("city").innerText=obj.errorString;
		document.getElementById("WeatherContainer").className = "errorLocaleValidate";
		setTimeout('validateWeatherLocation(escape(locale).replace(/^%u/g, "%"), setPostal)', Math.round(1000*60*5));
	}
}

function dealWithWeather(obj){

	if (obj.error == false){

  document.getElementById("desc").innerText=obj.description.toLowerCase();

		if(useRealFeel == true){
			tempValue = convertTemp(obj.realFeel);
		}else{
			tempValue = convertTemp(obj.temp)
		}
		document.getElementById("city").innerHTML=obj.city + ", " + tempValue + "° C";
		document.getElementById("weatherIcon").src="Icon Sets/"+iconSet+"/"+MiniIcons[obj.icon]+iconExt;
		document.getElementById("WeatherContainer").className = "";


	}else{
		//Could be down to any number of things, which is unhelpful...

		document.getElementById("WeatherContainer").className = "errorWeatherDataFetch";
	}


}

function weatherRefresherTemp(){
	fetchWeatherData(dealWithWeather,postal);
	setTimeout(weatherRefresherTemp, 60*1000*updateInterval);
}

var MiniIcons =
[
	"0",		       //0		tornado
	"1",		       //1		tropical storm
	"2",		       //2		hurricane
	"3",		       //3		severe thunderstorms
	"4",		       //4		thunderstorms
	"5",		       //5		mixed rain and snow
	"6",		       //6		mixed rain and sleet
	"7",		       //7		mixed snow and sleet
	"8",		       //8		freezing drizzle
	"9",		       //9		drizzle
	"10",		       //10	freezing rain
	"11",		       //11	showers
	"12",		       //12	showers
	"13",		       //13	snow flurries
	"14",		       //14	light snow showers
	"15",		       //15	blowing snow
	"16",		       //16	snow
	"17",		       //17	hail
	"18",		       //18	sleet
	"19",		       //19	dust
	"20",		       //20	foggy
	"21",		       //21	haze
	"22",		       //22	smoky
	"23",		       //23	blustery
	"24",		       //24	windy
	"25",		       //25	cold
	"26",		       //26	cloudy
	"27",		       //27	mostly cloudy (night)
	"28",		       //28	mostly cloudy (day)
	"29",		       //29	partly cloudy (night)
	"30",		       //30	partly cloudy (day)
	"31",		       //31	clear (night)
	"32",		       //32	sunny
	"33",		       //33	fair (night)
	"34",		       //34	fair (day)
	"35",		       //35	mixed rain and hail
	"36",		       //36	hot
	"37",		       //37	isolated thunderstorms
	"38",		       //38	scattered thunderstorms
	"39",		       //39	scattered thunderstorms
	"40",		       //40	scattered showers
	"41",		       //41	heavy snow
	"42",		       //42	scattered snow showers
	"43",		       //43	heavy snow
	"44",		       //44	partly cloudy
	"45",		       //45	thundershowers
	"46",		       //46	snow showers
	"47",		       //47	isolated thundershowers
	"dunno",		 //3200 	not available
]

function constructError (string)
{
	return {error:true, errorString:string};
}

function findChild (element, nodeName)
{
	var child;

	for (child = element.firstChild; child != null; child = child.nextSibling)
	{
		if (child.nodeName == nodeName)
			return child;
	}

	return null;
}


function fetchWeatherData (callback, zip)
{
	url="http://weather.yahooapis.com/forecastrss?u=f&w=" //u=Farenheit, because accuWeather sucks

	var xml_request = new XMLHttpRequest();
	xml_request.onload = function(e) {xml_loaded(e, xml_request, callback);}
	xml_request.overrideMimeType("text/xml");
	xml_request.open("GET", url+zip);
	xml_request.setRequestHeader("Cache-Control", "no-cache");
	xml_request.send(null);

	return xml_request;
}

function xml_loaded (event, request, callback)
{
	if (request.responseXML)
	{
		var obj = {error:false, errorString:null};
		var effectiveRoot = findChild(findChild(request.responseXML, "rss"), "channel");
		obj.city = findChild(effectiveRoot, "yweather:location").getAttribute("city");
		obj.realFeel = findChild(effectiveRoot, "yweather:wind").getAttribute("chill");//Only accounts for windChill

		conditionTag = findChild(findChild(effectiveRoot, "item"), "yweather:condition");
		obj.temp = conditionTag.getAttribute("temp");
		obj.icon = conditionTag.getAttribute("code");
		obj.description = conditionTag.getAttribute("text");
		callback (obj);
	}else{
		callback ({error:true, errorString:"XML request failed. no responseXML"});
	}
}


function validateWeatherLocation (location, callback)
{
	var obj = {error:false, errorString:null, cities: new Array};
	obj.cities[0] = {zip: location}; //Not very clever, are we?
	callback (obj);
}

</script></p>
<p><!----------------------------------------------------------------------------------------------------------------><br />
<!-- Display All - Weather-Clock-Date --></p>
<p> </p>
<div id="WeatherContainer">
<div id="TextContainer">
<p id="city">Home</p>
<p id="temp">°</p>
<p id="desc">...</p>
</div>
<p><img id="weatherIcon" /></p>
</div>
<table style="position: absolute; top: 20px; left: -60px; right: 0px; width: 320px; height: 481px;">
<tbody>
<tr>
<td align="center" valign="top" width="308"><span id="clock"><br />
<script language="JavaScript">updateClock(); setInterval('updateClock()', 1000 )</script><br />
</span></td>
</tr>
</tbody>
</table>
<table style="position: absolute; top: 85px; left: 35px; right: 0px; width: 320px; height: 481px;">
<tbody>
<tr>
<td align="center" valign="top" width="308"><span id="clock"><br />
<span id="ampm"> <script language="JavaScript">amPm(); setInterval('amPm()', 1000 )</script></span> </span></td>
</tr>
</tbody>
</table>
<table style="position: absolute; top: 110px; left: -105px; width: 320px; height: 481px;">
<tbody>
<tr>
<td id="date" style="text-align: center;" valign="top"><span id="calendar"><br />
<script language="JavaScript">calendarDate(); setInterval('calendarDate()', 1000 )</script><br />
</span></td>
</tr>
</tbody>
</table>
<p> </p>
<p> </p>
<p>Wallpaper.html範例<br />
<style>
<p>@font-face {<br />
font-family: Default1;<br />
src: url(Default1.otf);<br />
}</p>
<p>#Layer {<br />
width: 321px;<br />
height: 569px;<br />
position: absolute;<br />
top: -1px;<br />
right: 0px;<br />
down: 0px;<br />
left: -1px;<br />
}</p>
<p>.stretch {<br />
width:100%;<br />
height:100%;<br />
}</p>
<p>/* -------------------------------------------------------------------------------------- Digital Clock ------------------- */</p>
<p>	SPAN#clock {<br />
font-family: Default1;<br />
color: #1d1d1d;<br />
//	letter-spacing: 0.06em;<br />
//	text-shadow: 1px 4px 4px rgba(0,0,0,0.5);<br />
font-size: 75px;<br />
//	opacity: 0.8;<br />
}</p>
<p>	SPAN#ampm {<br />
// display: none;<br />
font-family: Default1;<br />
color: #1d1d1d;<br />
//	letter-spacing: 0.06em;<br />
//	text-shadow: 1px 4px 4px rgba(0,0,0,0.5);<br />
font-size: 14px;<br />
//	opacity: 0.8;<br />
}</p>
<p>/* -------------------------------------------------------------------------------------- Calendar ------------------- */</p>
<p>	TD#date {<br />
font-family: Default1;<br />
text-align: right;<br />
color: #1d1d1d;<br />
//	letter-spacing: 0.06em;<br />
//	text-shadow: 1px 4px 4px rgba(0,0,0,0.5);<br />
font-size: 12px;<br />
text-transform: uppercase;<br />
//	opacity: 0.8;<br />
}</p>
<p>	TD#season {<br />
font-family: Default1;<br />
text-align: center;<br />
color: #1d1d1d;<br />
letter-spacing: 0.06em;<br />
text-shadow: 1px 4px 4px rgba(0,0,0,0.5);<br />
font-size: 20px;<br />
text-transform: none;<br />
opacity: 0.8;<br />
display: none;<br />
}</p>
<p>/* -------------------------------------------------------------------------------------- Weather ------------------- */</p>
<p>	#WeatherContainer {<br />
background-color: rgba(0,0,0,0);<br />
}</p>
<p>	#TextContainer {<br />
font-size:55px;<br />
font-family: Default1;<br />
//	font-weight: bold;<br />
color:#1d1d1d;<br />
}</p>
<p>	#city {<br />
position: absolute; top: 113px; right: 0px; down: 0px; left: 92px; width: 320px; height: 481px;<br />
//	display: none;<br />
text-align: left;<br />
font-family: Default1;<br />
font-size: 12px;<br />
//	text-shadow: 1px 4px 4px rgba(0,0,0,0.5);<br />
color: #1d1d1d;<br />
text-transform: uppercase;<br />
}</p>
<p>	#temp {<br />
position: absolute; top: 100px; right: 0px; down: 0px; left: -23px; width: 320px; height: 481px;<br />
margin-top:0px;<br />
text-align: center;<br />
font-family: Default1;<br />
font-size: 14px;<br />
color: #1d1d1d;<br />
text-shadow: 1px 4px 4px rgba(0,0,0,0.5);<br />
opacity: 0.8;<br />
letter-spacing: 0.06em;<br />
display:none;<br />
}</p>
<p>	#desc{<br />
position: absolute; top: 200px; right: 0px; down: 0px; left: 0px; width: 320px; height: 461px;<br />
display: none;<br />
text-align: center;<br />
font-family: Default1;<br />
font-size: 14px;<br />
text-shadow: 1px 4px 4px rgba(0,0,0,0.5);<br />
color: #1d1d1d;<br />
}</p>
<p>	#TextContainer p{<br />
margin:0;<br />
}</p>
<p>	#weatherIcon{</p>
<p>		position: absolute; top: 43px; left: 220px; width: 320px; height: 461px;<br />
height:90;<br />
width:90;<br />
}</p>
</style>
</p>
<p><!----------------------------------------------------------------------------------------------------------------></p>
<p><!-- Display Wallpaper (LockBackground.png) here --></p>
<div id="Layer"><img class="stretch" src="Wallpaper.png" /></div>
<p> </p>
<p><!----------------------------------------------------------------------------------------------------------------></p>
<p><!-- Clock and Calendar Script --></p>
<p><script type="text/javascript">

function init ( )
{
	timeDisplay = document.createTextNode ( "" );
	document.getElementById("clock").appendChild ( timeDisplay );
}

function updateClock ( )
{
	var currentTime = new Date ( );
	var currentHours = currentTime.getHours ( );
	var currentMinutes = currentTime.getMinutes ( );
	var currentSeconds = currentTime.getSeconds ( );

<!-- Pad the minutes and seconds with leading zeros, if required -->

	currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
	currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

<!-- Defines either "AM" or "PM" as appropriate -->
	var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

<!-- Convert hours component of "12" to "24" -->
	//currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

<!-- Convert hours component from "0" to "12 at Midnight-->
	currentHours = ( currentHours == 0 ) ? 12 : currentHours;

<!-- Compose the string for display-->
	currentHours = ( currentHours < 10 ? "0" : "" ) + currentHours;
	var currentTimeString = currentHours + ":" + currentMinutes;

	<!-- Update the time display-->
	document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}

function init2 ( )
{
	timeDisplay = document.createTextNode ( "" );
	document.getElementById("ampm").appendChild ( timeDisplay );
}

function amPm ( )
{
	var currentTime = new Date ( );
	var currentHours = currentTime.getHours ( );

<!-- Defines either "AM" or "PM" as appropriate -->
	var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

<!-- Convert hours component of "12" to "24" -->
	//currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

<!-- Convert hours component from "0" to "12 at Midnight-->
	//currentHours = ( currentHours == 0 ) ? 12 : currentHours;

<!-- Compose the string for display-->
	var currentTimeString = timeOfDay;

<!-- Update the string for display of AM/PM-->
	document.getElementById("ampm").firstChild.nodeValue = currentTimeString;
}

function init3 ( )
{
	timeDisplay = document.createTextNode ( "" );

	document.getElementById("date").appendChild ( timeDisplay );

	document.getElementById("season").appendChild ( timeDisplay );
}

function calendarDate ( )
{
	var this_weekday_name_array = new Array("周日","周一","周二","周三","周四","周五","周六")
	//var this_weekday_name_array = new Array("sun","mon","tue","wed","thu","fri","sat")



    var this_month_name_array = new Array("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月")
    //var this_month_name_array = new Array("jan","feb","mar","apr","may","jun","jul","augus","sep","oct","nov","dec")

	var this_season_name_array = new Array("冬","冬","春","春","春","夏","夏","夏","秋","秋","秋","冬")
	//var this_season_name_array = new Array("Winter","Winter","Spring","Spring","Spring","Summer","Summer","Summer","Autumn","Autumn","Autumn","Winter")

	var this_date_timestamp = new Date()
	var this_weekday = this_date_timestamp.getDay()
	var this_date = this_date_timestamp.getDate()
	var this_month = this_date_timestamp.getMonth()
	var this_season = this_date_timestamp.getMonth()


	document.getElementById("date").firstChild.nodeValue = this_weekday_name_array[this_weekday] + ", " + this_month_name_array[this_month] + " " + this_date + ", "
	//document.getElementById("date").firstChild.nodeValue = this_weekday_name_array[this_weekday] + ", " +this_month_name_array[this_month] + " " + this_date + " | "

document.getElementById("season").firstChild.nodeValue = this_season_name_array[this_season]

}

<!----------------------------------------------------------------------------------------------------------------><!-- Weather Script -->

	var locale = "2306184"
	var isCelsius = true
	var useRealFeel = false
	var enableWallpaper = true;
	var enableLockScreen = true;
	var stylesheetWall = 'mini'
	var stylesheetLock = 'mini'
	var stylesheet = 'mini'
	var iconSetWall = 'stardock'
	var iconExtWall = ".png"
	var iconSetLock = 'stardock'
	var iconExtLock = '.png'
	var source = 'yahooWeather'
	var updateInterval = 60
	var postal;
	var demoMode = false;
	var enabled;

if (location.href.indexOf("LockBackground")  == -1){
	stylesheet = stylesheetWall;
	iconSet = iconSetWall;
	iconExt = iconExtWall;
	enabled = enableWallpaper;
}else{
	stylesheet = stylesheetLock;
	iconSet = iconSetLock;
	iconExt = iconExtLock;
	enabled = enableLockScreen;
}

if(enabled == true){
if(iconSet == null || iconSet == 'null' || iconSet == ""){
	var iconSet = stylesheet;
}

var headID = document.getElementsByTagName("head")[0];
var styleNode = document.createElement('link');
styleNode.type = 'text/css';
styleNode.rel = 'stylesheet';
styleNode.href = 'Stylesheets/'+stylesheet+'.css';
headID.appendChild(styleNode);

var scriptNode = document.createElement('script');
scriptNode.type = 'text/javascript';
scriptNode.src = 'Sources/'+source+'.js';
headID.appendChild(scriptNode);
}

function onLoad(){
	if (enabled == true){
	if (demoMode == true){
		document.getElementById("weatherIcon").src="Icon Sets/"+iconSet+"/"+"cloudy1"+iconExt;
		document.getElementById("city").innerText="Somewhere";
		document.getElementById("desc").innerText="Partly Cloudy";
		document.getElementById("temp").innerText="100º";

	}else{
	document.getElementById("weatherIcon").src="Icon Sets/"+iconSet+"/"+"dunno"+iconExt;
	validateWeatherLocation(escape(locale).replace(/^%u/g, "%"), setPostal)
	}
	}else{
		document.getElementsByTagName("body")[0].innerText='';
	}
}

function convertTemp(num)
{
	if (isCelsius == true)
		return Math.round ((num - 32) * 5 / 9);
	else
		return num;
}

function setPostal(obj){

	if (obj.error == false){
		if(obj.cities.length > 0){
			postal = escape(obj.cities[0].zip).replace(/^%u/g, "%")
			document.getElementById("WeatherContainer").className = "";
			weatherRefresherTemp();
		}else{
			document.getElementById("city").innerText="Not Found";
			document.getElementById("WeatherContainer").className = "errorLocaleNotFound";
		}
	}else{
		document.getElementById("city").innerText=obj.errorString;
		document.getElementById("WeatherContainer").className = "errorLocaleValidate";
		setTimeout('validateWeatherLocation(escape(locale).replace(/^%u/g, "%"), setPostal)', Math.round(1000*60*5));
	}
}

function dealWithWeather(obj){

	if (obj.error == false){

  document.getElementById("desc").innerText=obj.description.toLowerCase();

		if(useRealFeel == true){
			tempValue = convertTemp(obj.realFeel);
		}else{
			tempValue = convertTemp(obj.temp)
		}
		document.getElementById("city").innerHTML=obj.city + ", " + tempValue + "° C";
		document.getElementById("weatherIcon").src="Icon Sets/"+iconSet+"/"+MiniIcons[obj.icon]+iconExt;
		document.getElementById("WeatherContainer").className = "";


	}else{
		//Could be down to any number of things, which is unhelpful...

		document.getElementById("WeatherContainer").className = "errorWeatherDataFetch";
	}


}

function weatherRefresherTemp(){
	fetchWeatherData(dealWithWeather,postal);
	setTimeout(weatherRefresherTemp, 60*1000*updateInterval);
}

var MiniIcons =
[
	"0",		       //0		tornado
	"1",		       //1		tropical storm
	"2",		       //2		hurricane
	"3",		       //3		severe thunderstorms
	"4",		       //4		thunderstorms
	"5",		       //5		mixed rain and snow
	"6",		       //6		mixed rain and sleet
	"7",		       //7		mixed snow and sleet
	"8",		       //8		freezing drizzle
	"9",		       //9		drizzle
	"10",		       //10	freezing rain
	"11",		       //11	showers
	"12",		       //12	showers
	"13",		       //13	snow flurries
	"14",		       //14	light snow showers
	"15",		       //15	blowing snow
	"16",		       //16	snow
	"17",		       //17	hail
	"18",		       //18	sleet
	"19",		       //19	dust
	"20",		       //20	foggy
	"21",		       //21	haze
	"22",		       //22	smoky
	"23",		       //23	blustery
	"24",		       //24	windy
	"25",		       //25	cold
	"26",		       //26	cloudy
	"27",		       //27	mostly cloudy (night)
	"28",		       //28	mostly cloudy (day)
	"29",		       //29	partly cloudy (night)
	"30",		       //30	partly cloudy (day)
	"31",		       //31	clear (night)
	"32",		       //32	sunny
	"33",		       //33	fair (night)
	"34",		       //34	fair (day)
	"35",		       //35	mixed rain and hail
	"36",		       //36	hot
	"37",		       //37	isolated thunderstorms
	"38",		       //38	scattered thunderstorms
	"39",		       //39	scattered thunderstorms
	"40",		       //40	scattered showers
	"41",		       //41	heavy snow
	"42",		       //42	scattered snow showers
	"43",		       //43	heavy snow
	"44",		       //44	partly cloudy
	"45",		       //45	thundershowers
	"46",		       //46	snow showers
	"47",		       //47	isolated thundershowers
	"dunno",		 //3200 	not available
]

function constructError (string)
{
	return {error:true, errorString:string};
}

function findChild (element, nodeName)
{
	var child;

	for (child = element.firstChild; child != null; child = child.nextSibling)
	{
		if (child.nodeName == nodeName)
			return child;
	}

	return null;
}


function fetchWeatherData (callback, zip)
{
	url="http://weather.yahooapis.com/forecastrss?u=f&w=" //u=Farenheit, because accuWeather sucks

	var xml_request = new XMLHttpRequest();
	xml_request.onload = function(e) {xml_loaded(e, xml_request, callback);}
	xml_request.overrideMimeType("text/xml");
	xml_request.open("GET", url+zip);
	xml_request.setRequestHeader("Cache-Control", "no-cache");
	xml_request.send(null);

	return xml_request;
}

function xml_loaded (event, request, callback)
{
	if (request.responseXML)
	{
		var obj = {error:false, errorString:null};
		var effectiveRoot = findChild(findChild(request.responseXML, "rss"), "channel");
		obj.city = findChild(effectiveRoot, "yweather:location").getAttribute("city");
		obj.realFeel = findChild(effectiveRoot, "yweather:wind").getAttribute("chill");//Only accounts for windChill

		conditionTag = findChild(findChild(effectiveRoot, "item"), "yweather:condition");
		obj.temp = conditionTag.getAttribute("temp");
		obj.icon = conditionTag.getAttribute("code");
		obj.description = conditionTag.getAttribute("text");
		callback (obj);
	}else{
		callback ({error:true, errorString:"XML request failed. no responseXML"});
	}
}


function validateWeatherLocation (location, callback)
{
	var obj = {error:false, errorString:null, cities: new Array};
	obj.cities[0] = {zip: location}; //Not very clever, are we?
	callback (obj);
}

</script></p>
<p><!----------------------------------------------------------------------------------------------------------------><br />
<!-- Display All - Weather-Clock-Date --></p>
<p> </p>
<div id="WeatherContainer">
<div id="TextContainer">
<p id="city">Home</p>
<p id="temp">°</p>
<p id="desc">...</p>
</div>
<p><img id="weatherIcon" /></p>
</div>
<table style="position: absolute; top: 20px; left: -60px; right: 0px; width: 320px; height: 481px;">
<tbody>
<tr>
<td align="center" valign="top" width="308"><span id="clock"><br />
<script language="JavaScript">updateClock(); setInterval('updateClock()', 1000 )</script><br />
</span></td>
</tr>
</tbody>
</table>
<table style="position: absolute; top: 85px; left: 35px; right: 0px; width: 320px; height: 481px;">
<tbody>
<tr>
<td align="center" valign="top" width="308"><span id="clock"><br />
<span id="ampm"> <script language="JavaScript">amPm(); setInterval('amPm()', 1000 )</script></span> </span></td>
</tr>
</tbody>
</table>
<table style="position: absolute; top: 110px; left: -105px; width: 320px; height: 481px;">
<tbody>
<tr>
<td id="date" style="text-align: center;" valign="top"><span id="calendar"><br />
<script language="JavaScript">calendarDate(); setInterval('calendarDate()', 1000 )</script><br />
</span></td>
</tr>
</tbody>
</table>

臉書回應

篇回應

關於 窮苦人家的小孩

In every democracy, the people get the government they deserve. ~Alexis de Tocqueville
上一篇:
下一篇:

您可能會喜歡

root ASUS ZenPad 10(Z300M)

我的追劇用平板ASUS Zen …

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步瞭解 Akismet 如何處理網站訪客的留言資料