JS examples based on object-oriented implementation of multiple countdown

The examples of this paper describe the JS based on multiple countdown timer functions that are object-oriented. Share to everyone for reference, as follows:

The operational renderings are as follows:

Implementation code as follows: JS基于面向对象实现的多个倒计时器功能示例

Code

JavaScript test file
     0  hour     
Second
1 hour

2
hour
32

3
Hour
33
Hour

34 points
// Name Mount Metal: function mstimecount () {this._Hour = 0; // "Hour" THIS._MINUTE = 0; // "points" THIS._SECONDS = 0; // "Second" // this._Hourhtmlobj = {}; // "hour"HTML object this._minutehtmlobj = {}; //" points "html object this._secondshtmlobj = {}; //" second "HTML object // this._totalseconds = 0; // total second number}; mstimecount.prototype = {// 1. Get the object $: function (id) {Return Document.getElementById (ID);}, // 2. Initialization: / * * Arrtime: Incoming time array, format is [1, 30, 30], Represents 1 hour and 30 minutes 30 seconds; * Arrhtmlobj: Update time data HTML object array, format is ["Hour", "Minute", "Seconds"]; * / init: function (arRtime, arrhtmlobj) {var_this = this _THIS._HOUR = PARSEINT (Arrtime [0]); _this._minute = parseint (arrtime [1]); _this._seconds = parseint (arrtime [2]); _this._Hourtmlobj = _this. $ (arRhtmlobj [0]) ;. _this._minuteHtmlObj = _this $ (arrHtmlObj [1]);. _this._secondsHtmlObj = _this $ (arrHtmlObj [2]); _this._totalSeconds = parseInt (_this._hour * 60 * 60 + _this._minute * 60 + _this ._seconds); // Start timing: _this.timecount ();}, // 3. Timer: Timecount: function () {vAR _this = this; var tmptimecount = setInterval (function () {_this._totalseconds-; //lert(_this._totalseconds; _this.refreshtime (); if (_this._totalseconds 0) {_this._Hour = PARSEINT (_this._totalseconds / 3600); _this._minute = parseint ((_ this._totalseconds-_this._hu * 3600) / 60); _this._seconds = _this._totalseconds-_this._hour * 3600-_this._minute * 60; } else {_this._hour = _this._minute = _this._seconds = 0;} _this._hourHtmlObj.innerHTML = _this._hour; _this._minuteHtmlObj.innerHTML = _this._minute; _this._secondsHtmlObj.innerHTML = _this._seconds;}} Var timecount (); timecount0.init ([0,0,10], ["hour0", "minute0", "seconds0"]); var timecount1 = new mstimecount (); timecount1.init ([1, 31, 31], ["Hour1", "Minute11", "Seconds1"]); var timecount2 = new mstimecount); timecount2.init ([2, 32, 32], ["Hour2", "Minute2", "Seconds2"]); var timecount3 = new mstimecount (); timecount3.init ([3, 33, 33], [3, 33, 33] "Hour3", "Minute3", "Seconds3"]); var timecount4 = new mstimecount (); timecount4.init ([4, 34, 34], ["Hour4", "Minute4", "Seconds4"]);

PS: Here you recommend several time and timer related tools for your reference:
Online stopwatch tool: http://tools.jb51.net/bianmin/miaobiao
UNIX Timestamp Conversion Tool:
HTTP : //tools.jb51.net/code/unixtime
online time all over the world inquiry: http://tools.jb51.net/zhuanhuanqi/worldtime
Readers with JavaScript related content can be viewed on this site: "JavaScript Time and Date Operation Skill Summary", "JavaScript Object-Oriented Getting Tutorial", "JavaScript Error and Debugging Skills Summary", "JavaScript Data Structure Algorithm Tips Summary
© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment