From 4f83c95d20a19b42a9e47a51ce96fb7f50b1c573 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Wed, 13 May 2015 01:16:21 +0200 Subject: [PATCH] Use own location as API href. --- src/_h5ai/public/js/inc/boot.js | 16 +++++----------- src/_h5ai/public/js/inc/core/server.js | 7 +++---- src/_h5ai/public/js/inc/main/info.js | 23 +++++++---------------- 3 files changed, 15 insertions(+), 31 deletions(-) diff --git a/src/_h5ai/public/js/inc/boot.js b/src/_h5ai/public/js/inc/boot.js index 82b86200..9a8ace36 100644 --- a/src/_h5ai/public/js/inc/boot.js +++ b/src/_h5ai/public/js/inc/boot.js @@ -1,28 +1,22 @@ -modulejs.define('boot', ['$'], function ($) { +modulejs.define('boot', ['$', 'core/server'], function ($, server) { 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 href; + var data = {action: 'get', setup: true, options: true, types: true}; if (module === 'index') { - href = '.'; + data.theme = true; + data.langs = true; } else if (module === 'info') { data.refresh = true; - href = 'index.php'; } else { return; } - $.ajax({ - url: href, - data: data, - type: 'post', - dataType: 'json' - }).done(function (config) { + server.request(data, function (config) { modulejs.define('config', config); $(function () { modulejs.require('main/' + module); }); diff --git a/src/_h5ai/public/js/inc/core/server.js b/src/_h5ai/public/js/inc/core/server.js index ff5c028d..1de94806 100644 --- a/src/_h5ai/public/js/inc/core/server.js +++ b/src/_h5ai/public/js/inc/core/server.js @@ -1,9 +1,9 @@ -modulejs.define('core/server', ['_', '$', 'core/location'], function (_, $, location) { +modulejs.define('core/server', ['_', '$'], function (_, $) { function request(data, callback) { $.ajax({ - url: location.getAbsHref(), + url: '?', data: data, type: 'post', dataType: 'json' @@ -20,8 +20,7 @@ modulejs.define('core/server', ['_', '$', 'core/location'], function (_, $, loca function formRequest(data) { - var $form = $('
') - .attr('action', location.getAbsHref()); + var $form = $(''); _.each(data, function (val, key) { diff --git a/src/_h5ai/public/js/inc/main/info.js b/src/_h5ai/public/js/inc/main/info.js index 6a5288ca..03995263 100644 --- a/src/_h5ai/public/js/inc/main/info.js +++ b/src/_h5ai/public/js/inc/main/info.js @@ -1,4 +1,4 @@ -modulejs.define('main/info', ['$', 'config'], function ($, config) { +modulejs.define('main/info', ['$', 'config', 'core/server'], function ($, config, server) { var testsTemp = '