fixed some things. and did some UI changes
This commit is contained in:
File diff suppressed because one or more lines are too long
18
js/post/download.js
Normal file
18
js/post/download.js
Normal file
@@ -0,0 +1,18 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
// current page URL
|
||||
let url = window.location.href;
|
||||
|
||||
// replace `/html/` with `/markdown/`
|
||||
url = url.replace("/html/", "/markdown/");
|
||||
|
||||
// replace `.html` with `.md`
|
||||
url = url.replace(/\.html$/, ".md");
|
||||
|
||||
// assign to <a>
|
||||
const a = document.getElementById("download-md");
|
||||
a.href = url;
|
||||
|
||||
// suggest filename
|
||||
const filename = url.split("/").pop(); // e.g. markdowntest.md
|
||||
a.download = filename;
|
||||
});
|
||||
File diff suppressed because one or more lines are too long
@@ -1,31 +0,0 @@
|
||||
// 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;
|
||||
});
|
||||
46
js/search.js
Normal file
46
js/search.js
Normal file
@@ -0,0 +1,46 @@
|
||||
function search_ul_items() {
|
||||
const query = document.getElementById('searchbox').value.toLowerCase();
|
||||
const ul = document.querySelector('ul'); // only one UL
|
||||
if (!ul) return;
|
||||
|
||||
const items = ul.querySelectorAll('li');
|
||||
items.forEach(li => {
|
||||
if (li.textContent.toLowerCase().includes(query)) {
|
||||
li.style.display = 'list-item';
|
||||
} else {
|
||||
li.style.display = 'none';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Create search box and insert before the available pages paragraph
|
||||
window.addEventListener('DOMContentLoaded', function() {
|
||||
const searchDiv = document.createElement('div');
|
||||
searchDiv.style.marginBottom = '16px';
|
||||
searchDiv.style.paddingLeft = '19px';
|
||||
searchDiv.innerHTML = `
|
||||
<input
|
||||
type="text"
|
||||
id="searchbox"
|
||||
placeholder="Search pages..."
|
||||
style="
|
||||
padding: 6px 6px 6px 28px;
|
||||
font-size: 1em;
|
||||
width: 220px;
|
||||
background: url('../../css/icons/search.webp') no-repeat 6px center;
|
||||
background-size: 20px 20px;
|
||||
"
|
||||
title="Search for pages"
|
||||
/>
|
||||
`;
|
||||
const available = document.getElementById('available');
|
||||
available.parentNode.insertBefore(searchDiv, available);
|
||||
|
||||
const searchbox = document.getElementById('searchbox');
|
||||
if (searchbox) {
|
||||
searchbox.title = "Search for pages";
|
||||
searchbox.style.fontStyle = "bold";
|
||||
}
|
||||
|
||||
document.getElementById('searchbox').addEventListener('input', search_ul_items);
|
||||
});
|
||||
Reference in New Issue
Block a user