PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

PHP ALARM CLOCK WITH AUDIO

Go down

PHP ALARM CLOCK WITH AUDIO Empty PHP ALARM CLOCK WITH AUDIO

Post by jamied_uk 24th November 2013, 22:09

Code:

<title>J~Net Alarm Clock</title>
<html>
<head>
<body style="background:#000070">
<font color="orange" font size="+1">
<center>
<script type="text/javascript">
// http://soundjax.com/alarm-1.html
function playSound(filename){  
document.getElementById("sound").innerHTML='<audio autoplay="autoplay"><source src="' + filename + '.mp3" type="audio/mpeg" /><source src="' + filename + '.ogg" type="audio/ogg" /><embed hidden="true" autostart="true" loop="false" src="' + filename +'.mp3" /></audio>';
}
var hv;
var mv;
var sv;
var timer;
var timer2;
function set(){
hv=document.getElementById("h").value*1;
mv=document.getElementById("m").value*1;
sv=document.getElementById("s").value*1;
}
function countup(){
if(sv!=59){
sv++
}
else if(mv!=59){
mv++
sv=0;
}
else if(hv!=59){
hv++
mv=0;
sv=0;
}
else{
playSound('alarm')
alert("Finished counting up!")
clearTimeout(timer);
}
if(sv<10){
sv2="0"+sv;
}
else{sv2=sv}
if(mv<10){
mv2="0"+mv;
}
else{mv2=mv}
if(hv<10){
hv2="0"+hv;
}
else{hv2=hv}
document.getElementById("h").value=hv2;
document.getElementById("m").value=mv2;
document.getElementById("s").value=sv2;
}
function countdown(){
if(sv!=00){
sv--
}
else if(mv!=00){
mv--
sv=59;
}
else if(hv!=00){
hv--
mv=59;
sv=59;
}
else{
playSound('alarm')
alert("Finished counting down!")
clearTimeout(timer2);
}
if(sv<10){
sv2="0"+sv;
}
else{sv2=sv}
if(mv<10){
mv2="0"+mv;
}
else{mv2=mv}
if(hv<10){
hv2="0"+hv;
}
else{hv2=hv}
document.getElementById("h").value=hv2;
document.getElementById("m").value=mv2;
document.getElementById("s").value=sv2;
}
function thetime(){
var d=new Date();
var hours=d.getHours();
var mins=d.getMinutes();
var secs=d.getSeconds();
if(hours<10){
hours="0"+hours;
}
if(mins<10){
mins="0"+mins;
}
if(secs<10){
secs="0"+secs;
}
document.getElementById("times").value=hours+":"+mins+":"+secs;
if(timer==true && hours==hv && mins==mv && secs==sv){
playSound('alarm')
alert("Alarm ringing!")
}
}
function alarmonoff(){
if(document.getElementById("alarmbut").value=="Turn alarm on/set"){
timer=true;
document.getElementById("alarmbut").value="Turn alarm off/set";
}
else{
timer=false;
document.getElementById("alarmbut").value="Turn alarm on/set";
}
}
</script>
<div style="float:center; height:auto; width:500px;background:#EBEBEB; margin-left:25px; margin-right:5px; border:#CCC 2px solid;">
<div id="sound"></div>
</head>

<body onload="setInterval('thetime()',500)">

<table border="0">
  <tr>
    <td colspan="2"><input value="00" size="2" id="h">:<input value="00" size="2" id="m">:<input value="00" size="2" id="s"></td>
  </tr>
  <tr>
    <td><input type="text" size="8" id="times"></td>
    <td><input type="button" value="Stop" onclick="set(); clearTimeout(timer); clearTimeout(timer2)"></td>
  </tr>
  <tr>
    <td><input type="button" value="Count up" onclick="set(); timer=setInterval('countup()',1000)"></td>
    <td><input type="button" value="Count down" onclick="set(); timer2=setInterval('countdown()',1000)"></td>
  </tr>
  <tr>
    <td colspan="2"><input type="button" value="Turn alarm on/set" onclick="set(); alarmonoff()" id="alarmbut"></td>
  </tr>
</table>

<h1>
<font color="orange" font size="+1">
<a href="/"target="_new" >Leave Alarm Counting And Continue Browsing</a><br><p>
</h1>
<div style="clear:left; height:24px;"></div>
</body>
</html> 
jamied_uk
jamied_uk
Admin

Posts : 2951
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum