tethys.backend/resources/js/utils/Timer.js
Arno Kaimbacher 87e9314b00 - added NcModal.vue, NcActions.vue, NcButton.vue, FirstrunWizard.vue, Card.vue, Page0.vue, Page1.vue, Page2.vue, Page3.vue and some icons
- added lime color inside tailwind.config.js
- added some utilities scripts needed for components
- npm updates
- changed postcss.config.js for nesting css styles
- added about function to NavBar.vue
2023-12-21 09:30:21 +01:00

44 lines
859 B
JavaScript

/**
* @param {Function} callback The function to call
* @param {number} delay The time to wait
*/
export default function timer(callback, delay) {
let id;
let started;
let remaining = delay;
let running;
this.start = function () {
running = true;
started = new Date();
id = setTimeout(callback, remaining);
};
this.pause = function () {
running = false;
clearTimeout(id);
remaining -= new Date() - started;
};
this.clear = function () {
running = false;
clearTimeout(id);
remaining = 0;
};
this.getTimeLeft = function () {
if (running) {
this.pause();
this.start();
}
return remaining;
};
this.getStateRunning = function () {
return running;
};
this.start();
}