diff --git a/Y/Scripts/yfold.js b/Y/Scripts/yfold.js index 6240a15..9ab6118 100644 --- a/Y/Scripts/yfold.js +++ b/Y/Scripts/yfold.js @@ -94,41 +94,43 @@ function toggleYfold(id) { window.onload = function() { console.log("DOM loaded.") - var snippet = document.getElementsByTagName("code")[0]; - if ((snippet.classList.value.includes("page")) || (snippet.classList.value.includes("block"))) { - console.log(snippet); + var snippets = document.getElementsByTagName("code"); + for (var snippet of snippets) { + if ((snippet.classList.value.includes("page")) || (snippet.classList.value.includes("block"))) { + console.log(snippet); - let img = document.createElement('div'); - img.innerHTML = ''; - img.addEventListener('click', function() { - console.log(snippet.innerText); - navigator.clipboard.writeText(snippet.innerText).then(function() { - console.log("copié !"); - img.classList = "valid" - }, function() { - console.log("pas copié !"); - img.classList = "not-valid" + let img = document.createElement('div'); + img.innerHTML = ''; + img.addEventListener('click', function() { + console.log(snippet.innerText); + navigator.clipboard.writeText(snippet.innerText).then(function() { + console.log("copié !"); + img.classList = "valid" + }, function() { + console.log("pas copié !"); + img.classList = "not-valid" + }); }); - }); - let theme = document.createElement('div'); - theme.setAttribute("class", "theme"); - theme.innerHTML = ''; + let theme = document.createElement('div'); + theme.setAttribute("class", "theme"); + theme.innerHTML = ''; - theme.addEventListener('click', function() { - snippet.classList.toggle("light"); - console.log("theme switched !"); - if (theme.classList == "theme darken") { - theme.classList = "theme lighten"; - } else { - theme.classList = "theme darken"; - } - }); + theme.addEventListener('click', function() { + snippet.classList.toggle("light"); + console.log("theme switched !"); + if (theme.classList == "theme darken") { + theme.classList = "theme lighten"; + } else { + theme.classList = "theme darken"; + } + }); - snippet.appendChild(img) - snippet.appendChild(theme) - } else { - console.log(snippet.classList); + snippet.appendChild(img) + snippet.appendChild(theme) + } else { + console.log(snippet.classList); + } } if (typeof(Storage) !== "undefined") { diff --git a/Y/ystyle2.css b/Y/ystyle2.css index ae66cc9..4d742be 100644 --- a/Y/ystyle2.css +++ b/Y/ystyle2.css @@ -636,6 +636,10 @@ section.yfold.card > .yfold-content > h6 border-radius: 6px; } +code div { + display: none; +} + @keyframes appear { 0%