![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/www/html/libs/absol-full/dist/js/ |
Upload File : |
/*** module: node_modules/absol-acomp/js/CountdownClock.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _ACore = _interopRequireDefault(require("../ACore")); var _Element = _interopRequireDefault(require("absol/src/HTML5/Element")); require("../css/countdownclock.css"); var _ResizeSystem = _interopRequireDefault(require("absol/src/HTML5/ResizeSystem")); var _int = require("absol/src/Math/int"); var _ = _ACore.default._; var $ = _ACore.default.$; /*** * @extends AElement * @constructor */ function CountdownClock() { var thisC = this; this.$attachhook = _('attachhook').addTo(this).on('attached', function () { _ResizeSystem.default.add(this); this.requestUpdateSize(); if (thisC.autoStart) { thisC.start(); } }); this.$attachhook.requestUpdateSize = this._updateBorder.bind(this); this._tick = this._tick.bind(this); this.$border = $(".as-countdown-clock-border", this); this.$min = $(".as-countdown-clock-min", this); this.$sec = $(".as-countdown-clock-sec", this); this._prevText = -1; this._startTime = new Date().getTime(); this._totalSecond = 60; this._remainSecond = 0; this.totalSecond = 60; this.remainSecond = 0; this._intvId = -1; } CountdownClock.tag = 'CountdownClock'.toLowerCase(); CountdownClock.render = function () { return _({ extendEvent: ['finish', 'update'], class: 'as-countdown-clock', child: [{ class: 'as-countdown-clock-text', child: [{ tag: 'span', class: 'as-countdown-clock-min', child: { text: 0 } }, { text: ':' }, { tag: 'span', class: 'as-countdown-clock-sec', child: { text: '60' } }] }, { class: 'as-countdown-clock-border-wrapper', child: { class: 'as-countdown-clock-border' } }] }); }; CountdownClock.prototype._makePolygon = function (end) { var n = Math.ceil(Math.max(end / 0.2, 2)); var fan = Array(n).fill(0).map(function (u, i) { var angle = -Math.PI / 2 + end * i / n; return [(0, _int.numberAutoFixed)(50 + 60 * Math.cos(angle), 5) + '%', (0, _int.numberAutoFixed)(50 + 60 * Math.sin(angle), 5) + '%'].join(' '); }); fan.push('50% 50%'); return 'polygon(' + fan.join(', ') + ')'; }; CountdownClock.prototype._setBorderValue = function (val) { if (val >= 1 || !isFinite(val)) { this.$border.removeStyle("clip-path"); return; } var bound = this.$border.getBoundingClientRect(); var angle = val * Math.PI * 2; this.$border.addStyle("-webkit-clip-path", this._makePolygon(angle)); this.$border.addStyle("clip-path", this._makePolygon(angle)); }; CountdownClock.prototype._updateBorder = function () { this._setBorderValue(this._remainSecond / Math.max(0.001, this._totalSecond)); }; CountdownClock.prototype._updateText = function () { if (this._prevText === this.remainSecond) return; var remainSecond = this.remainSecond; var min = Math.floor(remainSecond / 60); var sec = remainSecond % 60; this.$sec.innerHTML = (sec < 10 ? "0" : "") + sec; this.$min.innerHTML = min; }; CountdownClock.prototype._tick = function () { var now = new Date().getTime(); var prevSec = this.remainSecond; this.remainSecond = Math.max(0, Math.ceil(this.totalSecond - (now - this._startTime) / 1000)); if (prevSec !== this.remainSecond) { this._updateText(); this.emit('update', { target: this, type: 'update' }, this); if (this.remainSecond === 0) { clearInterval(this._intvId); this._intvId = -1; this.emit('finish', { target: this, type: 'finish' }, this); } } }; CountdownClock.prototype.start = function () { if (this.remainSecond == 0) this.remainSecond = this.totalSecond; this._startTime = new Date().getTime() - (this.totalSecond - this.remainSecond) * 1000; this.resume(); }; CountdownClock.prototype.resume = function () { if (this._intvId > 0) return; this._intvId = setInterval(this._tick, 200); }; CountdownClock.prototype.pause = function () { if (this._intvId > 0) { clearInterval(this._intvId); this._intvId = -1; } }; CountdownClock.prototype.stop = function () { this.pause(); this.remainSecond = 0; }; CountdownClock.prototype.reset = function () { this.remainSecond = this.totalSecond; this._startTime = new Date().getTime(); }; CountdownClock.property = {}; CountdownClock.property.totalSecond = { set: function (value) { if (!(value >= 0)) { value = 0; } this._totalSecond = value; this._updateBorder(); }, get: function () { return this._totalSecond; } }; CountdownClock.property.remainSecond = { set: function (value) { if (!(value >= 0)) { value = 0; } this._remainSecond = value; this._updateBorder(); this._updateText(); }, get: function () { return this._remainSecond; } }; _ACore.default.install(CountdownClock); var _default = CountdownClock; exports.default = _default;