From 82496dc3f6aca4335522ef143609e899e24980b3 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Cura Date: Fri, 1 Jan 2010 00:44:54 +0100 Subject: [PATCH] [svn r39] add icon + manage message --- newyear.css | 2 +- newyear.js | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/newyear.css b/newyear.css index fffa623..0422761 100644 --- a/newyear.css +++ b/newyear.css @@ -14,5 +14,5 @@ div.new_year_count_css { text-align:center; color:red; - font-size:500px; + font-size:250px; } diff --git a/newyear.js b/newyear.js index de661d3..6c88916 100644 --- a/newyear.js +++ b/newyear.js @@ -47,16 +47,34 @@ function Pause(time) /*Get controls*/ var new_year_text = document.getElementById("new_year_text"); var new_year_count = document.getElementById("new_year_count"); -var next_year_val = new Date().getFullYear() + 1; -var next_year = new Date("01/01/" + next_year_val + " 00:00:00"); +var next_year_val; +var next_year; var coef=1000; +function calcNextYear() +{ + next_year_val = new Date().getFullYear() + 1; + next_year = new Date("01/01/" + next_year_val + " 00:00:00"); +} function CountDown() { /*Init years*/ var now = new Date(); - new_year_count.innerHTML = Math.round((next_year.getTime() - now.getTime()) / coef) + " s"; - setTimeout("CountDown()",100); + var countdown = Math.round((next_year.getTime() - now.getTime()) / coef); + if(countdown < 1 ) + { + new_year_count.innerHTML = "BONNE ANNE !! YOUPI"; + if(countdown > -60) + { + calcNextYear(); + } + } + else + { + new_year_count.innerHTML = countdown + " s"; + } + setTimeout("CountDown()",250); } +calcNextYear(); CountDown(); \ No newline at end of file