mirror of
https://github.com/thecyberlearn/quantum-website-2026.git
synced 2026-08-18 16:43:19 +00:00
headerjs and favicon fix
This commit is contained in:
parent
28c02c645a
commit
430560cfc1
69
header.js
69
header.js
@ -10,16 +10,13 @@
|
|||||||
if (document.getElementById('sh-header')) return;
|
if (document.getElementById('sh-header')) return;
|
||||||
|
|
||||||
// ─── Config: update nav links here ──────────────────────────────
|
// ─── Config: update nav links here ──────────────────────────────
|
||||||
var LOGO_URL = (function() {
|
var LOGO_URL = 'https://quantumtaskai.com/img/logo.png'; // always absolute — works cross-domain
|
||||||
// Works locally and on live domain without hardcoding
|
var HOME_URL = 'https://quantumtaskai.com';
|
||||||
var base = window.location.origin;
|
|
||||||
return base + '/img/logo.png';
|
|
||||||
})();
|
|
||||||
var HOME_URL = 'https://quantumtaskai.com';
|
|
||||||
|
|
||||||
var NAV_LINKS = [
|
var NAV_LINKS = [
|
||||||
{ label: 'Home', url: 'https://quantumtaskai.com' },
|
{ label: 'Home', url: 'https://quantumtaskai.com' },
|
||||||
{ label: 'AI Digital Branding', url: 'https://quantumtaskai.com/digital-branding.html' },
|
{ label: 'AI Digital Branding', url: 'https://quantumtaskai.com/digital-branding.html' },
|
||||||
|
{ label: 'Site Auditor', url: 'https://audit.quantumtaskai.com' },
|
||||||
{ label: 'Blog', url: 'https://blog.quantumtaskai.com/' },
|
{ label: 'Blog', url: 'https://blog.quantumtaskai.com/' },
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -139,13 +136,21 @@
|
|||||||
document.head.appendChild(styleEl);
|
document.head.appendChild(styleEl);
|
||||||
|
|
||||||
// ─── Detect active link ──────────────────────────────────────────
|
// ─── Detect active link ──────────────────────────────────────────
|
||||||
var currentUrl = window.location.href;
|
var currentOrigin = window.location.origin; // e.g. https://blog.quantumtaskai.com
|
||||||
|
var currentUrl = window.location.href;
|
||||||
|
|
||||||
function isActive(url) {
|
function isActive(url) {
|
||||||
if (url === HOME_URL) {
|
try {
|
||||||
return currentUrl === url || currentUrl === url + '/' || currentUrl === url + '/index.html';
|
var linkOrigin = new URL(url).origin;
|
||||||
}
|
// If the link is a subdomain root (e.g. https://blog.quantumtaskai.com/)
|
||||||
return currentUrl.indexOf(url) === 0;
|
// match by origin so any page on that subdomain highlights it
|
||||||
|
if (linkOrigin !== HOME_URL && linkOrigin === currentOrigin) return true;
|
||||||
|
// For same-domain links match by full URL prefix
|
||||||
|
if (url === HOME_URL || url === HOME_URL + '/') {
|
||||||
|
return currentOrigin === HOME_URL;
|
||||||
|
}
|
||||||
|
return currentUrl.indexOf(url) === 0;
|
||||||
|
} catch (e) { return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildNavItems() {
|
function buildNavItems() {
|
||||||
@ -160,12 +165,12 @@
|
|||||||
'<header id="sh-header">' +
|
'<header id="sh-header">' +
|
||||||
'<div class="sh-inner">' +
|
'<div class="sh-inner">' +
|
||||||
'<a href="' + HOME_URL + '" class="sh-logo">' +
|
'<a href="' + HOME_URL + '" class="sh-logo">' +
|
||||||
'<img src="' + LOGO_URL + '" alt="Quantum Tasks AI" height="60">' +
|
'<img src="' + LOGO_URL + '" alt="Quantum Tasks AI" height="60" loading="eager" fetchpriority="high">' +
|
||||||
'</a>' +
|
'</a>' +
|
||||||
'<nav aria-label="Main navigation">' +
|
'<nav aria-label="Main navigation">' +
|
||||||
'<ul class="sh-nav" id="sh-nav">' + buildNavItems() + '</ul>' +
|
'<ul class="sh-nav" id="sh-nav">' + buildNavItems() + '</ul>' +
|
||||||
'</nav>' +
|
'</nav>' +
|
||||||
'<button class="sh-burger" id="sh-burger" aria-label="Toggle navigation" aria-expanded="false">' +
|
'<button class="sh-burger" id="sh-burger" aria-label="Toggle navigation" aria-expanded="false" aria-controls="sh-nav">' +
|
||||||
'<svg width="22" height="22" viewBox="0 0 22 22" fill="none" aria-hidden="true">' +
|
'<svg width="22" height="22" viewBox="0 0 22 22" fill="none" aria-hidden="true">' +
|
||||||
'<path d="M3 5h16M3 11h16M3 17h16" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>' +
|
'<path d="M3 5h16M3 11h16M3 17h16" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>' +
|
||||||
'</svg>' +
|
'</svg>' +
|
||||||
@ -174,36 +179,46 @@
|
|||||||
'</header>';
|
'</header>';
|
||||||
|
|
||||||
// ─── Inject header at top of body ───────────────────────────────
|
// ─── Inject header at top of body ───────────────────────────────
|
||||||
document.body.insertAdjacentHTML('afterbegin', headerHTML);
|
// Guard: if script runs before <body> exists (e.g. loaded from <head>),
|
||||||
|
// wait for DOM ready instead of crashing
|
||||||
|
function inject() {
|
||||||
|
if (document.body) {
|
||||||
|
document.body.insertAdjacentHTML('afterbegin', headerHTML);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (document.readyState === 'loading') {
|
||||||
|
document.addEventListener('DOMContentLoaded', inject);
|
||||||
|
} else {
|
||||||
|
inject();
|
||||||
|
}
|
||||||
|
|
||||||
// ─── Hamburger logic ─────────────────────────────────────────────
|
// ─── Hamburger logic ─────────────────────────────────────────────
|
||||||
var burger = document.getElementById('sh-burger');
|
var burger = document.getElementById('sh-burger');
|
||||||
var nav = document.getElementById('sh-nav');
|
var nav = document.getElementById('sh-nav');
|
||||||
|
|
||||||
|
// Guard: bail out cleanly if injection failed for any reason
|
||||||
|
if (!burger || !nav) return;
|
||||||
|
|
||||||
|
function closeMenu() {
|
||||||
|
nav.classList.remove('sh-open');
|
||||||
|
burger.setAttribute('aria-expanded', 'false'); // always string
|
||||||
|
}
|
||||||
|
|
||||||
burger.addEventListener('click', function () {
|
burger.addEventListener('click', function () {
|
||||||
var open = nav.classList.toggle('sh-open');
|
var open = nav.classList.toggle('sh-open');
|
||||||
burger.setAttribute('aria-expanded', open);
|
burger.setAttribute('aria-expanded', String(open)); // string 'true'/'false'
|
||||||
});
|
});
|
||||||
|
|
||||||
document.addEventListener('click', function (e) {
|
document.addEventListener('click', function (e) {
|
||||||
if (!document.getElementById('sh-header').contains(e.target)) {
|
if (!document.getElementById('sh-header').contains(e.target)) closeMenu();
|
||||||
nav.classList.remove('sh-open');
|
|
||||||
burger.setAttribute('aria-expanded', 'false');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
document.addEventListener('keydown', function (e) {
|
document.addEventListener('keydown', function (e) {
|
||||||
if (e.key === 'Escape') {
|
if (e.key === 'Escape') closeMenu();
|
||||||
nav.classList.remove('sh-open');
|
|
||||||
burger.setAttribute('aria-expanded', 'false');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
nav.querySelectorAll('a').forEach(function (a) {
|
nav.querySelectorAll('a').forEach(function (a) {
|
||||||
a.addEventListener('click', function () {
|
a.addEventListener('click', closeMenu);
|
||||||
nav.classList.remove('sh-open');
|
|
||||||
burger.setAttribute('aria-expanded', 'false');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('Shared header loaded ✓');
|
console.log('Shared header loaded ✓');
|
||||||
|
|||||||
BIN
img/apple-touch-icon.png
Normal file
BIN
img/apple-touch-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
BIN
img/favicon-16x16.png
Normal file
BIN
img/favicon-16x16.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
BIN
img/favicon-32x32.png
Normal file
BIN
img/favicon-32x32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
BIN
img/favicon.ico
Normal file
BIN
img/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
Loading…
Reference in New Issue
Block a user