PageSourceSearch

https://muziekgieterij.nl/wp-content/plugins/mg-assets/assets/js/flipdown.js?ver=1732991635

js muziekgieterij.nl collected 2026-09-24 21:41:32 UTC 10,565 bytes, 275 lines download raw bytes

vendor: 10,565 bytes, lines 1-275
1"use strict";
2/*test*/
3function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
5function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
8
9function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
10
11var FlipDown = function () {
12    function FlipDown(uts) {
13        var el = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "flipdown";
14        var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
15
16        _classCallCheck(this, FlipDown);
17
18        if (typeof uts !== "number") {
19            throw new Error("FlipDown: Constructor expected unix timestamp, got ".concat(_typeof(uts), " instead."));
20        }
21
22        if (_typeof(el) === "object") {
23            opt = el;
24            el = "flipdown";
25        }
26
27        this.version = "0.3.2";
28        this.initialised = false;
29        this.now = this._getTime();
30        this.epoch = uts;
31        this.countdownEnded = false;
32        this.hasEndedCallback = null;
33        this.element = document.getElementById(el);
34        this.rotors = [];
35        this.rotorLeafFront = [];
36        this.rotorLeafRear = [];
37        this.rotorTops = [];
38        this.rotorBottoms = [];
39        this.countdown = null;
40        this.daysRemaining = 0;
41        this.clockValues = {};
42        this.clockStrings = {};
43        this.clockValuesAsString = [];
44        this.prevClockValuesAsString = [];
45        this.opts = this._parseOptions(opt);
46
47        this._setOptions();
48    }
49
50    _createClass(FlipDown, [{
51        key: "start",
52        value: function start() {
53            if (!this.initialised) this._init();
54            this.countdown = setInterval(this._tick.bind(this), 1000);
55            return this;
56        }
57    }, {
58        key: "ifEnded",
59        value: function ifEnded(cb) {
60            this.hasEndedCallback = function () {
61                cb();
62                this.hasEndedCallback = null;
63            };
64
65            return this;
66        }
67    }, {
68        key: "_getTime",
69        value: function _getTime() {
70            return new Date().getTime() / 1000;
71        }
72    }, {
73        key: "_hasCountdownEnded",
74        value: function _hasCountdownEnded() {
75            if (this.epoch - this.now < 0) {
76                this.countdownEnded = true;
77
78                if (this.hasEndedCallback != null) {
79                    this.hasEndedCallback();
80                    this.hasEndedCallback = null;
81                }
82
83                return true;
84            } else {
85                this.countdownEnded = false;
86                return false;
87            }
88        }
89    }, {
90        key: "_parseOptions",
91        value: function _parseOptions(opt) {
92            var headings = ["Days", "Hours", "Minutes", "Seconds"];
93
94            if (opt.headings && opt.headings.length === 4) {
95                headings = opt.headings;
96            }
97
98            return {
99                theme: opt.hasOwnProperty("theme") ? opt.theme : "dark",
100                headings: headings
101            };
102        }
103    }, {
104        key: "_setOptions",
105        value: function _setOptions() {
106            this.element.classList.add("flipdown__theme-".concat(this.opts.theme));
107        }
108    }, {
109        key: "_init",
110        value: function _init() {
111            this.initialised = true;
112
113            if (this._hasCountdownEnded()) {
114                this.daysremaining = 0;
115            } else {
116                this.daysremaining = Math.floor((this.epoch - this.now) / 86400).toString().length;
117            }
118
119            var dayRotorCount = this.daysremaining <= 2 ? 2 : this.daysremaining;
120
121            for (var i = 0; i < dayRotorCount + 6; i++) {
122                this.rotors.push(this._createRotor(0));
123            }
124
125            var dayRotors = [];
126
127            for (var i = 0; i < dayRotorCount; i++) {
128                dayRotors.push(this.rotors[i]);
129            }
130
131            this.element.appendChild(this._createRotorGroup(dayRotors, 0));
132            var count = dayRotorCount;
133
134            for (var i = 0; i < 3; i++) {
135                var otherRotors = [];
136
137                for (var j = 0; j < 2; j++) {
138                    otherRotors.push(this.rotors[count]);
139                    count++;
140                }
141
142                this.element.appendChild(this._createRotorGroup(otherRotors, i + 1));
143            }
144
145            this.rotorLeafFront = Array.prototype.slice.call(this.element.getElementsByClassName("rotor-leaf-front"));
146            this.rotorLeafRear = Array.prototype.slice.call(this.element.getElementsByClassName("rotor-leaf-rear"));
147            this.rotorTop = Array.prototype.slice.call(this.element.getElementsByClassName("rotor-top"));
148            this.rotorBottom = Array.prototype.slice.call(this.element.getElementsByClassName("rotor-bottom"));
149
150            this._tick();
151
152            this._updateClockValues(true);
153
154            return this;
155        }
156    }, {
157        key: "_createRotorGroup",
158        value: function _createRotorGroup(rotors, rotorIndex) {
159            var rotorGroup = document.createElement("div");
160            rotorGroup.className = "rotor-group";
161            var dayRotorGroupHeading = document.createElement("div");
162            dayRotorGroupHeading.className = "rotor-group-heading";
163            dayRotorGroupHeading.setAttribute("data-before", this.opts.headings[rotorIndex]);
164            rotorGroup.appendChild(dayRotorGroupHeading);
165            appendChildren(rotorGroup, rotors);
166            return rotorGroup;
167        }
168    }, {
169        key: "_createRotor",
170        value: function _createRotor() {
171            var v = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
172            var rotor = document.createElement("div");
173            var rotorLeaf = document.createElement("div");
174            var rotorLeafRear = document.createElement("figure");
175            var rotorLeafFront = document.createElement("figure");
176            var rotorTop = document.createElement("div");
177            var rotorBottom = document.createElement("div");
178            rotor.className = "rotor";
179            rotorLeaf.className = "rotor-leaf";
180            rotorLeafRear.className = "rotor-leaf-rear";
181            rotorLeafFront.className = "rotor-leaf-front";
182            rotorTop.className = "rotor-top";
183            rotorBottom.className = "rotor-bottom";
184            rotorLeafRear.textContent = v;
185            rotorTop.textContent = v;
186            rotorBottom.textContent = v;
187            appendChildren(rotor, [rotorLeaf, rotorTop, rotorBottom]);
188            appendChildren(rotorLeaf, [rotorLeafRear, rotorLeafFront]);
189            return rotor;
190        }
191    }, {
192        key: "_tick",
193        value: function _tick() {
194            this.now = this._getTime();
195            var diff = this.epoch - this.now <= 0 ? 0 : this.epoch - this.now;
196            this.clockValues.d = Math.floor(diff / 86400);
197            diff -= this.clockValues.d * 86400;
198            this.clockValues.h = Math.floor(diff / 3600);
199            diff -= this.clockValues.h * 3600;
200            this.clockValues.m = Math.floor(diff / 60);
201            diff -= this.clockValues.m * 60;
202            this.clockValues.s = Math.floor(diff);
203
204            this._updateClockValues();
205
206            this._hasCountdownEnded();
207        }
208    }, {
209        key: "_updateClockValues",
210        value: function _updateClockValues() {
211            var _this = this;
212
213            var init = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
214            this.clockStrings.d = pad(this.clockValues.d, 2);
215            this.clockStrings.h = pad(this.clockValues.h, 2);
216            this.clockStrings.m = pad(this.clockValues.m, 2);
217            this.clockStrings.s = pad(this.clockValues.s, 2);
218            this.clockValuesAsString = (this.clockStrings.d + this.clockStrings.h + this.clockStrings.m + this.clockStrings.s).split("");
219            this.rotorLeafFront.forEach(function (el, i) {
220                el.textContent = _this.prevClockValuesAsString[i];
221            });
222            this.rotorBottom.forEach(function (el, i) {
223                el.textContent = _this.prevClockValuesAsString[i];
224            });
225
226            function rotorTopFlip() {
227                var _this2 = this;
228
229                this.rotorTop.forEach(function (el, i) {
230                    if (el.textContent != _this2.clockValuesAsString[i]) {
231                        el.textContent = _this2.clockValuesAsString[i];
232                    }
233                });
234            }
235
236            function rotorLeafRearFlip() {
237                var _this3 = this;
238
239                this.rotorLeafRear.forEach(function (el, i) {
240                    if (el.textContent != _this3.clockValuesAsString[i]) {
241                        el.textContent = _this3.clockValuesAsString[i];
242                        el.parentElement.classList.add("flipped");
243                        var flip = setInterval(function () {
244                            el.parentElement.classList.remove("flipped");
245                            clearInterval(flip);
246                        }.bind(_this3), 500);
247                    }
248                });
249            }
250
251            if (!init) {
252                setTimeout(rotorTopFlip.bind(this), 500);
253                setTimeout(rotorLeafRearFlip.bind(this), 500);
254            } else {
255                rotorTopFlip.call(this);
256                rotorLeafRearFlip.call(this);
257            }
258
259            this.prevClockValuesAsString = this.clockValuesAsString;
260        }
261    }]);
262
263    return FlipDown;
264}();
265
266function pad(n, len) {
267    n = n.toString();
268    return n.length < len ? pad("0" + n, len) : n;
269}
270
271function appendChildren(parent, children) {
272    children.forEach(function (el) {
273        parent.appendChild(el);
274    });
275}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.