-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex-providers.js
More file actions
1 lines (1 loc) · 2.6 KB
/
Copy pathindex-providers.js
File metadata and controls
1 lines (1 loc) · 2.6 KB
1
async function loadHostingProviders(){const r=document.getElementById("hosting-providers-container");try{const[n,i]=await Promise.all([fetch("/api/hosting/count"),fetch("/api/hosting/providers")]),s=await n.json(),o=((await i.json()).providers||[]).filter(t=>t.status==="active");if(o.length===0){r.style.display="none";return}let e='<h3 style="color:var(--acreetion-green);margin:2rem 0 0.5rem">ISO Mirror Providers</h3>';e+='<div style="background:rgba(46,204,113,0.05);border:1px solid var(--acreetion-box-border);border-radius:12px;padding:1.25rem">',o.length>=5?(e+='<label for="fastest-mirror" style="display:block;margin-bottom:0.5rem;font-weight:600;color:var(--acreetion-text-bright)">Fastest Provider</label>',e+='<select id="fastest-mirror" style="width:100%;padding:0.6rem;background:var(--acreetion-panel-bg,#1a1a1a);color:var(--acreetion-text-bright);border:1px solid var(--acreetion-box-border);border-radius:8px;font-size:0.9rem;margin-bottom:0.75rem" >',e+='<option value="">Select a mirror...</option>',o.forEach(t=>{e+='<option value="'+safeUrl(t.mirror_url)+'">'+escAttr(t.org)+" \u2014 "+escAttr(t.location)+"</option>"}),e+="</select>"):(e+='<div style="display:flex;flex-direction:column;gap:0.5rem">',o.forEach(t=>{e+='<div style="display:flex;justify-content:space-between;align-items:center;padding:0.5rem 0;border-bottom:1px solid var(--acreetion-box-border)">',e+="<span><strong>"+escAttr(t.org)+'</strong> <span style="color:#888;font-size:0.85rem">'+escAttr(t.location)+"</span></span>",e+='<a href="'+safeUrl(t.mirror_url)+'" target="_blank" rel="noopener" class="btn" style="background:#2ecc71;color:#000;padding:0.3rem 0.8rem;font-size:0.8rem;border-radius:6px">ISO</a>',e+="</div>"}),e+="</div>"),e+='<a href="hosting.html" class="btn" style="margin-top:0.75rem;display:inline-block;background:transparent;color:var(--acreetion-green);border:1px solid var(--acreetion-green);padding:0.4rem 1rem;font-size:0.85rem;border-radius:8px">View All Providers</a>',e+="</div>",r.innerHTML=e;var a=document.getElementById("fastest-mirror");a&&a.addEventListener("change",function(){this.value&&this.value.indexOf("https://")===0&&(window.location.href=this.value)})}catch{r.style.display="none"}}function escAttr(r){return(r||"").replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function safeUrl(r){return!r||typeof r!="string"||r.indexOf("javascript:")===0||r.indexOf("data:")===0||r.indexOf("vbscript:")===0?"":r}window.addEventListener("DOMContentLoaded",function(){("requestIdleCallback"in window)?requestIdleCallback(loadHostingProviders,{timeout:4000}):setTimeout(loadHostingProviders,200)});