mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-06-03 16:48:38 -04:00
More refactorings.
This commit is contained in:
parent
c40fac67d0
commit
fc9f846cb5
13 changed files with 248 additions and 212 deletions
|
@ -1,46 +1,53 @@
|
|||
|
||||
modulejs.define('core/server', ['$', '_', 'config', 'core/location'], function ($, _, config, location) {
|
||||
|
||||
var server = _.extend({}, config.server, {
|
||||
var server = {
|
||||
|
||||
request: function (data, callback) {
|
||||
backend: config.setup.BACKEND,
|
||||
api: config.setup.API === true,
|
||||
name: config.setup.SERVER_NAME,
|
||||
version: config.setup.SERVER_VERSION,
|
||||
|
||||
if (server.api) {
|
||||
$.ajax({
|
||||
url: location.getAbsHref(),
|
||||
data: data,
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
success: function (json) {
|
||||
request: function (data, callback) {
|
||||
|
||||
callback(json);
|
||||
},
|
||||
error: function () {
|
||||
if (server.api) {
|
||||
$.ajax({
|
||||
url: location.getAbsHref(),
|
||||
data: data,
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
success: function (json) {
|
||||
|
||||
callback();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
callback();
|
||||
callback(json);
|
||||
},
|
||||
error: function () {
|
||||
|
||||
callback();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
|
||||
formRequest: function (data) {
|
||||
|
||||
if (server.api) {
|
||||
var $form = $('<form method="post" style="display:none;"/>')
|
||||
.attr('action', location.getAbsHref());
|
||||
|
||||
_.each(data, function (val, key) {
|
||||
|
||||
$('<input type="hidden"/>')
|
||||
.attr('name', key)
|
||||
.attr('value', val)
|
||||
.appendTo($form);
|
||||
});
|
||||
|
||||
$form.appendTo('body').submit().remove();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
formRequest: function (data) {
|
||||
|
||||
var $form = $('<form method="post" style="display:none;"/>')
|
||||
.attr('action', location.getAbsHref());
|
||||
|
||||
_.each(data, function (val, key) {
|
||||
|
||||
$('<input type="hidden"/>')
|
||||
.attr('name', key)
|
||||
.attr('value', val)
|
||||
.appendTo($form);
|
||||
});
|
||||
|
||||
$form.appendTo('body').submit().remove();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return server;
|
||||
});
|
||||
|
|
|
@ -5,9 +5,9 @@ modulejs.define('ext/custom', ['_', '$', 'core/settings', 'core/server', 'core/e
|
|||
enabled: false
|
||||
}, allsettings.custom),
|
||||
|
||||
onLocationChanged = function () {
|
||||
onLocationChanged = function (item) {
|
||||
|
||||
server.request({action: 'get', custom: true}, function (response) {
|
||||
server.request({action: 'get', custom: true, customHref: item.absHref}, function (response) {
|
||||
|
||||
var h, f;
|
||||
if (response) {
|
||||
|
|
|
@ -1,7 +1,22 @@
|
|||
|
||||
modulejs.define('info', ['$'], function ($) {
|
||||
modulejs.define('info', ['$', 'config'], function ($, config) {
|
||||
|
||||
var setCheckResult = function (el, result) {
|
||||
var map = function (setup) {
|
||||
|
||||
return {
|
||||
'php_version': setup['HAS_PHP_VERSION'],
|
||||
'cache_dir': setup['HAS_WRITABLE_CACHE'],
|
||||
'image_thumbs': setup['HAS_PHP_JPG'],
|
||||
'exif_thumbs': setup['HAS_PHP_EXIF'],
|
||||
'movie_thumbs': setup['HAS_CMD_FFMPEG'] || setup['HAS_CMD_AVCONV'],
|
||||
'pdf_thumbs': setup['HAS_CMD_CONVERT'],
|
||||
'shell_tar': setup['HAS_CMD_TAR'],
|
||||
'shell_zip': setup['HAS_CMD_ZIP'],
|
||||
'folder_sizes': setup['HAS_CMD_DU']
|
||||
};
|
||||
},
|
||||
|
||||
setValue = function (el, result) {
|
||||
|
||||
var $result = $(el).find('.result');
|
||||
|
||||
|
@ -14,17 +29,16 @@ modulejs.define('info', ['$'], function ($) {
|
|||
|
||||
init = function () {
|
||||
|
||||
$.getJSON('server/php/index.php', {action: 'get', checks: true}, function (json) {
|
||||
var setup = config.setup,
|
||||
values = map(setup);
|
||||
|
||||
if (json) {
|
||||
$('.idx-file .value').text(json.checks['path_index']);
|
||||
$('.test').each(function () {
|
||||
$('.test').each(function () {
|
||||
|
||||
setCheckResult(this, json.checks[$(this).data('id')]);
|
||||
});
|
||||
$('.test.php .result').text(json.checks['php_version']);
|
||||
}
|
||||
setValue(this, values[$(this).data('id')]);
|
||||
});
|
||||
|
||||
$('.idx-file .value').text(setup['INDEX_URL']);
|
||||
$('.test.php .result').text(setup['PHP_VERSION']);
|
||||
};
|
||||
|
||||
init();
|
||||
|
|
|
@ -31,27 +31,29 @@
|
|||
// @include "inc/**/*.js"
|
||||
|
||||
var $ = jQuery,
|
||||
mode = $('script[src$="scripts.js"]').data('mode');
|
||||
mode = $('script[src$="scripts.js"]').data('mode'),
|
||||
url = '.',
|
||||
module = 'main';
|
||||
|
||||
if ($('html').hasClass('no-browser')) {
|
||||
|
||||
} else if (mode === 'info') {
|
||||
|
||||
$(function () { modulejs.require('info'); });
|
||||
|
||||
} else {
|
||||
|
||||
$.ajax({
|
||||
url: '.',
|
||||
data: {action: 'get', options: true, types: true, langs: true, server: true},
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
success: function (config) {
|
||||
|
||||
modulejs.define('config', config);
|
||||
$(function () { modulejs.require('main'); });
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode === 'info') {
|
||||
url = 'server/php/index.php';
|
||||
module = 'info';
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: {action: 'get', setup: true, options: true, types: true, langs: true},
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
success: function (config) {
|
||||
|
||||
modulejs.define('config', config);
|
||||
$(function () { modulejs.require(module); });
|
||||
}
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue