-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
174 lines (139 loc) · 4.1 KB
/
script.js
File metadata and controls
174 lines (139 loc) · 4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// =====================
// Google Analytics (delayed load)
// =====================
setTimeout(() => {
const s = document.createElement('script');
s.src = "https://www.googletagmanager.com/gtag/js?id=G-9FWQFZME3Z";
s.async = true;
s.onload = () => {
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-9FWQFZME3Z');
};
document.head.appendChild(s);
}, 3000);
// =====================
// UTM TRACKING
// =====================
const params = new URLSearchParams(window.location.search);
const utmSource = params.get('utm_source');
if (utmSource) {
console.log('UTM Source:', utmSource);
document.cookie = `utm_source=${utmSource}; path=/; max-age=2592000; SameSite=Lax`;
}
// =====================
// MailerLite (safe load)
// =====================
(function(w,d,e,u,f,l,n){
w[f] = w[f] || function(){ (w[f].q = w[f].q || []).push(arguments); };
l = d.createElement(e);
l.async = 1;
l.src = u;
n = d.getElementsByTagName(e)[0];
n.parentNode.insertBefore(l,n);
})(window,document,'script','https://assets.mailerlite.com/js/universal.js','ml');
// Call only if available
setTimeout(() => {
if (typeof ml === "function") {
ml('account', '1922622');
}
}, 1000);
// =====================
// YouTube lazy load
// =====================
function loadVideo(el) {
if (!el) return;
el.innerHTML = `<iframe loading="lazy"
src="https://www.youtube.com/embed/99FexhxsXx8?autoplay=1"
allowfullscreen></iframe>`;
}
// =====================
// reCAPTCHA form
// =====================
function showForm(token) {
const el = document.getElementById("form-container");
if (el) el.style.display = "block";
}
// =====================
// Popup ad (safe)
// =====================
window.addEventListener("load", () => {
const popup = document.getElementById('popup-ad');
if (!popup) return;
setTimeout(() => {
popup.style.display = 'block';
}, 5000);
});
// =====================
// MailerLite success handler (safe)
// =====================
function ml_webform_success_33394663() {
const $ = window.ml_jQuery || window.jQuery;
if (!$) return;
$('.ml-subscribe-form-33394663 .row-success').show();
$('.ml-subscribe-form-33394663 .row-form').hide();
}
// =====================
// Last updated script (safe fetch)
// =====================
document.addEventListener("DOMContentLoaded", async () => {
const items = document.querySelectorAll(".last-updated");
for (const el of items) {
const path = el.dataset.meta;
if (!path) continue;
try {
const res = await fetch(path, { cache: "no-store" });
if (!res.ok) throw new Error();
const data = await res.json();
const last = new Date(data.lastUpdated);
const days = Math.floor(
(Date.now() - last) / (1000 * 60 * 60 * 24)
);
const text =
days === 0 ? "Updated today" :
days === 1 ? "Updated yesterday" :
`Updated ${days} days ago`;
el.textContent = `🕒 ${text}`;
} catch {
el.textContent = "";
}
}
});
// =====================
// Secret typing easter egg (safe)
// =====================
(function () {
let typed = "";
const secret = "HELLENICDEV";
const message = document.getElementById("hidden-thanks");
let triggered = false;
document.addEventListener("keydown", (e) => {
if (triggered) return;
if (e.key.length !== 1) return;
typed += e.key.toUpperCase();
typed = typed.slice(-secret.length);
if (typed === secret && message) {
message.style.display = "block";
triggered = true;
}
});
})();
// =====================
// Logo click
// =====================
function showThankYou() {
const msg = document.getElementById("hidden-thanks");
if (msg) msg.style.display = "block";
}
// =====================
// Navigation menu (safe)
// =====================
const menuButton = document.getElementById("menuButton");
const sideMenu = document.getElementById("sideMenu");
if (menuButton && sideMenu) {
menuButton.onclick = () => {
sideMenu.style.left =
sideMenu.style.left === "0px" ? "-250px" : "0px";
};
}