diff --git a/README.md b/README.md index 225b5b6..812b390 100644 --- a/README.md +++ b/README.md @@ -11,4 +11,11 @@ By clicking on the task this will set it to the current task in the timer. This ## Completing task -By clicking on the task in the current task will move it to the completed tasks and remove from the Todo list \ No newline at end of file +By clicking on the task in the current task will move it to the completed tasks and remove from the Todo list + +## Development + +``` +npm install +npm run dev +``` \ No newline at end of file diff --git a/src/modules/timer/controller.mjs b/src/modules/timer/controller.mjs index ecdeed0..3a5108c 100644 --- a/src/modules/timer/controller.mjs +++ b/src/modules/timer/controller.mjs @@ -18,30 +18,30 @@ const TimerController = { */ startTimer: function () { this.model.start(); - // Use a faster timeout for local testing - const timeout = - window.location.hostname === 'localhost' || - window.location.hostname === '127.0.0.1' - ? 1 - : 1000; + // // Use a faster timeout for local testing + // const timeout = + // window.location.hostname === 'localhost' || + // window.location.hostname === '127.0.0.1' + // ? 1 + // : 1000; // Only start a new timer if one is not already running - if (!this.countDown === null) return; - this.countDown = window.setInterval(() => { - //Make sure the timer is running and not paused - if (this.model.running) { - // Check if the timer has ended, if it has determine the next course of action - if (this.model.currentTime <= 0) { - this.model.stop(); - this.model.next(); - } else { - /** - * Decrease the timer - */ - this.model.decrease(); - } - } - // renderTimer(); - }, timeout); + // if (!this.countDown === null) return; + // this.countDown = window.setInterval(() => { + // //Make sure the timer is running and not paused + // if (this.model.running) { + // // Check if the timer has ended, if it has determine the next course of action + // if (this.model.currentTime <= 0) { + // this.model.stop(); + // this.model.next(); + // } else { + // /** + // * Decrease the timer + // */ + // this.model.decrease(); + // } + // } + // // renderTimer(); + // }, timeout); }, /** * Pause the timer diff --git a/src/modules/timer/model.mjs b/src/modules/timer/model.mjs index 55b3bde..7a02ca2 100644 --- a/src/modules/timer/model.mjs +++ b/src/modules/timer/model.mjs @@ -8,6 +8,7 @@ const TimerModel = { pompoms: 0, pubSub: null, subject: 'timer', + countDown: null, /** * Load the object with all its default settings */ @@ -15,6 +16,30 @@ const TimerModel = { // console.log(PubSub); this.pubSub = PubSub; this.publish(); + + // Use a faster timeout for local testing + const timeout = + window.location.hostname === 'localhost' || + window.location.hostname === '127.0.0.1' + ? 10 + : 1000; + + // create the timer once + this.countDown = window.setInterval(() => { + //Make sure the timer is running and not paused + if (this.running) { + // Check if the timer has ended, if it has determine the next course of action + if (this.currentTime <= 0) { + this.stop(); + this.next(); + } else { + /** + * Decrease the timer + */ + this.decrease(); + } + } + }, timeout); }, publish: function () { this.pubSub.publish(this);