# HG changeset patch # User Nicholas Jillings # Date 1464276966 -3600 # Node ID 5e1fb07919e73f1f71b70c2dea30d2a1854fa5ce # Parent 5d7ad658c69950cf2941f4072bf5f007ef6e8c47 Better loading dependancy block chain to ensure core.js only executes after all the other files have parsed diff -r 5d7ad658c699 -r 5e1fb07919e7 js/core.js --- a/js/core.js Thu May 26 16:06:42 2016 +0100 +++ b/js/core.js Thu May 26 16:36:06 2016 +0100 @@ -116,6 +116,16 @@ } } +var check_dependancies = function() { + // This will check for the data dependancies + if (typeof(jQuery) != "function") {return false;} + if (typeof(Specification) != "function") {return false;} + if (typeof(calculateLoudness) != "function") {return false;} + if (typeof(WAVE) != "function") {return false;} + if (typeof(validateXML) != "function") {return false;} + return true; +} + var onload = function() { // Function called once the browser has loaded all files. // This should perform any initial commands such as structure / loading documents @@ -3229,4 +3239,12 @@ }; } -onload(); \ No newline at end of file +var window_depedancy_callback; +window_depedancy_callback = window.setInterval(function(){ + if (check_dependancies()) { + window.clearInterval(window_depedancy_callback); + onload(); + } else { + document.getElementById("topLevelBody").innerHTML = "

Loading Resources

"; + } +},100); \ No newline at end of file