Download tasks/fandango/solution/site/implementation/clone/static/navigation.js from TIGER-Lab/WebsiteBench: direct link, hf CLI and curl.
- Browser
- Download file 31.9 kB
-
https://huggingface.co/datasets/TIGER-Lab/WebsiteBench/resolve/main/tasks/fandango/solution/site/implementation/clone/static/navigation.js
- Command line
-
hf download hf://datasets/TIGER-Lab/WebsiteBench/tasks/fandango/solution/site/implementation/clone/static/navigation.js
-
curl -L -o navigation.js https://huggingface.co/datasets/TIGER-Lab/WebsiteBench/resolve/main/tasks/fandango/solution/site/implementation/clone/static/navigation.js
31.9 kB
| /* Local destinations for the public Fandango navigation, captured September 4, 2026. */ | |
| let navState={cart:[],library:[],theaters:[]}; | |
| let storeSlide=0,streamSlide=0,newsCount=8; | |
| const navProducts=NAV_DATA.store.products; | |
| function localAnchor(href,label,cls='',accessible=''){return `<a href="${esc(href)}" data-link class="${cls}" ${accessible?`aria-label="${esc(accessible)}"`:''}>${label}</a>`;} | |
| function navSvg(name){ | |
| const paths={search:'<circle cx="10" cy="10" r="6"/><path d="m15 15 5 5"/>',account:'<circle cx="12" cy="7" r="4"/><path d="M4 22v-3a8 8 0 0 1 16 0v3z"/>',cart:'<path d="M4 6h16l-1 15H5zM8 8V5a4 4 0 0 1 8 0v3"/>',heart:'<path d="M12 21 3 12C-3 5 7-1 12 6c5-7 15-1 9 6z"/>',play:'<path d="m8 5 12 7-12 7z"/>'}; | |
| return `<svg class="nav-svg" viewBox="0 0 24 24" aria-hidden="true">${paths[name]||paths.search}</svg>`; | |
| } | |
| function bindNavigationChrome(){ | |
| root.querySelectorAll('[data-home-notice]').forEach(b=>b.onclick=()=>homeDialog(`<h2>${b.dataset.homeNotice==='privacy'?'Your Privacy Choices':'Feedback'}</h2><p>This is a local recreation. No information is sent to Fandango.</p>`)); | |
| } | |
| async function navUpdate(action){navState=await api('/api/navigation/state',{method:'POST',body:JSON.stringify(action)});return navState;} | |
| function navNotice(title,message){homeDialog(`<h2>${esc(title)}</h2><p>${esc(message)}</p>`);} | |
| function storeHref(href){ | |
| const u=new URL(href,'https://store.fandango.com'); | |
| if(u.pathname.startsWith('/products/')||u.pathname.startsWith('/collections/')||u.pathname.startsWith('/pages/'))return '/fanstore'+u.pathname; | |
| if(u.pathname==='/account')return '/account'; | |
| return '/fanstore'; | |
| } | |
| function storeHeader(){ | |
| return `<header class="store-header"><div class="store-brand-bar">${NAV_DATA.store.brands.map((b,i)=>localAnchor(i===0?'/movies':`/fanstore/collections/all?brand=${encodeURIComponent(b.title)}`,`<img src="${b.image}" alt="${esc(b.title)}">`)).join('')}</div> | |
| <a class="store-announcement" href="#newsletter">Sign up for the Fandango FanStore newsletter and save 15% on your first order!</a> | |
| <div class="store-nav">${localAnchor('/fanstore',`<img src="${NAV_DATA.store.logo}" alt="Fandango FanStore">`,'store-logo')} | |
| <nav aria-label="FanStore"><details><summary>Shop By Product</summary><div>${[...new Set(navProducts.map(p=>p.type).filter(Boolean))].map(t=>localAnchor(`/fanstore/collections/all?type=${encodeURIComponent(t)}`,esc(t))).join('')}</div></details><details><summary>Shop By Title</summary><div>${['Practical Magic 2','Spider-Man','Jaws','Back To The Future','Wicked','Star Wars'].map(t=>localAnchor(`/fanstore/collections/all?q=${encodeURIComponent(t)}`,esc(t))).join('')}</div></details><details><summary>Shop By Brand</summary><div>${[...new Set(navProducts.map(p=>p.brand))].map(t=>localAnchor(`/fanstore/collections/all?brand=${encodeURIComponent(t)}`,esc(t))).join('')}</div></details>${localAnchor('/fanstore/collections/movie-bundles','Movie Bundles')}${localAnchor('/fanstore/collections/all?sale=1','Sale')}</nav> | |
| <div class="store-tools"><button data-store-search aria-label="Search FanStore">${navSvg('search')}</button>${localAnchor('/account',navSvg('account'),'store-account','Account')}${localAnchor('/fanstore/cart',`${navSvg('cart')}<span>${navState.cart.reduce((n,l)=>n+l.quantity,0)||''}</span>`,'store-cart','Shopping bag')}</div></div></header>`; | |
| } | |
| function storeFooter(){ | |
| return `<section class="store-newsletter" id="newsletter"><h2>15% OFF FOR OUR SUPER FANS</h2><p>Sign up for the Fandango FanStore newsletter and SAVE 15% on your first order!</p><form data-newsletter><label for="store-email">Email</label><input type="email" id="store-email" required placeholder="Email"><button type="submit">SUBSCRIBE</button><p class="local-note">Local preview only. No subscription or email will be sent.</p></form></section> | |
| <footer class="store-footer">${NAV_DATA.store.footer.map(c=>`<section><h2>${esc(c.title)}</h2>${c.links.length?c.links.map(l=>localAnchor(l.href.startsWith('http')?'/help':storeHref(l.href),esc(l.title))).join(''):`<p>${esc(c.text.replace(c.title,''))}</p>`}</section>`).join('')}<p class="store-legal">© 2026 Fandango FanStore · ${localAnchor('/policies/privacy-policy','Privacy Policy')} · ${localAnchor('/policies/terms-of-use','Terms of Use')}<br>WebsiteBench offline recreation. Not the official store. No real purchases, payments or emails.</p></footer>`; | |
| } | |
| function storeLayout(content){ | |
| document.body.className='fanstore-page';root.innerHTML=storeHeader()+`<main class="store-main">${content}</main>`+storeFooter();bindGlobal(); | |
| root.querySelector('[data-store-search]').onclick=()=>{const d=homeDialog('<h2>Search FanStore</h2><form data-store-search-form><input name="q" aria-label="Search products" placeholder="Search products"><button class="primary">Search</button></form>');d.querySelector('form').onsubmit=e=>{e.preventDefault();const q=new FormData(e.currentTarget).get('q');d.close();go(`/fanstore/collections/all?q=${encodeURIComponent(q)}`);};d.querySelector('input').focus();}; | |
| root.querySelector('[data-newsletter]').onsubmit=e=>{e.preventDefault();navNotice('Newsletter preview','This local recreation does not subscribe you or send your email to a mailing list.');}; | |
| } | |
| function productCard(p){return `<article class="store-product-card">${localAnchor('/fanstore/products/'+p.id,`<div class="store-product-image"><img src="${p.image}" alt="${esc(p.title)}" loading="lazy">${!p.available?'<span class="store-badge sold">Sold Out</span>':p.tags.includes('New')?'<span class="store-badge">New</span>':''}</div><h3>${esc(p.title)}</h3><p>${money(p.price)}</p>`)}<button class="store-quick" data-quick="${esc(p.id)}">Quick view</button></article>`;} | |
| function bindProductCards(){root.querySelectorAll('[data-quick]').forEach(b=>b.onclick=()=>{const p=navProducts.find(p=>p.id===b.dataset.quick);const d=homeDialog(`<div class="quick-product"><img src="${p.image}" alt="${esc(p.title)}"><div><h2>${esc(p.title)}</h2><p>${money(p.price)}</p><p>${esc(p.description.slice(0,250))}</p>${localAnchor('/fanstore/products/'+p.id,'View full details','primary')}</div></div>`);d.querySelector('[data-link]').onclick=e=>{e.preventDefault();d.close();go('/fanstore/products/'+p.id);};});} | |
| function storeHero(){const s=NAV_DATA.store.slides[storeSlide];return `<section class="store-hero" aria-label="Featured bundle"><img class="store-hero-image" src="${s.image}" alt=""><div class="store-hero-copy"><img src="${s.logo}" alt="${esc(s.title)}"><p>NEW!</p><h1>${esc(s.title)}</h1>${localAnchor(storeHref(s.href),esc(s.cta),'store-buy')}</div><button class="round-arrow previous" data-store-slide="-1" aria-label="Previous bundle">‹</button><button class="round-arrow next" data-store-slide="1" aria-label="Next bundle">›</button><div class="nav-dots">${NAV_DATA.store.slides.map((s,i)=>`<button data-store-dot="${i}" aria-label="Show bundle ${i+1}" aria-current="${i===storeSlide}"></button>`).join('')}</div></section>`;} | |
| function storeHome(){ | |
| const tiles=NAV_DATA.store.tiles; | |
| storeLayout(storeHero()+`<div class="store-content"><div class="store-tiles two">${tiles.slice(0,2).map(t=>localAnchor(storeHref(t.href),`<img src="${t.image}" alt="${esc(t.title)}"><span>${esc(t.title)}</span>`)).join('')}</div><h2>FAN FAVORITES</h2><div class="store-tiles three">${tiles.slice(2).map(t=>localAnchor(storeHref(t.href),`<img src="${t.image}" alt="${esc(t.title)}"><span>${esc(t.title)}</span>`)).join('')}</div><h2>TRENDING</h2><div class="store-trending" data-scroll-row><div class="store-product-track">${NAV_DATA.store.trending.map(id=>productCard(navProducts.find(p=>p.id===id))).join('')}</div><button class="round-arrow previous" data-row-step="-1" aria-label="Previous trending products">‹</button><button class="round-arrow next" data-row-step="1" aria-label="Next trending products">›</button></div></div>`); | |
| root.querySelectorAll('[data-store-slide]').forEach(b=>b.onclick=()=>{storeSlide=(storeSlide+Number(b.dataset.storeSlide)+2)%2;storeHome();});root.querySelectorAll('[data-store-dot]').forEach(b=>b.onclick=()=>{storeSlide=Number(b.dataset.storeDot);storeHome();});bindRows();bindProductCards(); | |
| } | |
| function storeCollection(handle){ | |
| const q=new URLSearchParams(location.search),search=q.get('q')||'',type=q.get('type')||'',brand=q.get('brand')||'',sort=q.get('sort')||'featured';let rows=[...navProducts]; | |
| const terms={'mando-grogu-glass-set':'Mandalorian','jaws':'Jaws','golf-1':'golf','fandango-we-love-free':'We Love Free','movie-bundles':'bundle','practical-magic-2':'Practical Magic 2'}; | |
| const term=(search||terms[handle]||'').toLowerCase();if(term)rows=rows.filter(p=>(p.title+' '+p.type+' '+p.tags.join(' ')).toLowerCase().includes(term));if(type)rows=rows.filter(p=>p.type===type);if(brand)rows=rows.filter(p=>p.brand.toLowerCase()===brand.toLowerCase());if(q.has('sale'))rows=rows.filter(p=>p.tags.some(t=>/sale/i.test(t))); | |
| if(q.get('available'))rows=rows.filter(p=>p.available);if(q.get('max'))rows=rows.filter(p=>p.price<=Number(q.get('max'))); | |
| if(sort==='price-ascending')rows.sort((a,b)=>a.price-b.price);else if(sort==='price-descending')rows.sort((a,b)=>b.price-a.price);else if(sort==='title')rows.sort((a,b)=>a.title.localeCompare(b.title));else if(sort==='featured')rows.sort((a,b)=>{const ai=NAV_DATA.store.featuredOrder.indexOf(a.id),bi=NAV_DATA.store.featuredOrder.indexOf(b.id);return (ai<0?999:ai)-(bi<0?999:bi);}); | |
| const page=Math.max(1,Math.min(Number(q.get('page'))||1,Math.ceil(rows.length/24)||1)); | |
| storeLayout(`<div class="store-content catalog"><p class="breadcrumb">${localAnchor('/fanstore','Home')} / ${esc(terms[handle]||'All')}</p><h1>${search?`Search results for “${esc(search)}”`:esc(terms[handle]||'All')}</h1><form class="store-filters"><label>Search<input name="q" value="${esc(search)}" placeholder="Search products"></label><label>Product type<select name="type"><option value="">All products</option>${[...new Set(navProducts.map(p=>p.type).filter(Boolean))].map(t=>`<option ${t===type?'selected':''}>${esc(t)}</option>`).join('')}</select></label><label>Price: up to $<input name="max" type="number" min="0" value="${esc(q.get('max')||'')}" placeholder="Any"></label><label>Sort by<select name="sort">${[['featured','Featured'],['best-selling','Best selling'],['title','Alphabetically, A–Z'],['price-ascending','Price, low to high'],['price-descending','Price, high to low']].map(([v,t])=>`<option value="${v}" ${sort===v?'selected':''}>${t}</option>`).join('')}</select></label><button>Apply</button><span>${rows.length} products</span></form><div class="store-product-grid">${rows.slice((page-1)*24,page*24).map(productCard).join('')||'<p>No products found. Try another search or clear the filters.</p>'}</div><nav class="store-pagination" aria-label="Product pages">${Array.from({length:Math.ceil(rows.length/24)},(_,i)=>{const params=new URLSearchParams(q);params.set('page',i+1);return localAnchor(`/fanstore/collections/${handle}?${params}`,`${i+1}`,i+1===page?'selected':'');}).join('')}</nav></div>`); | |
| root.querySelector('.store-filters').onsubmit=e=>{e.preventDefault();go(`/fanstore/collections/${handle}?${new URLSearchParams(new FormData(e.currentTarget))}`);};bindProductCards(); | |
| } | |
| function storeProduct(id){ | |
| const p=navProducts.find(p=>p.id===id);if(!p){notFound();return;} | |
| const selected=new URLSearchParams(location.search).get('variant');let variant=p.variants.find(v=>v.id===selected)||p.variants.find(v=>v.available)||p.variants[0];const pictures=[...new Set([p.image,...p.images])]; | |
| storeLayout(`<div class="store-content"><p class="breadcrumb">${localAnchor('/fanstore','Home')} / ${localAnchor('/fanstore/collections/all','All')} / ${esc(p.title)}</p><div class="store-product-detail"><section class="store-gallery"><img class="store-detail-image" src="${variant?.image||p.image}" alt="${esc(p.title)}"><div>${pictures.map((image,i)=>`<button data-product-image="${image}" aria-label="View product image ${i+1}"><img src="${image}" alt=""></button>`).join('')}</div></section><section class="store-product-info"><p class="store-vendor">${esc(p.brand)}</p><h1>${esc(p.title)}</h1><p class="store-price">${money(variant?.price??p.price)}</p><form data-add-cart>${p.options.filter(o=>o.name!=='Title').map((o,i)=>`<label>${esc(o.name)}<select data-variant-option="${i}" aria-label="${esc(o.name)}">${o.values.map(v=>`<option ${variant?.options[i]===v?'selected':''}>${esc(v)}</option>`).join('')}</select></label>`).join('')}<label>Quantity<input name="quantity" type="number" min="1" max="99" value="1"></label><button class="store-add" ${!variant?.available?'disabled':''}>${!p.available?'Sold out':variant?'Add to cart':'Specifications unavailable'}</button><p class="local-note">Local shopping bag preview. No order or payment is placed.</p></form><h2>Product Details</h2><p class="product-description">${esc(p.description||'Product specifications were not returned by the source during this capture. The displayed title, image and price are from the verified catalog.')}</p></section></div></div>`); | |
| root.querySelectorAll('[data-product-image]').forEach(b=>b.onclick=()=>root.querySelector('.store-detail-image').src=b.dataset.productImage); | |
| root.querySelectorAll('[data-variant-option]').forEach(s=>s.onchange=()=>{const values=[...root.querySelectorAll('[data-variant-option]')].map(s=>s.value);variant=p.variants.find(v=>v.options.every((o,i)=>o===values[i]));const button=root.querySelector('.store-add');button.disabled=!variant?.available;button.textContent=variant?(variant.available?'Add to cart':'Sold out'):'Option unavailable in this preview';if(variant?.image)root.querySelector('.store-detail-image').src=variant.image;root.querySelector('.store-price').textContent=money(variant?.price??p.price);if(variant)history.replaceState({},'',`/fanstore/products/${id}?variant=${variant.id}`);}); | |
| root.querySelector('[data-add-cart]').onsubmit=async e=>{e.preventDefault();if(!variant?.available)return;try{const existing=navState.cart.find(l=>l.variant===variant.id)?.quantity||0;await navUpdate({kind:'cart',product:id,variant:variant.id,quantity:existing+Number(new FormData(e.currentTarget).get('quantity'))});go('/fanstore/cart');}catch(err){notify(err.message);}}; | |
| } | |
| function storeCart(){ | |
| storeLayout(`<div class="store-content cart-page"><h1>Your cart</h1>${navState.cart.length?`<div class="cart-lines">${navState.cart.map(l=>`<article>${localAnchor('/fanstore/products/'+l.product,`<img src="${l.image}" alt="${esc(l.title)}">`)}<div>${localAnchor('/fanstore/products/'+l.product,esc(l.title))}<p>${l.option==='Default Title'?'':esc(l.option)}</p><p>${money(l.price)}</p><button data-remove="${l.variant}">Remove</button></div><label>Quantity<input aria-label="Quantity for ${esc(l.title)}" data-cart-quantity="${l.variant}" type="number" min="0" max="99" value="${l.quantity}"></label><strong>${money(l.price*l.quantity)}</strong></article>`).join('')}</div><div class="cart-total"><h2>Subtotal ${money(navState.subtotal)}</h2><p>Shipping and taxes are not calculated in this local preview.</p><p class="local-note">Shopping bag saved locally. Real checkout is not connected.</p>${localAnchor('/fanstore/collections/all','Continue shopping','primary')}</div>`:`<p>Your cart is empty</p>${localAnchor('/fanstore/collections/all','Continue shopping','primary')}`}</div>`); | |
| const update=async(id,quantity)=>{const l=navState.cart.find(l=>l.variant===id);try{await navUpdate({kind:'cart',product:l.product,variant:id,quantity});storeCart();}catch(e){notify(e.message);}}; | |
| root.querySelectorAll('[data-cart-quantity]').forEach(input=>input.onchange=()=>update(input.dataset.cartQuantity,Number(input.value)));root.querySelectorAll('[data-remove]').forEach(b=>b.onclick=()=>update(b.dataset.remove,0)); | |
| } | |
| function bindRows(){root.querySelectorAll('[data-scroll-row]').forEach(row=>{const track=row.firstElementChild;const buttons=row.querySelectorAll('[data-row-step]');const update=()=>buttons.forEach(b=>b.disabled=Number(b.dataset.rowStep)<0?track.scrollLeft<1:track.scrollLeft>=track.scrollWidth-track.clientWidth-2);buttons.forEach(b=>b.onclick=()=>track.scrollBy({left:Number(b.dataset.rowStep)*track.clientWidth*.85,behavior:'smooth'}));track.onscroll=update;update();});} | |
| function streamHeader(){return `<header class="stream-header">${localAnchor('/streaming',`<img src="${NAV_DATA.streaming.logo}" alt="Fandango Stream">`,'stream-logo')}<nav aria-label="Streaming">${[['/streaming','Stream Free'],['/streaming?category=rent','Rent & Buy'],['/streaming?category=movies','Movies'],['/streaming?category=tv','TV'],['/streaming/library','My Library']].map(([h,t])=>localAnchor(h,t)).join('')}</nav><div class="stream-tools">${localAnchor('/account',homeIcon('fanclub')+'FanClub')}${localAnchor('/movies',homeIcon('movies')+'Buy Tickets')}${localAnchor('/help#gift-cards',homeIcon('gift')+'Gift Cards')}${localAnchor('/fanstore',homeIcon('fanstore')+'FanStore')}${localAnchor('/account',homeIcon('account')+'Sign In')}<button data-stream-search aria-label="Search streaming">${navSvg('search')}</button></div></header>`;} | |
| function streamLayout(content){document.body.className='streaming-page';root.innerHTML=streamHeader()+`<main>${content}</main><footer class="stream-footer"><div>${[['Watch',[['Movies','/streaming?category=movies'],['TV','/streaming?category=tv'],['Free','/streaming']]],['My Account',[['My Library','/streaming/library'],['Account','/account'],['Sign In','/account/login']]],['Features',[['FanClub','/account'],['Gift Cards','/help#gift-cards']]],['Help',[['Support','/help'],['Privacy Policy','/policies/privacy-policy'],['Terms of Use','/policies/terms-of-use']]]].map(([h,links])=>`<section><h2>${h}</h2>${links.map(([t,h])=>localAnchor(h,t)).join('')}</section>`).join('')}</div><p>WebsiteBench offline recreation. Not the official streaming service. Full-length films are not included.</p></footer>`;bindGlobal();root.querySelector('[data-stream-search]').onclick=()=>{const d=homeDialog('<h2>Search movies and TV</h2><form><input name="q" aria-label="Search streaming titles"><button class="primary">Search</button></form>');d.querySelector('form').onsubmit=e=>{e.preventDefault();const q=new FormData(e.currentTarget).get('q');d.close();go('/streaming?q='+encodeURIComponent(q));};};} | |
| function streamMovies(){const rows=[...NAV_DATA.streaming.rows.flatMap(r=>r.movies),...HOME_DATA.free.map(m=>({...m,id:m.href.split('/').pop()}))];return [...new Map(rows.map(m=>[m.id,m])).values()];} | |
| function streamRow(title,rows,wide=false){return `<section class="stream-row ${wide?'stream-wide':''}"><h2>${esc(title)}</h2><div data-scroll-row><div class="stream-track">${rows.map(m=>localAnchor('/streaming/movies/'+m.id,`<div><img src="${m.image}" alt="${esc(m.title)}" loading="lazy"><span>Free to Watch</span></div>`)).join('')}</div><button class="round-arrow previous" data-row-step="-1" aria-label="Previous ${esc(title)}">‹</button><button class="round-arrow next" data-row-step="1" aria-label="Next ${esc(title)}">›</button></div></section>`;} | |
| function streamHero(s,detail=false){return `<section class="stream-hero ${detail?'stream-detail':''}" style="background-image:url('${s.image}')"><div class="stream-hero-copy">${s.logo?`<img class="stream-title" src="${s.logo}" alt="${esc(s.title)}">`:`<h1>${esc(s.title)}</h1>`}<p class="stream-meta">${esc(s.metadata||'')}</p><p class="stream-synopsis">${esc(s.description||'')}</p><div class="stream-actions"><button class="stream-watch" data-watch="${s.id}">${navSvg('play')} Watch Now</button>${detail?`<button data-library="${s.id}">${navState.library.includes(s.id)?'✓ In My Library':'+ Add to My Library'}</button>`:localAnchor('/streaming/movies/'+s.id,'Details')}</div></div>${!detail?`<button class="round-arrow previous" data-stream-slide="-1" aria-label="Previous featured title">‹</button><button class="round-arrow next" data-stream-slide="1" aria-label="Next featured title">›</button><div class="nav-dots">${NAV_DATA.streaming.slides.map((s,i)=>`<button data-stream-dot="${i}" aria-label="Show featured title ${i+1}" aria-current="${i===streamSlide}"></button>`).join('')}</div>`:''}</section>`;} | |
| function bindStreaming(){bindRows();root.querySelectorAll('[data-stream-slide]').forEach(b=>b.onclick=()=>{streamSlide=(streamSlide+Number(b.dataset.streamSlide)+NAV_DATA.streaming.slides.length)%NAV_DATA.streaming.slides.length;streamHome();});root.querySelectorAll('[data-stream-dot]').forEach(b=>b.onclick=()=>{streamSlide=Number(b.dataset.streamDot);streamHome();});root.querySelectorAll('[data-watch]').forEach(b=>b.onclick=()=>navNotice('Watch preview','This local recreation does not include the licensed full-length movie. No streaming purchase, rental or subscription will be started.'));root.querySelectorAll('[data-library]').forEach(b=>b.onclick=async()=>{try{await navUpdate({kind:'library',id:b.dataset.library});b.textContent=navState.library.includes(b.dataset.library)?'✓ In My Library':'+ Add to My Library';}catch(e){notify(e.message);}});} | |
| function streamHome(){const q=new URLSearchParams(location.search),term=q.get('q'),category=q.get('category');let rows=streamMovies();if(term)rows=rows.filter(m=>m.title.toLowerCase().includes(term.toLowerCase()));if(category==='tv')rows=rows.filter(m=>/season/i.test(m.title));if(category==='movies')rows=rows.filter(m=>!/season/i.test(m.title));if(term||category){streamLayout(`<div class="stream-browse"><h1>${term?`Search: ${esc(term)}`:category==='tv'?'TV':category==='rent'?'Rent & Buy':'Movies'}</h1>${category==='rent'?'<p class="local-note">The captured source opened the free catalog. Rental offers and prices were not available in this snapshot.</p>':''}${streamRow(term?'Search results':'Browse titles',rows)}${!rows.length?'<p>No matching titles.</p>':''}</div>`);}else streamLayout(streamHero(NAV_DATA.streaming.slides[streamSlide])+NAV_DATA.streaming.rows.map(r=>streamRow(r.title,r.movies,r.wide)).join(''));bindStreaming();} | |
| function streamDetail(id){const hero=NAV_DATA.streaming.slides.find(m=>m.id===id),movie=streamMovies().find(m=>m.id===id);if(!hero&&!movie){notFound();return;}streamLayout(hero?streamHero(hero,true):`<section class="stream-poster-detail"><img src="${movie.image}" alt="${esc(movie.title)}"><div><h1>${esc(movie.title)}</h1><p>Free to Watch</p><button class="stream-watch" data-watch="${id}">${navSvg('play')} Watch Now</button><button data-library="${id}">${navState.library.includes(id)?'✓ In My Library':'+ Add to My Library'}</button></div></section>`);bindStreaming();} | |
| let newsResizeObserver; | |
| function bindNewsGrid(){const grid=root.querySelector('.news-grid');const align=()=>{const css=getComputedStyle(grid),gap=parseFloat(css.rowGap),step=parseFloat(css.gridAutoRows)+gap;grid.querySelectorAll('article').forEach(card=>card.style.gridRowEnd='span '+Math.ceil((card.getBoundingClientRect().height+gap)/step));};grid.querySelectorAll('img').forEach(img=>img.addEventListener('load',align));newsResizeObserver?.disconnect();newsResizeObserver=new ResizeObserver(align);newsResizeObserver.observe(grid);document.fonts.ready.then(align);align();} | |
| function newsPage(){layout(`<div class="news-page"><h1>Movie News</h1>${homeCarousel('news-now','Now Playing',HOME_DATA.now)}${homeCarousel('news-features','Features',NAV_DATA.news.features,'',true)}<section class="news-latest"><h2>Latest News</h2><div class="news-grid">${NAV_DATA.news.articles.slice(0,newsCount).map(a=>`<article>${localAnchor(homeHref(a.href),`<img src="${a.image}" alt="" loading="lazy"><h3>${esc(a.title)}</h3>`)}</article>`).join('')}</div>${newsCount<NAV_DATA.news.articles.length?'<button class="news-load" data-news-more>Load More Features</button>':''}</section></div>${newsBottom()}`);bindHomeCarousel();bindNewsGrid();root.querySelector('[data-news-more]')?.addEventListener('click',()=>{const y=scrollY;newsCount+=8;newsPage();window.scrollTo(0,y);});} | |
| function newsBottom(){return `<section class="home-new-soon"><h2>NEW & COMING SOON</h2><div>${HOME_DATA.newSoon.map(m=>homeLink(m.href,`<img src="${m.image}" alt="${esc(m.title)}" loading="lazy">`)).join('')}</div></section>`;} | |
| function newsDetail(path){const items=[...NAV_DATA.news.articles,...NAV_DATA.news.features,...HOME_DATA.features];const item=items.find(a=>new URL(a.href,HOME_DATA.source).pathname===path);if(!item){notFound();return;}const detail=NAV_DATA.news.details?.[path];layout(`<article class="news-article"><p>${localAnchor('/movie-news','Movie News')}</p><h1>${esc(item.title)}</h1>${detail?`<p class="article-byline">${esc(detail.author)} · ${esc(detail.date)}</p>`:''}<img class="article-cover" src="${detail?.image||item.image}" alt="${esc(item.title)}">${detail?detail.paragraphs.map(p=>`<p>${esc(p)}</p>`).join(''):`<p>${esc(item.description||'')}</p>`}${path.startsWith('/movie-trailer')?'<button class="primary" data-news-video>Play video</button>':''}${!detail?'<p class="local-note">This preview includes the captured cover and headline. The full article or licensed video was not available in the source capture.</p>':''}</article>${newsBottom()}`);root.querySelector('[data-news-video]')?.addEventListener('click',()=>navNotice('Video preview','The original video media was not available for local playback. This page will not redirect you to the official site.'));} | |
| function localTheaters(id){ | |
| const q=new URLSearchParams(location.search),onlySaved=q.get('filter')==='my-theaters',selected=q.get('theater')||id||'',chain=q.get('chain')||'',date=q.get('date')||NAV_DATA.theaters.date;let rows=NAV_DATA.theaters.rows; | |
| if(selected)rows=rows.filter(t=>t.id===selected);if(chain)rows=rows.filter(t=>t.name.startsWith(chain));if(onlySaved)rows=rows.filter(t=>navState.theaters.includes(t.id)); | |
| layout(`<div class="local-theaters"><h1>${id?esc(rows[0]?.name||'Theaters'): 'Movie times + Tickets near 90001'}</h1><div class="theater-tabs">${localAnchor('/theaters?zip=90001','Fandango Ticketing Theaters',!onlySaved?'selected':'')}${localAnchor('/theaters?zip=90001&filter=my-theaters','My theaters',onlySaved?'selected':'')}<button data-location>${homeIcon('location')} 90001</button></div><div class="local-dates" aria-label="Movie Times Calendar">${NAV_DATA.theaters.dates.map(d=>d.date).map(d=>localAnchor(`/theaters?zip=90001&date=${d}`,`${longDate(d)}`,date===d?'selected':'')).join('')}</div><div class="theater-controls"><label>Nearby Theaters<select data-theater-filter><option value="">All theaters</option>${NAV_DATA.theaters.rows.map(t=>`<option value="${t.id}" ${t.id===selected?'selected':''}>${esc(t.name)}</option>`).join('')}</select></label><label>Filter by Theater Chain<select data-chain-filter><option value="">All theater chains</option>${[...new Set(NAV_DATA.theaters.rows.map(t=>t.name.split(' ')[0]))].map(c=>`<option ${chain===c?'selected':''}>${esc(c)}</option>`).join('')}</select></label></div><div class="local-theater-list">${rows.map(t=>{const dated=date===NAV_DATA.theaters.date?t.movies:NAV_DATA.theaters.otherDates?.[date]?.find(r=>r.id===t.id)?.movies||[];return `<section class="local-theater"><header><div><h2>${localAnchor('/theaters/local/'+t.id,esc(t.name))}</h2><p>${esc(t.address)} <span>${esc(t.distance)}</span></p><button data-map="${t.id}">Map</button> · <button data-amenities="${t.id}">Amenities</button></div><button data-save-theater="${t.id}" aria-label="${navState.theaters.includes(t.id)?'Remove':'Save'} ${esc(t.name)}" class="${navState.theaters.includes(t.id)?'saved':''}">${navSvg('heart')}</button></header>${dated.map(m=>`<article class="local-showtime-movie"><div class="local-movie-info">${homeLink(m.href,`<img src="${m.image}" alt="${esc(m.title)}">`)}<div><h3>${homeLink(m.href,esc(m.title))}</h3><p>${esc(m.metadata)}</p></div></div><div class="local-showtime-groups">${m.groups.map(g=>`<section><h4>${esc(g.format)}</h4><p>${esc(g.amenities)}</p><div>${g.times.map(v=>`<button data-local-showtime="${esc(t.id)}" data-movie="${esc(m.title)}" data-time="${esc(v.time)}">${esc(v.time)}</button>`).join('')}</div></section>`).join('')}</div></article>`).join('')||'<p class="local-note">No showtimes were returned for this theater in the selected date capture.</p>'}</section>`;}).join('')||'<p>No theaters match the selected filters.</p>'}</div></div>`); | |
| root.querySelector('[data-location]').onclick=()=>homeLocationDialog(zip=>go('/theaters?zip='+zip));const change=()=>{const query=new URLSearchParams({zip:'90001',date,theater:root.querySelector('[data-theater-filter]').value,chain:root.querySelector('[data-chain-filter]').value});go('/theaters?'+query);};root.querySelector('[data-theater-filter]').onchange=change;root.querySelector('[data-chain-filter]').onchange=change; | |
| root.querySelectorAll('[data-amenities]').forEach(b=>b.onclick=()=>{const t=NAV_DATA.theaters.rows.find(t=>t.id===b.dataset.amenities);navNotice(t.name+' — Amenities',t.amenities.join(' · '));});root.querySelectorAll('[data-map]').forEach(b=>b.onclick=()=>{const t=NAV_DATA.theaters.rows.find(t=>t.id===b.dataset.map);navNotice(t.name,t.address+' · '+t.distance+' from 90001. An external map is not loaded in this offline preview.');});root.querySelectorAll('[data-save-theater]').forEach(b=>b.onclick=async()=>{try{await navUpdate({kind:'theaters',id:b.dataset.saveTheater});localTheaters(id);}catch(e){notify(e.message);}}); | |
| root.querySelectorAll('[data-local-showtime]').forEach(b=>b.onclick=()=>navNotice(b.dataset.movie,`${longDate(date)} · ${b.dataset.time}. This captured Los Angeles showtime has no verified ticket-price or seat inventory in the local preview. No real booking will be made.`)); | |
| } | |
| function referenceMovie(id){const m=[...HOME_DATA.now,...HOME_DATA.soon,...HOME_DATA.newSoon].find(m=>new URL(m.href,HOME_DATA.source).pathname.includes('/'+id+'/'));if(!m){notFound();return;}layout(`<section class="reference-movie"><img src="${m.image}" alt="${esc(m.title)}"><div><h1>${esc(m.title)}</h1><p>${localAnchor('/theaters?zip='+homeZip,'See nearby theater showtimes','primary')}</p><p class="local-note">The poster and title match the captured homepage. Additional movie details were not included in this source snapshot.</p></div></section>`);} | |
| async function navigationRoute(path){ | |
| if(path==='/theaters'){const zip=new URLSearchParams(location.search).get('zip')||'10003';if(['90001','10003'].includes(zip)){homeZip=zip;localStorage.setItem('fandango-home-zip',zip);}} | |
| if(!(/^(\/fanstore|\/streaming|\/movie-news|\/movie-photos|\/movie-trailer|\/theaters\/local|\/movies\/reference)/.test(path)||(path==='/theaters'&&new URLSearchParams(location.search).get('zip')==='90001')))return false; | |
| navState=await api('/api/navigation/state'); | |
| if(path==='/fanstore')storeHome();else if(path==='/fanstore/cart')storeCart();else if(path.startsWith('/fanstore/products/'))storeProduct(path.split('/')[3]);else if(path.startsWith('/fanstore/collections/'))storeCollection(path.split('/')[3]);else if(path.startsWith('/fanstore/pages/')){storeLayout(`<div class="store-content"><h1>${esc(path.split('/').pop().replaceAll('-',' '))}</h1><p>Real store policies do not apply to this offline shopping preview.</p>${localAnchor('/help','Local help and information')}</div>`);}else if(path==='/streaming')streamHome();else if(path==='/streaming/library'){streamLayout(`<div class="stream-browse"><h1>My Library</h1>${streamRow('Saved titles',streamMovies().filter(m=>navState.library.includes(m.id)))}${!navState.library.length?'<p>Your library is empty. Add a title from its details page.</p>':''}</div>`);bindStreaming();}else if(path.startsWith('/streaming/movies/'))streamDetail(path.split('/')[3]);else if(path==='/movie-news')newsPage();else if(/^\/movie-(news|photos|trailer)\//.test(path))newsDetail(path);else if(path.startsWith('/movies/reference/'))referenceMovie(path.split('/')[3]);else localTheaters(path.startsWith('/theaters/local/')?path.split('/')[3]:null); | |
| return true; | |
| } | |