blowfish/exampleSite/assets/js/home.js

36 lines
835 B
JavaScript
Raw Normal View History

2022-10-11 17:40:31 -05:00
var layouts = [
2022-10-16 11:25:13 -05:00
"background",
2022-10-11 17:40:31 -05:00
"hero",
"profile",
"card",
"page"
]
var currentLayout = 0
function switchHomeLayout() {
2022-10-11 17:40:31 -05:00
var old = currentLayout
currentLayout = currentLayout == layouts.length - 1 ? 0 : currentLayout + 1
var oldDiv = document.getElementById(layouts[old])
var currentDiv = document.getElementById(layouts[currentLayout])
const layoutCode = document.querySelectorAll("code[id=layout]");
2022-10-11 17:40:31 -05:00
currentDiv.style.display = "block";
oldDiv.style.display = "none";
layoutCode.forEach(function (el) {
el.innerText = layouts[currentLayout];
});
}
window.addEventListener("DOMContentLoaded", (event) => {
document.querySelectorAll("#switch-layout-button").forEach((button) =>
button.addEventListener("click", function (e) {
e.preventDefault();
switchHomeLayout();
})
);
});