mirror of
https://forge.chapril.org/tykayn/orgmode-to-gemini-blog
synced 2025-10-09 17:02:45 +02:00
up script pour générer, ajout bouton themes
This commit is contained in:
parent
55e0f2a55c
commit
8abe2f6aad
5 changed files with 71 additions and 6 deletions
|
|
@ -51,4 +51,37 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
|
||||
});
|
||||
|
||||
const themes_calsses = ['default', 'mastodon', 'another']
|
||||
|
||||
function makeThemesButton(){
|
||||
|
||||
// Crée un bouton pour changer de thème et l'ajoute au body
|
||||
const boutonTheme = document.createElement('button');
|
||||
boutonTheme.textContent = 'Changer de thème';
|
||||
boutonTheme.id = 'theme-switcher';
|
||||
document.body.appendChild(boutonTheme);
|
||||
|
||||
addEventListener('click', onClickThemeButton)
|
||||
}
|
||||
|
||||
|
||||
function onClickThemeButton(){
|
||||
|
||||
// Passer au thème suivant et appliquer la classe au body
|
||||
// On suppose que themes_calsses est un tableau global
|
||||
if (!window.currentThemeIndex && window.currentThemeIndex !== 0) {
|
||||
// Initialiser l'index du thème courant en fonction de la classe actuelle du body
|
||||
const currentClass = document.body.className;
|
||||
window.currentThemeIndex = themes_calsses.indexOf(currentClass);
|
||||
if (window.currentThemeIndex === -1) {
|
||||
window.currentThemeIndex = 0;
|
||||
}
|
||||
}
|
||||
// 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];
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue