elokuvahakemisto.html
<!DOCTYPE html><html lang="fi"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Leffahylly PRO v4</title><style>body { font-family: Arial, sans-serif; background:#0f0f0f; color:#fff; margin:0; }h1 { text-align:center; padding:20px; }#controls { display:flex; justify-content:center; gap:10px; flex-wrap:wrap; }input, select, button { padding:10px; border-radius:8px; border:none; }.grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(200px,1fr)); gap:20px; padding:20px; }.card { background:#1c1c1c; border-radius:15px; padding:15px; text-align:center; transition:0.3s; }.card:hover { transform:scale(1.05); box-shadow:0 0 15px rgba(0,191,255,0.5); }img { width:100%; border-radius:10px; min-height:300px; object-fit:cover; }a { color:#00bfff; text-decoration:none; display:block; margin-top:5px; }.badge { font-size:11px; color:#aaa; }</style></head><body><h1>🎬 Leffahylly PRO v4</h1><div id="controls"><input type="text" id="search" placeholder="Hae elokuvaa..."><select id="sort"><option value="az">A–Ö</option><option value="za">Ö–A</option></select><button onclick="clearCache()">Tyhjennä cache</button></div><div class="grid" id="movies"></div><script>const TMDB_API_KEY = "PASTE_YOUR_TMDB_API_KEY_HERE";const CACHE_KEY = "movieCache_v4";let cache = JSON.parse(localStorage.getItem(CACHE_KEY) || "{}");const movies = `19172001: Space Odyssey201230047 Ronin8 MileAbyssAccountantAccountant 2Ad AstraAir Force OneAlienAliensAlien CovenantAlien RomulusAlita Battle AngelAmerican SniperApollo 13AquamanAquaman the Lost KingdomArgoAvatar the Way of WaterAvangers Infinity WarAvangers EndgameBack to the Future 1Back to the Future 2Back to the Future 3Baby DriverBad Boys 1Bad Boys 2Bad Boys for LifeBad Boys Ride or DieThe BatmanBatman BeginsBlade Runner 2049Bohemian RhapsodyBourne IdentityBourne SupremacyBourne UltimatiumCasablancaDuneDune 2DunkirkE.T.ElvisEqualizerEqualizer 2Equalizer 3ExorcistFast XFord v FerrariForrest GumpGladiatorGladiator IIGodzillaGodzilla vs KongGood FellasGreen MileHeatInceptionInterstellarIndiana Jones and the Dial of DestinyJawsJokerJurassic ParkJustice League Zack SniderKnives OutLoganLord Of the Rings BoxMad Max Fury RoadMan of SteelMatrixMission ImpossibleMission Impossible FalloutMission Impossible Dead ReckoningOppenheimerPacific RimPulp FictionReady Player OneRocky IRocky IIRocky IIIRocky IVSaving Private RyanSevenShiningShutter IslandSisuSkyfallSpider-ManSpider-Man 2Spider-Man 3Spiderman Home ComingSpiderman Far from HomeSpiderman No Way HomeStar TrekStar Wars The Force AwakensStar Wars The Last JediStar Wars The Rise of SkywalkerSupermanTenetTerminatorTerminator 2 Judgement DayThe Dark KnightThe Dark Knight RisesThe RevenantTitanicTop GunTop Gun MaverickTransformersTron LegacyUnchartedVenomVenom Let there be CarnageV for VendettaWarcraft The BeginningWaterworldWonder WomanYesterdayZombieland Double Tap`.split("\n");function saveCache(){ localStorage.setItem(CACHE_KEY, JSON.stringify(cache)); }function clearCache(){ localStorage.removeItem(CACHE_KEY); location.reload(); }async function fetchBatch(list){ for(const title of list){ if(cache[title]) continue; try{ const res = await fetch(`https://api.themoviedb.org/3/search/movie?api_key=${TMDB_API_KEY}&query=${encodeURIComponent(title)}`); const data = await res.json(); if(!data.results?.length) continue; const m = data.results[0]; const details = await fetch(`https://api.themoviedb.org/3/movie/${m.id}?api_key=${TMDB_API_KEY}`).then(r=>r.json()); cache[title] = { poster: m.poster_path ? `https://image.tmdb.org/t/p/w500${m.poster_path}` : null, imdb: details.imdb_id ? `https://www.imdb.com/title/${details.imdb_id}` : null }; saveCache(); }catch{} }}const container = document.getElementById("movies");function render(list){ container.innerHTML=""; list.forEach(title=>{ const data = cache[title]; const card = document.createElement("div"); card.className="card"; card.innerHTML=` <img src="${data?.poster || `https://via.placeholder.com/300x450?text=${encodeURIComponent(title)}`}" /> <h3>${title}</h3> <a href="${data?.imdb || `https://www.imdb.com/find?q=${encodeURIComponent(title)}`}" target="_blank">IMDb</a> <a href="https://www.leffafriikki.com/?s=${encodeURIComponent(title)}" target="_blank">Arvostelu</a> <div class="badge">${data ? "valmis" : "ladataan..."}</div> `; container.appendChild(card); });}function sortMovies(list){ const mode=document.getElementById("sort").value; return [...list].sort((a,b)=> mode==='az'?a.localeCompare(b,'fi'):b.localeCompare(a,'fi'));}function update(){ const term=document.getElementById("search").value.toLowerCase(); let filtered=movies.filter(m=>m.toLowerCase().includes(term)); filtered=sortMovies(filtered); render(filtered);}// 🚀 batch lataus taustalla(async ()=>{ update(); await fetchBatch(movies); update();})();document.getElementById("search").addEventListener("input", update);document.getElementById("sort").addEventListener("change", update);</script></body></html>