Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions jquery.timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,32 +283,38 @@

/**
* @param {function=} updateFunction
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind updating the docblock? (also for the set function below)

* @param {boolean=} autostart
*/
function Stopwatch(updateFunction) {
function Stopwatch(updateFunction, autostart) {

if (typeof this == "function" || this.init) {
return new Stopwatch(updateFunction);
return new Stopwatch(updateFunction, autostart);
}

this.set(updateFunction);
this.set(updateFunction, autostart);

return this;
}

/**
* @param {function=} updateFunction
* @param {boolean=} autostart
*/
Stopwatch.prototype.set = function(updateFunction) {
Stopwatch.prototype.set = function(updateFunction, autostart) {

if (typeof updateFunction != "function") {
return;
}

this.init = true;
this.updateFunction = updateFunction;
this.startTime = new Date().getTime();
this.startTime = 0;
this.pauseStart = 0;
this.setInterval();

if (autostart) {
this.startTime = new Date().getTime();
this.setInterval();
}

};

Expand Down