張貼日期:Mar 10, 2010 8:42:44 AM
// 系統時鐘
function startclock()
{
var thetime=new Date();
var nhours=thetime.getHours();
var nmins=thetime.getMinutes();
var nsecn=thetime.getSeconds();
var nday=thetime.getDay();
var nmonth=thetime.getMonth();
var ntoday=thetime.getDate();
var nyear=thetime.getYear();
var AorP=" ";
if (nhours>=12)
AorP="P.M.";
else
AorP="A.M.";
if (nhours>=13)
nhours-=12;
if (nhours==0)
nhours=12;
if (nsecn<10)
nsecn="0"+nsecn;
if (nmins<10)
nmins="0"+nmins;
if (nday==0)
nday="日";
if (nday==1)
nday="一";
if (nday==2)
nday="二";
if (nday==3)
nday="三";
if (nday==4)
nday="四";
if (nday==5)
nday="五";
if (nday==6)
nday="六";
nmonth+=1;
if (nyear<=99)
nyear= "19"+nyear;
if ((nyear>99) && (nyear<2000))
nyear+=1900;
document.getElementById('clockspot').innerText=nyear+"/"+nmonth+"/"+ntoday+" 星期"+nday+" "+nhours+": "+nmins+": "+nsecn+" "+AorP;
setTimeout('startclock()',1000);
}
//去空白
function trim(myStr){
return myStr.replace(/[\s]*$/gi,"").replace(/^[\s]*/gi,"");
}
//檢查 Email 格式
function check_email(str) {
return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}
//跳頁
function jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//判斷數值
function IsNum(num_string) {
var re =/\d{1,}/
var re_result=re.exec(num_string)
if (re_result== num_string )
{
return true ;
}else{
return false ;
}
}
//刪除確認
function Del_confirm(myStr)
{
return confirm(myStr);
}
//Textarea 加大/縮小
var addH=1;
function addHeight() {
if (!document.getElementById('comment_content')) return flase;
var comment = document.getElementById('comment_content');
var nowH = parseInt(comment.style.height);
if (nowH < 650) {
nowH+=3;
comment.style.height=nowH+"px";
addH++;
if (addH > 25){
addH=1;
} else {
window.setTimeout("addHeight()","10");
}
}
}
function minHeight() {
if (!document.getElementById('comment_content')) return flase;
var comment = document.getElementById('comment_content');
var nowH = parseInt(comment.style.height);
if (nowH > 50) {
nowH-=3;
comment.style.height=nowH+"px";
addH++;
if (addH > 25){
addH=1;
} else {
window.setTimeout("minHeight()","10");
}
}
}
//跳頁下拉選單
function jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//全選/不全選
function CheckAll(form1) {
for (var i=0;i<form1.elements.length;i++) {
var e = form1.elements[i];
if (e.name != 'chkall') e.checked = form1.chkall.checked;
}
}
//等比例縮圖
function DrawImage(ImgD,FitWidth,FitHeight)
{
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0)
{
if(image.width/image.height>= FitWidth/FitHeight)
{
if(image.width>FitWidth)
{
ImgD.width=FitWidth;
ImgD.height=(image.height*FitWidth)/image.width;
}
else
{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
else
{
if(image.height>FitHeight)
{
ImgD.height=FitHeight;
ImgD.width=(image.width*FitHeight)/image.height;
}
else
{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
}
}