UNPKG

thelounge

Version:

The self-hosted Web IRC client

1 lines 1.8 kB
"use strict";!function(){const e=document.getElementById("loading-page-message");e.textContent="Loading the app…",document.getElementById("loading-reload").addEventListener("click",(()=>location.reload(!0)));const t=()=>{const e=document.getElementById("loading-reload");e&&(e.style.visibility="visible")},n=setTimeout((()=>{document.getElementById("loading-slow").style.visibility="visible",t()}),5e3),o=o=>{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");"string"==typeof e.theme&&t.dataset.serverTheme!==e.theme&&(t.attributes.href.value=`themes/${e.theme}.css`),"string"!=typeof e.userStyles||/[?&]nocss/.test(window.location.search)||(document.getElementById("user-specified-css").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)}}();