More changes to init procedure and API.

This commit is contained in:
Lars Jung 2012-10-11 14:45:18 +02:00
parent 15dd200b28
commit a087e96d69
6 changed files with 17 additions and 13 deletions

View File

@ -1,5 +1,5 @@
modulejs.define('h5ai-info', ['$', 'core/server'], function ($, server) {
modulejs.define('info', ['$'], function ($) {
var setCheckResult = function (id, result) {
@ -14,12 +14,12 @@ modulejs.define('h5ai-info', ['$', 'core/server'], function ($, server) {
init = function () {
server.request({action: 'get', checks: true}, function (json) {
$.getJSON('server/php/index.php', {action: 'get', checks: true}, function (json) {
if (json) {
$('.test').each(function () {
setCheckResult(this, json[$(this).data('id')]);
setCheckResult(this, json.checks[$(this).data('id')]);
});
}
});

View File

@ -1,5 +1,5 @@
modulejs.define('h5ai-main', ['_', 'core/event'], function (_, event) {
modulejs.define('main', ['_', 'core/event'], function (_, event) {
event.pub('beforeView');

View File

@ -24,8 +24,7 @@
var filename = 'client/js/scripts.js',
$scriptTag = $('script[src$="' + filename + '"]'),
src = $scriptTag.attr('src'),
main = $scriptTag.data('main'),
backend = $scriptTag.data('backend'),
mode = $scriptTag.data('mode'),
appHref = src.substr(0, src.length - filename.length),
@ -41,11 +40,16 @@
modulejs.define('moment', function () { return moment; });
modulejs.define('_', function () { return _; });
$(function () { modulejs.require(main); });
$(function () { modulejs.require('main'); });
};
if (backend === 'php') {
if (mode === 'info') {
modulejs.define('$', function () { return jQuery; });
$(function () { modulejs.require('info'); });
} else if (mode === 'php') {
$.getJSON('.', {
action: 'get',
@ -55,7 +59,7 @@
server: true
}, run);
} else if (backend === 'aai') {
} else if (mode === 'aai') {
var loadJson = function (href) {
@ -81,7 +85,7 @@
types: types,
langs: langs,
server: {
backend: backend,
backend: mode,
api: false,
name: 'apache',
version: null

View File

@ -15,7 +15,7 @@ html.no-js( lang="en" )
link( rel="apple-touch-icon", type="image/png", href="client/images/app-48x48.png" )
link( rel="stylesheet", href="//fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic,700italic|Ubuntu:400,700,400italic,700italic" )
link( rel="stylesheet", href="client/css/styles.css" )
script( src="client/js/scripts.js", data-main="h5ai-info", data-backend="php" )
script( src="client/js/scripts.js", data-mode="info" )
body#h5ai-info

View File

@ -18,7 +18,7 @@ head
link( rel="apple-touch-icon", type="image/png", href="#{href}client/images/app-48x48.png" )
link( rel="stylesheet", href="//fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic,700italic|Ubuntu:400,700,400italic,700italic" )
link( rel="stylesheet", href="#{href}client/css/styles.css" )
script( src="#{href}client/js/scripts.js", data-main="h5ai-main", data-backend="aai" )
script( src="#{href}client/js/scripts.js", data-mode="aai" )
|<body id="h5ai-main">

View File

@ -21,7 +21,7 @@ html.no-js( lang="en" )
link( rel="apple-touch-icon", type="image/png", href!="#{href}client/images/app-48x48.png" )
link( rel="stylesheet", href="//fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic,700italic|Ubuntu:400,700,400italic,700italic" )
link( rel="stylesheet", href!="#{href}client/css/styles.css" )
script( src!="#{href}client/js/scripts.js", data-main="h5ai-main", data-backend="php" )
script( src!="#{href}client/js/scripts.js", data-mode="php" )
body#h5ai-main