blowfish/exampleSite/assets/js/home.js

81 lines
1.9 KiB
JavaScript
Raw Normal View History

2022-10-11 17:40:31 -05:00
var layouts = [
2022-11-05 10:11:20 -05:00
"profile",
2022-10-16 11:25:13 -05:00
"background",
2022-10-11 17:40:31 -05:00
"hero",
2022-11-05 10:11:20 -05:00
"page",
"card"
2022-10-11 17:40:31 -05:00
]
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();
})
);
});
2022-11-05 10:11:20 -05:00
var list_config = [
"CardViewProse",
"CardViewScreenWidth",
"NormalView"
]
var titles = {
"CardViewProse" : "card view with constrained width",
"CardViewScreenWidth" : "card view with full width",
"NormalView" : "standard list view"
}
var currentConfig = 0
function switchList() {
var old = currentConfig
currentConfig = currentConfig == list_config.length - 1 ? 0 : currentConfig + 1
var oldDiv = document.getElementById(list_config[old])
var currentDiv = document.getElementById(list_config[currentConfig])
const configCode = document.querySelectorAll("code[id=config]");
console.log(currentConfig)
console.log(oldDiv)
console.log(currentDiv)
currentDiv.style.display = "block";
oldDiv.style.display = "none";
configCode.forEach(function (el) {
el.innerText = titles[list_config[currentConfig]];
});
}
window.addEventListener("DOMContentLoaded", (event) => {
document.querySelectorAll("#switch-config-button").forEach((button) =>
button.addEventListener("click", function (e) {
e.preventDefault();
switchList();
})
);
});