mirror of
https://forge.chapril.org/tykayn/orgmode-to-gemini-blog
synced 2025-10-09 17:02:45 +02:00
up post book
This commit is contained in:
parent
3965be8e26
commit
871b9bab61
3 changed files with 34 additions and 15 deletions
|
|
@ -1,5 +1,16 @@
|
|||
// search bar to send a request to a search engine for the current domain when sent
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
// Charger le thème depuis localStorage au plus tôt
|
||||
try {
|
||||
const savedTheme = localStorage.getItem('tkTheme');
|
||||
if (savedTheme && typeof savedTheme === 'string') {
|
||||
document.body.className = savedTheme;
|
||||
window.currentThemeIndex = 0; // sera recalculé au clic
|
||||
}
|
||||
} catch (e) {
|
||||
// ignore stockage indisponible
|
||||
}
|
||||
|
||||
// Obtient le nom de domaine de la page courante
|
||||
const currentDomain = window.location.hostname;
|
||||
const form = document.getElementById('recherche');
|
||||
|
|
@ -12,6 +23,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
const input = form.querySelector('.search-field');
|
||||
const query = input ? input.value : '';
|
||||
const url = `https://duckduckgo.com/?q=${encodeURIComponent(query)}+site%3A${encodeURIComponent(currentDomain)}`;
|
||||
|
||||
window.location.href = url;
|
||||
});
|
||||
}
|
||||
|
|
@ -35,6 +47,8 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Ajoutez un événement de touche au document
|
||||
document.addEventListener('keydown', function (event) {
|
||||
// Vérifiez si la touche appuyée est 'n' ou la flèche droite
|
||||
|
|
@ -85,19 +99,17 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
// Passer au thème suivant
|
||||
window.currentThemeIndex = (window.currentThemeIndex + 1) % themes_calsses.length;
|
||||
// Appliquer la nouvelle classe au body
|
||||
document.body.className = themes_calsses[window.currentThemeIndex];
|
||||
// Persister le thème
|
||||
try { localStorage.setItem('tk_theme', themes_calsses[window.currentThemeIndex]); } catch(e) {}
|
||||
const newTheme = themes_calsses[window.currentThemeIndex];
|
||||
document.body.className = newTheme;
|
||||
|
||||
// Sauvegarder le thème choisi
|
||||
try {
|
||||
localStorage.setItem('tkTheme', newTheme);
|
||||
} catch (e) {
|
||||
// ignore stockage indisponible
|
||||
}
|
||||
}
|
||||
|
||||
// Charger le thème depuis le localStorage si disponible
|
||||
try {
|
||||
const savedTheme = localStorage.getItem('tk_theme');
|
||||
if (savedTheme && themes_calsses.includes(savedTheme)) {
|
||||
document.body.className = savedTheme;
|
||||
window.currentThemeIndex = themes_calsses.indexOf(savedTheme);
|
||||
}
|
||||
} catch(e) {}
|
||||
|
||||
// créer le bouton thème au chargement
|
||||
makeThemesButton();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue