diff --git a/public/main.js b/public/main.js index cac1dff..6bc1e03 100644 --- a/public/main.js +++ b/public/main.js @@ -4,24 +4,49 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - +var gui = require('nw.gui'); var linewidth = 48; var devtype = "epson"; var device = "/dev/usb/lp0"; +var settingsValid = true; +var win = gui.Window.get(); +var tray = new nw.Tray({ + title: 'NickelBridge', + tooltip: 'Open NickelBridge configuration', + icon: 'public/assets/img/logo_64.png' +}); function loadSettings() { if (localStorage.getItem("linewidth") !== null && Number.parseInt(localStorage.getItem("linewidth")) != Number.NaN) { linewidth = Number.parseInt(localStorage.getItem("linewidth")); + } else { + settingsValid = false; } if (localStorage.getItem("devtype") !== null) { devtype = localStorage.getItem("devtype"); if (devtype != "epson" && devtype != "star") { devtype = "epson"; + settingsValid = false; } + } else { + settingsValid = false; } - if (localStorage.getItem("device") !== null) { + if (localStorage.getItem("device") !== null && localStorage.getItem("device") != "") { device = localStorage.getItem("device"); + } else { + settingsValid = false; } } -loadSettings(); \ No newline at end of file +loadSettings(); + +win.on('minimize', function () { + win.hide(); +}); +tray.on('click', function () { + win.show(); +}); + +if (settingsValid === true) { + win.hide(); +} \ No newline at end of file