var gui = require('gui'); function waitForAddAccountWindow(data) { var rh = 14; var sp = 4; var y = sp; let gadgets = []; gadgets.push({ kind: 'string', id: 201, label: "Name:", left: sp + 80, top: y, width: 300, height: rh }); gadgets.push({ kind: 'button', id: 202, label: "Open Account", left: sp + 80, top: y + rh + sp, width: 100, height: rh }); let win = gui.createWindow({ title: "New Account", width: sp + 80 + 300 + sp, height: y + rh + sp + rh + sp, left: 30, top: 30, gadgets: gadgets }); let indexOfNewAccount = -1; while (true) { var evt = gui.waitEvent(win); if (!evt) continue; if (evt.type === 'close') { gui.closeWindow(win); return null; } if (evt.type === 'gadgetup') { if (evt.id === 202) { const newAccountName = gui.get(win, 201); if (newAccountName.trim() != '') { data.push( { name: newAccountName, entries: [] } ); indexOfNewAccount = data.findIndex(p => p.name == newAccountName); gui.closeWindow(win); break; } } } } return indexOfNewAccount; } exports.waitForAddAccountWindow = waitForAddAccountWindow;