Skip to content

Commit d27d7e0

Browse files
Separate logic that detects when scripts are loadedd
from the logic that should call start_app()
1 parent 79f9e47 commit d27d7e0

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

  • deps/rabbitmq_management/priv/www/js

deps/rabbitmq_management/priv/www/js/main.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,10 @@ function check_login () {
139139
setup_constant_events()
140140
update_vhosts()
141141
update_interval()
142-
setup_extensions()
143-
142+
setup_extensions(function onCompleted() {
143+
console.info("All extensions have been loaded. Starting application ..");
144+
start_app();
145+
});
144146

145147
return true
146148
}
@@ -232,7 +234,7 @@ function update_vhosts() {
232234
store_pref('vhost', current_vhost);
233235
}
234236

235-
function setup_extensions() {
237+
function setup_extensions(onCompleted) {
236238
var extensions = JSON.parse(sync_get('/extensions'));
237239
var javascript_files = [];
238240
for (var i in extensions) {
@@ -253,21 +255,20 @@ function setup_extensions() {
253255
}
254256
}
255257
}
256-
// Load JavaScript files sequentially; start_app() runs when all have loaded and registered
257-
load_javascript_files_sequentially(javascript_files, 0);
258+
load_javascript_files_sequentially(javascript_files, 0, onCompleted);
258259
}
259260

260-
function load_javascript_files_sequentially(files, index) {
261+
function load_javascript_files_sequentially(files, index, onCompleted) {
261262
if (index >= files.length) {
262-
console.info("All extension are loaded. Starting app...");
263-
start_app();
263+
if (typeof onCompleted === 'function') {
264+
onCompleted();
265+
}
264266
return;
265267
}
266268
console.debug(`Loading extension ${files[index]} ...`);
267269
dynamic_javascript_file_load(files[index], function() {
268-
// Load next file after current one has finished loading
269270
console.debug(`Loaded extension ${files[index]} !`);
270-
load_javascript_files_sequentially(files, index + 1);
271+
load_javascript_files_sequentially(files, index + 1, onCompleted);
271272
});
272273
}
273274

0 commit comments

Comments
 (0)