diff --git a/jshint.json b/jshint.json
index 4fa8185f..7db98e63 100644
--- a/jshint.json
+++ b/jshint.json
@@ -16,13 +16,6 @@
// Globals
"predef": [
- "amplify",
- "Base64",
- "H5AI_CONFIG",
- "jQuery",
- "Modernizr",
- "modulejs",
- "moment",
- "_"
+ "modulejs"
]
}
\ No newline at end of file
diff --git a/src/_h5ai/js/inc/core/ajax.js b/src/_h5ai/js/inc/core/ajax.js
new file mode 100644
index 00000000..1dec7865
--- /dev/null
+++ b/src/_h5ai/js/inc/core/ajax.js
@@ -0,0 +1,157 @@
+
+modulejs.define('core/ajax', ['$', 'amplify', 'base64', 'core/resource'], function ($, amplify, base64, resource) {
+
+ var reContentType = /^text\/html;h5ai=/,
+
+ getStatus = function (href, withContent, callback) {
+
+ $.ajax({
+ url: href,
+ type: withContent ? 'GET' : 'HEAD',
+ complete: function (xhr) {
+
+ var res = {
+ status: xhr.status,
+ content: xhr.responseText
+ };
+
+ if (xhr.status === 200 && reContentType.test(xhr.getResponseHeader('Content-Type'))) {
+ res.status = 'h5ai';
+ }
+
+ callback(res);
+ }
+ });
+ },
+
+ getChecks = function (callback) {
+
+ $.ajax({
+ url: resource.api(),
+ data: {
+ action: 'getchecks'
+ },
+ type: 'POST',
+ dataType: 'json',
+ success: function (json) {
+
+ callback(json);
+ },
+ error: function () {
+
+ callback();
+ }
+ });
+ },
+
+ getArchive = function (data, callback) {
+
+ $.ajax({
+ url: resource.api(),
+ data: {
+ action: 'archive',
+ execution: data.execution,
+ format: data.format,
+ hrefs: data.hrefs
+ },
+ type: 'POST',
+ dataType: 'json',
+ beforeSend: function (xhr) {
+
+ if (data.user) {
+ xhr.setRequestHeader('Authorization', 'Basic ' + base64.encode(data.user + ':' + data.password));
+ }
+ },
+ success: function (json) {
+
+ callback(json);
+ },
+ error: function () {
+
+ callback();
+ }
+ });
+ },
+
+ getThumbSrc = function (data, callback) {
+
+ $.ajax({
+ url: resource.api(),
+ data: {
+ action: 'getthumbsrc',
+ type: data.type,
+ href: data.href,
+ mode: data.mode,
+ width: data.width,
+ height: data.height
+ },
+ type: 'POST',
+ dataType: 'json',
+ success: function (json) {
+
+ if (json.code === 0) {
+ callback(json.absHref);
+ }
+ callback();
+ },
+ error: function () {
+
+ callback();
+ }
+ });
+ },
+
+ getThumbSrcSmall = function (type, href, callback) {
+
+ getThumbSrc(
+ {
+ type: type,
+ href: href,
+ mode: 'square',
+ width: 16,
+ height: 16
+ },
+ callback
+ );
+ },
+
+ getThumbSrcBig = function (type, href, callback) {
+
+ getThumbSrc(
+ {
+ type: type,
+ href: href,
+ mode: 'rational',
+ width: 100,
+ height: 48
+ },
+ callback
+ );
+ },
+
+ getHtml = function (url, callback) {
+
+ $.ajax({
+ url: url,
+ dataType: 'html',
+ success: function (html) {
+
+ callback(html);
+ },
+ error: function () {
+
+ callback();
+ }
+ });
+ };
+
+
+ return {
+ getStatus: getStatus,
+ getChecks: getChecks,
+ getArchive: getArchive,
+ getThumbSrcSmall: getThumbSrcSmall,
+ getThumbSrcBig: getThumbSrcBig,
+ getHtml: getHtml
+ };
+});
diff --git a/src/_h5ai/js/inc/core/entry.js b/src/_h5ai/js/inc/core/entry.js
index 033970b3..3e82d5fc 100644
--- a/src/_h5ai/js/inc/core/entry.js
+++ b/src/_h5ai/js/inc/core/entry.js
@@ -1,5 +1,5 @@
-modulejs.define('core/entry', ['jQuery', 'core/parser', 'model/entry'], function ($, parser, Entry) {
+modulejs.define('core/entry', ['$', 'core/parser', 'model/entry'], function ($, parser, Entry) {
var absHref = document.location.pathname.replace(/[^\/]*$/, '');
diff --git a/src/_h5ai/js/inc/core/format.js b/src/_h5ai/js/inc/core/format.js
index 4fbeba5a..f59245f5 100644
--- a/src/_h5ai/js/inc/core/format.js
+++ b/src/_h5ai/js/inc/core/format.js
@@ -1,5 +1,5 @@
-modulejs.define('core/format', ['moment'], function (moment) {
+modulejs.define('core/format', ['_', 'moment'], function (_, moment) {
var reParseSize = /^\s*([\.\d]+)\s*([kmgt]?)b?\s*$/i,
treshhold = 1000.0,
diff --git a/src/_h5ai/js/inc/core/parser.js b/src/_h5ai/js/inc/core/parser.js
index 0f06d463..f840d052 100644
--- a/src/_h5ai/js/inc/core/parser.js
+++ b/src/_h5ai/js/inc/core/parser.js
@@ -1,5 +1,5 @@
-modulejs.define('core/parser', ['jQuery'], function ($) {
+modulejs.define('core/parser', ['$'], function ($) {
if ($('#data-apache-autoindex').length) {
return modulejs.require('parser/apache-autoindex');
diff --git a/src/_h5ai/js/inc/core/settings.js b/src/_h5ai/js/inc/core/settings.js
index bbb74f32..25fb084e 100644
--- a/src/_h5ai/js/inc/core/settings.js
+++ b/src/_h5ai/js/inc/core/settings.js
@@ -1,5 +1,5 @@
-modulejs.define('core/settings', ['H5AI_CONFIG'], function (config) {
+modulejs.define('core/settings', ['config', '_'], function (config, _) {
var defaults = {
rootAbsHref: '/',
@@ -12,7 +12,7 @@ modulejs.define('core/settings', ['H5AI_CONFIG'], function (config) {
});
-modulejs.define('core/types', ['H5AI_CONFIG'], function (config) {
+modulejs.define('core/types', ['config', '_'], function (config, _) {
var reEndsWithSlash = /\/$/,
reStartsWithDot = /^\./,
@@ -61,7 +61,7 @@ modulejs.define('core/types', ['H5AI_CONFIG'], function (config) {
});
-modulejs.define('core/langs', ['H5AI_CONFIG'], function (config) {
+modulejs.define('core/langs', ['config', '_'], function (config, _) {
var defaults = {
lang: 'unknown',
diff --git a/src/_h5ai/js/inc/ext/crumb.js b/src/_h5ai/js/inc/ext/crumb.js
index 8622a546..07d8ebcb 100644
--- a/src/_h5ai/js/inc/ext/crumb.js
+++ b/src/_h5ai/js/inc/ext/crumb.js
@@ -1,5 +1,5 @@
-modulejs.define('ext/crumb', ['jQuery', 'core/settings', 'core/resource', 'core/entry'], function ($, allsettings, resource, entry) {
+modulejs.define('ext/crumb', ['_', '$', 'core/settings', 'core/resource', 'core/entry'], function (_, $, allsettings, resource, entry) {
var defaults = {
enabled: false
diff --git a/src/_h5ai/js/inc/ext/custom.js b/src/_h5ai/js/inc/ext/custom.js
index dd5fce91..95be1a5a 100644
--- a/src/_h5ai/js/inc/ext/custom.js
+++ b/src/_h5ai/js/inc/ext/custom.js
@@ -1,5 +1,5 @@
-modulejs.define('ext/custom', ['jQuery', 'core/settings'], function ($, allsettings) {
+modulejs.define('ext/custom', ['_', '$', 'core/settings', 'core/ajax'], function (_, $, allsettings, ajax) {
var defaults = {
enabled: false,
@@ -16,23 +16,19 @@ modulejs.define('ext/custom', ['jQuery', 'core/settings'], function ($, allsetti
}
if (_.isString(settings.header)) {
- $.ajax({
- url: settings.header,
- dataType: 'html',
- success: function (data) {
+ ajax.getHtml(settings.header, function (html) {
- $('
').prependTo('#content');
+ if (html) {
+ $('').prependTo('#content');
}
});
}
if (_.isString(settings.footer)) {
- $.ajax({
- url: settings.footer,
- dataType: 'html',
- success: function (data) {
+ ajax.getHtml(settings.footer, function (html) {
- $('').appendTo('#content');
+ if (html) {
+ $('').appendTo('#content');
}
});
}
diff --git a/src/_h5ai/js/inc/ext/download.js b/src/_h5ai/js/inc/ext/download.js
index af007f37..719555f9 100644
--- a/src/_h5ai/js/inc/ext/download.js
+++ b/src/_h5ai/js/inc/ext/download.js
@@ -1,5 +1,5 @@
-modulejs.define('ext/download', ['jQuery', 'core/settings', 'core/resource', 'core/event'], function ($, allsettings, resource, event) {
+modulejs.define('ext/download', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/ajax'], function (_, $, allsettings, resource, event, ajax) {
var defaults = {
enabled: false,
@@ -33,19 +33,19 @@ modulejs.define('ext/download', ['jQuery', 'core/settings', 'core/resource', 'co
}, 1000);
},
- handleResponse = function (response) {
+ handleResponse = function (json) {
$download.removeClass('current');
$img.attr('src', resource.image('download'));
- if (response) {
- if (response.code === 0) {
+ if (json) {
+ if (json.code === 0) {
setTimeout(function () { // wait here so the img above can be updated in time
- window.location = resource.api() + '?action=getarchive&id=' + response.id + '&as=h5ai-selection.' + settings.format;
+ window.location = resource.api() + '?action=getarchive&id=' + json.id + '&as=h5ai-selection.' + settings.format;
}, 200);
} else {
- if (response.code === 401) {
+ if (json.code === 401) {
$downloadAuth
.css({
left: $download.offset().left,
@@ -65,34 +65,13 @@ modulejs.define('ext/download', ['jQuery', 'core/settings', 'core/resource', 'co
$download.addClass('current');
$img.attr('src', resource.image('loading.gif', true));
- $.ajax({
- url: resource.api(),
- data: {
- action: 'archive',
- execution: settings.execution,
- format: settings.format,
- hrefs: hrefsStr
- },
- type: 'POST',
- dataType: 'json',
- beforeSend: function (xhr) {
-
- var user = $downloadUser.val(),
- password = $downloadPassword.val();
-
- if (user) {
- xhr.setRequestHeader('Authorization', 'Basic ' + Base64.encode(user + ':' + password));
- }
- },
- success: function (response) {
-
- handleResponse(response);
- },
- error: function () {
-
- handleResponse();
- }
- });
+ ajax.getArchive({
+ execution: settings.execution,
+ format: settings.format,
+ hrefs: hrefsStr,
+ user: $downloadUser.val(),
+ password: $downloadPassword.val()
+ }, handleResponse);
},
onSelection = function (entries) {
diff --git a/src/_h5ai/js/inc/ext/filter.js b/src/_h5ai/js/inc/ext/filter.js
index b0ce24cf..2af67a7b 100644
--- a/src/_h5ai/js/inc/ext/filter.js
+++ b/src/_h5ai/js/inc/ext/filter.js
@@ -1,5 +1,5 @@
-modulejs.define('ext/filter', ['jQuery', 'core/settings', 'core/resource'], function ($, allsettings, resource) {
+modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource'], function (_, $, allsettings, resource) {
var defaults = {
enabled: false
diff --git a/src/_h5ai/js/inc/ext/folderstatus.js b/src/_h5ai/js/inc/ext/folderstatus.js
index 9d1326ad..4c110db4 100644
--- a/src/_h5ai/js/inc/ext/folderstatus.js
+++ b/src/_h5ai/js/inc/ext/folderstatus.js
@@ -1,5 +1,5 @@
-modulejs.define('ext/folderstatus', ['jQuery', 'core/settings'], function ($, allsettings) {
+modulejs.define('ext/folderstatus', ['_', 'core/settings'], function (_, allsettings) {
var defaults = {
enabled: false,
diff --git a/src/_h5ai/js/inc/ext/l10n.js b/src/_h5ai/js/inc/ext/l10n.js
index ca8ed7bd..daf7c3f0 100644
--- a/src/_h5ai/js/inc/ext/l10n.js
+++ b/src/_h5ai/js/inc/ext/l10n.js
@@ -1,5 +1,5 @@
-modulejs.define('ext/l10n', ['jQuery', 'core/settings', 'core/langs', 'core/format', 'core/store', 'core/event'], function ($, allsettings, langs, format, store, event) {
+modulejs.define('ext/l10n', ['_', '$', 'core/settings', 'core/langs', 'core/format', 'core/store', 'core/event'], function (_, $, allsettings, langs, format, store, event) {
var defaults = {
enabled: true,
diff --git a/src/_h5ai/js/inc/ext/link-hover-states.js b/src/_h5ai/js/inc/ext/link-hover-states.js
index 5b5db61e..dc403b19 100644
--- a/src/_h5ai/js/inc/ext/link-hover-states.js
+++ b/src/_h5ai/js/inc/ext/link-hover-states.js
@@ -1,5 +1,5 @@
-modulejs.define('ext/link-hover-states', ['jQuery', 'core/settings'], function ($, allsettings) {
+modulejs.define('ext/link-hover-states', ['_', '$', 'core/settings'], function (_, $, allsettings) {
var defaults = {
enabled: false
diff --git a/src/_h5ai/js/inc/ext/mode.js b/src/_h5ai/js/inc/ext/mode.js
index 7253d9df..6b2cd6c1 100644
--- a/src/_h5ai/js/inc/ext/mode.js
+++ b/src/_h5ai/js/inc/ext/mode.js
@@ -1,5 +1,5 @@
-modulejs.define('ext/mode', ['jQuery', 'core/settings', 'core/parser'], function ($, allsettings, parser) {
+modulejs.define('ext/mode', ['_', '$', 'core/settings', 'core/parser'], function (_, $, allsettings, parser) {
var defaults = {
enabled: false,
diff --git a/src/_h5ai/js/inc/ext/preview-img.js b/src/_h5ai/js/inc/ext/preview-img.js
index 814abef2..628c676f 100644
--- a/src/_h5ai/js/inc/ext/preview-img.js
+++ b/src/_h5ai/js/inc/ext/preview-img.js
@@ -1,5 +1,5 @@
-modulejs.define('ext/preview-img', ['jQuery', 'core/settings', 'core/resource', 'core/store', 'core/entry'], function ($, allsettings, resource, store, entry) {
+modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/resource', 'core/store', 'core/entry'], function (_, $, allsettings, resource, store, entry) {
var defaults = {
enabled: false,
diff --git a/src/_h5ai/js/inc/ext/qrcode.js b/src/_h5ai/js/inc/ext/qrcode.js
index c325009a..cdd183b0 100644
--- a/src/_h5ai/js/inc/ext/qrcode.js
+++ b/src/_h5ai/js/inc/ext/qrcode.js
@@ -1,5 +1,5 @@
-modulejs.define('ext/qrcode', ['jQuery', 'core/settings', 'core/event'], function ($, allsettings, event) {
+modulejs.define('ext/qrcode', ['_', '$', 'modernizr', 'core/settings', 'core/event'], function (_, $, modernizr, allsettings, event) {
var defaults = {
enabled: false,
@@ -15,7 +15,7 @@ modulejs.define('ext/qrcode', ['jQuery', 'core/settings', 'core/event'], functio
update = function (entry) {
$context.find('.qrcode').empty().qrcode({
- render: Modernizr.canvas ? 'canvas' : 'div',
+ render: modernizr.canvas ? 'canvas' : 'div',
width: settings.size,
height: settings.size,
color: '#333',
diff --git a/src/_h5ai/js/inc/ext/select.js b/src/_h5ai/js/inc/ext/select.js
index 29fbc358..6d89af00 100644
--- a/src/_h5ai/js/inc/ext/select.js
+++ b/src/_h5ai/js/inc/ext/select.js
@@ -1,5 +1,5 @@
-modulejs.define('ext/select', ['jQuery', 'core/settings', 'core/event'], function ($, allsettings, event) {
+modulejs.define('ext/select', ['_', '$', 'core/settings', 'core/event'], function (_, $, allsettings, event) {
var defaults = {
enabled: false
diff --git a/src/_h5ai/js/inc/ext/sort.js b/src/_h5ai/js/inc/ext/sort.js
index 9b12b0cd..1272bb39 100644
--- a/src/_h5ai/js/inc/ext/sort.js
+++ b/src/_h5ai/js/inc/ext/sort.js
@@ -1,5 +1,5 @@
-modulejs.define('ext/sort', ['jQuery', 'core/settings', 'core/resource', 'core/store'], function ($, allsettings, resource, store) {
+modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/store'], function (_, $, allsettings, resource, store) {
var defaults = {
enabled: false,
diff --git a/src/_h5ai/js/inc/ext/statusbar.js b/src/_h5ai/js/inc/ext/statusbar.js
index 6d985e44..112703c3 100644
--- a/src/_h5ai/js/inc/ext/statusbar.js
+++ b/src/_h5ai/js/inc/ext/statusbar.js
@@ -1,5 +1,5 @@
-modulejs.define('ext/statusbar', ['jQuery', 'core/settings', 'core/format', 'core/event', 'core/entry'], function ($, allsettings, format, event, entry) {
+modulejs.define('ext/statusbar', ['_', '$', 'core/settings', 'core/format', 'core/event', 'core/entry'], function (_, $, allsettings, format, event, entry) {
var defaults = {
enabled: false
diff --git a/src/_h5ai/js/inc/ext/thumbnails.js b/src/_h5ai/js/inc/ext/thumbnails.js
index 2dac49fb..468e5a37 100644
--- a/src/_h5ai/js/inc/ext/thumbnails.js
+++ b/src/_h5ai/js/inc/ext/thumbnails.js
@@ -1,5 +1,5 @@
-modulejs.define('ext/thumbnails', ['jQuery', 'core/settings', 'core/resource', 'core/entry'], function ($, allsettings, resource, entry) {
+modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/entry', 'core/ajax'], function (_, allsettings, entry, ajax) {
var defaults = {
enabled: false,
@@ -11,46 +11,32 @@ modulejs.define('ext/thumbnails', ['jQuery', 'core/settings', 'core/resource', '
settings = _.extend({}, defaults, allsettings.thumbnails),
- requestThumb = function ($img, data) {
-
- $.getJSON(resource.api(), data, function (json) {
-
- if (json.code === 0) {
- $img.addClass('thumb').attr('src', json.absHref);
- }
- });
- },
-
checkEntry = function (entry) {
if (entry.$extended) {
var type = null;
- if ($.inArray(entry.type, settings.img) >= 0) {
+ if (_.indexOf(settings.img, entry.type) >= 0) {
type = 'img';
- } else if ($.inArray(entry.type, settings.mov) >= 0) {
+ } else if (_.indexOf(settings.mov, entry.type) >= 0) {
type = 'mov';
- } else if ($.inArray(entry.type, settings.doc) >= 0) {
+ } else if (_.indexOf(settings.doc, entry.type) >= 0) {
type = 'doc';
}
if (type) {
- requestThumb(entry.$extended.find('.icon.small img'), {
- action: 'getthumbsrc',
- type: type,
- href: entry.absHref,
- mode: 'square',
- width: 16,
- height: 16
+ ajax.getThumbSrcSmall(type, entry.absHref, function (src) {
+
+ if (src) {
+ entry.$extended.find('.icon.small img').addClass('thumb').attr('src', src);
+ }
});
- requestThumb(entry.$extended.find('.icon.big img'), {
- action: 'getthumbsrc',
- type: type,
- href: entry.absHref,
- mode: 'rational',
- width: 100,
- height: 48
+ ajax.getThumbSrcBig(type, entry.absHref, function (src) {
+
+ if (src) {
+ entry.$extended.find('.icon.big img').addClass('thumb').attr('src', src);
+ }
});
}
}
diff --git a/src/_h5ai/js/inc/ext/title.js b/src/_h5ai/js/inc/ext/title.js
index 2a9097e1..3bea5c81 100644
--- a/src/_h5ai/js/inc/ext/title.js
+++ b/src/_h5ai/js/inc/ext/title.js
@@ -1,5 +1,5 @@
-modulejs.define('ext/title', ['jQuery', 'core/settings', 'core/entry'], function ($, allsettings, entry) {
+modulejs.define('ext/title', ['_', 'core/settings', 'core/entry'], function (_, allsettings, entry) {
var defaults = {
enabled: false
diff --git a/src/_h5ai/js/inc/ext/tree.js b/src/_h5ai/js/inc/ext/tree.js
index 3d2decc2..9ea16a40 100644
--- a/src/_h5ai/js/inc/ext/tree.js
+++ b/src/_h5ai/js/inc/ext/tree.js
@@ -1,5 +1,5 @@
-modulejs.define('ext/tree', ['jQuery', 'core/settings', 'core/resource', 'core/event', 'core/entry', 'core/parser'], function ($, allsettings, resource, event, entry, parser) {
+modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/event', 'core/entry', 'core/parser'], function (_, $, allsettings, resource, event, entry, parser) {
var defaults = {
enabled: false,
diff --git a/src/_h5ai/js/inc/h5ai-info.js b/src/_h5ai/js/inc/h5ai-info.js
index 640fd3b5..606d57cd 100644
--- a/src/_h5ai/js/inc/h5ai-info.js
+++ b/src/_h5ai/js/inc/h5ai-info.js
@@ -1,5 +1,5 @@
-modulejs.define('h5ai-info', ['jQuery', 'core/resource'], function ($, resource) {
+modulejs.define('h5ai-info', ['$', 'core/ajax'], function ($, ajax) {
var setCheckResult = function (id, result) {
@@ -12,37 +12,17 @@ modulejs.define('h5ai-info', ['jQuery', 'core/resource'], function ($, resource)
}
},
- handleChecksResponse = function (response) {
-
- $('.test').each(function () {
-
- setCheckResult(this, response && response[$(this).data('id')]);
- });
- },
-
- checks = function () {
-
- $.ajax({
- url: resource.api(),
- data: {
- action: 'getchecks'
- },
- type: 'POST',
- dataType: 'json',
- success: function (response) {
-
- handleChecksResponse(response);
- },
- error: function () {
-
- handleChecksResponse();
- }
- });
- },
-
init = function () {
- checks();
+ ajax.getChecks(function (json) {
+
+ if (json) {
+ $('.test').each(function () {
+
+ setCheckResult(this, json[$(this).data('id')]);
+ });
+ }
+ });
};
init();
diff --git a/src/_h5ai/js/inc/h5ai-main.js b/src/_h5ai/js/inc/h5ai-main.js
index f0d6811a..cdda40ff 100644
--- a/src/_h5ai/js/inc/h5ai-main.js
+++ b/src/_h5ai/js/inc/h5ai-main.js
@@ -1,5 +1,5 @@
-modulejs.define('h5ai-main', ['jQuery', 'core/event', 'core/settings'], function ($, event, settings) {
+modulejs.define('h5ai-main', ['_', 'core/event', 'core/settings'], function (_, event, settings) {
event.pub('beforeView');
diff --git a/src/_h5ai/js/inc/main.js b/src/_h5ai/js/inc/main.js
index cf153fd1..656ce41b 100644
--- a/src/_h5ai/js/inc/main.js
+++ b/src/_h5ai/js/inc/main.js
@@ -3,6 +3,7 @@
'use strict';
+ // @include "core/ajax.js"
// @include "core/entry.js"
// @include "core/event.js"
// @include "core/format.js"
@@ -42,21 +43,19 @@
$(function () {
+ /*global H5AI_CONFIG, amplify, Base64, jQuery, Modernizr, moment, _ */
- // define it on doc ready, so the script order in the doc doesn't matter
- modulejs.define('H5AI_CONFIG', H5AI_CONFIG);
+ // Register predefined globals on doc ready, so the script order inside
+ // the document doesn't matter. `jQuery`, `moment` and `underscore` are
+ // itself functions, so they have to be wrapped to not be handled as
+ // constructors.
+ modulejs.define('config', H5AI_CONFIG);
modulejs.define('amplify', amplify);
-
- // `jQuery` and `moment` are itself functions, so they have to be wrapped
- // to not be taken as a constructor
- modulejs.define('jQuery', function () {
-
- return jQuery;
- });
- modulejs.define('moment', function () {
-
- return moment;
- });
+ modulejs.define('base64', Base64);
+ modulejs.define('$', function () { return jQuery; });
+ modulejs.define('modernizr', Modernizr);
+ modulejs.define('moment', function () { return moment; });
+ modulejs.define('_', function () { return _; });
modulejs.require($('body').attr('id'));
});
diff --git a/src/_h5ai/js/inc/model/entry.js b/src/_h5ai/js/inc/model/entry.js
index 665fcbda..cac504a0 100644
--- a/src/_h5ai/js/inc/model/entry.js
+++ b/src/_h5ai/js/inc/model/entry.js
@@ -1,5 +1,5 @@
-modulejs.define('model/entry', ['jQuery', 'core/types'], function ($, types) {
+modulejs.define('model/entry', ['_', 'core/types', 'core/ajax'], function (_, types, ajax) {
var domain = document.domain,
location = document.location.pathname.replace(/[^\/]*$/, ''),
@@ -56,25 +56,13 @@ modulejs.define('model/entry', ['jQuery', 'core/types'], function ($, types) {
},
- reContentType = /^text\/html;h5ai=/,
-
ajaxRequest = function (self, parser, callback) {
- $.ajax({
- url: self.absHref,
- type: parser ? 'GET' : 'HEAD',
- complete: function (xhr) {
+ ajax.getStatus(self.absHref, parser, function (response) {
- if (xhr.status === 200 && reContentType.test(xhr.getResponseHeader('Content-Type'))) {
- self.status = 'h5ai';
- if (parser) {
- parser.parse(self.absHref, xhr.responseText);
- }
- } else {
- self.status = xhr.status;
- }
-
- callback(self);
+ self.status = response.status;
+ if (parser && response.status === 'h5ai') {
+ parser.parse(self.absHref, response.content);
}
});
},
diff --git a/src/_h5ai/js/inc/parser/apache-autoindex.js b/src/_h5ai/js/inc/parser/apache-autoindex.js
index caa1d71a..5123aeed 100644
--- a/src/_h5ai/js/inc/parser/apache-autoindex.js
+++ b/src/_h5ai/js/inc/parser/apache-autoindex.js
@@ -1,5 +1,5 @@
-modulejs.define('parser/apache-autoindex', ['jQuery', 'core/settings', 'core/format', 'model/entry'], function ($, settings, format, Entry) {
+modulejs.define('parser/apache-autoindex', ['_', '$', 'core/settings', 'core/format', 'model/entry'], function (_, $, settings, format, Entry) {
var parseTableRow = function (absHref, tr) {
diff --git a/src/_h5ai/js/inc/parser/generic-json.js b/src/_h5ai/js/inc/parser/generic-json.js
index 672377b5..64a742be 100644
--- a/src/_h5ai/js/inc/parser/generic-json.js
+++ b/src/_h5ai/js/inc/parser/generic-json.js
@@ -1,5 +1,5 @@
-modulejs.define('parser/generic-json', ['jQuery', 'core/settings', 'model/entry'], function ($, settings, Entry) {
+modulejs.define('parser/generic-json', ['_', '$', 'core/settings', 'model/entry'], function (_, $, settings, Entry) {
var parser = {
id: 'generic-json',
diff --git a/src/_h5ai/js/inc/view/extended.js b/src/_h5ai/js/inc/view/extended.js
index a1f29e37..8690f6b5 100644
--- a/src/_h5ai/js/inc/view/extended.js
+++ b/src/_h5ai/js/inc/view/extended.js
@@ -1,5 +1,5 @@
-modulejs.define('view/extended', ['jQuery', 'core/settings', 'core/resource', 'core/format', 'core/event', 'core/entry'], function ($, allsettings, resource, format, event, entry) {
+modulejs.define('view/extended', ['_', '$', 'core/settings', 'core/resource', 'core/format', 'core/event', 'core/entry'], function (_, $, allsettings, resource, format, event, entry) {
var defaults = {
modes: ['details', 'icons'],
diff --git a/src/_h5ai/js/inc/view/spacing.js b/src/_h5ai/js/inc/view/spacing.js
index 6055fa8c..a559979e 100644
--- a/src/_h5ai/js/inc/view/spacing.js
+++ b/src/_h5ai/js/inc/view/spacing.js
@@ -1,5 +1,5 @@
-modulejs.define('view/spacing', ['jQuery', 'core/settings', 'core/event'], function ($, allsettings, event) {
+modulejs.define('view/spacing', ['_', '$', 'core/settings', 'core/event'], function (_, $, allsettings, event) {
var defaults = {
maxWidth: 960,
diff --git a/src/_h5ai/js/inc/view/viewmode.js b/src/_h5ai/js/inc/view/viewmode.js
index a321acbb..10b17308 100644
--- a/src/_h5ai/js/inc/view/viewmode.js
+++ b/src/_h5ai/js/inc/view/viewmode.js
@@ -1,5 +1,5 @@
-modulejs.define('view/viewmode', ['jQuery', 'core/settings', 'core/resource', 'core/store'], function ($, allsettings, resource, store) {
+modulejs.define('view/viewmode', ['_', '$', 'core/settings', 'core/resource', 'core/store'], function (_, $, allsettings, resource, store) {
var defaults = {
modes: ['details', 'list', 'icons'],