150 lines
6.1 KiB
JavaScript
150 lines
6.1 KiB
JavaScript
"use strict";var b=["ar-SA","bn-BD","bul-BG","ca-ES","cs-CZ","da-DK","de-DE","el-GR","en-US","es-ES","et","fi","fil","fr-FR","gl","id-ID","it-IT","ja-JP","ja-KS","kab-KAB","kn-IN","ko-KR","nl-NL","no-NO","pl-PL","pt-BR","pt-PT","ro-RO","ru-RU","sk-SK","sv-SE","th-TH","tr-TR","ug-CN","uk-UA","vi-VN","zh-CN","zh-TW"];(async()=>{window.onerror=e=>{console.error(e),a("SOMETHING_HAPPENED",e)},window.onunhandledrejection=e=>{console.error(e),a("SOMETHING_HAPPENED_IN_PROMISE",e)};const f=localStorage.getItem("v"),s=VERSION;f!==VERSION&&localStorage.setItem("v",VERSION);const l=b;let o=localStorage.getItem("lang");(o==null||!l.includes(o))&&(l.includes(navigator.language)?o=navigator.language:(o=l.find(e=>e.split("-")[0]===navigator.language),o==null&&(o="en-US")));const c=await fetch(`/assets/locales/${o}.${s}.json`);if(c.status===200)localStorage.setItem("lang",o),localStorage.setItem("locale",await c.text()),localStorage.setItem("localeVersion",s);else{await p(),a("LOCALE_FETCH");return}function d(){import(`/assets/${CLIENT_ENTRY}`).catch(async e=>{await p(),console.error(e),a("APP_IMPORT",e)})}document.readyState!=="loading"?d():window.addEventListener("DOMContentLoaded",()=>{d()});const m=localStorage.getItem("theme");if(m){for(const[e,t]of Object.entries(JSON.parse(m)))if(document.documentElement.style.setProperty(`--${e}`,t.toString()),e==="htmlThemeColor"){for(const n of document.head.children)if(n.tagName==="META"&&n.getAttribute("name")==="theme-color"){n.setAttribute("content",t);break}}}const u=localStorage.getItem("colorSchema");u&&document.documentElement.style.setProperty("color-schema",u);let r=localStorage.getItem("fontSize");r&&(r<10&&(localStorage.setItem("fontSize",null),r=localStorage.getItem("fontSize")),document.documentElement.style.fontSize=`${r}px`),["ja-JP","ja-KS","ko-KR","zh-CN","zh-TW"].includes(o)&&document.documentElement.classList.add("useCJKFont"),localStorage.getItem("useSystemFont")&&document.documentElement.classList.add("useSystemFont");const g=localStorage.getItem("wallpaper");g&&(document.documentElement.style.backgroundImage=`url(${g})`);const i=localStorage.getItem("customCss");if(i&&i.length>0){const e=document.createElement("style");e.innerHTML=i,document.head.appendChild(e)}async function S(e){const t=document.createElement("style");t.appendChild(document.createTextNode(e)),document.head.appendChild(t)}function a(e,t){let n=document.getElementById("errors");n||(document.body.innerHTML=`
|
|
<svg class="icon-warning" xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-alert-triangle" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
|
<path d="M12 9v2m0 4v.01"></path>
|
|
<path d="M5 19h14a2 2 0 0 0 1.84 -2.75l-7.1 -12.25a2 2 0 0 0 -3.5 0l-7.1 12.25a2 2 0 0 0 1.75 2.75"></path>
|
|
</svg>
|
|
<h1>An error has occurred!</h1>
|
|
<button class="button-big" onclick="location.reload(true);">
|
|
<span class="button-label-big">↻ Refresh</span>
|
|
</button>
|
|
<p class="dont-worry">Don't worry, it's (probably) not your fault.</p>
|
|
<p>Please make sure your browser is up-to-date.</p>
|
|
<p>While we don't serve ads, ad-blockers might interfere with this application,<br/> so disabling them might also fix this issue.</p>
|
|
<p>If the problem persists after refreshing, please contact your instance's administrator.<br>You may also try the following options:</p>
|
|
<a href="/flush">
|
|
<button class="button-small">
|
|
<span class="button-label-small">🗑 Clear preferences and cache</span>
|
|
</button>
|
|
</a>
|
|
<br>
|
|
<a href="/cli">
|
|
<button class="button-small">
|
|
<span class="button-label-small">🗫 Start the simple client</span>
|
|
</button>
|
|
</a>
|
|
<br>
|
|
<a href="/bios">
|
|
<button class="button-small">
|
|
<span class="button-label-small">⚙ Start the repair tool</span>
|
|
</button>
|
|
</a>
|
|
<br>
|
|
<div id="errors"></div>
|
|
`,n=document.getElementById("errors"));const h=document.createElement("details");h.innerHTML=`
|
|
<br>
|
|
<summary>
|
|
<code>ERROR CODE: ${e}</code>
|
|
</summary>
|
|
<code>${JSON.stringify(t)}</code>`,n.appendChild(h),S(`
|
|
* {
|
|
font-family: Roboto,HelveticaNeue,Arial,sans-serif;
|
|
}
|
|
|
|
#iceshrimp_app,
|
|
#splash {
|
|
display: none !important;
|
|
}
|
|
|
|
body,
|
|
html {
|
|
background-color: #3b364c;
|
|
color: rgb(231, 237, 255);
|
|
justify-content: center;
|
|
margin: auto;
|
|
padding: 10px;
|
|
text-align: center;
|
|
}
|
|
|
|
button {
|
|
border-radius: 999px;
|
|
padding: 0px 12px 0px 12px;
|
|
border: none;
|
|
cursor: pointer;
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
.button-big {
|
|
background: linear-gradient(-45deg, rgb(154, 146, 255), rgb(131, 114, 245));
|
|
line-height: 50px;
|
|
}
|
|
|
|
.button-big:hover {
|
|
background: rgb(201, 197, 255);
|
|
}
|
|
|
|
.button-small {
|
|
background: #544d77;
|
|
line-height: 40px;
|
|
}
|
|
|
|
.button-small:hover {
|
|
background: #504967;
|
|
}
|
|
|
|
.button-label-big {
|
|
color: #3b364c;
|
|
font-weight: bold;
|
|
font-size: 2em;
|
|
padding: 12px;
|
|
}
|
|
|
|
.button-label-small {
|
|
color: rgb(231, 237, 255);
|
|
font-size: 16px;
|
|
padding: 12px;
|
|
}
|
|
|
|
a {
|
|
color: rgb(255, 123, 114);
|
|
text-decoration: none;
|
|
}
|
|
|
|
p,
|
|
li {
|
|
font-size: 16px;
|
|
}
|
|
|
|
.dont-worry,
|
|
#msg {
|
|
font-size: 18px;
|
|
}
|
|
|
|
.icon-warning {
|
|
color: rgb(236, 182, 55);
|
|
height: 4rem;
|
|
padding-top: 2rem;
|
|
}
|
|
|
|
h1 {
|
|
font-size: 32px;
|
|
}
|
|
|
|
code {
|
|
font-family: Fira, FiraCode, monospace;
|
|
}
|
|
|
|
details {
|
|
background: #423c55;
|
|
margin-bottom: 2rem;
|
|
padding: 0.5rem 1rem;
|
|
width: 40rem;
|
|
border-radius: 10px;
|
|
justify-content: center;
|
|
margin: auto;
|
|
}
|
|
|
|
summary {
|
|
cursor: pointer;
|
|
}
|
|
|
|
summary > * {
|
|
display: inline;
|
|
}
|
|
|
|
@media screen and (max-width: 500px) {
|
|
details {
|
|
width: 50%;
|
|
}
|
|
`)}async function p(){try{const t=await(await fetch("/api/meta",{method:"POST",cache:"no-cache"})).json();t.version!=s&&(localStorage.setItem("v",t.version),y())}catch(e){throw console.error(e),a("UPDATE_CHECK",e),e}}function y(){try{navigator.serviceWorker.controller.postMessage("clear"),navigator.serviceWorker.getRegistrations().then(e=>{e.forEach(t=>t.unregister())})}catch(e){console.error(e)}location.reload()}})();
|