Skip to content

Instantly share code, notes, and snippets.

@MiLk
Created October 21, 2011 15:14
Show Gist options
  • Save MiLk/1304086 to your computer and use it in GitHub Desktop.
Save MiLk/1304086 to your computer and use it in GitHub Desktop.
<!--JOURS-->
<div class="jours">
<img src="./images/landing/compteur/1.png" width="46" height="66" alt="1" class="jours_01"/>
<img src="./images/landing/compteur/5.png" width="46" height="66" alt="5" class="jours_02"/>
<img src="./images/landing/compteur/7.png" width="46" height="66" alt="7" class="jours_03"/>
</div>
<!--HEURES-->
<div class="heures">
<img src="./images/landing/compteur/2.png" width="46" height="66" alt="2" class="heures_01"/>
<img src="./images/landing/compteur/4.png" width="46" height="66" alt="4" class="heures_02"/>
</div>
<!--MINUTES-->
<div class="minutes">
<img src="./images/landing/compteur/5.png" width="46" height="66" alt="5" class="minutes_01"/>
<img src="./images/landing/compteur/9.png" width="46" height="66" alt="9" class="minutes_02"/>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
function Rebour() {
var date1 = new Date();
var date2 = new Date ("Feb 01 12:00:00 2012");
var sec = (date2 - date1) / 1000;
var n = 24 * 3600;
if (sec > 0) {
j = Math.floor (sec / n);
h = Math.floor ((sec - (j * n)) / 3600);
mn = Math.floor ((sec - ((j * n + h * 3600))) / 60);
sec = Math.floor (sec - ((j * n + h * 3600 + mn * 60)));
j += '';
h += '';
mn += '';
sec += '';
if(j.length < 2)
j = "00"+j;
else if(j.length < 3)
j = "0"+j;
if(h.length < 2)
h = "0"+h;
if(mn.length < 2)
mn = "0"+mn;
if(sec.length < 2)
sec = "0"+sec;
$(".compteur .jours_01").attr("src","./images/landing/compteur/"+j.charAt(0)+".png");
$(".compteur .jours_02").attr("src","./images/landing/compteur/"+j.charAt(1)+".png");
$(".compteur .jours_03").attr("src","./images/landing/compteur/"+j.charAt(2)+".png");
$(".compteur .heures_01").attr("src","./images/landing/compteur/"+h.charAt(0)+".png");
$(".compteur .heures_02").attr("src","./images/landing/compteur/"+h.charAt(1)+".png");
$(".compteur .minutes_01").attr("src","./images/landing/compteur/"+mn.charAt(0)+".png");
$(".compteur .minutes_02").attr("src","./images/landing/compteur/"+mn.charAt(1)+".png");
}
setTimeout("Rebour();", 1000);
}
$(document).ready(function() {
Rebour();
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment