UNPKG

thelounge

Version:

The self-hosted Web IRC client

1 lines 1.88 kB
"use strict";!function(){const e=document.getElementById("loading-page-message");e&&(e.textContent="Loading the app…"),document.getElementById("loading-reload")?.addEventListener("click",(()=>location.reload()));const t=()=>{const e=document.getElementById("loading-reload");e&&(e.style.visibility="visible")},n=setTimeout((()=>{const e=document.getElementById("loading-slow");e&&(e.style.visibility="visible"),t()}),5e3),o=o=>{if(!e)return;e.textContent="An error has occurred that prevented the client from loading correctly.";const r=document.createElement("summary");r.textContent="More details";const i=document.createElement("pre");i.textContent=o.message;const s=document.createElement("p");s.textContent="Open the developer tools of your browser for more information.";const a=document.createElement("details");a.appendChild(r),a.appendChild(i),a.appendChild(s),e.parentNode?.insertBefore(a,e.nextSibling),window.clearTimeout(n),t()};window.addEventListener("error",o),window.g_TheLoungeRemoveLoading=()=>{delete window.g_TheLoungeRemoveLoading,window.clearTimeout(n),window.removeEventListener("error",o),document.getElementById("loading")?.remove()};try{const e=JSON.parse(localStorage.getItem("settings")||"{}"),t=document.getElementById("theme");if(!t)return;if("string"==typeof e.theme&&t?.dataset.serverTheme!==e.theme&&t.setAttribute("href",`themes/${e.theme}.css`),"string"==typeof e.userStyles&&!/[?&]nocss/.test(window.location.search)){const t=document.getElementById("user-specified-css");if(!t)return;t.innerHTML=e.userStyles}}catch(e){}if("serviceWorker"in navigator){navigator.serviceWorker.register("service-worker.js");const e=t=>{"fetch-error"===t.data.type&&(o({message:`Service worker failed to fetch an url: ${t.data.message}`}),navigator.serviceWorker.removeEventListener("message",e))};navigator.serviceWorker.addEventListener("message",e)}}();