diff options
| author | root | 2014-09-13 22:26:58 +0200 |
|---|---|---|
| committer | root | 2014-09-13 22:26:58 +0200 |
| commit | c5639ee890215e4e8e0f544821ea8d285ca58eb8 (patch) | |
| tree | 29f685943c61c4d7ec0e376e485686e985b97065 /boring.js | |
| parent | f8c60cae423fc78ed21d17a9217716ccc1e6dab1 (diff) | |
| download | video-dl-c5639ee890215e4e8e0f544821ea8d285ca58eb8.tar.gz | |
init
Diffstat (limited to 'boring.js')
| -rw-r--r-- | boring.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/boring.js b/boring.js new file mode 100644 index 0000000..cd26733 --- /dev/null +++ b/boring.js @@ -0,0 +1,50 @@ +Function.prototype.Timer = function (interval, calls, onend) { + var count = 0; + var payloadFunction = this; + var startTime = new Date(); + var callbackFunction = function () { + return payloadFunction(startTime, count); + }; + var endFunction = function () { + if (onend) { + onend(startTime, count, calls); + } + }; + var timerFunction = function () { + count++; + if (count < calls && callbackFunction() != false) { + window.setTimeout(timerFunction, interval); + } else { + endFunction(); + } + }; + timerFunction(); + }; + +function leadingzero (number) { + return (number < 10) ? '0' + number : number; +} + +function countdown (seconds, target) { + var element = document.getElementById(target); + + var showTimer = function () { + if (seconds > 0) { + var m = Math.floor((seconds % 3600) / 60); + var s = seconds % 60; + element.innerHTML= + leadingzero(m) + ':' + + leadingzero(s); + seconds--; + } else { + return false; + } + }; + + var completed = function () { + printPlayer(); + }; + + showTimer.Timer(1000, Infinity, completed); +} + |
