|
@@ -233,7 +233,7 @@
|
233
|
233
|
</div>
|
234
|
234
|
<div class="modal-action">
|
235
|
235
|
<form method="dialog" id="closeCalendarForm"></form>
|
236
|
|
- <button type="button" class="btn bg-babybluedark">Simpan</button>
|
|
236
|
+ <button type="button" class="btn bg-babybluedark" id="saveDate">Simpan</button>
|
237
|
237
|
<button type="button" class="btn" id="submitCloseCalendarForm">Tutup</button>
|
238
|
238
|
</div>
|
239
|
239
|
</div>
|
|
@@ -247,4 +247,63 @@
|
247
|
247
|
});
|
248
|
248
|
});
|
249
|
249
|
</script>
|
|
250
|
+
|
|
251
|
+<script>
|
|
252
|
+ function getMobileOperatingSystem() {
|
|
253
|
+ var userAgent = navigator.userAgent || navigator.vendor || window.opera;
|
|
254
|
+
|
|
255
|
+ if (/windows phone/i.test(userAgent)) {
|
|
256
|
+ return "Windows Phone";
|
|
257
|
+ }
|
|
258
|
+
|
|
259
|
+ if (/android/i.test(userAgent)) {
|
|
260
|
+ return "Android";
|
|
261
|
+ }
|
|
262
|
+
|
|
263
|
+ if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
|
|
264
|
+ return "iOS";
|
|
265
|
+ }
|
|
266
|
+
|
|
267
|
+ return "unknown";
|
|
268
|
+ }
|
|
269
|
+
|
|
270
|
+ document.getElementById('saveDate').addEventListener('click', function () {
|
|
271
|
+ const os = getMobileOperatingSystem();
|
|
272
|
+ console.log("Operating System: " + os);
|
|
273
|
+
|
|
274
|
+ const title = 'Majlis Perkahwinan Aliff & Ayuna';
|
|
275
|
+ const startDate = '20240817T110000Z';
|
|
276
|
+ const endDate = '20240817T160000Z';
|
|
277
|
+ const details = 'Majlis Resepsi Perkawinan Aliff & Ayuna';
|
|
278
|
+ const location = 'Dewan Jubli Perak Sultan Haji Ahmad Shah, Jalan Teluk Sisek, Kuantan, Pahang';
|
|
279
|
+
|
|
280
|
+ if (os === 'iOS') {
|
|
281
|
+ const icsContent = `BEGIN:VCALENDAR
|
|
282
|
+ VERSION:2.0
|
|
283
|
+ BEGIN:VEVENT
|
|
284
|
+ SUMMARY:${title}
|
|
285
|
+ DTSTART:${startDate}
|
|
286
|
+ DTEND:${endDate}
|
|
287
|
+ DESCRIPTION:${details}
|
|
288
|
+ LOCATION:${location}
|
|
289
|
+ END:VEVENT
|
|
290
|
+ END:VCALENDAR`;
|
|
291
|
+
|
|
292
|
+ const blob = new Blob([icsContent], { type: 'text/calendar' });
|
|
293
|
+ const url = URL.createObjectURL(blob);
|
|
294
|
+ const a = document.createElement('a');
|
|
295
|
+ a.href = url;
|
|
296
|
+ a.download = 'event.ics';
|
|
297
|
+ document.body.appendChild(a);
|
|
298
|
+ a.click();
|
|
299
|
+ document.body.removeChild(a);
|
|
300
|
+ URL.revokeObjectURL(url);
|
|
301
|
+ } else if (os === 'Android') {
|
|
302
|
+ const googleCalendarUrl = `https://calendar.google.com/calendar/render?action=TEMPLATE&text=${encodeURIComponent(title)}&dates=${startDate}/${endDate}&details=${encodeURIComponent(details)}&location=${encodeURIComponent(location)}`;
|
|
303
|
+ window.open(googleCalendarUrl, '_blank');
|
|
304
|
+ } else {
|
|
305
|
+ alert('Your device is not supported for this feature.');
|
|
306
|
+ }
|
|
307
|
+ });
|
|
308
|
+</script>
|
250
|
309
|
@endpush
|