diff --git a/src/_h5ai/client/js/scripts.js b/src/_h5ai/client/js/scripts.js index a1cab5ba..f56fb641 100644 --- a/src/_h5ai/client/js/scripts.js +++ b/src/_h5ai/client/js/scripts.js @@ -16,52 +16,42 @@ // app // --- -(function ($) { +(function () { 'use strict'; + /*global amplify, jQuery, Modernizr, moment, _ */ + // `jQuery`, `moment` and `underscore` are itself functions, + // so they have to be wrapped to not be handled as constructors. + modulejs.define('amplify', amplify); + modulejs.define('$', function () { return jQuery; }); + modulejs.define('modernizr', Modernizr); + modulejs.define('moment', function () { return moment; }); + modulejs.define('_', function () { return _; }); + // @include "inc/**/*.js" - var filename = 'client/js/scripts.js', - $scriptTag = $('script[src$="' + filename + '"]'), - src = $scriptTag.attr('src'), - mode = $scriptTag.data('mode'), - - appHref = src.substr(0, src.length - filename.length), - - run = function (config) { - /*global amplify, Base64, jQuery, Modernizr, moment, _ */ - - // `jQuery`, `moment` and `underscore` are itself functions, - // so they have to be wrapped to not be handled as constructors. - modulejs.define('config', config); - modulejs.define('amplify', amplify); - modulejs.define('$', function () { return jQuery; }); - modulejs.define('modernizr', Modernizr); - modulejs.define('moment', function () { return moment; }); - modulejs.define('_', function () { return _; }); - - $(function () { modulejs.require('main'); }); - }; - + var $ = jQuery, + filename = 'client/js/scripts.js', + $script = $('script[src$="' + filename + '"]'), + mode = $script.data('mode'); if (mode === 'info') { - modulejs.define('$', function () { return jQuery; }); $(function () { modulejs.require('info'); }); } else if (mode === 'php') { - $.getJSON('.', { - action: 'get', - options: true, - types: true, - langs: true, - server: true - }, run); + $.getJSON('.', {action: 'get', options: true, types: true, langs: true, server: true}, function (config) { + + modulejs.define('config', config); + $(function () { modulejs.require('main'); }); + }); } else if (mode === 'aai') { - var loadJson = function (href) { + var src = $script.attr('src'), + appHref = src.substr(0, src.length - filename.length), + loadJson = function (href) { var deferred = $.Deferred(); @@ -80,18 +70,21 @@ loadJson(appHref + 'conf/langs.json') ).done(function (options, types, langs) { - run({ - options: options, - types: types, - langs: langs, - server: { - backend: mode, - api: false, - name: 'apache', - version: null - } - }); + var config = { + options: options, + types: types, + langs: langs, + server: { + backend: mode, + api: false, + name: 'apache', + version: null + } + }; + + modulejs.define('config', config); + $(function () { modulejs.require('main'); }); }); } -}(jQuery)); +}());