1'use strict'; 2 3var _createClass = function () { function 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 4 5function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 6 7(function () { 8 9 'use strict'; 10 11 var CountDown = function () { 12 function CountDown(container) { 13 _classCallCheck(this, CountDown); 14 15 this.container = container; 16 this.date = moment(container.getAttribute('data-time'), 'X'); 17 this.setCount = this.setCount.bind(this); 18 this.refreshDate = this.refreshDate.bind(this); 19 } 20 21 _createClass(CountDown, [{ 22 key: 'setCount', 23 value: function setCount() { 24 var _this = this; 25 26 setInterval(function () { 27 _this.refreshDate(); 28 }, 1000); 29 } 30 }, { 31 key: 'secondsToHms', 32 value: function secondsToHms(diff) { 33 var days = void 0, 34 hours = void 0, 35 minutes = void 0, 36 seconds = void 0; 37 seconds = diff; 38 minutes = Math.floor(seconds / 60); 39 seconds = seconds % 60; 40 hours = Math.floor(minutes / 60); 41 minutes = minutes % 60; 42 days = Math.floor(hours / 24); 43 hours = hours % 24; 44 return { 45 days: days, 46 hours: hours, 47 minutes: minutes, 48 seconds: seconds 49 }; 50 } 51 }, { 52 key: 'refreshDate', 53 value: function refreshDate() { 54 var now = moment(); 55 var diff = this.date.diff(now, 'seconds'); 56 var refresh = this.secondsToHms(diff); 57 var elements = ['days', 'hours', 'minutes', 'seconds']; 58 for (var index = 0; index < elements.length; index++) { 59 var element = elements[index]; 60 if (this.container.querySelector('.' + element).innerText != refresh[element]) this.container.querySelector('.' + element).innerText = refresh[element]; 61 } 62 } 63 }]); 64 65 return CountDown; 66 }(); 67 68 setTimeout(function () { 69 if (document.querySelector('.countdown')) { 70 var countdowns = document.querySelectorAll('.countdown'); 71 for (var index = 0; index < countdowns.length; index++) { 72 var countdown = new CountDown(countdowns[index]); 73 countdown.setCount(); 74 } 75 } 76 }, 300); 77})(); 78//# sourceMappingURL=countdown.js.map
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.