I've created for a mine project a simple countdown script in JS, I think it's easy to use and really flexible.
Here is the code:
<script>
function countdown() {
var yourdate = new Date("April 12, 2013 9:30:00");
var now = new Date();
var timeDifference = yourdate.getTime() - now.getTime();
if (timeDifference <= 0) {
clearTimeout(timer);
//any other code to run on countdown completition
}
var seconds = Math.floor(timeDifference / 1000);
var minutes = Math.floor(seconds / 60);
var hours = Math.floor(minutes / 60);
var days = Math.floor(hours / 24);
hours %= 24;
minutes %= 60;
seconds %= 60;
document.getElementById("days").innerHTML = days;
document.getElementById("hours").innerHTML = hours;
document.getElementById("minutes").innerHTML = minutes;
document.getElementById("seconds").innerHTML = seconds;
var timer = setTimeout('countdown()',1000);
}
</script>
<style>
#cdcontainer{
text-align: center;
}
#countdown li{
display: inline;
list-style-type: none;
padding-right: 10px;
font-size: 60px;
background: #1560BD;
}
</style>
<body onload="countdown()">
<div id="cdcontainer">
<ul id="countdown">
<li id="days"></li>
<li id="hours"></li>
<li id="minutes"></li>
<li id="seconds"></li>
</ul>
</div>
</body>
This code is shared in the same license of the blog (creative commons, for more info check the end of the page)
I hope this simple script will help you, for any information comment or send me an e-mail to damianoandre@gmail.com
Bye, Dami
mercoledì 20 febbraio 2013
domenica 10 febbraio 2013
Ice lamp
Today I'm gonna talk about a cool and simple project: an ice lamp.
To start you need:
-rubber balloon
-1 LED
-some wires
-a 9v battery
First of all solder or connect in any other way the LED with you wires.
Then fill the balloon of water and put the LED with its wires inside (some water should get out).
To start you need:
-rubber balloon
-1 LED
-some wires
-a 9v battery
First of all solder or connect in any other way the LED with you wires.
Then fill the balloon of water and put the LED with its wires inside (some water should get out).
Now put the balloon in a freezer for about 3 hours.
After 3 hours connect your wires to 9v battery and the LED should light up.
Here are some photos of the final result:
Iscriviti a:
Post (Atom)