Skip to content

Commit 09a6fc6

Browse files
committed
Workaround for nw >= 0.3.0
1 parent 84f8abd commit 09a6fc6

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

background.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
'use strict';
22

33
function startApplication() {
4+
var timestampId = Date.now();
45
chrome.app.window.create('index.html',
56
{
6-
id: 'main',
7+
id: "main" + timestampId,
78
frame: 'chrome',
89
innerBounds : {
910
'width' : 1340,

js/main.js

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,13 @@ function BlackboxLogViewer() {
103103
playbackRate = PLAYBACK_DEFAULT_RATE,
104104

105105
graphZoom = GRAPH_DEFAULT_ZOOM,
106-
lastGraphZoom = GRAPH_DEFAULT_ZOOM, // QuickZoom function.
107-
currentWindowId;
108-
109-
if (chrome.windows) {
110-
chrome.windows.getCurrent(function(currentWindow) {
111-
currentWindowId = currentWindow.id;
112-
});
113-
}
106+
lastGraphZoom = GRAPH_DEFAULT_ZOOM; // QuickZoom function.
114107

115108
function createNewBlackboxWindow(fileToOpen) {
109+
var timestampId = Date.now();
116110
chrome.app.window.create('index.html',
117111
{
112+
'id': "main" + timestampId,
118113
'innerBounds' : {
119114
'width' : INNER_BOUNDS_WIDTH,
120115
'height' : INNER_BOUNDS_HEIGHT
@@ -1959,21 +1954,20 @@ function BlackboxLogViewer() {
19591954

19601955
// All the windows opened try to open the new blackbox,
19611956
// so we limit it to one of them, the first in the list for example
1962-
chrome.windows.getAll(function(windows) {
1957+
var windows = chrome.app.window.getAll();
1958+
var firstWindow = windows[0];
1959+
var currentWindowId = chrome.app.window.current().id;
19631960

1964-
var firstWindow = windows[0];
1961+
if (currentWindowId == firstWindow.id) {
1962+
var filePathToOpenExpression = /.*"([^"]*)"$/;
1963+
var fileToOpen = path.match(filePathToOpenExpression);
19651964

1966-
if (currentWindowId == firstWindow.id) {
1967-
var filePathToOpenExpression = /.*"([^"]*)"$/;
1968-
var fileToOpen = path.match(filePathToOpenExpression);
1969-
1970-
if (fileToOpen.length > 1) {
1971-
var fullPathFile = fileToOpen[1];
1972-
createNewBlackboxWindow([fullPathFile]);
1973-
}
1965+
if (fileToOpen.length > 1) {
1966+
var fullPathFile = fileToOpen[1];
1967+
createNewBlackboxWindow([fullPathFile]);
19741968
}
1969+
}
19751970

1976-
});
19771971
});
19781972
} catch (e) {
19791973
// Require not supported, chrome app

0 commit comments

Comments
 (0)