Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="sf-caution-time-box" data-time='1346364000000'>
- <div class="sf-caution-inner">
- <div class="sf-countdown-days">
- <div class="count">--</div>
- <div class="units">DAYS</div>
- </div>
- <div class="sf-countdown-hours">
- <div class="count">--</div>
- <div class="units">HOURS</div>
- </div>
- <div class="sf-countdown-minutes">
- <div class="count">--</div>
- <div class="units">MINS</div>
- </div>
- <div class="sf-countdown-seconds">
- <div class="count">--</div>
- <div class="units">SECS</div>
- </div>
- </div>
- </div>
- </div>
- var sf = sf || {};
- sf.home = (function ($) {
- var myStartTime,
- times,
- timerElms;
- function init(){
- if($('.sf-caution-time-box').length > 0){
- var d = new Date();
- myStartTime = d.getTime();
- times = [];
- timerElms = $('.sf-caution-time-box');
- $('.sf-caution-time-box').each(function(i,elm){
- times.push($(elm).attr('data-time'));
- })
- setInterval(calculateTime,1000);
- calculateTime();
- }
- $('.sf-fb-icon').bind('click',function(e){ sf.tracker.trackFacebookFollow()});
- $('.sf-tweet-icon').bind('click',function(e){ sf.tracker.trackTwitterFollow()});
- }
- function calculateTime(){
- var d = new Date();
- var nowTime = d.getTime();
- var secsPassed = nowTime - myStartTime;
- timerElms.each(function(i,elm){
- var d = Math.floor((times[i] - LOAD_TIME - secsPassed)/86400000);
- var h = Math.floor((times[i] -LOAD_TIME - secsPassed) / (1000*60*60));
- var m = Math.floor((times[i] - LOAD_TIME - secsPassed) % (1000*60*60)) / (1000*60);
- var s = Math.floor((((times[i] - LOAD_TIME - secsPassed) % (1000*60*60)) % (1000*60)) / 1000);
- h = Math.floor(h%24);
- m = Math.floor(m%60);
- s = Math.floor(s%60);
- var ds = "" + d;
- var hs = "" + h;
- var ms = "" + m;
- var ss = "" + s;
- if(ds.length < 2){
- ds = "0"+ds;
- }
- if(hs.length < 2){
- hs = "0"+hs;
- }
- if(ms.length < 2){
- ms = "0"+ms;
- }
- if(ss.length < 2){
- ss = "0"+ss;
- }
- elm =$(elm);
- elm.find('.sf-countdown-days').find('.count').text(ds);
- elm.find('.sf-countdown-hours').find('.count').text(hs);
- elm.find('.sf-countdown-minutes').find('.count').text(ms);
- elm.find('.sf-countdown-seconds').find('.count').text(ss);
- })
- }
- return {
- init:init
- };
- })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement