mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-24 12:07:10 -04:00
Refactor js init sequence.
This commit is contained in:
parent
b1b5e37ab6
commit
5f2a7985d8
5 changed files with 34 additions and 33 deletions
30
src/_h5ai/client/js/inc/boot.js
Normal file
30
src/_h5ai/client/js/inc/boot.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
modulejs.define('boot', ['$'], function ($) {
|
||||
|
||||
if ($('html').hasClass('no-browser')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var module = $('script[data-module]').data('module');
|
||||
var data = {action: 'get', setup: true, options: true, types: true, theme: true, langs: true};
|
||||
var url;
|
||||
|
||||
if (module === 'index') {
|
||||
url = '.';
|
||||
} else if (module === 'info') {
|
||||
data.updatecmds = true;
|
||||
url = 'server/php/index.php';
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: data,
|
||||
type: 'POST',
|
||||
dataType: 'json'
|
||||
}).done(function (config) {
|
||||
|
||||
modulejs.define('config', config);
|
||||
$(function () { modulejs.require('main/' + module); });
|
||||
});
|
||||
});
|
|
@ -1,4 +1,4 @@
|
|||
modulejs.define('main', ['_', 'core/event'], function (_, event) {
|
||||
modulejs.define('main/index', ['_', 'core/event'], function (_, event) {
|
||||
|
||||
modulejs.require('view/ensure');
|
||||
modulejs.require('view/items');
|
|
@ -1,4 +1,4 @@
|
|||
modulejs.define('info', ['$', 'config'], function ($, config) {
|
||||
modulejs.define('main/info', ['$', 'config'], function ($, config) {
|
||||
|
||||
var testsTemp =
|
||||
'<ul id="tests">';
|
|
@ -10,7 +10,6 @@
|
|||
'use strict';
|
||||
|
||||
var win = window;
|
||||
|
||||
modulejs.define('$', function () { return win.jQuery; });
|
||||
modulejs.define('_', function () { return win._; });
|
||||
modulejs.define('marked', function () { return win.marked; });
|
||||
|
@ -19,33 +18,5 @@
|
|||
|
||||
// @include "inc/**/*.js"
|
||||
|
||||
var $ = win.jQuery;
|
||||
|
||||
if ($('html').hasClass('no-browser')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var module = $('script[data-module]').data('module');
|
||||
var data = {action: 'get', setup: true, options: true, types: true, theme: true, langs: true};
|
||||
var url;
|
||||
|
||||
if (module === 'main') {
|
||||
url = '.';
|
||||
} else if (module === 'info') {
|
||||
data.updatecmds = true;
|
||||
url = 'server/php/index.php';
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: data,
|
||||
type: 'POST',
|
||||
dataType: 'json'
|
||||
}).done(function (config) {
|
||||
|
||||
modulejs.define('config', config);
|
||||
$(function () { modulejs.require(module); });
|
||||
});
|
||||
modulejs.require('boot');
|
||||
}());
|
||||
|
|
|
@ -16,7 +16,7 @@ head
|
|||
link( rel="shortcut icon", href!="#{app_href}client/images/favicon/favicon-16-32.ico" )
|
||||
link( rel="apple-touch-icon-precomposed", type="image/png", href!="#{app_href}client/images/favicon/favicon-152.png" )
|
||||
link( rel="stylesheet", href!="#{app_href}client/css/styles.css" )
|
||||
script( src!="#{app_href}client/js/scripts.js", data-module="main" )
|
||||
script( src!="#{app_href}client/js/scripts.js", data-module="index" )
|
||||
|
||||
body
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue