|
<style>
div{}
button{}
</style>
<div id=\"dd\"> </div>
<script type=\"text/javascript\">
<!--
String.prototype.format = function(){
var tmpStr = this;
var iLen = arguments.length;
for(var i=0;i<iLen;i++){
tmpStr = tmpStr.replace(new RegExp(\"\\{\" + i + \"\\}\", \"g\"), arguments);
}
return tmpStr;
}
Number.prototype.We = function(bt){
var byte = bt || 2;
var data = this.toString();
return (new Array(byte + 1).join(\"0\") + data).substring(data.length);
}
function $() {
var elements = new Array();
for (var i = 0; i < arguments.length; i++) {
var element = arguments;
if (typeof element == ’string’)
element = document.getElementById(element);
if (arguments.length == 1)
return element;
elements.push(element);
}
return elements;
}
function CountDown(){
var ref = this;
var temp = \"\";
this.Timer = null;
this.Max = 0;
this.Current = 0;
this.Element = null;
this.Format = \"mm:ss\";
this.Step = 1000;
function formatDate(template, input){
var day = input / 60 /60 /24 | 0;
var hour = (input - day * 60* 60 * 24) / 60 /60 | 0;
var minute = (input - day * 60* 60 * 24 - hour * 60 * 60) / 60 | 0;
var second = input - day * 60* 60 * 24 - hour * 60 * 60 - minute * 60;
if(temp == \"\"){
temp = template.replace(/dd/g, \"{0}\").replace(/d/g, \"{1}\");
temp = temp.replace(/hh/g, \"{2}\").replace(/h/g, \"{3}\");
temp = temp.replace(/mm/g, \"{4}\").replace(/m/g, \"{5}\");
temp = temp.replace(/ss/g, \"{6}\").replace(/s/g, \"{7}\");
}
return temp.format(day.We(), day, hour.We(), hour, minute.We(), minute, second.We(), second)
}
this.Reset = function(){
this.Clear();
this.Current = this.Max;
}
this.Create = function(element){
if(typeof(element) == \"string\"){
if($(element) == null)document.write(\"<div id=\\"{0}\\"></div>\".format(element));
this.Element = $(element);
} else this.Element = element;
}
this.Start = function(){
this.OnBeforeStart();
this.Clear();
if(this.Current == 0)this.Current = this.Max;
this.Timer = setInterval(this.ShowText, this.Step);
}
this.Stop = function(){
this.Reset();
this.OnStop();
}
this.Pause = function(){
this.Clear();
this.OnPause();
}
this.Clear = function(){
if(this.Timer != null)clearInterval(this.Timer);
}
this.ShowText = function(){
with(ref){
if(--Current > -1) Element.innerText = formatDate(Format, Current);
else {Clear();OnTimeOut();};
}
}
this.OnBeforeStart = function(){}
this.OnStop = function(){}
this.OnPause = function(){}
this.OnTimeOut = function(){}
this.toString = function(){
return \"DHTML CountDown\";
}
}
var cd = new CountDown();
cd.Create(\"ddd\");
cd.Max = 60;
cd.Start();
cd.OnTimeOut = function(){alert(\"时间到!\");}
var cd1 = new CountDown();
cd1.Format = \"d天 h小时:mm:ss\";
cd1.Create(\"dd\");
cd1.Max = 300000;
cd1.Start();
//-->
</script>
<button onclick=\"cd.Pause()\">Time2 Pause</button>
<button onclick=\"cd.Start()\">Time2 Start</button>
<div contentEditable style=\"ime-mode[s:4]isabled\">123</div>
<input style=\"ime-mode[s:4]isabled\" value=\"123\"> |
广告, 技术, 空间, 系统, 服务器, 教程, 破解, 服务器, 诺德尔, 破解, 3389, 服务器, 锐起, 网吧, 无盘, 教程, 绿茶, 诺德尔, 软件, 系统, 诺德尔, 绿茶, 系统, FTP, Windows, 系统, 电脑, 教程, 网络, ROS, ROS, ROS, 路由, 路由, linux, 网络,
|