Guest_imported
New member
- Jan 1, 1970
- 0
Please help me with A CS problem.
I need to set this up so the animation only runs when the alarm is on and the counter is showing a negitive number. Can anyone Help me?
<html>
<head>
<title>prog5T</title>
<script>
/*DEFINITIONS:
"running" starts "false" but is "true" after the timer has been started and remains "true" until a reset occurs
"counting" starts "false" and is toggled by the start stop button
"dirup" starts "true" and defines the direction up or down that the timer counts and is toggled up the direction button
"init" is the value from which the timer is set to start counting
"alarm" starts false but becomes "true" when "count" is negative and starts the twinkles anmation if "alarmon" is "true"
When alarmon is "false" the twinkles animation does not turn on when alarm=true
*/
function Start_Stop_Button()
{thetime=new Date();
counting=!counting;
if(running==false){start=thetime; running=true ;}else
{delt=thetime-start; document.myForm.Counter.value="Count="+(init+((dirup==true)?delt:-delt)/1000)+"secs"}
}
function Reset_Button()
{running=false;
init=+document.myForm.Initcount.value;//NOTE TYPE CONVERSION to try to get number
alarm=false; counting=false;
if (isNaN(init)){init=0; document.myForm.Initcount.value="Enter value of counter here (reset to zero as default)"};
document.myForm.Counter.value="Count="+init+"secs";
}
function Direction_Button()
{document.myForm.Direction.value=(dirup==false)?'Count Up':'Count Down';
dirup=!dirup;
}
function pclock()
{time=new Date();
document.myForm.Date_Time.value=time;
if(counting==true){count=init+(time-start)*((dirup==true)? 1:-1)/1000;
document.myForm.Counter.value="Count="+count+"secs";
if(count<0) {alarm=true}else {alarm=false};}
setTimeout("pclock();",100);
}
}
function Alarmset_button()
{document.myForm.Alarmset.value=
/* Following function definitions variables are initialized
*/
running=false; counting=false ; dirup=true; init=0; alarmon=true; alarm=false;
</script>
</head>
<body text="#FFFFFF" bgcolor="#000000" onload="pclock();">
<!-- The following are the layer definitions for Gwen' twinkles -->
<LAYER NAME="a" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#FFFF00"
CLIP="0,0,15,15"></LAYER>
<LAYER NAME="b" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#FFFF00"
CLIP="0,0,15,15"></LAYER>
<LAYER NAME="c" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#FFFF00"
CLIP="0,0,15,15"></LAYER>
<LAYER NAME="d" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#FFFF00"
CLIP="0,0,15,15"></LAYER>
<LAYER NAME="e" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#FFFF00"
CLIP="0,0,15,15"></LAYER>
<LAYER NAME="f" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#FFFF00"
CLIP="0,0,15,15"></LAYER>
<LAYER NAME="g" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#FFFF00"
CLIP="0,0,15,15"></LAYER>
<script LANGUAGE="JavaScript" SRC="twinkleT.js"></script>
<form NAME="myForm"><input TYPE = "text" NAME = "Date_Time" SIZE = 60><font color="#FFFF00">
<font size=+1><a href=" TARGET="GOV CLOCK">Click here for Official US Government Time</a>
</font></font><p>
<input TYPE = "text" NAME = "Initcount" Value= "Enter value of counter here (reset to zero as default" SIZE = 60>
<input TYPE="button" NAME="Direction" VALUE="Count Up " onClick="Direction_Button()">
<input TYPE="button" VALUE="Reset Count" onClick="Reset_Button()">
<input TYPE = "text" NAME = "Counter" SIZE = 20>
<input TYPE="button" VALUE="Start/Stop" onClick="Start_Stop_Button()">
<input TYPE="button" NAME="Alarmset" VALUE=" Alarm On "
onClick="this.value=(alarmon==false)?' Alarm On':' Alarm Off';alarmon=!alarmon"></form>
</body>
</html>
I need to set this up so the animation only runs when the alarm is on and the counter is showing a negitive number. Can anyone Help me?
<html>
<head>
<title>prog5T</title>
<script>
/*DEFINITIONS:
"running" starts "false" but is "true" after the timer has been started and remains "true" until a reset occurs
"counting" starts "false" and is toggled by the start stop button
"dirup" starts "true" and defines the direction up or down that the timer counts and is toggled up the direction button
"init" is the value from which the timer is set to start counting
"alarm" starts false but becomes "true" when "count" is negative and starts the twinkles anmation if "alarmon" is "true"
When alarmon is "false" the twinkles animation does not turn on when alarm=true
*/
function Start_Stop_Button()
{thetime=new Date();
counting=!counting;
if(running==false){start=thetime; running=true ;}else
{delt=thetime-start; document.myForm.Counter.value="Count="+(init+((dirup==true)?delt:-delt)/1000)+"secs"}
}
function Reset_Button()
{running=false;
init=+document.myForm.Initcount.value;//NOTE TYPE CONVERSION to try to get number
alarm=false; counting=false;
if (isNaN(init)){init=0; document.myForm.Initcount.value="Enter value of counter here (reset to zero as default)"};
document.myForm.Counter.value="Count="+init+"secs";
}
function Direction_Button()
{document.myForm.Direction.value=(dirup==false)?'Count Up':'Count Down';
dirup=!dirup;
}
function pclock()
{time=new Date();
document.myForm.Date_Time.value=time;
if(counting==true){count=init+(time-start)*((dirup==true)? 1:-1)/1000;
document.myForm.Counter.value="Count="+count+"secs";
if(count<0) {alarm=true}else {alarm=false};}
setTimeout("pclock();",100);
}
}
function Alarmset_button()
{document.myForm.Alarmset.value=
/* Following function definitions variables are initialized
*/
running=false; counting=false ; dirup=true; init=0; alarmon=true; alarm=false;
</script>
</head>
<body text="#FFFFFF" bgcolor="#000000" onload="pclock();">
<!-- The following are the layer definitions for Gwen' twinkles -->
<LAYER NAME="a" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#FFFF00"
CLIP="0,0,15,15"></LAYER>
<LAYER NAME="b" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#FFFF00"
CLIP="0,0,15,15"></LAYER>
<LAYER NAME="c" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#FFFF00"
CLIP="0,0,15,15"></LAYER>
<LAYER NAME="d" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#FFFF00"
CLIP="0,0,15,15"></LAYER>
<LAYER NAME="e" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#FFFF00"
CLIP="0,0,15,15"></LAYER>
<LAYER NAME="f" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#FFFF00"
CLIP="0,0,15,15"></LAYER>
<LAYER NAME="g" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#FFFF00"
CLIP="0,0,15,15"></LAYER>
<script LANGUAGE="JavaScript" SRC="twinkleT.js"></script>
<form NAME="myForm"><input TYPE = "text" NAME = "Date_Time" SIZE = 60><font color="#FFFF00">
<font size=+1><a href=" TARGET="GOV CLOCK">Click here for Official US Government Time</a>
</font></font><p>
<input TYPE = "text" NAME = "Initcount" Value= "Enter value of counter here (reset to zero as default" SIZE = 60>
<input TYPE="button" NAME="Direction" VALUE="Count Up " onClick="Direction_Button()">
<input TYPE="button" VALUE="Reset Count" onClick="Reset_Button()">
<input TYPE = "text" NAME = "Counter" SIZE = 20>
<input TYPE="button" VALUE="Start/Stop" onClick="Start_Stop_Button()">
<input TYPE="button" NAME="Alarmset" VALUE=" Alarm On "
onClick="this.value=(alarmon==false)?' Alarm On':' Alarm Off';alarmon=!alarmon"></form>
</body>
</html>