daily pastebin goal
60%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var tick = function(init) {
  2.     if (init == undefined) {
  3.         init = false;
  4.     }
  5.     var current_time = new Date();
  6.     current_time = current_time.valueOf();
  7.     if (current_time > target_time) {
  8.         var time = new Date();
  9.         target_time = new Date(time.getFullYear(), time.getMonth(), time.getDate());
  10.         target_time = target_time.valueOf()+1000*60*60*24*45;          
  11.     }
  12.  
  13.     var time_diff = Math.floor((target_time - current_time)/1000);
  14.     //alert(time_diff);
  15.     var second_2 = time_diff % 10; time_diff = Math.floor(time_diff/10);
  16.     var second_1 = time_diff % 6; time_diff = Math.floor(time_diff/6);
  17.     var minute_2 = time_diff % 10; time_diff = Math.floor(time_diff/10);
  18.     var minute_1 = time_diff % 6; time_diff = Math.floor(time_diff/6);
  19.     var hour_2 = time_diff % 10; time_diff = Math.floor(time_diff/10);
  20.     var hour_1 = time_diff % 6; time_diff = Math.floor(time_diff/6);
  21.  
  22.     var day_2 = Math.floor(time_diff/24);
  23.     var day_1 = time_diff % 24;
  24.  
  25.     set_slide('span.secondPlay', second_2);
  26.  
  27.     if ((second_2 == 9) || init) {set_slide('span.second6Play', second_1);
  28.     if ((second_1 == 5) || init) {set_slide('span.minutePlay', minute_2);
  29.     if ((minute_2 == 9) || init) {set_slide('span.minute6Play', minute_1);
  30.     if ((minute_1 == 5) || init) {set_slide('span.hourPlay', hour_2);
  31.     if ((hour_2 == 9) || init) {set_slide('span.hour2Play', hour_1);
  32.  
  33.     if ((hour_1 == 1) || init) {set_slide('span.dayPlay', day_2);
  34.     if ((day_2 == 9) || init) {set_slide('span.day1Play', day_1);}}}}}}}
  35.   }
  36. tick(true);
  37. setInterval(tick, 1000);
  38.    
  39. <div class="timer">
  40.                             <div class="container" style = 'padding-top:0px;'>
  41.                                 <div class="days">
  42.                                     <span class="flip day1Play"></span>
  43.                                     <span class="flip dayPlay"></span>
  44.                                     <em>дней</em>
  45.                                 </div>
  46.                                 <div class="hours">
  47.                                     <span class="flip hour2Play"></span>
  48.                                     <span class="flip hourPlay"></span>
  49.                                     <em>часов</em>
  50.                                 </div>
  51.                                 <div class="minutes">
  52.                                     <span class="flip minute6Play"></span>
  53.                                     <span class="flip minutePlay"></span>
  54.                                     <em>минут</em>
  55.                                 </div>
  56.                                 <div class="seconds">
  57.                                     <span class="flip second6Play"></span>
  58.                                     <span class="flip secondPlay"></span>
  59.                                     <em>секунд</em>
  60.                                 </div>
  61.                             </div>
  62.                         </div>
  63.    
  64. day_2 = (time_diff / (60 * 60 * 24)) % 10;    
  65. day_1 = Math.floor( (time_diff / (60 * 60 * 24)) / 10);
  66.    
  67. var time_diff = Math.floor((target_time - current_time)/1000);
  68.  
  69. day_2 = (time_diff / (60 * 60 * 24)) % 10;    
  70. day_1 = Math.floor( (time_diff / (60 * 60 * 24)) / 10);  
  71.  
  72. var second_2 = time_diff % 10; time_diff = Math.floor(time_diff/10);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top