Replace native js confirm() with a new gui.confirm() method that uses electrons "dialog" module. Resolves issue #25

This commit is contained in:
mmcwilliams 2019-08-04 19:52:52 -04:00
parent 1b83fe6937
commit cfa22d3a1d
1 changed files with 14 additions and 7 deletions

View File

@ -62,7 +62,7 @@ gui.updateCam = function (t) {
if (parseInt(val) === cam.pos) { if (parseInt(val) === cam.pos) {
return false; return false;
} }
change = confirm(`Are you sure you want to set camera counter to ${val}?`); change = gui.confirm(`Are you sure you want to set camera counter to ${val}?`);
if (change) { if (change) {
cam.pos = parseInt(val); cam.pos = parseInt(val);
@ -80,7 +80,7 @@ gui.updateCam2 = function (t) {
if (parseInt(val) === cam.pos) { if (parseInt(val) === cam.pos) {
return false; return false;
} }
change = confirm(`Are you sure you want to set second camera counter to ${val}?`); change = gui.confirm(`Are you sure you want to set second camera counter to ${val}?`);
if (change) { if (change) {
cam.second.pos = parseInt(val); cam.second.pos = parseInt(val);
@ -97,7 +97,7 @@ gui.updateProj = function (t) {
if (parseInt(val) === proj.pos) { if (parseInt(val) === proj.pos) {
return false; return false;
} }
change = confirm(`Are you sure you want to set projector counter to ${val}?`); change = gui.confirm(`Are you sure you want to set projector counter to ${val}?`);
if (change) { if (change) {
proj.pos = parseInt(val); proj.pos = parseInt(val);
gui.updateState(); gui.updateState();
@ -114,7 +114,7 @@ gui.updateProj2 = function (t) {
if (parseInt(val) === proj.second.pos) { if (parseInt(val) === proj.second.pos) {
return false; return false;
} }
change = confirm(`Are you sure you want to set second projector counter to ${val}?`); change = gui.confirm(`Are you sure you want to set second projector counter to ${val}?`);
if (change) { if (change) {
proj.second.pos = parseInt(val); proj.second.pos = parseInt(val);
gui.updateState(); gui.updateState();
@ -207,9 +207,16 @@ gui.info = function (title, message) {
title: title, title: title,
message : message message : message
}; };
dialog.showMessageBox(config); return dialog.showMessageBox(config);
};
gui.confirm = function (message) {
const config = {
buttons : ['Yes', 'Cancel'],
message
}
const res = dialog.showMessageBox(config);
return res === 0;
}; };
gui.confirm = function () {};
gui.warn = function (title, message) { gui.warn = function (title, message) {
'use strict'; 'use strict';
const config = { const config = {
@ -218,7 +225,7 @@ gui.warn = function (title, message) {
title: title, title: title,
message : message message : message
}; };
dialog.showMessageBox(config); return dialog.showMessageBox(config);
}; };
gui.error = function () {}; gui.error = function () {};