diff options
author | Sergej Pozdnyakov <afinogen89@gmail.com> | 2017-12-26 20:04:13 +0300 |
---|---|---|
committer | Sergej Pozdnyakov <afinogen89@gmail.com> | 2017-12-26 20:04:13 +0300 |
commit | cacc4522c22a3bcd7a1eb4402f22b1809bcdc18f (patch) | |
tree | 11744e49017952c593f3b4c60a81034e5dc665dd /main.js | |
parent | db002fb1f5106101e14f7e3d6128fb3c88cf020f (diff) |
fix error for `require`
Diffstat (limited to 'main.js')
-rw-r--r-- | main.js | 48 |
1 files changed, 26 insertions, 22 deletions
@@ -38,30 +38,34 @@ $(document).ready(function () { break; } - // Load native UI library - var gui = require('nw.gui'); - var win = gui.Window.get(); - //Get saved size and position - chrome.storage.local.get('windowSize', function (result) { - if (result.windowSize) { - win.height = result.windowSize.height; - win.width = result.windowSize.width; - win.x = result.windowSize.x; - win.y = result.windowSize.y; - } - }); + if (typeof require !== "undefined") { + // Load native UI library + var gui = require('nw.gui'); + var win = gui.Window.get(); + //Get saved size and position + chrome.storage.local.get('windowSize', function (result) { + if (result.windowSize) { + win.height = result.windowSize.height; + win.width = result.windowSize.width; + win.x = result.windowSize.x; + win.y = result.windowSize.y; + } + }); - win.on('close', function() { - //Save window size and position - var currentWin = this; - chrome.storage.local.set({'windowSize': {height: win.height, width: win.width, x: win.x, y: win.y}}, function() { - // Notify that we saved. - console.log('Settings saved'); + win.on('close', function () { + //Save window size and position + var currentWin = this; + chrome.storage.local.set({'windowSize': {height: win.height, width: win.width, x: win.x, y: win.y}}, function () { + // Notify that we saved. + console.log('Settings saved'); + }); + this.hide(); // Pretend to be closed already + console.log("We're closing..."); + this.close(true); }); - this.hide(); // Pretend to be closed already - console.log("We're closing..."); - this.close(true); - }); + } else { + console.log('Not load require'); + } chrome.storage.local.get('logopen', function (result) { if (result.logopen) { |