2008 07 26 15 22 在xuite上放上衛星雲圖(2)


又更新了之前的衛星雲圖 javascript 。
這次增加了可以讓使用者選擇是要看東亞的衛星雲圖,
或者是只看台灣的衛星雲圖。


<script language="javascript">

function showImg(base_url)
{
return function() {
var d = new Date();
var i = 0;
var img_url = base_url;

if (d.getUTCMinutes() < 5) { // 至少等5分鍾,才使用新的衛星雲圖
i=1;
}
d.setUTCHours(d.getUTCHours() + 8 - i); // trick : 變成台灣的時區
var tmp = d.getUTCFullYear();
if (tmp < 10) {
img_url += "0";
}
img_url += tmp;
img_url +="-";
if (d.getUTCMonth() + 1 < 10) {
img_url += "0";
}
img_url += (d.getUTCMonth() + 1);
img_url +="-";
if (d.getUTCDate() < 10) {
img_url += "0";
}
img_url += (d.getUTCDate());
img_url +="-";

if (d.getUTCHours() < 10) {
img_url += "0";
}
img_url += (d.getUTCHours());
img_url += ".jpg";
return img_url;
}
}

s3q = showImg("http://www.cwb.gov.tw/V5/observe/satellite/Data/s3q/s3q-"); // 台灣氣象雲圖
s1q = showImg("http://www.cwb.gov.tw/V5/observe/satellite/Data/s1q/s1q-"); // 東亞氣象雲圖

document.write("<a href=\"javascript:void(0)\" onclick=\"");
document.write("javascript:document.getElementById('satellite_img').src = s3q();");
document.write("javascript:document.getElementById('satellite_href').href = s3q();");
document.write("\">");
document.write("台灣");
document.write("</a> ");


document.write("<a href=\"javascript:void(0)\" onclick=\"");
document.write("javascript:document.getElementById('satellite_img').src = s1q();");
document.write("javascript:document.getElementById('satellite_href').href = s1q();");
document.write("\">");
document.write("東亞");
document.write("</a>");

document.write("<br />");

document.write("<a href=\"");
document.write(s1q());
document.write("\" id=\"satellite_href\">");
document.write("<img width=190 id=\"satellite_img\" src=\"");
document.write(s1q());
document.write("\"/>");
document.write("</a>");

</script>