My class structure is something like this:
var jpTWUI = function(id, connection){
this.id = id;
this.muteButton = "#mute";
this.hangupButton = "#hang";
this.transferButton = "#trans";
this.parentElement = jQuery('#timerCon');
this.connection = connection;
this.interval = "";
this.createElements();
this.addEvents();
};
jpTWUI.prototype = {
createElements: function(){ ... },
addEvents: function(){...},
startTimer: function(){...}
}
Now I have created an object and called the class something like this
var callHandler = new jpTWUI('timerCon', connection);
callHandler.startTimer();
But the problem is that the method startTimer has the setInterval function which display the duration in minutes and seconds.
I want to implement one more method like stopTimer which stop that startTimer's interval, I know I have to user window.clearInterval. but when I implemented the function stopTimer in the same class then I don't know how do I access that method with the class like:
var callHandler = new jpTWUI('timerCon', device);
callHandler.stopTimer();
Hope you guys understand what I want to achieve, this is first time I have used the class in javascript..
Please guide me is this approach is correct?? or how do i make it correct..
this.interval = setInterval(function(){..}, 1000)but i don't know how do i access this.interval into the stopTimer()..