function renderTopBar(title = ' ', subtitle = '', buttonHTML = '', showSearch = false, additionalHTML = '') { return `

` + title + '

' + subtitle + `

` + buttonHTML + `
` + ((showSearch) ? `
` : ``) + additionalHTML + `
` } function renderBottomBar(path) { return `
` + renderBottomBarButtons(bottombarbuttons, path) + `
` } function renderBottomBarButtons(Buttons, path) { var results = `
`; var btn = []; var hit = false; Buttons.forEach(btns => { btn = btns.split(','); try { if (((path != '/dongwaa/') ? (btn[1] != '/dongwaa/') : (btn[1] === '/dongwaa/')) && path.startsWith(btn[1])) { results += ` ` hit = true } else { results += ` ` } } catch (error) { }; }); if (!hit) { results += ` ` } results += `
` return results } var popArray = [] var LoadingStatusQueue = 0; var errorLoadingCSS = ['', ''] function LoadingStatus(type, presistant = false, title = '', subtitle = '') { if (type != 'hide' && LoadingStatusQueue > 0) { //console.log('[LoadingStatus] ' + type + ' queued') setTimeout(() => {LoadingStatus(type, presistant, title, subtitle)}, 500, type, presistant, title, subtitle); return false; } var l = document.getElementById("topbar_loading"); var presistTime = 2850; switch (type) { case 'success': LoadingStatus('show') presistTime = 2850; LoadingStatusQueue += 1; setTimeout(() => {LoadingStatusQueue -= 1}, presistTime + 750) l.innerHTML = '' break case 'warning': LoadingStatus('show') presistTime = 6350; LoadingStatusQueue += 1; setTimeout(() => {LoadingStatusQueue -= 1}, presistTime + 750) l.innerHTML = '' setTimeout(() => {l.style.opacity = 0.3}, 600) setTimeout(() => {l.style.opacity = 1}, 1300) setTimeout(() => {l.style.opacity = 0.3}, 2000) setTimeout(() => {l.style.opacity = 1}, 2700) break case 'error': LoadingStatus('show') presistTime = 6850; LoadingStatusQueue += 1; setTimeout(() => {LoadingStatusQueue -= 1}, presistTime + 750) l.innerHTML = errorLoadingCSS[1] setTimeout(() => {l.innerHTML = errorLoadingCSS[0]}, 850) setTimeout(() => {l.innerHTML = errorLoadingCSS[1]}, 1350) setTimeout(() => {l.innerHTML = errorLoadingCSS[0]}, 1850) setTimeout(() => {l.innerHTML = errorLoadingCSS[1]}, 2350) setTimeout(() => {l.innerHTML = errorLoadingCSS[0]}, 2850) setTimeout(() => {l.innerHTML = errorLoadingCSS[1]}, 3350) break case 'show': LoadingStatusQueue += 1; setTimeout(() => {LoadingStatusQueue -= 1}, 50) l.innerHTML = ""; l.style.display = 'unset'; setTimeout(() => { l.style.opacity = 1; l.style.transform = 'translateX(0)'; l.style.width = '2.25em'; }, 25) presistant = true; break case 'hide': LoadingStatusQueue += 1; setTimeout(() => {LoadingStatusQueue -= 1}, 700) l.style.opacity = 0; l.style.transform = 'translateX(-1.5em)'; setTimeout(() => { l.style.width = '0'; }, 0) //50 setTimeout(() => { l.style.display = 'none'; l.innerHTML = ""; }, 650) //700 presistant = true; break } if (title) { document.getElementById("topbar_title_inwarp_sec_buf").style.maxHeight = '0' document.getElementById("topbar_title_inwrap_secondary").style.maxHeight = '0' document.getElementById("topbar_title_inwrap_main").style.opacity = 0 document.getElementById("topbar_title_inwrap_secondary").style.opacity = 0 document.getElementById("topbar_inwrap_title").innerText = title document.getElementById("topbar_inwrap_subtitle").innerText = subtitle setTimeout(() => { document.getElementById("topbar_title_inwrap_main").style.display = 'none' document.getElementById("topbar_title_inwrap_secondary").style.opacity = 1 document.getElementById("topbar_title_inwrap_secondary").style.maxHeight = 'unset' document.getElementById("topbar_title_inwarp_sec_buf").style.maxHeight = '3.5em' }, 200) } if (!presistant) { setTimeout(() => { LoadingStatus('hide') }, presistTime - 300) setTimeout(() => { document.getElementById("topbar_title_inwrap_secondary").style.opacity = 0 document.getElementById("topbar_title_inwarp_sec_buf").style.maxHeight = '0' }, presistTime - 200) setTimeout(() => { document.getElementById("topbar_title_inwrap_main").style.display = 'block' document.getElementById("topbar_inwrap_title").innerText = '' document.getElementById("topbar_inwrap_subtitle").innerText = '' setTimeout(() => {document.getElementById("topbar_title_inwrap_main").style.opacity = 1}, 200) }, presistTime) } } //make back button works window.onpopstate = function (event) { popArray.pop() boot(decodeURIComponent((event.state) ? event.state.plate : window.location.pathname), true) } //getting acc info in cookies function getCookie(name) { let matches = document.cookie.match(new RegExp( "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" )); return matches ? decodeURIComponent(matches[1]) : undefined; } const authemail = getCookie('authemail'); var signinlevel = (authemail != undefined) ? 1 : 0 ; //add css into html function installCSS(targetCSS) { var stylesheet = document.createElement('link') stylesheet.href = resourceNETpath.concat(targetCSS) stylesheet.rel = 'stylesheet' document.getElementsByTagName('head')[0].appendChild(stylesheet) } installCSS('webel.css'); // -> function hrefInterrupt(event) { if (!(event.target.getAttribute('href').startsWith('http://') || event.target.getAttribute('href').startsWith('https://'))) { event.preventDefault(); boot(event.target.getAttribute('href')); } } //list of post-script cleanup function postCleanup() { document.querySelectorAll('a').forEach(link => link.addEventListener('mousedown', hrefInterrupt)); exe('cleanup') } //load new page var prev_boot_call = 'none'; var isBootRunning = false; function boot(path, noHistory) { //check if boot is already running, prevent accidental double-clicking and overwriting if (isBootRunning) { console.log('[boot] boot aready running! current process: '.concat(prev_boot_call).concat(', ').concat(path).concat(' will be skipped loading.')); return false; //stop running boot } isBootRunning = true; //check should add current URL into history, then change URL shown in browser (noHistory) ? history.replaceState(null, window.title, path) : history.pushState({ plate: path }, window.title, path); window.scrollTo({ top: 0, behavior: 'smooth' }); //window.removeEventListener('scroll', dwLib_scrolling); //remove infinite scroll script from lib //document.querySelectorAll('.lib_div').forEach(e => e.remove()); //remove lib div from body if (path == '/' || path == '' || path == undefined) { //home page path = '/'; } else if (path.startsWith('/!')) { //reserved for api call, invalid for HTML, no init and no script path = undefined; } else { //any other page //path = path; } if (prev_boot_call != path) { //if already init page then don't init it again prev_boot_call = path; document.getElementById('core').innerHTML = init(path); postCleanup(); } exe(path); //execute scripts isBootRunning = false; return true; } boot(window.location.pathname, true)