PageSourceSearch

https://www.nivea.co.id/dist/NiveaX/modules/Countdown-Countdown.82a7606b.js

js nivea.co.id collected 2026-10-05 23:16:23 UTC 6,689 bytes, 2 lines download raw bytes

1"use strict";(self.NiveaXwebpackJsonp=self.NiveaXwebpackJsonp||[]).push([[1378],{94542:(t,e,n)=>{n.r(e),n.d(e,{default:()=>a});var s=n(98684),o=n(930);const i='[data-module="Countdown"]';var r,u;!function(t){t.weeks="weeks",t.days="days",t.hours="hours",t.minutes="minutes",t.seconds="seconds"}(r||(r={})),function(t){t.days="days",t.weeks="weeks",t.hoursMinutesSeconds="hoursMinutesSeconds"}(u||(u={}));class a{static setup(t=i){Array.from(document.querySelectorAll(t)).filter(t=>!t.dataset.moduleInitialized).forEach(t=>{new a(t),t.dataset.moduleInitialized="true"})}constructor(t){this.element=t,this.init()}init(){this.targetDateTime=this.getTargetDateTime(),this.targetDateTime&&(this.initTimeToTarget(),this.initCountdownFormat(),this.createTimeElements(),this.startCountdown())}getTargetDateTime(){let t=this.element.getAttribute("data-target-datetime");if(!t)return;return new Date(t)}initTimeToTarget(){this.updateWeeksToTarget(),this.updateDaysToTarget(),this.updateHoursMinutesSecondsToTarget()}initCountdownFormat(){const t=this.element.getAttribute("data-format");this.currentCountdownFormat=u[t]?u[t]:u.hoursMinutesSeconds,this.updateCurrentCountdownFormat()}createTimeElements(){this.currentCountdownFormat==u.weeks&&this.weeksToTarget>0?this.createWeeksElement():this.currentCountdownFormat==u.days&&this.daysToTarget>0?this.createDaysElement():this.createHoursMinutesSecondsElement()}startCountdown(){const t=setInterval(()=>{this.countdown(t)},1e3)}getMsToTarget(){const t=new Date;return this.targetDateTime.getTime()-t.getTime()}updateDaysToTarget(){this.daysToTarget=this.getTimeToTargetIn(r.days)}updateWeeksToTarget(){this.weeksToTarget=this.getTimeToTargetIn(r.weeks)}updateHoursMinutesSecondsToTarget(){this.hoursToTarget=this.getTimeToTargetIn(r.hours),this.minutesToTarget=this.getTimeToTargetIn(r.minutes),this.secondsToTarget=this.getTimeToTargetIn(r.seconds)}updateCurrentCountdownFormat(){this.currentCountdownFormat==u.weeks&&this.weeksToTarget<1&&(this.currentCountdownFormat=u.days,this.removeCountdownTimeUnitElement(r.weeks),this.createDaysElement()),this.currentCountdownFormat==u.days&&this.daysToTarget<1&&(this.currentCountdownFormat=u.hoursMinutesSeconds,this.removeCountdownTimeUnitElement(r.days),this.createHoursMinutesSecondsElement())}removeCountdownTimeUnitElement(t){const e=this.element.querySelector(".nx-countdown__time-unit-"+t);if(e){const t=e.closest(".nx-countdown__time");null==t||t.remove()}}createHoursMinutesSecondsElement(){this.createHoursElement(),this.createMinutesElement(),this.createSecondsElement()}createWeeksElement(){const t=(0,o.z1)(r.weeks,this.weeksToTarget.toString(),this.element.getAttribute("data-weeks-label")),e=this.element.querySelector(".nx-countdown__time-container");null==e||e.appendChild(t)}createDaysElement(){var t;if(!this.element.querySelector(".nx-countdown__time-unit-"+r.days)){const e=(0,o.z1)(r.days,this.daysToTarget.toString(),this.element.getAttribute("data-days-label"));null===(t=this.element.querySelector(".nx-countdown__time-container"))||void 0===t||t.appendChild(e)}}createHoursElement(){if(!this.element.querySelector(".nx-countdown__time-unit-"+r.hours)){const t=this.element.querySelector(".nx-countdown__time-container");null==t||t.appendChild((0,o.z1)(r.hours,this.getTimeStringWithPreZero(this.hoursToTarget),this.element.getAttribute("data-hours-label"))),null==t||t.appendChild((0,o.Nq)(r.hours))}}createMinutesElement(){if(!this.element.querySelector(".nx-countdown__time-unit-"+r.minutes)){const t=this.element.querySelector(".nx-countdown__time-container");null==t||t.appendChild((0,o.z1)(r.minutes,this.getTimeStringWithPreZero(this.minutesToTarget),this.element.getAttribute("data-minutes-label"))),null==t||t.appendChild((0,o.Nq)(r.minutes))}}createSecondsElement(){if(!this.element.querySelector(".nx-countdown__time-unit-"+r.seconds)){const t=this.element.querySelector(".nx-countdown__time-container");null==t||t.appendChild((0,o.z1)(r.seconds,this.getTimeStringWithPreZero(this.secondsToTarget),this.element.getAttribute("data-seconds-label")))}}getTimeToTargetIn(t){const e=this.getMsToTarget();switch(t){case r.weeks:{const t=Math.floor(e/6048e5);return t>=0?t:0}case r.days:{const t=Math.floor(e/864e5);return t>=0?t:0}case r.hours:{const t=Math.floor(e/36e5);return t>=0?t:0}case r.minutes:{const t=Math.floor(e%36e5/6e4);return t>=0?t:0}case r.seconds:{const t=Math.floor(e%6e4/1e3);return t>=0?t:0}default:return}}countdown(t){if(this.currentCountdownFormat==u.weeks){const t=this.weeksToTarget;this.updateWeeksToTarget(),this.updateCurrentCountdownFormat(),t!=this.weeksToTarget&&this.updateWeeksElement()}if(this.currentCountdownFormat==u.days){const t=this.daysToTarget;this.updateDaysToTarget(),this.updateCurrentCountdownFormat(),t!=this.daysToTarget&&this.updateDaysElement()}if(this.currentCountdownFormat==u.hoursMinutesSeconds){const t=this.hoursToTarget,e=this.minutesToTarget;this.updateHoursMinutesSecondsToTarget(),this.updateCurrentCountdownFormat(),t!=this.hoursToTarget&&this.updateHoursElement(),e!=this.minutesToTarget&&this.updateMinuteElement(),this.updateSecondsElement()}this.getMsToTarget()<0&&this.stopCountdown(t)}updateWeeksElement(){const t=this.element.querySelectorAll(".nx-countdown__time-unit-"+r.weeks);this.updateUnitSubElements(t,this.weeksToTarget,!1)}updateDaysElement(){const t=this.element.querySelectorAll(".nx-countdown__time-unit-"+r.days);this.updateUnitSubElements(t,this.daysToTarget,!1)}updateHoursElement(){const t=this.element.querySelectorAll(".nx-countdown__time-unit-"+r.hours);this.updateUnitSubElements(t,this.hoursToTarget,!0)}updateMinuteElement(){const t=this.element.querySelectorAll(".nx-countdown__time-unit-"+r.minutes);this.updateUnitSubElements(t,this.minutesToTarget,!0)}updateSecondsElement(){const t=this.element.querySelectorAll(".nx-countdown__time-unit-"+r.seconds);this.updateUnitSubElements(t,this.secondsToTarget,!0)}updateUnitSubElements(t,e,n){t.length>1&&t.forEach(t=>{t.classList.contains("nx-countdown__time-unit-a")?((0,s.jo)(t,"nx-countdown__time-unit--fade-in","nx-countdown__time-unit-a"),(0,s.gR)(t,"nx-countdown__time-unit--fade-out","nx-countdown__time-unit-b"),t.offsetHeight):t.classList.contains("nx-countdown__time-unit-b")&&(t.innerHTML=n?this.getTimeStringWithPreZero(e):e.toString(),(0,s.jo)(t,"nx-countdown__time-unit--fade-out","nx-countdown__time-unit-b"),(0,s.gR)(t,"nx-countdown__time-unit--fade-in","nx-countdown__time-unit-a"),t.offsetHeight)})}getTimeStringWithPreZero(t){let e=t.toString();return t<10&&(e="0".concat(e)),e}stopCountdown(t){clearInterval(t)}}a.setup(i)}}]);
2//# sourceMappingURL=/dist/NiveaX/./modules/Countdown-Countdown.82a7606b.js.0b94f9bc.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.