Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
nw_gui.App.on('open', function (argString) {
argString = argString.split(' ')
var nr = argString[argString.length - 1]
if (!open_windows[nr]) {
// search for window with the lowest win_nr
// to open a new window just once
var wins = nw_gui.global.__nw_windows
var keys = Object.keys(wins)
var win_nrs = []
keys.forEach(function(e) {
win_nrs.push(wins[e][0].window.win_nr)
})
win_nrs.sort()
var is_win_with_lowest_nr = window.win_nr == win_nrs[0].toString()
if (is_win_with_lowest_nr) {
log('opened sequencer',nr)
open_new_sequencer_window(nr)
}
}
else {
// hack for not working window.focus()
chrome.windows.update(open_windows[nr].id, {focused : true});
}