From 182ae418ba4336584b8ef07cc9ae392ad2cd323b Mon Sep 17 00:00:00 2001 From: sent Date: Thu, 17 Apr 2025 11:16:00 -0700 Subject: [PATCH] Delete public/assets/js/$.js --- public/assets/js/$.js | 329 ------------------------------------------ 1 file changed, 329 deletions(-) delete mode 100644 public/assets/js/$.js diff --git a/public/assets/js/$.js b/public/assets/js/$.js deleted file mode 100644 index dffc3d59..00000000 --- a/public/assets/js/$.js +++ /dev/null @@ -1,329 +0,0 @@ -document.addEventListener('DOMContentLoaded', () => { - const historyStack = []; - let currentIndex = -1; - const refreshIcon = document.getElementById('refreshIcon'); - const fullscreenIcon = document.getElementById('fullscreenIcon'); - const backIcon = document.getElementById('backIcon'); - const forwardIcon = document.getElementById('forwardIcon'); - const iframe = document.getElementById('cool-iframe'); - const erudaLoadingScreen = document.getElementById('erudaLoadingScreen'); - const navBar = document.querySelector('.navbar'); - const topBar = document.querySelector('.topbar'); - const searchInput1 = document.getElementById('searchInput'); - const searchInput2 = document.getElementById('searchInputt'); - const movies = document.getElementById('movies'); - const ai = document.getElementById('ai'); - const navbarToggle = document.getElementById('navbar-toggle'); - let loadingHidden = false; - let hideTimeout; - let duckLoadCount = 0; - - if (!refreshIcon || !fullscreenIcon || !backIcon || !forwardIcon || !iframe) return; - - function showLoadingScreen(withToast = true, showEruda = false) { - clearTimeout(hideTimeout); - loadingHidden = false; - NProgress.start(); - hideTimeout = setTimeout(() => { - hideLoadingScreen(); - }, 15000); - if (withToast) { - showToast( - 'Consider joining our Discord <3', - 'success', - 'heart' - ); - } - } - - function hideLoadingScreen() { - if (loadingHidden) return; - clearTimeout(hideTimeout); - loadingHidden = true; - NProgress.done(); - } - - refreshIcon.addEventListener('click', () => { - refreshIcon.classList.add('spin'); - if (iframe.tagName === 'IFRAME') { - const currentUrl = iframe.contentWindow.location.href; - if (normalizeUrl(currentUrl) !== normalizeUrl(historyStack[currentIndex] || '')) { - addToHistory(currentUrl); - } - iframe.contentWindow.location.reload(true); - } - setTimeout(() => refreshIcon.classList.remove('spin'), 300); - }); - - fullscreenIcon.addEventListener('click', () => { - if (iframe.requestFullscreen) iframe.requestFullscreen(); - else if (iframe.mozRequestFullScreen) iframe.mozRequestFullScreen(); - else if (iframe.webkitRequestFullscreen) iframe.webkitRequestFullscreen(); - else if (iframe.msRequestFullscreen) iframe.msRequestFullscreen(); - }); - - backIcon.addEventListener('click', () => { - if (currentIndex > 0) { - currentIndex--; - iframe.src = historyStack[currentIndex]; - showLoadingScreen(false, false); - updateNavButtons(); - updateDecodedSearchInput(); - } - }); - - forwardIcon.addEventListener('click', () => { - if (currentIndex < historyStack.length - 1) { - currentIndex++; - iframe.src = historyStack[currentIndex]; - showLoadingScreen(false, false); - updateNavButtons(); - updateDecodedSearchInput(); - } - }); - - function normalizeUrl(urlStr) { - try { - const url = new URL(urlStr); - url.searchParams.delete('ia'); - return url.toString(); - } catch (e) { - return urlStr; - } - } - - function addToHistory(url) { - const normalized = normalizeUrl(url); - if (currentIndex >= 0 && normalizeUrl(historyStack[currentIndex]) === normalized) return; - if (currentIndex < historyStack.length - 1) historyStack.splice(currentIndex + 1); - historyStack.push(url); - currentIndex++; - updateNavButtons(); - updateDecodedSearchInput(); - } - - function updateNavButtons() { - backIcon.disabled = currentIndex <= 0; - forwardIcon.disabled = currentIndex >= historyStack.length - 1; - backIcon.classList.toggle('disabled', currentIndex <= 0); - forwardIcon.classList.toggle('disabled', currentIndex >= historyStack.length - 1); - } - - function updateDecodedSearchInput() { - if (!searchInput2) return; - let url = ''; - if (currentIndex >= 0 && historyStack[currentIndex]) { - url = historyStack[currentIndex]; - } else if (iframe.src) { - url = iframe.src; - } - searchInput2.value = decodeUrl(url); - const lockIcon = document.getElementById('lockIcon'); - if (lockIcon) { - lockIcon.className = decodeUrl(url).startsWith('https://') ? - 'fa-regular fa-lock' : - 'fa-regular fa-lock-open'; - lockIcon.style.color = ''; - } - } - - iframe.addEventListener('load', () => { - duckLoadCount = 0; - try { - hideLoadingScreen(); - } catch (error) { - console.error('Error during iframe load:', error); - hideLoadingScreen(); - } finally { - if (erudaLoadingScreen) erudaLoadingScreen.style.display = 'none'; - } - }); - - iframe.addEventListener('error', () => { - console.error('Error loading iframe content.'); - hideLoadingScreen(); - }); - - iframe.addEventListener('loadstart', () => { - const url = iframe.src; - const isDuck = url.includes('duckduckgo.com/search'); - if (isDuck && duckLoadCount >= 1) return; - if (isDuck) duckLoadCount++; - if (navbarToggle && navbarToggle.checked && navBar) { - navBar.style.display = 'block'; - } - showLoadingScreen(false, false); - }); - - if (navbarToggle && navBar) { - const savedNavbarState = localStorage.getItem('navbarToggled'); - navbarToggle.checked = savedNavbarState === null ? true : savedNavbarState === 'true'; - navBar.style.display = iframe.style.display === 'block' && navbarToggle.checked ? 'block' : 'none'; - navbarToggle.addEventListener('change', () => { - localStorage.setItem('navbarToggled', navbarToggle.checked); - navBar.style.display = iframe.style.display === 'block' && navbarToggle.checked ? 'block' : 'none'; - }); - } - - iframe.style.display = 'none'; - window.addEventListener('load', hideLoadingScreen); - - [searchInput1, searchInput2].forEach(input => { - if (input) { - input.addEventListener('keyup', e => { - if (e.key === 'Enter') handleSearch(input.value); - }); - } - }); - - if (movies) movies.addEventListener('click', e => { - e.preventDefault(); - handleSearch('https://movies.usewaves.site/'); - }); - - if (ai) ai.addEventListener('click', e => { - e.preventDefault(); - handleSearch('https://ai.usewaves.site/'); - }); - - function clearBackground() { - const preserved = [ - document.querySelector('.navbar'), - document.getElementById('cool-iframe'), - document.querySelector('.loading-screen'), - erudaLoadingScreen - ]; - Array.from(document.body.children).forEach(child => { - if (!preserved.includes(child)) child.remove(); - }); - } - - async function handleSearch(query) { - clearBackground(); - let searchURL; - if (query.startsWith('/assets/g/') || query.startsWith(window.location.origin + '/assets/g/')) { - searchURL = query; - } else { - searchURL = generateSearchUrl(query); - } - if (searchInput2) searchInput2.value = searchURL; - historyStack.length = 0; - currentIndex = -1; - showLoadingScreen(true, false); - iframe.style.display = 'block'; - if (topBar) topBar.style.display = 'none'; - backIcon.disabled = forwardIcon.disabled = true; - let finalUrl; - try { - const u = new URL(searchURL, window.location.origin); - if (u.origin === window.location.origin && u.pathname.startsWith('/assets/g/')) { - finalUrl = u.href; - } else { - finalUrl = await getUrl(searchURL); - } - } catch (err) { - console.error('Error parsing URL, proxying by default:', err); - finalUrl = await getUrl(searchURL); - } - iframe.src = finalUrl; - iframe.onload = () => { - hideLoadingScreen(); - if (navbarToggle && navbarToggle.checked && navBar) navBar.style.display = 'block'; - generateSubject(); - updateDecodedSearchInput(); - }; - iframe.onerror = () => { - console.error('Failed to load content.'); - hideLoadingScreen(); - }; - } - - window.handleSearch = handleSearch; - - function generateSearchUrl(query) { - try { - return new URL(query).toString(); - } catch { - try { - const u = new URL(`https://${query}`); - if (u.hostname.includes('.')) return u.toString(); - } catch {} - } - return `https://duckduckgo.com/search?q=${encodeURIComponent(query)}&ia=web`; - } - - function showToast(message, type = 'success', iconType = 'check') { - const toast = document.createElement('div'); - toast.className = `toast show ${type}`; - const icons = { - success: '', - error: '', - info: '', - warning: '', - heart: '' - }; - const icon = icons[iconType] || icons.heart; - toast.innerHTML = `${icon}${message} `; - const progressBar = document.createElement('div'); - progressBar.className = 'progress-bar'; - toast.appendChild(progressBar); - const closeBtn = document.createElement('button'); - closeBtn.className = 'toast-close'; - closeBtn.innerHTML = ''; - closeBtn.addEventListener('click', () => { - toast.classList.add('hide'); - setTimeout(() => toast.remove(), 500); - }); - toast.appendChild(closeBtn); - document.body.appendChild(toast); - setTimeout(() => { - toast.classList.add('hide'); - setTimeout(() => toast.remove(), 500); - }, 3000); - } - - function preloadResources(url) { - if (!url) { - console.error('Preload failed: URL is undefined or empty.'); - return; - } - try { - const link = document.createElement('link'); - link.rel = 'preload'; - link.href = url; - link.as = 'fetch'; - link.crossOrigin = 'anonymous'; - document.head.appendChild(link); - console.log(`Resource preloaded: ${url}`); - } catch (error) { - console.error('Error preloading resource:', error); - } - } - - function getUrl(url) { - return Promise.resolve(__uv$config.prefix + __uv$config.encodeUrl(url)); - } - - function generateSubject() { - const subjects = ['math', 'science', 'history', 'art', 'programming', 'philosophy']; - const random = subjects[Math.floor(Math.random() * subjects.length)]; - history.replaceState({}, '', '/learning?subject=' + random); - } - - function decodeUrl(enc) { - try { - const o = new URL(enc, window.location.origin); - const p = (__uv$config && __uv$config.prefix) || '/wa/a/'; - if (o.pathname.startsWith(p)) { - const part = o.pathname.slice(p.length); - return (__uv$config.decodeUrl ? __uv$config.decodeUrl(part) : decodeURIComponent(part)); - } - } catch {} - return enc; - } - - window.decodeUrl = decodeUrl; - window.addToHistory = addToHistory; - window.updateDecodedSearchInput = updateDecodedSearchInput; - window.normalizeUrl = normalizeUrl; -}); \ No newline at end of file