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UAAYP,EAC7B1B,KAAKW,aAAasB,UAAYjC,KAAKqB,kBAAkBS,GACrD9B,KAAKa,eAAeoB,UAAYjC,KAAKqB,kBAAkBU,GACvD/B,KAAKe,eAAekB,UAAYjC,KAAKqB,kBAAkBW,GAEnDP,EAAW,GACbS,SAASC,S,CAIb,MAAOC,G,CAGX,CAGA,OAAAC,GACA,E,uGC1DK,SAASC,KACZ,IAAAC,8BAAwC,EAAA9C,UAAW,EAAAe,YAAYC,qBAAqB,EAAAP,eAAeT,UAAUA,WAAY+C,EAC7H,CAEA,SAASA,EAAiBC,GACtB,IAAIC,EAAe,IAAI,EAAAjD,UAAUgD,GAC3BE,OAAQ,KAAOF,EAAexC,aAAa,EAAAC,eAAeT,UAAUA,WAAa,aAAeiD,CAC1G,C","sources":["webpack://LoBSiteTemplates/./src/components/countdown/countdownController.ts","webpack://LoBSiteTemplates/./src/components/countdown/countdownInitialiser.ts"],"sourcesContent":["import { InstanceComponentBase } from '../../shared/instanceComponentBase';\r\nimport { AttributeEnums } from '../../shared/utilities/enums/attributeEnums';\r\nimport { HelperUtils } from '../../shared/utilities/helperUtils';\r\n\r\n\r\nexport class Countdown extends InstanceComponentBase {\r\n private expiryDate: Date = new Date(this.htmlElement.getAttribute(AttributeEnums.Countdown.CountdownExpires));\r\n private expiryDateDistance = this.expiryDate.getTime();\r\n\r\n private DaysElement: HTMLElement | null = this.htmlElement.querySelector(HelperUtils.addDataAttributeTags(AttributeEnums.Countdown.CountdownDays));\r\n private HoursElement: HTMLElement | null = this.htmlElement.querySelector(HelperUtils.addDataAttributeTags(AttributeEnums.Countdown.CountdownHours));\r\n private MinutesElement: HTMLElement | null = this.htmlElement.querySelector(HelperUtils.addDataAttributeTags(AttributeEnums.Countdown.CountdownMinutes));\r\n private SecondsElement: HTMLElement | null = this.htmlElement.querySelector(HelperUtils.addDataAttributeTags(AttributeEnums.Countdown.CountdownSeconds));\r\n\r\n constructor(public htmlElement: Element) {\r\n super(htmlElement);\r\n this.startCountdown();\r\n }\r\n\r\n startCountdown() {\r\n let countInterval;\r\n if (new Date().getTime() < this.expiryDateDistance) {\r\n countInterval = setInterval((): void => {\r\n this.updatePage();\r\n }, 1000);\r\n }\r\n }\r\n\r\n forceTwoCarecters(string: string) {\r\n if (string.length === 1) {\r\n string = \"0\" + string;\r\n }\r\n return string;\r\n }\r\n\r\n updatePage() {\r\n let now = new Date().getTime();\r\n let distance: number = this.expiryDateDistance - now;\r\n\r\n let days: string = Math.floor(distance / (1000 * 60 * 60 * 24)).toString();\r\n let hours: string = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)).toString();\r\n let minutes: string = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)).toString();\r\n let seconds: string = Math.floor((distance % (1000 * 60)) / 1000).toString();\r\n\r\n try {\r\n if(this.DaysElement !== null && this.HoursElement !== null && this.MinutesElement !== null && this.SecondsElement !== null){\r\n this.DaysElement.innerHTML = days;\r\n this.HoursElement.innerHTML = this.forceTwoCarecters(hours);\r\n this.MinutesElement.innerHTML = this.forceTwoCarecters(minutes);\r\n this.SecondsElement.innerHTML = this.forceTwoCarecters(seconds);\r\n \r\n if (distance < 0) {\r\n location.reload();\r\n }\r\n }\r\n\r\n } catch (error) {\r\n console.log(`Countdown: updatePage Error`);\r\n }\r\n }\r\n\r\n //------ Clean Up Processes Start -----//\r\n dispose(): void {\r\n }\r\n //------ Clean Up Processes End -----//\r\n}","import { initialiseInstanceComponents } from '../../shared/instanceComponentInitialiser';\r\nimport { AttributeEnums } from '../../shared/utilities/enums/attributeEnums';\r\nimport { HelperUtils } from '../../shared/utilities/helperUtils';\r\nimport { Countdown } from './countdownController';\r\n\r\nexport function initialiseCountdown() {\r\n initialiseInstanceComponents<Countdown>(Countdown, HelperUtils.addDataAttributeTags(AttributeEnums.Countdown.Countdown), countdownFactory);\r\n}\r\n\r\nfunction countdownFactory(currentElement: Element): void {\r\n let newCountdown = new Countdown(currentElement);\r\n (<any>window)['sh' + currentElement.getAttribute(AttributeEnums.Countdown.Countdown) + 'Countdown'] = newCountdown;\r\n}"],"names":["Countdown","InstanceComponentBase","constructor","htmlElement","super","expiryDate","Date","this","getAttribute","AttributeEnums","CountdownExpires","expiryDateDistance","getTime","DaysElement","querySelector","HelperUtils","addDataAttributeTags","CountdownDays","HoursElement","CountdownHours","MinutesElement","CountdownMinutes","SecondsElement","CountdownSeconds","startCountdown","countInterval","setInterval","updatePage","forceTwoCarecters","string","length","now","distance","days","Math","floor","toString","hours","minutes","seconds","innerHTML","location","reload","error","dispose","initialiseCountdown","initialiseInstanceComponents","countdownFactory","currentElement","newCountdown","window"],"sourceRoot":""}