极酷时间和日历 coollllll

极酷时间和日历 coollllll

效果:

代码:


[复制到剪切板]
CODE:
<style type="text/css"
body 
        
background-color#D4D0C8; 

.
m_fieldset 
        
padding0,10,5,10
        
text-aligncenter
        
width150px

.
m_legend 
        
font-familyTahoma
        
font-size11px
        
padding-bottom5px

.
m_frameborder 
        
border-left2px inset #D4D0C8; 
        
border-top2px inset #D4D0C8; 
        
border-right2px inset #FFFFFF; 
        
border-bottom2px inset #FFFFFF; 
        
width100px
        
height19px
        
background-color#FFFFFF; 
        
overflowhidden
        
text-alignright
        
font-family"Tahoma"
        
font-size10px

.
m_arrow 
        
width16px
        
height8px
        
font-family"Webdings"
        
font-size7px
        
line-height2px
        
padding-left2px
        
cursor: default; 

.
m_input 
        
width18px
        
height14px
        
border0px solid black
        
font-family"Tahoma"
        
font-size9px
        
text-alignright
        
ime-mode:disabled

</
style

<
script language="javascript"
//        Written by cloudchen, 2004/03/15 
function minute(name,fName

        
this.name name
        
this.fName fName || "m_input"
        
this.timer null
        
this.fObj null
         
        
this.toString = function() 
        { 
                var 
objDate = new Date(); 
                var 
sMinute_Common "class=\"m_input\" maxlength=\"2\" name=\""+this.fName+"\" onfocus=\""+this.name+".setFocusObj(this)\" onblur=\""+this.name+".setTime(this)\" onkeyup=\""+this.name+".prevent(this)\" onkeypress=\"if (!/[0-9]/.test(String.fromCharCode(event.keyCode)))event.keyCode=0\" onpaste=\"return false\" ondragenter=\"return false\""
                var 
sButton_Common "class=\"m_arrow\" onfocus=\"this.blur()\" onmouseup=\""+this.name+".controlTime()\" disabled" 
                
var str ""
                
str += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" 
                
str += "<tr>" 
                
str += "<td>" 
                
str += "<div class=\"m_frameborder\">" 
                
str += "<input radix=\"24\" value=\""+this.formatTime(objDate.getHours())+"\" "+sMinute_Common+">:" 
                
str += "<input radix=\"60\" value=\""+this.formatTime(objDate.getMinutes())+"\" "+sMinute_Common+">:" 
                
str += "<input radix=\"60\" value=\""+this.formatTime(objDate.getSeconds())+"\" "+sMinute_Common+">" 
                
str += "</div>" 
                
str += "</td>" 
                
str += "<td>" 
                
str += "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\">" 
                
str += "<tr><td><button id=\""+this.fName+"_up\" "+sButton_Common+">5</button></td></tr>" 
                
str += "<tr><td><button id=\""+this.fName+"_down\" "+sButton_Common+">6</button></td></tr>" 
                
str += "</table>" 
                
str += "</td>" 
                
str += "</tr>" 
                
str += "</table>" 
                
return str
        } 
        
this.play = function() 
        { 
                
this.timer setInterval(this.name+".playback()",1000); 
        } 
        
this.formatTime = function(sTime
        { 
                
sTime = ("0"+sTime); 
                return 
sTime.substr(sTime.length-2); 
        } 
        
this.playback = function() 
        { 
                var 
objDate = new Date(); 
                var 
arrDate = [objDate.getHours(),objDate.getMinutes(),objDate.getSeconds()]; 
                var 
objMinute document.getElementsByName(this.fName); 
                for (var 
i=0;i<objMinute.length;i++) 
                { 
                        
objMinute[i].value this.formatTime(arrDate[i]) 
                } 
        } 
        
this.prevent = function(obj
        { 
                
clearInterval(this.timer); 
                
this.setFocusObj(obj); 
                var 
value parseInt(obj.value,10); 
                var 
radix parseInt(obj.radix,10)-1
                if (
obj.value>radix||obj.value<0
                { 
                        
obj.value obj.value.substr(0,1); 
                } 
        } 
        
this.controlTime = function(cmd
        { 
                
event.cancelBubble true
                if (!
this.fObj) return; 
                
clearInterval(this.timer); 
                var 
cmd event.srcElement.innerText=="5"?true:false
                var 
parseInt(this.fObj.value,10); 
                var 
radix parseInt(this.fObj.radix,10)-1
                if (
i==radix&&cmd
                { 
                        
0
                } 
                else if (
i==0&&!cmd
                { 
                        
radix
                } 
                else 
                { 
                        
cmd?i++:i--; 
                } 
                
this.fObj.value this.formatTime(i); 
                
this.fObj.select(); 
        } 
        
this.setTime = function(obj
        { 
                
obj.value this.formatTime(obj.value); 
        } 
        
this.setFocusObj = function(obj
        { 
                eval(
this.fName+"_up").disabled = eval(this.fName+"_down").disabled false
                
this.fObj obj
        } 
        
this.getTime = function() 
        { 
                var 
arrTime = new Array(2); 
                for (var 
i=0;i<document.getElementsByName(this.fName).length;i++) 
                { 
                        
arrTime[i] = document.getElementsByName(this.fName)[i].value
                } 
                return 
arrTime.join(":"); 
        } 

<\/
script


<
style type="text/css"
body 
        
background-color#D4D0C8; 

.
c_fieldset 
        
padding0,10,5,10
        
text-aligncenter
        
width180px

.
c_legend 
        
font-familyTahoma
        
font-size11px
        
padding-bottom5px

.
c_frameborder 
        
border-left2px inset #D4D0C8; 
        
border-top2px inset #D4D0C8; 
        
border-right2px inset #FFFFFF; 
        
border-bottom2px inset #FFFFFF; 
        
background-color#FFFFFF; 
        
overflowhidden
        
font-family"Tahoma"
        
font-size10px
        
width:160px
        
height:120px

.
c_frameborder td 
        
width23px
        
height16px
        
font-family"Tahoma"
        
font-size11px
        
text-aligncenter
        
cursor: default; 

.
c_frameborder .selected 
        
background-color:#0A246A; 
        
width:12px
        
height:12px
        
color:white

.
c_frameborder span 
        
width:12px
        
height:12px

.
c_arrow 
        
width16px
        
height8px
        
font-family"Webdings"
        
font-size7px
        
line-height2px
        
padding-left2px
        
cursor: default; 

.
c_year 
        
font-family"Tahoma"
        
font-size11px
        
cursor: default; 
        
width:55px
        
height:19px

.
c_month 
        
width:75px
        
height:20px
        
font:11px "Tahoma"

.
c_dateHead 
        
background-color:#808080; 
        
color:#D4D0C8; 

</
style

<
script language="javascript"
//        Written by cloudchen, 2004/03/16 
function calendar(name,fName

        
this.name name
        
this.fName fName || "calendar"
        
this.year = new Date().getFullYear(); 
        
this.month = new Date().getMonth(); 
        
this.date = new Date().getDate(); 
        
//private 
        
this.toString = function() 
        { 
                var 
str ""
                
str += "<table border=\"0\" cellspacing=\"3\" cellpadding=\"0\" onselectstart=\"return false\">"
                
str += "<tr>"
                
str += "<td>"
                
str += this.drawMonth(); 
                
str += "</td>"
                
str += "<td align=\"right\">"
                
str += this.drawYear(); 
                
str += "</td>"
                
str += "</tr>"
                
str += "<tr>"
                
str += "<td colspan=\"2\">"
                
str += "<div class=\"c_frameborder\">"
                
str += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"c_dateHead\">"
                
str += "<tr>"
                
str += "<td>&#26085;</td><td>&#19968;</td><td>&#20108;</td><td>&#19977;</td><td>&#22235;</td><td>&#20116;</td><td>&#20845;</td>"
                
str += "</tr>"
                
str += "</table>"
                
str += this.drawDate(); 
                
str += "</div>"
                
str += "</td>"
                
str += "</tr>"
                
str += "</table>"
                return 
str
        } 
        
//private 
        
this.drawYear = function() 
        { 
                var 
str ""
                
str += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
                
str += "<tr>"
                
str += "<td>"
                
str += "<input class=\"c_year\" maxlength=\"4\" value=\""+this.year+"\" name=\""+this.fName+"\" id=\""+this.fName+"_year\" readonly>"
                
//DateField 
                
str += "<input type=\"hidden\" name=\""+this.fName+"\" value=\""+this.date+"\" id=\""+this.fName+"_date\">"
                
str += "</td>"
                
str += "<td>"
                
str += "<table cellspacing=\"2\" cellpadding=\"0\" border=\"0\">"
                
str += "<tr>"
                
str += "<td><button class=\"c_arrow\" onfocus=\"this.blur()\" onclick=\"event.cancelBubble=true;document.getElementById('"+this.fName+"_year').value++;"+this.name+".redrawDate()\">5</button></td>"
                
str += "</tr>"
                
str += "<tr>"
                
str += "<td><button class=\"c_arrow\" onfocus=\"this.blur()\" onclick=\"event.cancelBubble=true;document.getElementById('"+this.fName+"_year').value--;"+this.name+".redrawDate()\">6</button></td>"
                
str += "</tr>"
                
str += "</table>"
                
str += "</td>"
                
str += "</tr>"
                
str += "</table>"
                return 
str
        } 
        
//priavate 
        
this.drawMonth = function() 
        { 
                var 
aMonthName = ["&#19968;","&#20108;","&#19977;","&#22235;","&#20116;","&#20845;","&#19971;","&#20843;","&#20061;","&#21313;","&#21313;&#19968;","&#21313;&#20108;"]; 
                var 
str ""
                
str += "<select class=\"c_month\" name=\""+this.fName+"\" id=\""+this.fName+"_month\" onchange=\""+this.name+".redrawDate()\">"
                for (var 
i=0;i<aMonthName.length;i++) { 
                        
str += "<option value=\""+(i+1)+"\" "+(i==this.month?"selected":"")+">"+aMonthName[i]+"&#26376;</option>"
                } 
                
str += "</select>"
                return 
str
        } 
        
//private 
        
this.drawDate = function() 
        { 
                var 
str ""
                var 
fDay = new Date(this.year,this.month,1).getDay(); 
                var 
fDate 1-fDay
                var 
lDay = new Date(this.year,this.month+1,0).getDay(); 
                var 
lDate = new Date(this.year,this.month+1,0).getDate(); 
                
str += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" id=\""+this.fName+"_dateTable"+"\">"
                for (var 
i=1,j=fDate;i<7;i++) 
                { 
                        
str += "<tr>"
                        for (var 
k=0;k<7;k++) 
                        { 
                                
str += "<td><span"+(j==this.date?" class=\"selected\"":"")+" onclick=\""+this.name+".redrawDate(this.innerText)\">"+(isDate(j++))+"</span></td>"
                        } 
                        
str += "</tr>"
                } 
                
str += "</table>"
                return 
str

                function 
isDate(n
                { 
                        return (
n>=1&&n<=lDate)?n:""
                } 
        } 
        
//public 
        
this.redrawDate = function(d
        { 
                
this.year document.getElementById(this.fName+"_year").value
                
this.month document.getElementById(this.fName+"_month").value-1
                
this.date || this.date
                
document.getElementById(this.fName+"_year").value this.year
                
document.getElementById(this.fName+"_month").selectedIndex this.month
                
document.getElementById(this.fName+"_date").value this.date
                if (
this.date>new Date(this.year,this.month+1,0).getDate()) this.date = new Date(this.year,this.month+1,0).getDate(); 
                
document.getElementById(this.fName+"_dateTable").outerHTML this.drawDate(); 
        } 
        
//public 
        
this.getDate = function(delimiter
        { 
                if (!
delimiterdelimiter "/"
                var 
aValue = [this.year,(this.month+1),this.date]; 
                return 
aValue.join(delimiter); 
        } 

<\/
script
<
table border="0"
<
tr><td
<
fieldset class="c_fieldset"><legend class="c_legend">&#26085;&#26399;(T)</legend> 
<!-- &#35843;&#29992;&#26085;&#21382; --> 
<script
var 
= new calendar("c"); 
document.write(c); 
<\/
script
<!-- &
#35843;&#29992;&#26085;&#21382; --> 
</fieldset
</
td
<
td valign="top"
<
fieldset class="m_fieldset"><legend class="m_legend">&#26102;&#38388;(T)</legend> 
<!-- &#35843;&#29992;&#26102;&#38388;&#38047; --> 
<script
var 
= new minute("m"); 
m.play(); 
document.write(m); 
<\/
script
<!-- &
#35843;&#29992;&#26102;&#38388;&#38047; --> 
</fieldset
</
td></tr
<
tr
<
td colspan="2"
<
button onclick="alert(c.getDate())" style="font:8px Webdings;width:15px;height:15px;line-height:6px;">4</button
<
button style="font:10px Arial;height:15px;height:16px;border:0px;" onfocus="this.blur()">GetDate</button

<
button onclick="alert(m.getTime())" style="font:8px Webdings;width:15px;height:15px;line-height:6px;">4</button
<
button style="font:10px Arial;height:15px;height:16px;border:0px;" onfocus="this.blur()">GetTime</button
</
td
</
tr
</
table> ;


如履薄冰

起来
如履薄冰

這好像不錯呀

look

rfg

弓虽

ffdsa

呵呵~~