diff --git a/Dashboard.js b/Dashboard.js index ac0507ce8..0794dc76f 100644 --- a/Dashboard.js +++ b/Dashboard.js @@ -33,6 +33,8 @@ function newDashboard () { function start () { try { + setBrowserEvents() + systemEventHandler = newSystemEventHandler() systemEventHandler.initialize(startCanvas) @@ -107,4 +109,11 @@ function newDashboard () { if (ERROR_LOG === true) { logger.write('[ERROR] browserResized -> err = ' + err.stack) } } } + + function setBrowserEvents () { + window.onbeforeunload = onBrowserClosed + function onBrowserClosed () { + window.alert('My Window is closing') + } + } } diff --git a/ProductStorage.js b/ProductStorage.js index acd829022..371270b90 100644 --- a/ProductStorage.js +++ b/ProductStorage.js @@ -257,10 +257,19 @@ function newProductStorage (pName) { return } } - let event = { - totalValue: pCaller.getExpectedFiles(), - currentValue: pCaller.getFilesLoaded() + let event + if (pCaller !== undefined) { + event = { + totalValue: pCaller.getExpectedFiles(), + currentValue: pCaller.getFilesLoaded() + } + } else { // When there are no data the reference to the caller wont arrive here. + event = { + totalValue: 1, + currentValue: 1 + } } + thisObject.eventHandler.raiseEvent('File Sequence Loaded', event) if (event.currentValue === event.totalValue) {