mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
* Add Bootstrap Extension * Rename main.yml * Artifact Upload * Fix Bootstrap Reference Error * BootstrapTreeProcessor * getiterator removed * keys function * Style Images * Update docs_build.yml * Added Meta Files * Template Get * Fix Page Ref * Update BASE_URL * Sort Schemas * Add Sitemaps * Add favicons, open-graph, and setup guide * Update Setup.md * Update .gitignore * Update Setup.md * Use _blank on external links * Restructured Docs * Fix Links * Added XML Schemas * Name XML Schemas * Improved Best Practices * Add Logs For Static Files * Make docs build happen on PR * Responsive Footer * Started On Table OF Contents * Added Table Of Contents * Fix <code> bg colors * Remove unused CSS * Add canonical link * Fix OGP Image * Try ScrollSpy on TOC * Added ScrollSpy * Improve TOC Spacing * Custom Scroll Bars * Fix Formatting in ship_log.md
55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
$(document).on('click', 'a[href^="#"]', function (event) {
|
|
if (this.href.split("#")[1] === "top") return;
|
|
event.preventDefault();
|
|
history.pushState({}, '', this.href);
|
|
});
|
|
|
|
function flashElement(elementId) {
|
|
myElement = document.getElementById(elementId).parentNode;
|
|
myElement.classList.add("jsfh-animated-property");
|
|
setTimeout(function () {
|
|
myElement.classList.remove("jsfh-animated-property");
|
|
}, 1000);
|
|
}
|
|
|
|
function setAnchor(anchorLinkDestination) {
|
|
history.pushState({}, '', anchorLinkDestination);
|
|
}
|
|
|
|
function anchorOnLoad() {
|
|
let linkTarget = window.location.hash.split("?")[0].split("&")[0];
|
|
if (linkTarget[0] === "#") {
|
|
let idTarget = linkTarget.substring(1);
|
|
if (idTarget !== "top") {
|
|
anchorLink(idTarget);
|
|
}
|
|
}
|
|
}
|
|
|
|
function anchorLink(linkTarget) {
|
|
const target = $("#" + linkTarget);
|
|
target.parents().addBack().filter(".collapse:not(.show), .tab-pane, [role='tab']").each(
|
|
function (index) {
|
|
if ($(this).hasClass("collapse")) {
|
|
$(this).collapse("show");
|
|
} else if ($(this).hasClass("tab-pane")) {
|
|
const tabToShow = $("a[href='#" + $(this).attr("id") + "']");
|
|
if (tabToShow) {
|
|
tabToShow.tab("show");
|
|
}
|
|
} else if ($(this).attr("role") === "tab") {
|
|
$(this).tab("show");
|
|
}
|
|
}
|
|
);
|
|
|
|
setTimeout(function () {
|
|
let targetElement = document.getElementById(linkTarget);
|
|
if (targetElement) {
|
|
targetElement.scrollIntoView({block: "center", behavior: "smooth"});
|
|
setTimeout(function () {
|
|
flashElement(linkTarget);
|
|
}, 500);
|
|
}
|
|
}, 1000);
|
|
} |