PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 4.4.8
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v4.4.8
4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / assets / js / meetup-timezone.js
embedpress / assets / js Last commit date
chunks 6 months ago vendor 9 months ago admin.build.js 7 months ago admin.js 10 months ago analytics-tracker.js 10 months ago analytics.build.js 6 months ago blocks.build.js 6 months ago carousel.js 1 year ago documents-viewer-script.js 3 years ago feature-notices.js 7 months ago front.js 6 months ago frontend.build.js 10 months ago gallery-justify.js 10 months ago gutneberg-script.js 1 year ago index.html 7 years ago initCarousel.js 2 years ago initplyr.js 9 months ago instafeed.js 7 months ago lazy-load.js 7 months ago license.js 7 months ago meetup-timezone.js 6 months ago preview.js 9 months ago settings.js 7 months ago sponsored.js 10 months ago
meetup-timezone.js
138 lines
1 /**
2 * EmbedPress Meetup Timezone Converter
3 *
4 * Converts UTC timestamps to visitor's local timezone for Meetup embeds
5 */
6 (function () {
7 'use strict';
8
9 /**
10 * Format date according to the specified format string
11 */
12 function formatDate(date, format) {
13 const months = ['January', 'February', 'March', 'April', 'May', 'June',
14 'July', 'August', 'September', 'October', 'November', 'December'];
15 const monthsShort = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
16 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
17 const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
18 const daysShort = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
19
20 const replacements = {
21 // Year
22 'Y': date.getFullYear(),
23 'y': String(date.getFullYear()).slice(-2),
24
25 // Month
26 'F': months[date.getMonth()],
27 'M': monthsShort[date.getMonth()],
28 'm': String(date.getMonth() + 1).padStart(2, '0'),
29 'n': date.getMonth() + 1,
30
31 // Day
32 'd': String(date.getDate()).padStart(2, '0'),
33 'j': date.getDate(),
34 'D': daysShort[date.getDay()],
35 'l': days[date.getDay()],
36
37 // Time
38 'H': String(date.getHours()).padStart(2, '0'),
39 'h': String(date.getHours() % 12 || 12).padStart(2, '0'),
40 'G': date.getHours(),
41 'g': date.getHours() % 12 || 12,
42 'i': String(date.getMinutes()).padStart(2, '0'),
43 's': String(date.getSeconds()).padStart(2, '0'),
44 'A': date.getHours() >= 12 ? 'PM' : 'AM',
45 'a': date.getHours() >= 12 ? 'pm' : 'am',
46 };
47
48 let formatted = format;
49
50 // Use a unique placeholder pattern that won't conflict with date format characters
51 // Using Unicode characters that are unlikely to appear in format strings
52 const placeholderPrefix = '\u{1F4C5}'; // Calendar emoji as unique marker
53 const placeholders = {};
54
55 // First pass: replace format characters with unique placeholders
56 for (const key in replacements) {
57 const placeholder = placeholderPrefix + key + placeholderPrefix;
58 placeholders[placeholder] = replacements[key];
59 formatted = formatted.split(key).join(placeholder);
60 }
61
62 // Second pass: replace placeholders with actual values
63 for (const placeholder in placeholders) {
64 formatted = formatted.split(placeholder).join(placeholders[placeholder]);
65 }
66
67 return formatted;
68 }
69
70 /**
71 * Format time according to the specified format string
72 */
73 function formatTime(date, format) {
74 return formatDate(date, format);
75 }
76
77 /**
78 * Convert UTC timestamps to visitor's local timezone
79 */
80 function convertTimezones() {
81 // Find all elements with visitor timezone data attribute
82 const elements = document.querySelectorAll('[data-visitor-timezone="true"]');
83
84 console.log('EmbedPress Meetup Timezone: Found ' + elements.length + ' elements to convert');
85
86 elements.forEach(function (element) {
87 const utcTimestamp = parseInt(element.getAttribute('data-utc-timestamp'), 10);
88
89 if (!utcTimestamp || isNaN(utcTimestamp)) {
90 return;
91 }
92
93 // Create date object from UTC timestamp
94 const date = new Date(utcTimestamp * 1000);
95
96 console.log('Converting timestamp:', utcTimestamp, 'to local date:', date.toString());
97
98 // Check if this is a date element or time element
99 const isDateElement = element.classList.contains('ep-event-date');
100 const isTimeElement = element.classList.contains('ep-event-end-time');
101
102 // Get timezone abbreviation
103 const timezoneAbbr = date.toLocaleTimeString('en-US', {
104 timeZoneName: 'short'
105 }).split(' ').pop();
106
107 if (isDateElement) {
108 // Format date and time
109 const dateFormat = element.getAttribute('data-date-format') || 'F j, Y';
110 const timeFormat = element.getAttribute('data-time-format') || 'g:i A';
111
112 // Combine date and time format
113 const formattedDate = formatDate(date, dateFormat);
114 const formattedTime = formatTime(date, timeFormat);
115
116 const newText = formattedDate + ', ' + formattedTime + ' ' + timezoneAbbr;
117 console.log('Formatted date:', newText);
118 element.textContent = newText;
119 } else if (isTimeElement) {
120 // Format time only (for end time)
121 const timeFormat = element.getAttribute('data-time-format') || 'g:i A';
122 element.textContent = formatTime(date, timeFormat) + ' ' + timezoneAbbr;
123 }
124 });
125 }
126
127 // Convert on page load
128 if (document.readyState === 'loading') {
129 document.addEventListener('DOMContentLoaded', convertTimezones);
130 } else {
131 convertTimezones();
132 }
133
134 // Convert after AJAX load more
135 document.addEventListener('embedpress:meetup:loaded', convertTimezones);
136 })();
137
138