Skip to content

Commit 8def578

Browse files
committed
refactor(docs): extract inline scripts to main.js and simplify HTML
1 parent 40abda4 commit 8def578

3 files changed

Lines changed: 245 additions & 290 deletions

File tree

docs/index.html

Lines changed: 3 additions & 251 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179

180180
<!-- Hero -->
181181
<main
182-
class="max-w-7xl mx-auto px-6 py-16 sm:py-20 lg:py-28 grid grid-cols-1 lg:grid-cols-[1.02fr_0.98fr] gap-16 xl:gap-24 items-center relative"
182+
class="max-w-7xl mx-auto px-6 py-16 sm:py-20 lg:py-28 min-h-[calc(90vh-65px)] grid grid-cols-1 lg:grid-cols-[1.02fr_0.98fr] gap-16 xl:gap-24 items-center relative"
183183
>
184184
<div class="max-w-2xl">
185185
<div class="flex justify-center sm:justify-start">
@@ -295,9 +295,6 @@ <h3 class="text-limitra-dark dark:text-limitra-light font-black text-xl">
295295
<p class="text-sm font-bold text-limitra-dark dark:text-limitra-light">
296296
Daily Video Limit
297297
</p>
298-
<p class="text-xs text-gray-500 dark:text-limitra-muted mt-1">
299-
Stops the feed after your limit.
300-
</p>
301298
</div>
302299
<div
303300
class="text-1xl font-black font-mono text-limitra-dark dark:text-limitra-light"
@@ -310,9 +307,6 @@ <h3 class="text-limitra-dark dark:text-limitra-light font-black text-xl">
310307
<p class="text-sm font-bold text-limitra-dark dark:text-limitra-light">
311308
Time Limit
312309
</p>
313-
<p class="text-xs text-gray-500 dark:text-limitra-muted mt-1">
314-
Keeps sessions intentional.
315-
</p>
316310
</div>
317311
<div
318312
class="text-1xl font-black font-mono text-limitra-dark dark:text-limitra-light"
@@ -355,7 +349,7 @@ <h3 class="text-limitra-dark dark:text-limitra-light font-black text-xl">
355349
<div
356350
class="min-w-24 text-center border-2 border-limitra-dark dark:border-limitra-light bg-white dark:bg-limitra-dark px-3 py-2 shadow-[2px_2px_0px_0px_var(--color-limitra-dark)] dark:shadow-[2px_2px_0px_0px_var(--color-limitra-light)]"
357351
>
358-
<p class="text-[10px] font-mono font-bold text-limitra-accent">SOON</p>
352+
<p class="text-[11px] font-mono font-bold text-limitra-accent">01:24:00</p>
359353
</div>
360354
</div>
361355
</div>
@@ -880,248 +874,6 @@ <h3 class="text-lg font-bold mb-4 text-limitra-dark dark:text-limitra-light">
880874
</div>
881875
</div>
882876
</footer>
883-
884-
<!-- Theme toggle -->
885-
<script>
886-
const themeToggleBtn = document.getElementById('themeToggle');
887-
const sunIcon = document.getElementById('sunIcon');
888-
const moonIcon = document.getElementById('moonIcon');
889-
function applyTheme(isDark) {
890-
document.documentElement.classList.toggle('dark', isDark);
891-
sunIcon.classList.toggle('hidden', !isDark);
892-
moonIcon.classList.toggle('hidden', isDark);
893-
localStorage.theme = isDark ? 'dark' : 'light';
894-
}
895-
const isDark =
896-
localStorage.theme === 'dark' ||
897-
(!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches);
898-
applyTheme(isDark);
899-
themeToggleBtn.addEventListener('click', () =>
900-
applyTheme(!document.documentElement.classList.contains('dark')),
901-
);
902-
</script>
903-
904-
<!-- Copy wallet address -->
905-
<script>
906-
function fallbackCopy(text) {
907-
const ta = document.createElement('textarea');
908-
ta.value = text;
909-
ta.style.cssText = 'position:fixed;opacity:0';
910-
document.body.appendChild(ta);
911-
ta.focus();
912-
ta.select();
913-
try {
914-
document.execCommand('copy');
915-
return true;
916-
} catch {
917-
return false;
918-
} finally {
919-
document.body.removeChild(ta);
920-
}
921-
}
922-
const copyToClipboard = async (text) => {
923-
try {
924-
await navigator.clipboard.writeText(text);
925-
return true;
926-
} catch {
927-
return fallbackCopy(text);
928-
}
929-
};
930-
document.addEventListener('DOMContentLoaded', () => {
931-
const copyBtn = document.getElementById('copyBtn');
932-
const walletAddress = document.getElementById('walletAddress');
933-
let clickCount = 0,
934-
spamResetTimer = null,
935-
resetTextTimer = null,
936-
isSpamming = false;
937-
copyBtn.addEventListener('click', async () => {
938-
clickCount++;
939-
clearTimeout(spamResetTimer);
940-
spamResetTimer = setTimeout(() => {
941-
clickCount = 0;
942-
}, 2000);
943-
if (clickCount >= 10) {
944-
isSpamming = true;
945-
copyBtn.textContent = 'THAAAAAAAANKS!!!';
946-
clearTimeout(resetTextTimer);
947-
resetTextTimer = setTimeout(() => {
948-
isSpamming = false;
949-
copyBtn.textContent = 'Copy Address';
950-
clickCount = 0;
951-
}, 2000);
952-
return;
953-
}
954-
if (isSpamming) {
955-
clearTimeout(resetTextTimer);
956-
resetTextTimer = setTimeout(() => {
957-
isSpamming = false;
958-
copyBtn.textContent = 'Copy Address';
959-
clickCount = 0;
960-
}, 2000);
961-
return;
962-
}
963-
const success = await copyToClipboard(walletAddress.textContent?.trim());
964-
copyBtn.textContent = success ? 'Copied!' : 'Failed!';
965-
clearTimeout(resetTextTimer);
966-
resetTextTimer = setTimeout(() => {
967-
if (!isSpamming) copyBtn.textContent = 'Copy Address';
968-
}, 2000);
969-
});
970-
});
971-
const preloadedQRs = {};
972-
function preloadQRs() {
973-
wallets.forEach((w) => {
974-
const img = new Image();
975-
img.src = w.qr;
976-
preloadedQRs[w.qr] = img;
977-
});
978-
}
979-
const wallets = [
980-
{
981-
label: 'USDT (TRC20)',
982-
address: 'THxLYXCCzJrDZbL39MnZUrgtgm3HSx2NUg',
983-
network: 'Send only via (TRC20) network',
984-
qr: './assets/qr-usdt.png',
985-
},
986-
{
987-
label: 'BTC',
988-
address: '133R2PeTSCeymBireCWZ4uJxhjFYZQSje7',
989-
network: 'Send only via Bitcoin (BTC) network',
990-
qr: './assets/qr-btc.png',
991-
},
992-
{
993-
label: 'Ethereum (ERC20)',
994-
address: '0xaba5b53b6e11c6210d51f53dc6728ab47c4f3f1b',
995-
network: 'Send only via Ethereum (ERC20) network',
996-
qr: './assets/qr-eth.png',
997-
},
998-
];
999-
document.addEventListener('DOMContentLoaded', () => {
1000-
preloadQRs();
1001-
setQR(wallets[0].qr);
1002-
});
1003-
function setQR(src) {
1004-
const img = document.getElementById('qrImage');
1005-
if (preloadedQRs[src]) {
1006-
img.src = preloadedQRs[src].src;
1007-
}
1008-
}
1009-
const walletLabel = document.getElementById('walletLabel');
1010-
const walletAddress = document.getElementById('walletAddress');
1011-
const networkHint = document.getElementById('networkHint');
1012-
const qrImage = document.getElementById('qrImage');
1013-
const tabs = document.querySelectorAll('.wallet-tab');
1014-
tabs.forEach((tab) => {
1015-
tab.addEventListener('click', () => {
1016-
tabs.forEach((t) => t.classList.remove('active-tab'));
1017-
tab.classList.add('active-tab');
1018-
const index = parseInt(tab.dataset.index);
1019-
const w = wallets[index];
1020-
walletLabel.textContent = w.label;
1021-
walletAddress.textContent = w.address;
1022-
networkHint.textContent = w.network;
1023-
setQR(w.qr);
1024-
});
1025-
});
1026-
</script>
1027-
1028-
<!-- Floating nav on scroll -->
1029-
<script>
1030-
(function () {
1031-
const nav = document.getElementById('mainNav');
1032-
const NAV_SCROLL_THRESHOLD = 80;
1033-
function onScroll() {
1034-
if (window.matchMedia('(max-width: 767px)').matches) {
1035-
nav.classList.remove('nav-floating');
1036-
return;
1037-
}
1038-
if (window.scrollY > NAV_SCROLL_THRESHOLD) {
1039-
nav.classList.add('nav-floating');
1040-
} else {
1041-
nav.classList.remove('nav-floating');
1042-
}
1043-
}
1044-
window.addEventListener('scroll', onScroll, { passive: true });
1045-
window.addEventListener('resize', onScroll);
1046-
onScroll();
1047-
})();
1048-
</script>
1049-
1050-
<!-- Time-waster modal -->
1051-
<div
1052-
id="timeWasterModal"
1053-
class="fixed inset-0 z-100 hidden items-center justify-center bg-black/50 backdrop-blur-sm p-4"
1054-
>
1055-
<div
1056-
id="modalContent"
1057-
class="relative bg-white dark:bg-limitra-dark border-4 border-limitra-dark dark:border-limitra-light px-8 py-12 sm:px-14 sm:py-16 max-w-2xl w-full shadow-[12px_12px_0px_0px_var(--color-limitra-accent)] text-center transform scale-95 opacity-0 transition-all duration-300"
1058-
>
1059-
<div
1060-
class="absolute -top-5 -left-5 bg-limitra-accent text-white font-mono font-extrabold text-base px-6 py-1.5 border-[3px] border-limitra-dark dark:border-limitra-light rotate-[-5deg] shadow-[4px_4px_0px_0px_var(--color-limitra-dark)] dark:shadow-[4px_4px_0px_0px_var(--color-limitra-light)] tracking-[2px] uppercase z-10"
1061-
>
1062-
BLOCKED
1063-
</div>
1064-
<h3
1065-
class="text-4xl font-black text-limitra-dark dark:text-limitra-light mb-6 uppercase tracking-tighter"
1066-
>
1067-
Time Waster Detected
1068-
</h3>
1069-
<p
1070-
class="text-limitra-dark dark:text-limitra-light font-extrabold text-xl mb-12 leading-snug tracking-tight"
1071-
>
1072-
We built Limitra™ to stop you from wasting time. Yet, here you are, spending over 10
1073-
minutes just scrolling through a landing page. The irony is real. Install it and go do
1074-
something useful.
1075-
</p>
1076-
<button
1077-
id="closeModalBtn"
1078-
class="brutal-btn-primary w-full py-5 text-xl tracking-wider uppercase"
1079-
>
1080-
FINE, I'LL INSTALL IT
1081-
</button>
1082-
</div>
1083-
</div>
1084-
1085-
<!-- Time waster timer -->
1086-
<script>
1087-
const IDLE_TIME_LIMIT = 600000; // 10 min
1088-
const modal = document.getElementById('timeWasterModal');
1089-
const modalContent = document.getElementById('modalContent');
1090-
const closeBtn = document.getElementById('closeModalBtn');
1091-
let idleTimer,
1092-
remainingTime = IDLE_TIME_LIMIT,
1093-
startTime,
1094-
hasShownModal = false;
1095-
function startTimer() {
1096-
if (hasShownModal) return;
1097-
startTime = Date.now();
1098-
idleTimer = setTimeout(showModal, remainingTime);
1099-
}
1100-
function pauseTimer() {
1101-
if (hasShownModal) return;
1102-
clearTimeout(idleTimer);
1103-
remainingTime -= Date.now() - startTime;
1104-
}
1105-
function showModal() {
1106-
hasShownModal = true;
1107-
modal.classList.remove('hidden');
1108-
modal.classList.add('flex');
1109-
setTimeout(() => {
1110-
modalContent.classList.remove('scale-95', 'opacity-0');
1111-
modalContent.classList.add('scale-100', 'opacity-100');
1112-
}, 10);
1113-
}
1114-
closeBtn.addEventListener('click', () => {
1115-
modal.classList.add('hidden');
1116-
modal.classList.remove('flex');
1117-
modalContent.classList.add('scale-95', 'opacity-0');
1118-
window.scrollTo({ top: 0, behavior: 'smooth' });
1119-
});
1120-
document.addEventListener('visibilitychange', () => {
1121-
document.hidden ? pauseTimer() : startTimer();
1122-
});
1123-
startTimer();
1124-
window.addEventListener('beforeunload', () => clearTimeout(idleTimer));
1125-
</script>
877+
<script src="./js/main.js" defer></script>
1126878
</body>
1127879
</html>

0 commit comments

Comments
 (0)