80 lines
No EOL
3 KiB
HTML
80 lines
No EOL
3 KiB
HTML
<head>
|
|
<title>Alarm</title>
|
|
<meta name=viewport content=width=240>
|
|
<script type="text/javascript">
|
|
var jsalarm={
|
|
padfield:function(f){
|
|
return (f<10)? "0"+f : f
|
|
},
|
|
showcurrenttime:function(){
|
|
var dateobj=new Date()
|
|
var ct=this.padfield(dateobj.getHours())+":"+this.padfield(dateobj.getMinutes())+":"+this.padfield(dateobj.getSeconds())
|
|
this.ctref.innerHTML=ct
|
|
this.ctref.setAttribute("title", ct)
|
|
if (typeof this.hourwake!="undefined"){ //if alarm is set
|
|
if (this.ctref.title==(this.hourwake+":"+this.minutewake+":"+this.secondwake)){
|
|
clearInterval(jsalarm.timer)
|
|
window.location=document.getElementById("musicloc").value
|
|
}
|
|
}
|
|
},
|
|
init:function(){
|
|
var dateobj=new Date()
|
|
this.ctref=document.getElementById("jsalarm_ct")
|
|
this.submitref=document.getElementById("submitbutton")
|
|
this.submitref.onclick=function(){
|
|
jsalarm.setalarm()
|
|
this.value="Alarm Set"
|
|
this.disabled=true
|
|
return false
|
|
}
|
|
this.resetref=document.getElementById("resetbutton")
|
|
this.resetref.onclick=function(){
|
|
jsalarm.submitref.disabled=false
|
|
jsalarm.hourwake=undefined
|
|
jsalarm.hourselect.disabled=false
|
|
jsalarm.minuteselect.disabled=false
|
|
jsalarm.secondselect.disabled=false
|
|
return false
|
|
}
|
|
var selections=document.getElementsByTagName("select")
|
|
this.hourselect=selections[0]
|
|
this.minuteselect=selections[1]
|
|
this.secondselect=selections[2]
|
|
for (var i=0; i<60; i++){
|
|
if (i<24) //If still within range of hours field: 0-23
|
|
this.hourselect[i]=new Option(this.padfield(i), this.padfield(i), false, dateobj.getHours()==i)
|
|
this.minuteselect[i]=new Option(this.padfield(i), this.padfield(i), false, dateobj.getMinutes()==i)
|
|
this.secondselect[i]=new Option(this.padfield(i), this.padfield(i), false, dateobj.getSeconds()==i)
|
|
|
|
}
|
|
jsalarm.showcurrenttime()
|
|
jsalarm.timer=setInterval(function(){jsalarm.showcurrenttime()}, 1000)
|
|
},
|
|
setalarm:function(){
|
|
this.hourwake=this.hourselect.options[this.hourselect.selectedIndex].value
|
|
this.minutewake=this.minuteselect.options[this.minuteselect.selectedIndex].value
|
|
this.secondwake=this.secondselect.options[this.secondselect.selectedIndex].value
|
|
this.hourselect.disabled=true
|
|
this.minuteselect.disabled=true
|
|
this.secondselect.disabled=true
|
|
}
|
|
}
|
|
</script>
|
|
</head>
|
|
<body bgcolor=khaki>
|
|
<center><font size=1>
|
|
<form action="" method="">
|
|
<div id="jsalarmclock">
|
|
<div><div class="leftcolumn"></div>
|
|
<span id="jsalarm_ct" style="letter-spacing: 2px"></span></div>
|
|
<div><p><div class="leftcolumn">Set Alarm:</div><p> Hour: <span><select></select></span> Minutes: <span><select></select></span> <br>Seconds: <span><select></select></span></div>
|
|
<div><div class="leftcolumn">Alarm Action:</div>
|
|
<input type="text" id="musicloc" size="25" value="javascript:alert('BEEP BEEP BEEP BEEP');" /></div>
|
|
<input type="submit" value="Set Alarm!" id="submitbutton" />
|
|
<input type="reset" value="Reset" id="resetbutton" /> <input type="button" value="STOP" onclick="javascript:history.go(-1)" />
|
|
</div>
|
|
</form>
|
|
<script type="text/javascript">
|
|
jsalarm.init()
|
|
</script></body> |