Mage / electron /assets /js /renderer.js
Mythus's picture
Upload 233 files
f46e223
raw
history blame contribute delete
891 Bytes
const getControlsHeight = () => {
const controls = document.querySelector("#controls");
if (controls) {
return controls.offsetHeight;
}
return 0;
};
function calculateLayoutSize() {
const webview = document.querySelector("webview");
const windowWidth = document.documentElement.clientWidth;
const windowHeight = document.documentElement.clientHeight;
const controlsHeight = getControlsHeight();
const webviewHeight = windowHeight - controlsHeight;
webview.style.width = windowWidth + "px";
webview.style.height = webviewHeight + "px";
}
const homeButton = () => {
document.querySelector("#home").onclick = () => {
const home = document.getElementById("webview").getAttribute("data-home");
document.querySelector("webview").src = home;
};
};
window.onload = () => {
calculateLayoutSize();
homeButton();
};
window.onresize = calculateLayoutSize;