mirror of
https://github.com/rcon-web-admin/rcon-web-admin.git
synced 2026-12-04 08:48:11 +00:00
31 lines
644 B
JavaScript
31 lines
644 B
JavaScript
"use strict";
|
|
|
|
/**
|
|
* Global Interval Handling
|
|
*/
|
|
var Interval = {};
|
|
|
|
/** @type {object} */
|
|
Interval.list = {};
|
|
|
|
/**
|
|
* Create an interval, automatically destroy previous interval if exist
|
|
* @param {string} id
|
|
* @param {function} func
|
|
* @param {number} step
|
|
*/
|
|
Interval.create = function (id, func, step) {
|
|
Interval.destroy(id);
|
|
Interval.list[id] = setInterval(func, step);
|
|
};
|
|
|
|
/**
|
|
* Destroy an interval
|
|
* @param {string} id
|
|
*/
|
|
Interval.destroy = function (id) {
|
|
if (typeof Interval.list[id] != "undefined" && Interval.list[id] !== null) {
|
|
clearInterval(Interval.list[id]);
|
|
Interval.list[id] = null;
|
|
}
|
|
}; |