Universal Remote Code Finder -

.progress-bar-bg background: #232a3f; border-radius: 40px; height: 8px; width: 100%; overflow: hidden;

/* test buttons grid (remote style) */ .test-grid display: flex; flex-wrap: wrap; gap: 14px; margin: 20px 0 24px; justify-content: center;

/* code finder status */ .finder-status background: #07090f; border-radius: 2rem; padding: 1rem 1.4rem; margin-bottom: 1.8rem; border-left: 4px solid #3b82f6; universal remote code finder

.brand-buttons display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 16px 0;

.big-action background: #2a3958; width: auto; padding: 12px 28px; font-size: 0.9rem; font-weight: 600; Press POWER/VOL+ on remote to test

.info-msg background: #11161f; border-radius: 1.5rem; padding: 12px 18px; font-size: 0.8rem; color: #b9c7e3; text-align: center; margin-top: 12px; border: 1px solid #2f3a4e;

// List of brands (order as shown) const brandList = ["samsung", "lg", "sony", "hisense", "toshiba", "panasonic", "sharp", "vizio"]; // Display names mapping const brandDisplayNames = samsung: "Samsung", lg: "LG", sony: "Sony", hisense: "Hisense", toshiba: "Toshiba", panasonic: "Panasonic", sharp: "Sharp", vizio: "Vizio" ; Select a brand first

