Skip to content

Commit

Permalink
Avoid race condition at loading. Fixes #265.
Browse files Browse the repository at this point in the history
Using the simple solution...
  • Loading branch information
ivmartel committed Dec 18, 2016
1 parent 1f25ace commit ab4e17e
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 20 deletions.
24 changes: 19 additions & 5 deletions viewers/mobile/applauncher.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,23 @@ dwv.image.decoderScripts = {
dwv.browser.check();
// initialise i18n
dwv.i18nInitialise();
// launch when page is ready
$(document).ready( function()
{
// and i18n is loaded
dwv.i18nOnLoaded( startApp );

// status flags
var domContentLoaded = false;
var i18nLoaded = false;
// launch when both DOM and i18n are ready
function launchApp() {
if ( domContentLoaded && i18nLoaded ) {
startApp();
}
}
// DOM ready?
$(document).ready( function() {
domContentLoaded = true;
launchApp();
});
// i18n ready?
dwv.i18nOnLoaded( function () {
i18nLoaded = true;
launchApp();
});
24 changes: 19 additions & 5 deletions viewers/simple/applauncher.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,23 @@ dwv.image.decoderScripts = {
dwv.browser.check();
// initialise i18n
dwv.i18nInitialise();
// launch when page is loaded
$(document).ready( function()
{
// and i18n is loaded
dwv.i18nOnLoaded( startApp );

// status flags
var domContentLoaded = false;
var i18nLoaded = false;
// launch when both DOM and i18n are ready
function launchApp() {
if ( domContentLoaded && i18nLoaded ) {
startApp();
}
}
// DOM ready?
$(document).ready( function() {
domContentLoaded = true;
launchApp();
});
// i18n ready?
dwv.i18nOnLoaded( function () {
i18nLoaded = true;
launchApp();
});
24 changes: 19 additions & 5 deletions viewers/simplistic/applauncher.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,23 @@ dwv.image.decoderScripts = {
dwv.browser.check();
// initialise i18n
dwv.i18nInitialise();
// launch when page is loaded
document.addEventListener("DOMContentLoaded", function (/*event*/)
{
// and i18n is loaded
dwv.i18nOnLoaded( startApp );

// status flags
var domContentLoaded = false;
var i18nLoaded = false;
// launch when both DOM and i18n are ready
function launchApp() {
if ( domContentLoaded && i18nLoaded ) {
startApp();
}
}
// DOM ready?
document.addEventListener("DOMContentLoaded", function (/*event*/) {
domContentLoaded = true;
launchApp();
});
// i18n ready?
dwv.i18nOnLoaded( function () {
i18nLoaded = true;
launchApp();
});
24 changes: 19 additions & 5 deletions viewers/static/applauncher.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,23 @@ dwv.image.decoderScripts = {
dwv.browser.check();
// initialise i18n
dwv.i18nInitialise();
// launch when page is loaded
$(document).ready( function()
{
// and i18n is loaded
dwv.i18nOnLoaded( startApp );

// status flags
var domContentLoaded = false;
var i18nLoaded = false;
// launch when both DOM and i18n are ready
function launchApp() {
if ( domContentLoaded && i18nLoaded ) {
startApp();
}
}
// DOM ready?
$(document).ready( function() {
domContentLoaded = true;
launchApp();
});
// i18n ready?
dwv.i18nOnLoaded( function () {
i18nLoaded = true;
launchApp();
});

0 comments on commit ab4e17e

Please sign in to comment.