diff --git a/components/header.php b/components/header.php index 9d661b3..7d09937 100644 --- a/components/header.php +++ b/components/header.php @@ -30,14 +30,14 @@ $showNowPlaying = !empty($is_index) || !empty($do_fullscreen_header);
0) echo " style=\"padding-bottom: {$offset}px\""; ?>> -
-
+
@@ -49,7 +49,7 @@ $showNowPlaying = !empty($is_index) || !empty($do_fullscreen_header);
- > + >
diff --git a/pages/index.php b/pages/index.php index 53825db..a08f6c7 100644 --- a/pages/index.php +++ b/pages/index.php @@ -195,7 +195,7 @@ $router->get('/', function() use ($db) { $body .= "
- +
Projects
More
@@ -228,7 +228,7 @@ HTML; $body .= << - +
{$project->getName()}
HTML; @@ -254,7 +254,7 @@ HTML;
- +
Contact
More
diff --git a/public/assets/2021.js b/public/assets/2021.js index b3f32fb..a42ef0a 100644 --- a/public/assets/2021.js +++ b/public/assets/2021.js @@ -61,97 +61,6 @@ window.fm = (function() { hXhr.send(); } - this.dynloadCurrent = function() { - return { - components: { - header: { - title: document.title, - is_index: document.body.classList.contains('index'), - do_fullscreen_header: document.body.classList.contains('fullscreen-header'), - is_now_playing: document.body.classList.contains('now-playing'), - }, - footer: { - onload: this.onload || [], - } - }, - raw_html: fm.container.innerHTML, - }; - }; - - this.dynloadApply = function(state) { - if((state.components || {}).header) { - document.title = state.components.header.title || ''; - document.body.classList[state.components.header.is_index ? 'add' : 'remove']('index'); - document.body.classList[state.components.header.do_fullscreen_header ? 'add' : 'remove']('fullscreen-header'); - document.body.classList[state.components.header.is_now_playing ? 'add' : 'remove']('now-playing'); - } - - if(typeof state.raw_html !== 'undefined') - this.container.innerHTML = state.raw_html; - - if((state.components || {}).footer) { - this.runFuncs(state.components.footer.onload || []); - } - - fm.dynloadInit(); - fm.setRandomHeaderBackgroundIfNotPlaying(); - }; - - this.dynloadInit = function(initial) { - if(initial) { - history.replaceState(this.dynloadCurrent(), document.title, location.toString()); - window.addEventListener('popstate', function(ev) { - fm.dynloadApply(ev.state || {}); - }); - } - - var dynload = document.querySelectorAll('[data-fm-dynload]'); - for(var i = 0; i < dynload.length; ++i) - (function(dc){ - var url = new URL(dc.href), - hash = url.hash.substring(1); - url.hash = ''; - dc.removeAttribute('data-fm-dynload'); - dc.addEventListener('click', function(ev) { - ev.stopPropagation(); - ev.preventDefault(); - - var xhr = new XMLHttpRequest; - xhr.onload = function() { - try { - var obj = JSON.parse(xhr.responseText); - } catch(ex) {} - if(!obj) { - location.assign(dc.href); - return; - } - var title = ((obj.components || {}).header || {}).title || ''; - history.pushState(obj, title, dc.href); - fm.dynloadApply(obj); - if(hash) { - var targetEl = document.getElementById(hash); - if(targetEl) { - setTimeout(function() { - window.scrollTo({ - top: targetEl.getBoundingClientRect().top, - behavior: 'smooth' - }); - }, 500); - } - } - }; - xhr.onerror = function(ev) { - location.assign(dc.href); - }; - xhr.open('GET', url); - xhr.setRequestHeader('Accept', 'application/x-fdynload+json'); - xhr.send(); - }, true); - })(dynload[i]); - }; - - this.dynloadInit(true); - this.selectTextInElement = function(elem) { // MSIE if(document.body.createTextRange) { diff --git a/public/index.php b/public/index.php index 9bd2d63..999f2aa 100644 --- a/public/index.php +++ b/public/index.php @@ -68,17 +68,7 @@ define('FM_ERRS' , [ ], ]); -define('FM_DYNLOAD', filter_input(INPUT_SERVER, 'HTTP_ACCEPT') === 'application/x-fdynload+json'); - function fm_component(string $_component_name, array $vars = []): string { - if(FM_DYNLOAD) { - global $fmComponentVars; - if(!isset($fmComponentVars)) - $fmComponentVars = []; - $fmComponentVars[$_component_name] = $vars; - return ''; - } - extract($vars); ob_start(); @@ -208,15 +198,7 @@ if($result !== null && !is_bool($result)) { header('Content-Type: text/html; charset=utf-8'); echo $result; } else { - if(FM_DYNLOAD) { - header('Content-Type: application/x-fdynload+json'); - echo json_encode([ - 'components' => $fmComponentVars ?? [], - 'raw_html' => $result, - ]); - } else { - echo $result; - } + echo $result; } } }