// Current state let currentBrand = "samsung"; // default let currentCodeList = [...codeDatabase.samsung]; let currentIndex = 0; // index in currentCodeList let currentCode = currentCodeList[0] || "----"; // Auto-find state let autoFindInterval = null; let isAutoFinding = false; // saved working code storage let savedWorkingCode = null; // DOM elements const currentCodeDisplay = document.getElementById("currentCodeDisplay"); const progressFill = document.getElementById("progressFill"); const codeCounterSpan = document.getElementById("codeCounter"); const brandContainer = document.getElementById("brandButtonsContainer"); const powerBtn = document.getElementById("powerBtn"); const volUpBtn = document.getElementById("volUpBtn"); const muteBtn = document.getElementById("muteBtn"); const nextCodeBtn = document.getElementById("nextCodeBtn"); const autoFindBtn = document.getElementById("autoFindBtn"); const saveCodeBtn = document.getElementById("saveCodeBtn"); const infoMsgDiv = document.getElementById("infoMessage"); // Helper: update UI with current code & progress function updateUI() if (!currentCodeList.length) currentCodeDisplay.textContent = "----"; progressFill.style.width = "0%"; codeCounterSpan.textContent = `code 0 / 0`; return; currentCode = currentCodeList[currentIndex]; currentCodeDisplay.textContent = currentCode; const progressPercent = ((currentIndex + 1) / currentCodeList.length) * 100; progressFill.style.width = `$progressPercent%`; codeCounterSpan.textContent = `code $currentIndex+1 / $currentCodeList.length`; // Switch brand: reset index, update code list, stop auto-find, refresh UI function setBrand(brandKey) if (autoFindInterval) stopAutoFind(); currentBrand = brandKey; // fetch code list, fallback to empty array currentCodeList = codeDatabase[brandKey] ? [...codeDatabase[brandKey]] : []; if (currentCodeList.length === 0) // fallback: generate dummy codes (should not happen) currentCodeList = ["0000", "0001"]; currentIndex = 0; updateUI(); // reset saved working code hint savedWorkingCode = null; showTemporaryMessage(`🔁 Switched to $brandDisplayNames[brandKey]. Starting from first code.`, false); // Highlight active brand button document.querySelectorAll('.brand-btn').forEach(btn => if(btn.dataset.brand === brandKey) btn.classList.add('active'); else btn.classList.remove('active'); ); // Move to next code (manual) function nextCode() if (autoFindInterval) stopAutoFind(); if (!currentCodeList.length) return; currentIndex = (currentIndex + 1) % currentCodeList.length; updateUI(); playBeepSimulation(); showTemporaryMessage(`➡️ Testing code $currentCode — Press POWER/VOL+ to check response`, true); // Auto-find: iterate codes every 1.2 seconds function startAutoFind() if (autoFindInterval) stopAutoFind(); if (!currentCodeList.length) showTemporaryMessage("⚠️ No codes available for this brand.", false); return; isAutoFinding = true; autoFindBtn.textContent = "⏸️ STOP"; autoFindBtn.style.background = "#c2410c"; showTemporaryMessage("🔎 AUTO-FIND ACTIVE: cycling codes every 1.2s. Press POWER/VOL+ on remote to test. Click STOP when device responds.", false); autoFindInterval = setInterval(() => // cycle to next code if (currentCodeList.length) currentIndex = (currentIndex + 1) % currentCodeList.length; updateUI(); // subtle visual flash currentCodeDisplay.style.transform = "scale(1.02)"; setTimeout(() => if(currentCodeDisplay) currentCodeDisplay.style.transform = ""; , 150); , 1200); function stopAutoFind() if (autoFindInterval) clearInterval(autoFindInterval); autoFindInterval = null; isAutoFinding = false; autoFindBtn.textContent = "🔄 AUTO-FIND"; autoFindBtn.style.background = ""; showTemporaryMessage("⏹️ Auto-find stopped. You can manually test codes.", true); // toggle auto-find function toggleAutoFind() if (isAutoFinding) stopAutoFind(); else startAutoFind(); // Simulate sending IR command (just UI feedback) function sendIRCommand(commandName) // Save current code as working code function saveWorkingCode() currentCode === "----") showTemporaryMessage("❗ No active code to save. Select a brand first.", false); return; savedWorkingCode = currentCode; showTemporaryMessage(`💾 WORKING CODE SAVED: $currentCode for $brandDisplayNames[currentBrand]. Use POWER/VOL+ to verify.`, false); // Add a little celebration effect saveCodeBtn.style.transform = "scale(0.98)"; setTimeout(() => if(saveCodeBtn) saveCodeBtn.style.transform = ""; , 120); // If auto-find is running, recommend to stop if (isAutoFinding) showTemporaryMessage(`🎉 Code found! Consider stopping auto-find and keep using this code.`, true); // Helper to show transient message in info box without overwriting permanently let msgTimeout = null; function showTemporaryMessage(message, keepInstructionStyle = false) if (msgTimeout) clearTimeout(msgTimeout); const originalHTML = infoMsgDiv.innerHTML; infoMsgDiv.style.transition = "0.1s"; infoMsgDiv.innerHTML = `<span>✨ $message</span>`; if (!keepInstructionStyle) // but we will revert after delay msgTimeout = setTimeout(() => if (infoMsgDiv) if (savedWorkingCode) infoMsgDiv.innerHTML = `✅ WORKING CODE: $savedWorkingCode ($brandDisplayNames[currentBrand]) — Use POWER to confirm.`; else infoMsgDiv.innerHTML = `💡 Press <strong>POWER / VOL+ / MUTE</strong> after each code change.<br> If device responds → click <strong>SAVE WORKING CODE</strong>.`; , 2800); // Simulate beep-like subtle feedback on next code function playBeepSimulation() // just a visual flick on the code display currentCodeDisplay.style.opacity = "0.6"; setTimeout(() => if(currentCodeDisplay) currentCodeDisplay.style.opacity = "1"; , 80); // Reset to initial state when brand changes via buttons function buildBrandButtons() brandContainer.innerHTML = ""; brandList.forEach(brandKey => const btn = document.createElement("button"); btn.className = "brand-btn"; if (brandKey === currentBrand) btn.classList.add("active"); btn.textContent = brandDisplayNames[brandKey]; btn.dataset.brand = brandKey; btn.addEventListener("click", () => if (isAutoFinding) stopAutoFind(); setBrand(brandKey); ); brandContainer.appendChild(btn); ); // Additional button to reset message if needed function refreshMessageDefault() if (!msgTimeout) if (savedWorkingCode) infoMsgDiv.innerHTML = `✅ WORKING CODE: $savedWorkingCode ($brandDisplayNames[currentBrand]) — Use POWER to confirm.`; else infoMsgDiv.innerHTML = `💡 Press <strong>POWER / VOL+ / MUTE</strong> after each code change.<br> If device responds → click <strong>SAVE WORKING CODE</strong>.`; // Event listeners powerBtn.addEventListener("click", () => sendIRCommand("POWER"); refreshMessageDefault(); ); volUpBtn.addEventListener("click", () => sendIRCommand("VOL+"); refreshMessageDefault(); ); muteBtn.addEventListener("click", () => sendIRCommand("MUTE"); refreshMessageDefault(); ); nextCodeBtn.addEventListener("click", () => nextCode(); refreshMessageDefault(); ); autoFindBtn.addEventListener("click", () => toggleAutoFind(); refreshMessageDefault(); ); saveCodeBtn.addEventListener("click", () => saveWorkingCode(); refreshMessageDefault(); ); // initial load buildBrandButtons(); // set default samsung codes setBrand("samsung"); refreshMessageDefault(); // Additional guard: if brand list somehow empty, reload window.addEventListener("load", () => if (currentCodeList.length) updateUI(); showTemporaryMessage("🔌 Ready: select brand, test codes with POWER button.", true); setTimeout(() => refreshMessageDefault(), 2000); ); </script> </body> </html>