Replace Zepto with ki.js, rewrite all JS
[plack-app-gruntmaster.git] / js / 90-timers.js
index 6ec5bdf82a66e416e5f725d5aa3ed55e9d233080..7281f6f3fd689a9d37c364ff335886660802038f 100644 (file)
@@ -1,35 +1,31 @@
-(function(){
-       'use strict';
+function update_timer(timer){
+       var start = parseInt(timer.dataset.start);
+       var stop  = parseInt(timer.dataset.stop);
+       var value = parseInt(timer.dataset.value);
+       var now   = Math.floor(Date.now() / 1000);
 
-       function update_timer(timer){
-               var start = parseInt(timer.dataset.start);
-               var stop  = parseInt(timer.dataset.stop);
-               var value = parseInt(timer.dataset.value);
-               var now   = Math.floor(Date.now() / 1000);
+       var left = stop - now;
+       var total = stop - start;
+       if(left < 0)
+               left = 0;
 
-               var left = stop - now;
-               var total = stop - start;
-               if(left < 0)
-                       left = 0;
-
-               if(value) {
-                       value = Math.max(value * 3 / 10, value * left / total);
-                       timer.innerHTML = Math.floor(value);
-               } else {
-                       var hours = left / 60 / 60;
-                       hours = hours < 10 ? '0' : hours : hours;
-                       var minutes = left / 60 % 60;
-                       minutes = minutes < 10 ? '0' : minutes : minutes;
-                       var seconds = left % 60;
-                       seconds = seconds < 10 ? '0' : seconds : seconds;
-                       timer.innerHTML = hours + ':' + minutes + ':' + seconds;
-               }
+       if(value) {
+               value = Math.max(value * 3 / 10, value * left / total);
+               timer.innerHTML = Math.floor(value);
+       } else {
+               var hours = left / 60 / 60;
+               hours = hours < 10 ? '0' + hours : hours;
+               var minutes = left / 60 % 60;
+               minutes = minutes < 10 ? '0' + minutes : minutes;
+               var seconds = left % 60;
+               seconds = seconds < 10 ? '0' + seconds : seconds;
+               timer.innerHTML = hours + ':' + minutes + ':' + seconds;
        }
+}
 
-       $( document ).ready(function() {
-               $('.timer').each(function(index, item){
-                       update_timer(item);
-                       setInterval(function(){update_timer(item)}, 1000);
-               });
+$(function() {
+       $('.timer').each(function(item){
+               update_timer(item);
+               setInterval(function(){update_timer(item)}, 1000);
        });
-})();
+});
This page took 0.0123 seconds and 4 git commands to generate.