C
CES
All,
I was wondering if someone could point me to a tutorial on creating & accessing functions from within a wrapper function.
I've created a group of functions related to a timer event. All works well until I try to enclose these functions into a class like structure ie:
function dTimer(div){
//Insert the Javascript Code Below
startTimer();
}
The problem seems to be with:
timerID = self.setTimeout("counterStatus()", delay);
But I can't figure out what the problem is. As always any guidance would be appreciated. Thanks in advance. - CES
--- Javascript ---
var secs = 5;
var timerID = null;
var timerRunning = false;
var delay = 1000;
function startTimer(){
stopTimer();
counterStatus();
}
function stopTimer(){
if(timerRunning != null){
clearTimeout(timerID);
timerRunning = false;
secs = 5;
}
}
function resetTimer(){
stopTimer();
}
function counterStatus(){
if (secs==0){
stopTimer();
// Due something(div);
}else{
secs = secs - 1;
timerRunning = true;
timerID = self.setTimeout("counterStatus()", delay);
}
}
---HTML---
<div id="test" style="width:100px; height:100px; background-color:Red;" onmouseout="startTimer('')" onmouseover="resetTimer('')">
</div>
I was wondering if someone could point me to a tutorial on creating & accessing functions from within a wrapper function.
I've created a group of functions related to a timer event. All works well until I try to enclose these functions into a class like structure ie:
function dTimer(div){
//Insert the Javascript Code Below
startTimer();
}
The problem seems to be with:
timerID = self.setTimeout("counterStatus()", delay);
But I can't figure out what the problem is. As always any guidance would be appreciated. Thanks in advance. - CES
--- Javascript ---
var secs = 5;
var timerID = null;
var timerRunning = false;
var delay = 1000;
function startTimer(){
stopTimer();
counterStatus();
}
function stopTimer(){
if(timerRunning != null){
clearTimeout(timerID);
timerRunning = false;
secs = 5;
}
}
function resetTimer(){
stopTimer();
}
function counterStatus(){
if (secs==0){
stopTimer();
// Due something(div);
}else{
secs = secs - 1;
timerRunning = true;
timerID = self.setTimeout("counterStatus()", delay);
}
}
---HTML---
<div id="test" style="width:100px; height:100px; background-color:Red;" onmouseout="startTimer('')" onmouseover="resetTimer('')">
</div>