diff --git a/src/discovery.config.js b/src/discovery.config.js index 7df833d76..78d24b387 100644 --- a/src/discovery.config.js +++ b/src/discovery.config.js @@ -281,6 +281,7 @@ require.config({ exports: "MathJax", init: function () { MathJax.Hub.Config({ + messageStyle: 'none', HTML: ["input/TeX","output/HTML-CSS"], TeX: { extensions: ["AMSmath.js","AMSsymbols.js"], equationNumbers: { autoNumber: "AMS" } }, diff --git a/src/index.html b/src/index.html index 9b39f2a77..ed2b2a9fb 100644 --- a/src/index.html +++ b/src/index.html @@ -2,14 +2,14 @@ - - - + + + NASA/ADS Search (Beta Interface) - + @@ -27,11 +27,23 @@
-
-
astrophysics
-
data system
-
- loading... +
+
+
astrophysics
+
data system
+
+
+
+
+ loading... +
+
+
0% Complete
+
+
+ +
+
@@ -47,9 +59,41 @@ window.require = { waitSeconds: 30 }; + + // Progress Bar + (function () { + var progressBar = document.getElementById('app_loading_progress'); + var message = document.getElementById('app_loading_message'); + var progressInner = document.querySelector('#app_loading_progress>div'); + var progressValue = 0; + + window.__setAppLoadingProgress = function (val, msg) { + progressBar.setAttribute('aria-valuenow', val); + progressBar.style = 'width: ' + val + '%'; + progressInner.innerText = val + '% Complete'; + message.innerHTML = msg ? msg : message.innerHTML; + progressValue = val; + }; + setTimeout(function () { window.__setAppLoadingProgress(10); }, 200); + setTimeout(function () { window.__setAppLoadingProgress(15); }, 500); + window.__setAppLoadingProgress(5, 'Downloading Assets'); + window.__PAGE_LOAD_TIMESTAMP = new Date(); + + // Show a reload button if the page is taking too long + setTimeout(function check () { + if (progressValue !== 100) { + var msg = 'Loading the application is taking a long time... '; + msg += ''; + window.__setAppLoadingProgress(progressValue, msg); + } else { + setTimeout(check, 10000); + } + }, 10000); + })(); + - + diff --git a/src/js/apps/discovery/main.js b/src/js/apps/discovery/main.js index 84c36d289..f1af08398 100644 --- a/src/js/apps/discovery/main.js +++ b/src/js/apps/discovery/main.js @@ -20,17 +20,17 @@ define(['config', 'module'], function(config, module) { 'js/components/application', 'js/mixins/discovery_bootstrap', 'js/mixins/api_access', + 'analytics', 'es5-shim' - ], - function(Router, - Application, - DiscoveryBootstrap, - ApiAccess - ) { + ], function(Router, Application, DiscoveryBootstrap, ApiAccess, analytics) { + + var updateProgress = (typeof window.__setAppLoadingProgress === 'function') ? + window.__setAppLoadingProgress : function () {}; + Application.prototype.shim(); // at the beginning, we don't know anything about ourselves... - var debug = window.location.href.indexOf('debug=true') > -1 ? true : false; + var debug = window.location.href.indexOf('debug=true') > -1; // app object will load everything var app = new (Application.extend(DiscoveryBootstrap))({'debug': debug, timeout: 30000}); @@ -38,8 +38,11 @@ define(['config', 'module'], function(config, module) { // load the objects/widgets/modules (using discovery.config.js) var defer = app.loadModules(module.config()); + updateProgress(20, 'Starting Application'); + // after they are loaded; we'll kick off the application defer.done(function() { + updateProgress(50, 'Modules Loaded'); // this will activate all loaded modules app.activate(); @@ -50,7 +53,9 @@ define(['config', 'module'], function(config, module) { // set some important urls, parameters before doing anything app.configure(); + updateProgress(95, 'Finishing Up...'); app.bootstrap().done(function (data) { + updateProgress(100); app.onBootstrap(data); pubsub.publish(pubsub.getCurrentPubSubKey(), pubsub.APP_BOOTSTRAPPED); @@ -80,6 +85,21 @@ define(['config', 'module'], function(config, module) { window.bbb = app; } + // app is loaded, send timing event + + if (__PAGE_LOAD_TIMESTAMP) { + var time = new Date() - __PAGE_LOAD_TIMESTAMP; + analytics('send', { + hitType: 'timing', + timingCategory: 'Application', + timingVar: 'Loaded', + timingValue: time + }); + if (debug) { + console.log('Application Started: ' + time + 'ms'); + } + + } }).fail(function () { app.redirect('500.html'); }); @@ -94,8 +114,4 @@ define(['config', 'module'], function(config, module) { }); }); - - - - });