Skip to content

Commit

Permalink
Workaround for nw >= 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
McGiverGim committed Jul 4, 2018
1 parent 84f8abd commit 09a6fc6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
3 changes: 2 additions & 1 deletion background.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
'use strict';

function startApplication() {
var timestampId = Date.now();
chrome.app.window.create('index.html',
{
id: 'main',
id: "main" + timestampId,
frame: 'chrome',
innerBounds : {
'width' : 1340,
Expand Down
32 changes: 13 additions & 19 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,13 @@ function BlackboxLogViewer() {
playbackRate = PLAYBACK_DEFAULT_RATE,

graphZoom = GRAPH_DEFAULT_ZOOM,
lastGraphZoom = GRAPH_DEFAULT_ZOOM, // QuickZoom function.
currentWindowId;

if (chrome.windows) {
chrome.windows.getCurrent(function(currentWindow) {
currentWindowId = currentWindow.id;
});
}
lastGraphZoom = GRAPH_DEFAULT_ZOOM; // QuickZoom function.

function createNewBlackboxWindow(fileToOpen) {
var timestampId = Date.now();
chrome.app.window.create('index.html',
{
'id': "main" + timestampId,
'innerBounds' : {
'width' : INNER_BOUNDS_WIDTH,
'height' : INNER_BOUNDS_HEIGHT
Expand Down Expand Up @@ -1959,21 +1954,20 @@ function BlackboxLogViewer() {

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

var firstWindow = windows[0];
if (currentWindowId == firstWindow.id) {
var filePathToOpenExpression = /.*"([^"]*)"$/;
var fileToOpen = path.match(filePathToOpenExpression);

if (currentWindowId == firstWindow.id) {
var filePathToOpenExpression = /.*"([^"]*)"$/;
var fileToOpen = path.match(filePathToOpenExpression);

if (fileToOpen.length > 1) {
var fullPathFile = fileToOpen[1];
createNewBlackboxWindow([fullPathFile]);
}
if (fileToOpen.length > 1) {
var fullPathFile = fileToOpen[1];
createNewBlackboxWindow([fullPathFile]);
}
}

});
});
} catch (e) {
// Require not supported, chrome app
Expand Down

0 comments on commit 09a6fc6

Please sign in to comment.