mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-03-21 21:10:00 +01:00
Adds ajax abstraction. Refactors global dependencies.
This commit is contained in:
parent
018a574d5e
commit
64640ada83
@ -16,13 +16,6 @@
|
||||
|
||||
// Globals
|
||||
"predef": [
|
||||
"amplify",
|
||||
"Base64",
|
||||
"H5AI_CONFIG",
|
||||
"jQuery",
|
||||
"Modernizr",
|
||||
"modulejs",
|
||||
"moment",
|
||||
"_"
|
||||
"modulejs"
|
||||
]
|
||||
}
|
157
src/_h5ai/js/inc/core/ajax.js
Normal file
157
src/_h5ai/js/inc/core/ajax.js
Normal file
@ -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
|
||||
};
|
||||
});
|
@ -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(/[^\/]*$/, '');
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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');
|
||||
|
@ -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',
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
||||
$('<div id="content-header">' + data + '</div>').prependTo('#content');
|
||||
if (html) {
|
||||
$('<div id="content-header">' + html + '</div>').prependTo('#content');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (_.isString(settings.footer)) {
|
||||
$.ajax({
|
||||
url: settings.footer,
|
||||
dataType: 'html',
|
||||
success: function (data) {
|
||||
ajax.getHtml(settings.footer, function (html) {
|
||||
|
||||
$('<div id="content-footer">' + data + '</div>').appendTo('#content');
|
||||
if (html) {
|
||||
$('<div id="content-footer">' + html + '</div>').appendTo('#content');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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',
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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();
|
||||
|
@ -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');
|
||||
|
||||
|
@ -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'));
|
||||
});
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -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) {
|
||||
|
||||
|
@ -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',
|
||||
|
@ -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'],
|
||||
|
@ -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,
|
||||
|
@ -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'],
|
||||
|
Loading…
x
Reference in New Issue
Block a user