Last active
April 19, 2016 08:41
-
-
Save omeha2/39c59e30167c1195640d046c20253a21 to your computer and use it in GitHub Desktop.
countdown which save in localstorage timer, for BVB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="bvb_bc_countdown bc_15_min"> | |
<span class="bvb_panel bvb_minute"> | |
<span class="tdigit">00</span> | |
<span class="tlabel">minutes</span> | |
</span> | |
<span class="bvb_panel bvb_sec"> | |
<span class="tdigit">00</span> | |
<span class="tlabel">seconds</span> | |
</span> | |
</div> | |
<script> | |
jQuery(function($){ | |
var old = localStorage.getItem("bc_start_timer"); | |
var default_time = 15*60; // 15 minutes | |
var end = default_time; | |
var current_date = new Date(); | |
if(old){ | |
var end_time = new Date(old); | |
end = default_time - (current_date - end_time)/1000; | |
}else{ | |
localStorage.setItem("bc_start_timer",current_date); | |
} | |
if(end>=1) | |
setInterval(function(){ | |
end--; | |
if(end<1) | |
return false; | |
var mins = Math.floor(end/60); | |
var secs = Math.floor(end - mins*60); | |
$('.bc_15_min .bvb_minute .tdigit').html(mins); | |
$('.bc_15_min .bvb_sec .tdigit').html(secs); | |
},1000); | |
}); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.bvb_bc_countdown { | |
text-align: center; | |
} | |
.bvb_bc_countdown .bvb_panel { | |
display: inline-block; | |
margin-right: 10px; | |
min-width: 120px; | |
color: #FFF; | |
} | |
.bvb_bc_countdown .tdigit { | |
font-size: 30px; | |
font-weight: 500; | |
display: inline-block; | |
width: 100%; | |
padding: 7px; | |
line-height: 100%; | |
background-color: #F86855; | |
} | |
.bvb_bc_countdown .tlabel { | |
font-size: 15px; | |
width: 100%; | |
display: inline-block; | |
line-height: 100%; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment