XVoxel-ASync/preload.js

56 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

window.electron = require("electron");
/* electron.contextBridge.exposeInMainWorld("load", function (moduleName) {
try {
return Promise.resolve(require(moduleName));
} catch (e) {
return Promise.reject(e);
}
}); */
var windowActionButtons = [
{
"divID": "minwin",
"imgID": "mwi",
"title": "Minimize",
"click": function (event) {
electron.ipcRenderer.send("ev", "minimize");
}
},
{
"divID": "maxrestorewin",
"imgID": "mrwi",
"title": "Maximize/Restore",
"click": function (event) {
electron.ipcRenderer.send("ev", "maximizerestore");
}
},
{
"divID": "closewin",
"imgID": "cwi",
"title": "Close",
"click": function (event) {
window.close();
}
}
];
window.addEventListener("DOMContentLoaded", function () {
var actionButtonContainer = document.getElementById("actionbuttoncontainer");
for (var b = 0; b < windowActionButtons.length; b++) {
var buttonData = windowActionButtons[b];
var button = document.createElement("div");
button.id = buttonData.divID;
button.title = buttonData.title;
button.classList.add("windowactionbutton");
button.onclick = buttonData.click;
var buttonImage = document.createElement("img");
buttonImage.id = buttonData.imgID;
button.appendChild(buttonImage);
actionButtonContainer.appendChild(button);
}
});