Browse Source

fixing

master
azri 4 months ago
parent
commit
b7add733ba
1 changed files with 56 additions and 49 deletions
  1. 56
    49
      resources/js/app.js

+ 56
- 49
resources/js/app.js View File

@@ -3,54 +3,6 @@ import './bootstrap';
3 3
 import '@fortawesome/fontawesome-free/css/all.min.css';
4 4
 
5 5
 
6
-//Countdown date (adjust this date to your desired countdown target)
7
-const countdownDate = new Date('2024-08-17T11:00:00').getTime();
8
-
9
-//Update the countdown every second
10
-const countdownElement = document.getElementById('countdown');
11
-const countdownTimer = setInterval(() => {
12
-    //Get the current date and time
13
-    const now = new Date().getTime();
14
-
15
-    //Calculate the time remaining
16
-    const distance = countdownDate - now;
17
-
18
-    //Calculate days, hours, minutes, and seconds
19
-    const days = Math.floor(distance / (1000 * 60 * 60 * 24));
20
-    const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
21
-    const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
22
-    const seconds = Math.floor((distance % (1000 * 60)) / 1000);
23
-
24
-    //Format the countdown into a string
25
-    const countdownHTML = `
26
-        <div class="flex flex-col">
27
-            <div class="flex gap-8 justify-center">
28
-                <div class="font-medium text-gray-500">${days}</div>
29
-                <div class="font-medium text-gray-500">:</div>
30
-                <div class="font-medium text-gray-500">${hours.toString().padStart(2, '0')}</div>
31
-                <div class="font-medium text-gray-500">:</div>
32
-                <div class="font-medium text-gray-500">${minutes.toString().padStart(2, '0')}</div>
33
-                <div class="font-medium text-gray-500">:</div>
34
-                <div class="font-medium text-gray-500">${seconds.toString().padStart(2, '0')}</div>
35
-            </div>
36
-            <div class="flex gap-14 justify-center">
37
-                <div class="font-medium text-gray-600">Hari</div>
38
-                <div class="font-medium text-gray-600">Jam</div>
39
-                <div class="font-medium text-gray-600">Minit</div>
40
-                <div class="font-medium text-gray-600">Saat</div>
41
-            </div>
42
-        </div>
43
-    `;
44
-
45
-    //Display the countdown in the element
46
-    countdownElement.innerHTML = countdownHTML;
47
-
48
-    //If the countdown is over, clear the timer and display a message
49
-    if (distance < 0) {
50
-        clearInterval(countdownTimer);
51
-        countdownElement.innerHTML = 'Majlis berlangsung';
52
-    }
53
-}, 1000); // Update every second (1000 milliseconds)
54 6
 
55 7
 document.addEventListener('DOMContentLoaded', function () {
56 8
 
@@ -85,6 +37,10 @@ document.addEventListener('click', function () {
85 37
         }, 600)
86 38
     }
87 39
 
40
+    setTimeout(()=>{
41
+        eventCountdown();
42
+    },2000)
43
+
88 44
 });
89 45
 
90 46
 function smoothScrollBy(distance, duration) {
@@ -105,7 +61,6 @@ function smoothScrollBy(distance, duration) {
105 61
     requestAnimationFrame(scroll);
106 62
 }
107 63
 
108
-
109 64
 // to ensure all images is loaded before starting animation and gimmick
110 65
 function imageLoading() {
111 66
     const images = document.querySelectorAll("img");
@@ -175,3 +130,55 @@ function playMusic(){
175 130
         }
176 131
     }
177 132
 }
133
+
134
+function eventCountdown(){
135
+
136
+//Countdown date (adjust this date to your desired countdown target)
137
+const countdownDate = new Date('2024-08-17T11:00:00').getTime();
138
+
139
+//Update the countdown every second
140
+const countdownElement = document.getElementById('countdown');
141
+const countdownTimer = setInterval(() => {
142
+    //Get the current date and time
143
+    const now = new Date().getTime();
144
+
145
+    //Calculate the time remaining
146
+    const distance = countdownDate - now;
147
+
148
+    //Calculate days, hours, minutes, and seconds
149
+    const days = Math.floor(distance / (1000 * 60 * 60 * 24));
150
+    const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
151
+    const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
152
+    const seconds = Math.floor((distance % (1000 * 60)) / 1000);
153
+
154
+    //Format the countdown into a string
155
+    const countdownHTML = `
156
+        <div class="flex flex-col">
157
+            <div class="flex gap-8 justify-center">
158
+                <div class="font-medium text-gray-500">${days}</div>
159
+                <div class="font-medium text-gray-500">:</div>
160
+                <div class="font-medium text-gray-500">${hours.toString().padStart(2, '0')}</div>
161
+                <div class="font-medium text-gray-500">:</div>
162
+                <div class="font-medium text-gray-500">${minutes.toString().padStart(2, '0')}</div>
163
+                <div class="font-medium text-gray-500">:</div>
164
+                <div class="font-medium text-gray-500">${seconds.toString().padStart(2, '0')}</div>
165
+            </div>
166
+            <div class="flex gap-14 justify-center">
167
+                <div class="font-medium text-gray-600">Hari</div>
168
+                <div class="font-medium text-gray-600">Jam</div>
169
+                <div class="font-medium text-gray-600">Minit</div>
170
+                <div class="font-medium text-gray-600">Saat</div>
171
+            </div>
172
+        </div>
173
+    `;
174
+
175
+    //Display the countdown in the element
176
+    countdownElement.innerHTML = countdownHTML;
177
+
178
+    //If the countdown is over, clear the timer and display a message
179
+    if (distance < 0) {
180
+        clearInterval(countdownTimer);
181
+        countdownElement.innerHTML = 'Majlis berlangsung';
182
+    }
183
+}, 1000); // Update every second (1000 milliseconds)
184
+}

Loading…
Cancel
Save