Initial Commit

This commit is contained in:
2025-09-22 19:44:55 +02:00
commit b668eb3d77
15 changed files with 680 additions and 0 deletions

1
js/main.js Normal file

File diff suppressed because one or more lines are too long

38
js/normal.js Normal file
View File

@@ -0,0 +1,38 @@
/**
* Strips ".html" from link text, preserving href.
* Idempotent and works for dynamically added links.
*
* @param {HTMLElement} link - The <a> element to process
*/
function beautifyLinkText(link) {
const originalText = link.dataset.originalText || link.textContent;
// Only strip if the text ends with ".html"
if (originalText.endsWith(".html")) {
link.textContent = originalText.replace(/\.html$/, "");
}
// Store original text to avoid double-processing
link.dataset.originalText = originalText;
}
// Process all existing links
document.querySelectorAll("a").forEach(beautifyLinkText);
// Observe new links added dynamically
const observer = new MutationObserver(mutations => {
mutations.forEach(mutation => {
mutation.addedNodes.forEach(node => {
if (node.nodeType !== 1) return; // Not an element
if (node.tagName === "A") {
beautifyLinkText(node);
} else {
node.querySelectorAll("a").forEach(beautifyLinkText);
}
});
});
});
observer.observe(document.body, { childList: true, subtree: true });

1
js/post/main.js Normal file

File diff suppressed because one or more lines are too long

31
js/post/normal.js Normal file
View File

@@ -0,0 +1,31 @@
// Theme toggling script for PyPost
function toggleTheme() {
const darkStyles = document.getElementById('dark-styles');
const lightStyles = document.getElementById('light-styles');
const currentlyLight = !lightStyles.disabled;
document.body.classList.add('theme-transitioning');
if (currentlyLight) {
// Switch to dark
lightStyles.disabled = true;
darkStyles.disabled = false;
} else {
// Switch to light
lightStyles.disabled = false;
darkStyles.disabled = true;
}
setTimeout(() => {
document.body.classList.remove('theme-transitioning');
}, 400);
}
document.addEventListener('DOMContentLoaded', function() {
const darkStyles = document.getElementById('dark-styles');
const lightStyles = document.getElementById('light-styles');
// Always start in light mode
lightStyles.disabled = false;
darkStyles.disabled = true;
});