const snippetDatabase = [ { id: "brat-modules", title: "Brat Modules", category: "Feature", path: "../dokumentasi/feature/brat-modules.js", filename: "brat-modules.js", updatedAt: "2026-04-05" }, { id: "github-dl", title: "GitHub Downloader", category: "Feature", path: "../dokumentasi/feature/githubDl.js", filename: "githubDl.js", updatedAt: "2026-04-06" }, { id: "jadwal-sholat", title: "Jadwal Sholat", category: "Feature", path: "../dokumentasi/feature/jadwalSholat.js", filename: "jadwalSholat.js", updatedAt: "2026-04-06" }, { id: "tourl", title: "To URL (Upload Image)", category: "Feature", path: "../dokumentasi/feature/tourl.js", filename: "tourl.js", updatedAt: "2026-04-07" }, { id: "twitter-dl", title: "Twitter Downloader", category: "Feature", path: "../dokumentasi/feature/twitterDl.js", filename: "twitterDl.js", updatedAt: "2026-04-06" }, { id: "youtube-play", title: "YouTube Play", category: "Feature", path: "../dokumentasi/feature/youtubePlay.js", filename: "youtubePlay.js", updatedAt: "2026-04-07" }, { id: "youtube-search", title: "YouTube Search", category: "Feature", path: "../dokumentasi/feature/youtubeSearch.js", filename: "youtubeSearch.js", updatedAt: "2026-04-07" }, { id: "athars-uploader", title: "Athars Uploader", category: "Scraper", path: "../dokumentasi/scraper/athars-uploader.js", filename: "athars-uploader.js", updatedAt: "2026-04-05" }, { id: "flixpatrol", title: "FlixPatrol Data", category: "Scraper", path: "../dokumentasi/scraper/flixpatrol.js", filename: "flixpatrol.js", updatedAt: "2026-04-05" }, { id: "search-movies", title: "Search Movies", category: "Scraper", path: "../dokumentasi/scraper/searchMovies.js", filename: "searchMovies.js", updatedAt: "2026-04-07", password: "M0v1e$" }, { id: "soundcloud-dl", title: "SoundCloud Downloader", category: "Scraper", path: "../dokumentasi/scraper/souncloud-dl.js", filename: "souncloud-dl.js", updatedAt: "2026-04-06", password: "S0oundcloud*" }, { id: "ssweb", title: "SS Web", category: "Scraper", path: "../dokumentasi/scraper/ssweb.js", filename: "ssweb.js", updatedAt: "2026-04-06" }, { id: "steam", title: "Steam Search/Data", category: "Scraper", path: "../dokumentasi/scraper/steam.js", filename: "steam.js", updatedAt: "2026-04-06", password: "$Team%" }, { id: "tiktok-dl", title: "Tiktok Downloader (No Watermark)", category: "Scraper", path: "../dokumentasi/scraper/tiktokdl.js", filename: "tiktokdl.js", updatedAt: "2026-04-05", password: "tiktokdl-tikwm" } ]; let currentCategory = "Semua"; let searchQuery = ""; document.addEventListener("DOMContentLoaded", () => { snippetDatabase.sort((a, b) => a.title.localeCompare(b.title)); if (document.getElementById('snippets-container')) { initDocs(); } }); function initDocs() { renderSidebar(); renderSnippets(); document.addEventListener("click", handleCopyClick); const searchDesktop = document.getElementById('search-input'); const searchMobile = document.getElementById('search-input-mobile'); if (searchDesktop) { searchDesktop.addEventListener('input', (e) => { searchQuery = e.target.value.toLowerCase(); if (searchMobile) searchMobile.value = e.target.value; renderSnippets(); }); } if (searchMobile) { searchMobile.addEventListener('input', (e) => { searchQuery = e.target.value.toLowerCase(); if (searchDesktop) searchDesktop.value = e.target.value; renderSnippets(); }); } } function setCategory(cat) { currentCategory = cat; renderSidebar(); renderSnippets(); } function renderSidebar() { const uniqueCategories = [...new Set(snippetDatabase.map(item => item.category))]; const categoryList = document.getElementById('category-list'); categoryList.innerHTML = ''; const totalFiles = snippetDatabase.length; categoryList.appendChild(createSidebarItem("Semua", totalFiles)); uniqueCategories.forEach(cat => { const count = snippetDatabase.filter(item => item.category === cat).length; categoryList.appendChild(createSidebarItem(cat, count)); }); } function createSidebarItem(catName, count) { const li = document.createElement('li'); li.className = "flex-shrink-0 md:w-full"; const isActive = currentCategory === catName; li.innerHTML = ` `; return li; } async function renderSnippets() { const titleEl = document.getElementById('current-category-title'); const infoEl = document.getElementById('current-category-info'); titleEl.textContent = currentCategory === "Semua" ? "Lihat Semua Snippet" : `Kategori: ${currentCategory}`; infoEl.textContent = searchQuery ? `Menampilkan pencarian untuk "${searchQuery}"` : `Koleksi kode untuk ${currentCategory}.`; const container = document.getElementById('snippets-container'); container.innerHTML = `
Memuat data kode...
`; const filteredData = snippetDatabase.filter(item => { const matchCategory = currentCategory === "Semua" || item.category === currentCategory; const matchSearch = item.title.toLowerCase().includes(searchQuery) || item.filename.toLowerCase().includes(searchQuery); return matchCategory && matchSearch; }); if(filteredData.length === 0) { container.innerHTML = `

Snippet tidak ditemukan.

`; return; } let htmlContent = ''; filteredData.forEach(item => { let dateHtml = ''; if(item.updatedAt) { const dateObj = new Date(item.updatedAt); const formattedDate = dateObj.toLocaleDateString('id-ID', { day: 'numeric', month: 'short', year: 'numeric' }); dateHtml = `${formattedDate}`; } const isLocked = item.password !== undefined && item.password !== ""; let codeBlockArea = ''; if (isLocked) { codeBlockArea = `

Snippet Eksklusif

Masukkan akses password untuk membuka kode dan fitur unduh.

`; } else { codeBlockArea = `
Mengambil sumber kode...
`; } htmlContent += `

${isLocked ? '' : ''} ${item.title}

${dateHtml}
Unduh
${codeBlockArea}
`; }); container.innerHTML = htmlContent; for (const item of filteredData) { if (!item.password) { const codeElement = document.getElementById(`code-${item.id}`); try { const response = await fetch(item.path); if (!response.ok) throw new Error('Not found'); const codeText = await response.text(); codeElement.textContent = codeText; } catch (error) { codeElement.textContent = `// Error memuat file: ${item.filename}\n// Pastikan path benar.`; } } } Prism.highlightAll(); } window.unlockFile = async function(id) { const item = snippetDatabase.find(x => x.id === id); if (!item) return; const inputPw = document.getElementById(`pw-input-${id}`); const errorMsg = document.getElementById(`pw-error-${id}`); if (inputPw.value === item.password) { errorMsg.classList.add('hidden'); document.getElementById(`lock-screen-${id}`).classList.add('hidden'); document.getElementById(`code-wrapper-${id}`).classList.remove('hidden'); const actionBtnContainer = document.getElementById(`action-btns-${id}`); actionBtnContainer.classList.remove('hidden'); actionBtnContainer.classList.add('grid', 'grid-cols-2', 'md:flex'); const codeElement = document.getElementById(`code-${id}`); codeElement.textContent = "Membuka kode..."; try { const response = await fetch(item.path); if (!response.ok) throw new Error('Not found'); const codeText = await response.text(); codeElement.textContent = codeText; Prism.highlightElement(codeElement); } catch (error) { codeElement.textContent = `// Error memuat file: ${item.filename}`; } } else { errorMsg.classList.remove('hidden'); inputPw.value = ''; inputPw.focus(); } } function handleCopyClick(e) { const btn = e.target.closest('.copy-btn'); if (!btn) return; const codeId = btn.getAttribute('data-id'); const codeContent = document.getElementById(codeId).textContent; const textSpan = btn.querySelector('.copy-text'); navigator.clipboard.writeText(codeContent).then(() => { const originalText = textSpan.textContent; textSpan.textContent = "Berhasil"; btn.classList.add("bg-green-600", "border-green-500", "text-white"); btn.classList.remove("bg-sapura-bg", "hover:bg-sapura-accent", "border-sapura-border"); setTimeout(() => { textSpan.textContent = originalText; btn.classList.remove("bg-green-600", "border-green-500", "text-white"); btn.classList.add("bg-sapura-bg", "hover:bg-sapura-accent", "border-sapura-border"); }, 2000); }).catch(err => { alert('Gagal menyalin kode!'); }); }