willpower232/TOTPBTF3

View on GitHub
public_html/js/app.js

Summary

Maintainability
A
0 mins
Test Coverage
!function(e,t,n){var s,i,o,c=function(e,t){return(t||n).querySelector(e)||null};if(n.documentElement.scrollHeight>n.documentElement.clientHeight&&c("body").classList.add("scrollup"),e.onscroll=function(){this.oldScroll>this.scrollY?c("body").classList.add("scrollup"):c("body").classList.remove("scrollup"),this.oldScroll=this.scrollY},void 0!==e.refreshat){var r,a,d=c(".a-timer"),l=function(){(a=(30-(e.refreshat-Date.now()/1e3))/30*100)>100&&(a=100)},u=function(){return 100==a},f=function(){var n;t.onLine?e.location.reload():((n=c(".a-code"))&&(n.innerText="offline please wait",n.style.letterSpacing=".1em"),e.addEventListener("online",function(){e.location.reload()}))},h=null;setInterval(function(){l(),d&&(d.style.setProperty("--progress",a),u()?(d.classList.remove("show"),d.classList.add("done")):null===h?h=!0:!0===h&&d.classList.add("show"))});var v=function(){r=setInterval(function(){u()&&(m(),setTimeout(f,1200))},700)},m=function(){clearInterval(r)};v(),void 0!==n.addEventListener&&void 0!==n.hidden&&n.addEventListener("visibilitychange",function(){n.hidden?m():(l(),u()?f():v())})}(s=c('input[name="light_mode"]'))&&"fetch"in e&&(s.removeAttribute("disabled"),s.addEventListener("change",function(e){var t=new FormData;t.append("light_mode",s.checked),fetch("/api/profile/setLightMode",{method:"POST",body:t,headers:{"X-Requested-With":"XMLHttpRequest",Accept:"application/json","X-CSRF-TOKEN":c('meta[name="csrf-token"]').getAttribute("content")},credentials:"same-origin"}).then(function(e){if(e.ok)return e.json();alert("System error: received "+e.status+" "+e.statusText),s.checked=!s.checked}).catch(function(e){alert("System error: "+e),s.checked=!s.checked}).then(function(e){!0===e.current_state?n.body.parentNode.classList.add("inverted"):!1===e.current_state&&n.body.parentNode.classList.remove("inverted")})})),"clipboard"in t&&(i=c(".js-copy"))&&(i.classList.add("enabled"),i.addEventListener("click",function(e){var n=c(e.target.dataset.copies).innerText;t.clipboard.writeText(n).then(function(){i.classList.add("success")}).catch(function(e){i.classList.add("failure"),console.log(e)}).finally(function(){setTimeout(function(){i.classList.remove("success","failure")},800)})})),(o=c(".breadcrumbs"))&&e.addEventListener("resize",function e(){var t=o.firstElementChild,n=o.lastElementChild,s=o.offsetWidth;return n.offsetLeft+n.offsetWidth>s?o.classList.add("overflowed"):t.offsetLeft>0&&o.classList.remove("overflowed"),e}())}(window,navigator,document);