|
1
|
/* Self-contained accessible preview. No client JavaScript, external resources or real commerce data. */ |
|
2
|
addEventListener("fetch", event => event.respondWith(serve(event.request))); |
|
3
|
const I18N = { |
|
4
|
fa:{dir:"rtl",banner:"پیشنمایش طراحی؛ خرید و پرداخت غیرفعال است",h:"فروشگاه شما،",h2:"در یک نگاه متفاوت",desc:"پیشنمایش سبک فروشگاه چندکشوری مدوسا، بدون نیاز به اجرای جاوااسکریپت.",market:"انتخاب کشور",language:"زبان",examples:"مجموعههای نمونه",info:"این موارد فقط نمونه طراحی هستند؛ قیمت، موجودی و امکان سفارش واقعی ندارند.",cat:"دستهبندی",all:"همه",iranian:"محصولات منتخب ایران",electronics:"دیجیتال و الکترونیک",search:"جستوجو",placeholder:"جستوجو در نمونهها",empty:"موردی مطابق جستوجو نبود",more:"توضیحات نمونه",name:["گوشی هوشمند","لپتاپ","لوازم صوتی","دوربین","چای ایرانی","سفال ایرانی","منسوجات دستباف","زعفران"],countries:["ایران","امارات","عمان","عراق","قطر"]}, |
|
5
|
en:{dir:"ltr",banner:"Design preview; purchase and payment are disabled",h:"Your store,",h2:"a fresh perspective",desc:"A lightweight Medusa storefront showcase across five markets, with no client-side JavaScript required.",market:"Select market",language:"Language",examples:"Sample collections",info:"Illustrative design samples only: no real price, stock or checkout.",cat:"Category",all:"All",iranian:"Iran-origin collections",electronics:"Electronics",search:"Search",placeholder:"Search examples",empty:"No examples matched",more:"Sample details",name:["Smartphone","Laptop","Audio accessories","Camera","Iranian tea","Iranian pottery","Handwoven textiles","Saffron"],countries:["Iran","UAE","Oman","Iraq","Qatar"]}, |
|
6
|
ar:{dir:"rtl",banner:"معاينة التصميم؛ الشراء والدفع غير متاحين",h:"متجرك،",h2:"برؤية جديدة",desc:"نسخة عرض خفيفة لمتجر Medusa في خمسة أسواق دون الحاجة إلى JavaScript.",market:"اختر السوق",language:"اللغة",examples:"مجموعات نموذجية",info:"هذه أمثلة تصميمية فقط، بلا أسعار حقيقية أو مخزون أو شراء.",cat:"الفئة",all:"الكل",iranian:"منتجات مختارة من إيران",electronics:"الإلكترونيات",search:"بحث",placeholder:"ابحث في الأمثلة",empty:"لا توجد نتائج",more:"تفاصيل المثال",name:["هاتف ذكي","حاسوب محمول","سماعات","كاميرا","الشاي الإيراني","الفخار الإيراني","منسوجات يدوية","الزعفران"],countries:["إيران","الإمارات","عمان","العراق","قطر"]} |
|
7
|
}; |
|
8
|
const CODES=["IR","AE","OM","IQ","QA"]; |
|
9
|
const CURRENCY=["IRR","AED","OMR","IQD","QAR"]; |
|
10
|
const CSS=':root{font-family:Tahoma,Arial,sans-serif;background:#f7f6f0;color:#1a382b}*{box-sizing:border-box}body{margin:0;min-width:300px}a{color:inherit;text-decoration:none}button,input{font:inherit}.bar{background:#164638;color:#f7f8ee;text-align:center;padding:11px 14px;font-size:12px}header{background:#fffcf6;display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:16px;padding:21px clamp(20px,5vw,75px)}.brand{display:flex;direction:ltr;align-items:center;gap:10px;font-size:20px;font-weight:900}.brand b{padding:10px 14px;border-radius:12px;background:#194c39;color:#fff}.brand small{font-size:9px;letter-spacing:2px;display:block}.lang{display:flex;gap:7px}.lang a,.countries a,.filters a{display:inline-block;background:white;border:1px solid #dbe3d8;border-radius:8px;padding:10px 12px;font-size:12px}.lang a.sel,.countries a.sel,.filters a.sel{background:#194b3c;border-color:#194b3c;color:white}main{max-width:1450px;margin:auto}.hero{background:linear-gradient(115deg,#dfeadf,#f7f2e6);padding:clamp(55px,9vw,110px) clamp(23px,7vw,100px)}.tag{color:#437b63;font-weight:800;font-size:12px;letter-spacing:1px}h1{font-size:clamp(40px,6vw,79px);letter-spacing:-.05em;line-height:1.2;margin:20px 0}h1 em{color:#427d61;font-style:normal}.hero p{max-width:650px;line-height:2;color:#5b6f60;font-size:15px}.market-pill{margin-top:25px;display:inline-flex;gap:13px;align-items:center;border:1px solid #d5e1d5;border-radius:9px;background:#fff;padding:12px 17px;font-size:13px}.market-pill strong{color:#287452;direction:ltr}.content{padding:55px clamp(20px,6vw,90px) 80px}h2{font-size:clamp(28px,3.3vw,41px);margin:0 0 10px}.note{color:#6b7d6c;font-size:13px;line-height:2;max-width:700px}.label{font-size:12px;font-weight:800;color:#467456;margin:26px 0 11px}.countries,.filters{display:flex;gap:8px;flex-wrap:wrap}.search{display:flex;gap:9px;flex-wrap:wrap;margin:22px 0 28px}.search input{padding:13px;border:1px solid #d7dfd5;border-radius:9px;min-width:200px;flex:1;max-width:430px;background:white}.search button{background:#194c39;color:white;border:0;border-radius:9px;padding:13px 22px}.grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:20px}.card{background:white;border:1px solid #e5ebe1;border-radius:13px;overflow:hidden}.art{height:195px;display:grid;place-items:center;background:linear-gradient(135deg,#dae7d8,#eeeadd);color:#699879;font-size:67px;font-family:Georgia,serif}.card:nth-child(2n) .art{background:linear-gradient(125deg,#ece3d8,#f4f1e8);color:#b08b6c}.cardbody{padding:20px}.meta{color:#5c8469;font-size:10px;font-weight:700}.card h3{font-size:18px;margin:12px 0 5px}.card p,.card details{font-size:12px;color:#728274;line-height:1.8}.card details{margin-top:15px}.card summary{cursor:pointer;color:#2d7552;font-weight:bold}.empty{padding:28px;background:#f1f4ea;border-radius:12px}footer{background:#184638;color:#e4efe5;text-align:center;padding:30px 20px;font-size:12px;line-height:2}@media(max-width:1000px){.grid{grid-template-columns:repeat(3,minmax(0,1fr))}}@media(max-width:720px){.grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.art{height:140px;font-size:48px}.cardbody{padding:13px}.card h3{font-size:15px}.hero{padding:52px 23px}}@media(max-width:390px){.art{height:110px}.card h3{font-size:14px}header{padding:15px}.lang a{padding:8px}.countries a{padding:9px}}'; |
|
11
|
function esc(v){return String(v).replace(/[&<>"']/g,x=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[x]));} |
|
12
|
function makeUrl(lang,market,kind,q){const p=new URLSearchParams({lang,market});if(kind!=="all")p.set("kind",kind);if(q)p.set("q",q);return "/?"+p.toString()+"#browse";} |
|
13
|
function response(req){ |
|
14
|
const u=new URL(req.url); |
|
15
|
if(u.pathname==="/health")return new Response("OK",{headers:{"Content-Type":"text/plain","Cache-Control":"no-store"}}); |
|
16
|
if(u.pathname!=="/"&&u.pathname!=="/index.html")return new Response("Not Found",{status:404}); |
|
17
|
const lang=Object.prototype.hasOwnProperty.call(I18N,u.searchParams.get("lang"))?u.searchParams.get("lang"):"fa"; |
|
18
|
const market=CODES.includes(u.searchParams.get("market"))?u.searchParams.get("market"):"IR"; |
|
19
|
const kind=["all","iranian","electronics"].includes(u.searchParams.get("kind"))?u.searchParams.get("kind"):"all"; |
|
20
|
const q=(u.searchParams.get("q")||"").slice(0,80).trim(),t=I18N[lang],m=CODES.indexOf(market); |
|
21
|
const langs=[["fa","فارسی"],["ar","العربية"],["en","English"]].map(p=>'<a class="'+(lang===p[0]?"sel":"")+'" href="'+esc(makeUrl(p[0],market,kind,q))+'">'+p[1]+'</a>').join(""); |
|
22
|
const markets=CODES.map((code,i)=>'<a class="'+(code===market?"sel":"")+'" href="'+esc(makeUrl(lang,code,"all",""))+'">'+esc(t.countries[i])+'</a>').join(""); |
|
23
|
const filterOpts=[["all",t.all],["iranian",t.iranian],["electronics",t.electronics]].filter(p=>market==="IR"||p[0]!=="electronics"); |
|
24
|
const filters=filterOpts.map(p=>'<a class="'+(kind===p[0]?"sel":"")+'" href="'+esc(makeUrl(lang,market,p[0],q))+'">'+esc(p[1])+'</a>').join(""); |
|
25
|
const cards=t.name.map((name,i)=>({name,i,family:i<4?"electronics":"iranian"})).filter(x=>(market==="IR"||x.family==="iranian")&&(kind==="all"||kind===x.family)&&(!q||x.name.toLowerCase().includes(q.toLowerCase()))).map(x=>'<article class="card"><div class="art" aria-hidden="true">'+String(x.i+1).padStart(2,"0")+'</div><div class="cardbody"><div class="meta">'+esc(t[x.family])+'</div><h3>'+esc(x.name)+'</h3><p>'+esc(t.info)+'</p><details><summary>'+esc(t.more)+'</summary><p>'+esc(t.info)+'</p></details></div></article>').join(""); |
|
26
|
const html='<!doctype html><html lang="'+lang+'" dir="'+t.dir+'"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Medusa Commerce | Preview</title><style>'+CSS+'</style></head><body><div class="bar">'+esc(t.banner)+'</div><header><div class="brand"><b>M</b><span>MEDUSA<small>COMMERCE</small></span></div><nav class="lang" aria-label="'+esc(lang==="fa"?"زبان":lang==="ar"?"اللغة":"Language")+'">'+langs+'</nav></header><main><section class="hero"><div class="tag">MEDUSA COMMERCE / 05 MARKETS</div><h1>'+esc(t.h)+'<br><em>'+esc(t.h2)+'</em></h1><p>'+esc(t.desc)+'</p><div class="market-pill">'+esc(t.market)+': '+esc(t.countries[m])+' <strong>'+CURRENCY[m]+'</strong></div></section><section class="content" id="browse"><h2>'+esc(t.examples)+'</h2><p class="note">'+esc(t.info)+'</p><div class="label">'+esc(t.market)+'</div><nav class="countries">'+markets+'</nav><div class="label">'+esc(t.cat)+'</div><nav class="filters">'+filters+'</nav><form class="search" method="get"><input type="hidden" name="lang" value="'+lang+'"><input type="hidden" name="market" value="'+market+'"><input type="search" name="q" value="'+esc(q)+'" aria-label="'+esc(t.search)+'" placeholder="'+esc(t.placeholder)+'"><button>'+esc(t.search)+'</button></form>'+(cards?'<div class="grid">'+cards+'</div>':'<p class="empty">'+esc(t.empty)+'</p>')+'</section></main><footer>MEDUSA COMMERCE · PREVIEW<br>'+esc(t.banner)+'</footer></body></html>'; |
|
27
|
return new Response(req.method==="HEAD"?null:html,{headers:{"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-store","X-Content-Type-Options":"nosniff","X-Robots-Tag":"noindex, nofollow","Content-Security-Policy":"default-src 'none'; style-src 'unsafe-inline'; form-action 'self'; base-uri 'none'; frame-ancestors 'none'"}}); |
|
28
|
} |
|
29
|
function serve(req){if(req.method!=="GET"&&req.method!=="HEAD")return new Response("Method Not Allowed",{status:405});return response(req);} |