mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-25 12:34:47 -04:00
Refactores js.
This commit is contained in:
parent
4a530f5ec0
commit
240adb79eb
22 changed files with 702 additions and 571 deletions
|
@ -50,8 +50,8 @@
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="lint" depends="build-prepare">
|
<target name="lint" depends="build-prepare">
|
||||||
<wepp file="${build.dir}/_h5ai/js/inc/H5ai.js" tofile="${build.dir}/_h5ai/js/inc/H5ai.js" />
|
<wepp file="${build.dir}/_h5ai/js/inc/main.js" tofile="${build.dir}/_h5ai/js/inc/main.js" />
|
||||||
<jslint files="${build.dir}/_h5ai/js/inc/H5ai.js" />
|
<jslint files="${build.dir}/_h5ai/js/inc/main.js" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,112 +0,0 @@
|
||||||
|
|
||||||
(function ($, h5ai) {
|
|
||||||
|
|
||||||
var cache = {},
|
|
||||||
pathnameStatusCache = {},
|
|
||||||
contentTypeRegEx = /^text\/html;h5ai=/,
|
|
||||||
getPath = function (folder, tableRow) {
|
|
||||||
|
|
||||||
var absHref = h5ai.util.getAbsHref(folder, tableRow),
|
|
||||||
path = cache[absHref];
|
|
||||||
|
|
||||||
if (!path) {
|
|
||||||
path = h5ai.Path(folder, tableRow);
|
|
||||||
if (!path.isParentFolder) {
|
|
||||||
cache[path.absHref] = path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return path;
|
|
||||||
},
|
|
||||||
fetchStatus = function (pathname, callback) {
|
|
||||||
|
|
||||||
if (h5ai.settings.folderStatus[pathname]) {
|
|
||||||
callback(h5ai.settings.folderStatus[pathname]);
|
|
||||||
return;
|
|
||||||
} else if (pathnameStatusCache[pathname]) {
|
|
||||||
callback(pathnameStatusCache[pathname]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: pathname,
|
|
||||||
type: 'HEAD',
|
|
||||||
complete: function (xhr) {
|
|
||||||
|
|
||||||
var status = xhr.status;
|
|
||||||
|
|
||||||
if (status === 200 && contentTypeRegEx.test(xhr.getResponseHeader('Content-Type'))) {
|
|
||||||
status = 'h5ai';
|
|
||||||
}
|
|
||||||
pathnameStatusCache[pathname] = status;
|
|
||||||
callback(status);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
updatePath = function (path) {
|
|
||||||
|
|
||||||
if (path.isFolder && !path.isParentFolder && path.status === undefined) {
|
|
||||||
fetchStatus(path.absHref, function (status) {
|
|
||||||
|
|
||||||
if (status !== 'h5ai') {
|
|
||||||
path.status = status;
|
|
||||||
}
|
|
||||||
h5ai.html.updateHtml(path);
|
|
||||||
h5ai.core.linkHoverStates();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
updatePaths = function () {
|
|
||||||
|
|
||||||
$.each(cache, function (ref, cached) {
|
|
||||||
updatePath(cached);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
fetchStatusAndContent = function (pathname, includeParent, callback) {
|
|
||||||
|
|
||||||
fetchStatus(pathname, function (status) {
|
|
||||||
|
|
||||||
if (status !== 'h5ai') {
|
|
||||||
callback(status, {});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: pathname,
|
|
||||||
type: 'GET',
|
|
||||||
dataType: 'html',
|
|
||||||
error: function (xhr) {
|
|
||||||
|
|
||||||
callback(xhr.status, {}); // since it was checked before this should never happen
|
|
||||||
},
|
|
||||||
success: function (html, status, xhr) {
|
|
||||||
|
|
||||||
var content = {};
|
|
||||||
|
|
||||||
if (!contentTypeRegEx.test(xhr.getResponseHeader('Content-Type'))) {
|
|
||||||
callback(xhr.status, {}); // since it was checked before this should never happen
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$(html).find('#table td').closest('tr').each(function () {
|
|
||||||
|
|
||||||
var path = getPath(pathname, this);
|
|
||||||
|
|
||||||
if (path.isFolder && (!path.isParentFolder || includeParent)) {
|
|
||||||
content[path.absHref] = path;
|
|
||||||
updatePath(path);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
callback('h5ai', content);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
h5ai.connector = {
|
|
||||||
getPath: getPath,
|
|
||||||
updatePaths: updatePaths,
|
|
||||||
fetchStatusAndContent: fetchStatusAndContent
|
|
||||||
};
|
|
||||||
|
|
||||||
}(jQuery, h5ai));
|
|
|
@ -1,104 +0,0 @@
|
||||||
|
|
||||||
(function ($, config) {
|
|
||||||
'use strict';
|
|
||||||
/*jslint browser: true, confusion: true, regexp: true, vars: true, white: true */
|
|
||||||
/*global Modernizr, jQuery, amplify, Base64, H5AI_CONFIG */
|
|
||||||
|
|
||||||
var defaults = {
|
|
||||||
store: {
|
|
||||||
viewmode: 'h5ai.pref.viewmode',
|
|
||||||
lang: 'h5ai.pref.lang'
|
|
||||||
},
|
|
||||||
callbacks: {
|
|
||||||
pathClick: []
|
|
||||||
},
|
|
||||||
|
|
||||||
rootAbsHref: '/',
|
|
||||||
h5aiAbsHref: '/_h5ai/',
|
|
||||||
customHeader: null,
|
|
||||||
customFooter: null,
|
|
||||||
viewmodes: ['details', 'icons'],
|
|
||||||
sortorder: 'na',
|
|
||||||
showTree: true,
|
|
||||||
slideTree: true,
|
|
||||||
folderStatus: {},
|
|
||||||
lang: 'en',
|
|
||||||
useBrowserLang: true,
|
|
||||||
setParentFolderLabels: true,
|
|
||||||
linkHoverStates: true,
|
|
||||||
dateFormat: 'yyyy-MM-dd HH:mm',
|
|
||||||
showThumbs: false,
|
|
||||||
thumbTypes: ['bmp', 'gif', 'ico', 'image', 'jpg', 'png', 'tiff'],
|
|
||||||
zippedDownload: false,
|
|
||||||
qrCodesSize: null,
|
|
||||||
showFilter: false
|
|
||||||
},
|
|
||||||
|
|
||||||
initMethods = [],
|
|
||||||
addInitMethod = function (fn) {
|
|
||||||
|
|
||||||
if ($.isFunction(fn)) {
|
|
||||||
initMethods.push(fn);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
init = function () {
|
|
||||||
|
|
||||||
var $html = $('html');
|
|
||||||
|
|
||||||
h5ai.isJs = $html.hasClass('h5ai-js');
|
|
||||||
h5ai.isPhp = $html.hasClass('h5ai-php');
|
|
||||||
|
|
||||||
if (!h5ai.isJs && !h5ai.isPhp) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (h5ai.isJs) {
|
|
||||||
h5ai.extended.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
$.each(initMethods, function (idx, initMethod) {
|
|
||||||
|
|
||||||
initMethod();
|
|
||||||
})
|
|
||||||
|
|
||||||
// h5ai.core.init();
|
|
||||||
h5ai.localize.init();
|
|
||||||
h5ai.sort.init();
|
|
||||||
h5ai.finder.init();
|
|
||||||
h5ai.zippedDownload.init();
|
|
||||||
h5ai.context.init();
|
|
||||||
|
|
||||||
if (h5ai.isPhp) {
|
|
||||||
$('#tree').scrollpanel();
|
|
||||||
h5ai.core.shiftTree(false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// publish for testing
|
|
||||||
window.h5ai = h5ai;
|
|
||||||
},
|
|
||||||
h5ai = function (fn) {
|
|
||||||
|
|
||||||
addInitMethod(fn);
|
|
||||||
};
|
|
||||||
|
|
||||||
h5ai.config = config;
|
|
||||||
h5ai.settings = $.extend({}, defaults, config.options);
|
|
||||||
|
|
||||||
// @include "Util.js"
|
|
||||||
// @include "Core.js"
|
|
||||||
// @include "Localize.js"
|
|
||||||
// @include "Sort.js"
|
|
||||||
// @include "ZippedDownload.js"
|
|
||||||
// @include "Finder.js"
|
|
||||||
// @include "Context.js"
|
|
||||||
|
|
||||||
// @include "Path.js"
|
|
||||||
// @include "Connector.js"
|
|
||||||
// @include "Html.js"
|
|
||||||
// @include "Extended.js"
|
|
||||||
|
|
||||||
// @include "splash.js"
|
|
||||||
|
|
||||||
$(init);
|
|
||||||
|
|
||||||
}(jQuery, H5AI_CONFIG));
|
|
|
@ -1,95 +0,0 @@
|
||||||
|
|
||||||
(function (document, $, h5ai) {
|
|
||||||
|
|
||||||
h5ai.Path = function (folder, tableRow) {
|
|
||||||
|
|
||||||
var path = {},
|
|
||||||
$tds, $a, date, size, splits;
|
|
||||||
|
|
||||||
// path.parentFolder: undefined
|
|
||||||
// path.label: undefined
|
|
||||||
// path.type: undefined
|
|
||||||
// path.href: undefined
|
|
||||||
// path.time: undefined
|
|
||||||
// path.size: undefined
|
|
||||||
// path.absHref: undefined
|
|
||||||
// path.isFolder: undefined
|
|
||||||
// path.isParentFolder: undefined
|
|
||||||
// path.isCurrentFolder: undefined
|
|
||||||
// path.isDomain: undefined
|
|
||||||
|
|
||||||
path.status = undefined; // undefined, 'h5ai' or HTTP response code
|
|
||||||
path.content = undefined; // associative array path.absHref -> path
|
|
||||||
path.html = {
|
|
||||||
$crumb: undefined,
|
|
||||||
$extended: undefined,
|
|
||||||
$tree: undefined
|
|
||||||
};
|
|
||||||
path.treeOpen = false;
|
|
||||||
|
|
||||||
if (!h5ai.util.pathEndsWithSlash(folder)) {
|
|
||||||
folder += '/';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tableRow) {
|
|
||||||
$tds = $(tableRow).find('td');
|
|
||||||
$a = $tds.eq(1).find('a');
|
|
||||||
date = Date.parse($tds.eq(2).text());
|
|
||||||
size = h5ai.util.parseSize($tds.eq(3).text());
|
|
||||||
|
|
||||||
path.parentFolder = folder;
|
|
||||||
path.label = $a.text();
|
|
||||||
path.type = h5ai.util.pathEndsWithSlash(path.label) ? 'folder' : h5ai.core.getFileType(path.label);
|
|
||||||
path.href = $a.attr('href');
|
|
||||||
path.time = date ? date.getTime() : 0;
|
|
||||||
path.size = size;
|
|
||||||
} else {
|
|
||||||
splits = h5ai.util.splitPath(folder);
|
|
||||||
|
|
||||||
path.parentFolder = splits.parent || '';
|
|
||||||
path.label = h5ai.util.checkedDecodeUri(splits.name);
|
|
||||||
if (path.label === '/') {
|
|
||||||
path.label = h5ai.util.checkedDecodeUri(document.domain);
|
|
||||||
}
|
|
||||||
path.type = 'folder';
|
|
||||||
path.href = splits.name;
|
|
||||||
path.time = 0;
|
|
||||||
path.size = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (h5ai.util.pathEndsWithSlash(path.label)) {
|
|
||||||
path.label = path.label.slice(0, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
path.isFolder = (path.type === 'folder');
|
|
||||||
path.isParentFolder = (path.label === 'Parent Directory');
|
|
||||||
if (path.isParentFolder) {
|
|
||||||
path.isFolder = true;
|
|
||||||
path.type = 'folder-parent';
|
|
||||||
}
|
|
||||||
path.absHref = path.isParentFolder ? path.href : path.parentFolder + path.href;
|
|
||||||
path.isCurrentFolder = (path.absHref === document.location.pathname);
|
|
||||||
path.isDomain = (path.absHref === '/');
|
|
||||||
|
|
||||||
if (path.isParentFolder && h5ai.settings.setParentFolderLabels) {
|
|
||||||
if (path.isDomain) {
|
|
||||||
path.label = h5ai.util.checkedDecodeUri(document.domain);
|
|
||||||
} else {
|
|
||||||
splits = h5ai.util.splitPath(path.parentFolder);
|
|
||||||
path.label = h5ai.util.checkedDecodeUri(splits.parentname);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
path.isEmpty = function () {
|
|
||||||
|
|
||||||
return !path.content || $.isEmptyObject(path.content);
|
|
||||||
};
|
|
||||||
path.onClick = function (context) {
|
|
||||||
|
|
||||||
h5ai.core.triggerPathClick(path, context);
|
|
||||||
};
|
|
||||||
|
|
||||||
return path;
|
|
||||||
};
|
|
||||||
|
|
||||||
}(document, jQuery, h5ai));
|
|
|
@ -1,155 +0,0 @@
|
||||||
|
|
||||||
(function ($, h5ai) {
|
|
||||||
|
|
||||||
var type = function (entry) {
|
|
||||||
|
|
||||||
var $entry = $(entry);
|
|
||||||
|
|
||||||
if ($entry.hasClass('folder-parent')) {
|
|
||||||
return 0;
|
|
||||||
} else if ($entry.hasClass('folder')) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 2;
|
|
||||||
},
|
|
||||||
cmp = function (entry1, entry2, rev, getVal) {
|
|
||||||
|
|
||||||
var res, val1, val2;
|
|
||||||
|
|
||||||
res = type(entry1) - type(entry2);
|
|
||||||
if (res !== 0) {
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
val1 = getVal(entry1);
|
|
||||||
val2 = getVal(entry2);
|
|
||||||
if (val1 < val2) {
|
|
||||||
return rev ? 1 : -1;
|
|
||||||
} else if (val1 > val2) {
|
|
||||||
return rev ? -1 : 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
},
|
|
||||||
cmpName = function (entry1, entry2) {
|
|
||||||
|
|
||||||
return cmp(entry1, entry2, false, function (entry) {
|
|
||||||
return $(entry).find('.label').text().toLowerCase();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
cmpTime = function (entry1, entry2) {
|
|
||||||
|
|
||||||
return cmp(entry1, entry2, false, function (entry) {
|
|
||||||
return $(entry).find('.date').data('time');
|
|
||||||
});
|
|
||||||
},
|
|
||||||
cmpSize = function (entry1, entry2) {
|
|
||||||
|
|
||||||
return cmp(entry1, entry2, false, function (entry) {
|
|
||||||
return $(entry).find('.size').data('bytes');
|
|
||||||
});
|
|
||||||
},
|
|
||||||
cmpNameRev = function (entry1, entry2) {
|
|
||||||
|
|
||||||
return cmp(entry1, entry2, true, function (entry) {
|
|
||||||
return $(entry).find('.label').text().toLowerCase();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
cmpTimeRev = function (entry1, entry2) {
|
|
||||||
|
|
||||||
return cmp(entry1, entry2, true, function (entry) {
|
|
||||||
return $(entry).find('.date').data('time');
|
|
||||||
});
|
|
||||||
},
|
|
||||||
cmpSizeRev = function (entry1, entry2) {
|
|
||||||
|
|
||||||
return cmp(entry1, entry2, true, function (entry) {
|
|
||||||
return $(entry).find('.size').data('bytes');
|
|
||||||
});
|
|
||||||
},
|
|
||||||
sort = function (fn) {
|
|
||||||
|
|
||||||
$('#extended .entry').detach().sort(fn).appendTo($('#extended > ul'));
|
|
||||||
},
|
|
||||||
$all, orders,
|
|
||||||
sortBy = function (id) {
|
|
||||||
|
|
||||||
var order = orders[id];
|
|
||||||
|
|
||||||
$all.removeClass('ascending').removeClass('descending');
|
|
||||||
order.head.addClass(order.clas);
|
|
||||||
sort(order.fn);
|
|
||||||
h5ai.core.hash({sort: id});
|
|
||||||
},
|
|
||||||
init = function () {
|
|
||||||
|
|
||||||
var $ascending = $('<img src="' + h5ai.core.image('ascending') + '" class="sort ascending" alt="ascending" />'),
|
|
||||||
$descending = $('<img src="' + h5ai.core.image('descending') + '" class="sort descending" alt="descending" />'),
|
|
||||||
initialOrder = h5ai.core.hash('sort'),
|
|
||||||
$header = $('#extended li.header'),
|
|
||||||
$label = $header.find('a.label'),
|
|
||||||
$date = $header.find('a.date'),
|
|
||||||
$size = $header.find('a.size');
|
|
||||||
|
|
||||||
$all = $header.find('a.label,a.date,a.size');
|
|
||||||
orders = {
|
|
||||||
na: {
|
|
||||||
head: $label,
|
|
||||||
clas: 'ascending',
|
|
||||||
fn: cmpName
|
|
||||||
},
|
|
||||||
nd: {
|
|
||||||
head: $label,
|
|
||||||
clas: 'descending',
|
|
||||||
fn: cmpNameRev
|
|
||||||
},
|
|
||||||
da: {
|
|
||||||
head: $date,
|
|
||||||
clas: 'ascending',
|
|
||||||
fn: cmpTime
|
|
||||||
},
|
|
||||||
dd: {
|
|
||||||
head: $date,
|
|
||||||
clas: 'descending',
|
|
||||||
fn: cmpTimeRev
|
|
||||||
},
|
|
||||||
sa: {
|
|
||||||
head: $size,
|
|
||||||
clas: 'ascending',
|
|
||||||
fn: cmpSize
|
|
||||||
},
|
|
||||||
sd: {
|
|
||||||
head: $size,
|
|
||||||
clas: 'descending',
|
|
||||||
fn: cmpSizeRev
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
sortBy(initialOrder ? initialOrder : h5ai.settings.sortorder);
|
|
||||||
|
|
||||||
$label
|
|
||||||
.append($ascending.clone()).append($descending.clone())
|
|
||||||
.click(function (event) {
|
|
||||||
sortBy('n' + ($label.hasClass('ascending') ? 'd' : 'a'));
|
|
||||||
event.preventDefault();
|
|
||||||
});
|
|
||||||
|
|
||||||
$date
|
|
||||||
.prepend($ascending.clone()).prepend($descending.clone())
|
|
||||||
.click(function (event) {
|
|
||||||
sortBy('d' + ($date.hasClass('ascending') ? 'd' : 'a'));
|
|
||||||
event.preventDefault();
|
|
||||||
});
|
|
||||||
|
|
||||||
$size
|
|
||||||
.prepend($ascending.clone()).prepend($descending.clone())
|
|
||||||
.click(function (event) {
|
|
||||||
sortBy('s' + ($size.hasClass('ascending') ? 'd' : 'a'));
|
|
||||||
event.preventDefault();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
h5ai.sort = {
|
|
||||||
init: init
|
|
||||||
};
|
|
||||||
|
|
||||||
}(jQuery, h5ai));
|
|
|
@ -1,5 +1,112 @@
|
||||||
|
|
||||||
(function ($, h5ai) {
|
Module.define('conhtml', [jQuery, 'settings', 'path', 'util', 'core', 'localize'], function ($, settings, pathFactory, util, core, localize) {
|
||||||
|
|
||||||
|
var cache = {},
|
||||||
|
pathnameStatusCache = {},
|
||||||
|
contentTypeRegEx = /^text\/html;h5ai=/,
|
||||||
|
getPath = function (folder, tableRow) {
|
||||||
|
|
||||||
|
var absHref = util.getAbsHref(folder, tableRow),
|
||||||
|
path = cache[absHref];
|
||||||
|
|
||||||
|
if (!path) {
|
||||||
|
path = pathFactory.create(folder, tableRow);
|
||||||
|
if (!path.isParentFolder) {
|
||||||
|
cache[path.absHref] = path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
},
|
||||||
|
fetchStatus = function (pathname, callback) {
|
||||||
|
|
||||||
|
if (settings.folderStatus[pathname]) {
|
||||||
|
callback(settings.folderStatus[pathname]);
|
||||||
|
return;
|
||||||
|
} else if (pathnameStatusCache[pathname]) {
|
||||||
|
callback(pathnameStatusCache[pathname]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: pathname,
|
||||||
|
type: 'HEAD',
|
||||||
|
complete: function (xhr) {
|
||||||
|
|
||||||
|
var status = xhr.status;
|
||||||
|
|
||||||
|
if (status === 200 && contentTypeRegEx.test(xhr.getResponseHeader('Content-Type'))) {
|
||||||
|
status = 'h5ai';
|
||||||
|
}
|
||||||
|
pathnameStatusCache[pathname] = status;
|
||||||
|
callback(status);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
updatePath = function (path) {
|
||||||
|
|
||||||
|
if (path.isFolder && !path.isParentFolder && path.status === undefined) {
|
||||||
|
fetchStatus(path.absHref, function (status) {
|
||||||
|
|
||||||
|
if (status !== 'h5ai') {
|
||||||
|
path.status = status;
|
||||||
|
}
|
||||||
|
updateHtml(path);
|
||||||
|
core.linkHoverStates();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
updatePaths = function () {
|
||||||
|
|
||||||
|
$.each(cache, function (ref, cached) {
|
||||||
|
updatePath(cached);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
fetchStatusAndContent = function (pathname, includeParent, callback) {
|
||||||
|
|
||||||
|
fetchStatus(pathname, function (status) {
|
||||||
|
|
||||||
|
if (status !== 'h5ai') {
|
||||||
|
callback(status, {});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: pathname,
|
||||||
|
type: 'GET',
|
||||||
|
dataType: 'html',
|
||||||
|
error: function (xhr) {
|
||||||
|
|
||||||
|
callback(xhr.status, {}); // since it was checked before this should never happen
|
||||||
|
},
|
||||||
|
success: function (html, status, xhr) {
|
||||||
|
|
||||||
|
var content = {};
|
||||||
|
|
||||||
|
if (!contentTypeRegEx.test(xhr.getResponseHeader('Content-Type'))) {
|
||||||
|
callback(xhr.status, {}); // since it was checked before this should never happen
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$(html).find('#table td').closest('tr').each(function () {
|
||||||
|
|
||||||
|
var path = getPath(pathname, this);
|
||||||
|
|
||||||
|
if (path.isFolder && (!path.isParentFolder || includeParent)) {
|
||||||
|
content[path.absHref] = path;
|
||||||
|
updatePath(path);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
callback('h5ai', content);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var onClick = function (path, context) {
|
var onClick = function (path, context) {
|
||||||
|
|
||||||
|
@ -22,12 +129,12 @@
|
||||||
$a = $html.find("a")
|
$a = $html.find("a")
|
||||||
.attr("href", path.absHref)
|
.attr("href", path.absHref)
|
||||||
.click(function() { onClick(path, "crumb"); })
|
.click(function() { onClick(path, "crumb"); })
|
||||||
.find("img").attr("src", h5ai.core.image("crumb")).end()
|
.find("img").attr("src", core.image("crumb")).end()
|
||||||
.find("span").text(path.label).end();
|
.find("span").text(path.label).end();
|
||||||
|
|
||||||
if (path.isDomain) {
|
if (path.isDomain) {
|
||||||
$html.addClass("domain");
|
$html.addClass("domain");
|
||||||
$a.find("img").attr("src", h5ai.core.image("home"));
|
$a.find("img").attr("src", core.image("home"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path.isCurrentFolder) {
|
if (path.isCurrentFolder) {
|
||||||
|
@ -36,7 +143,7 @@
|
||||||
|
|
||||||
if (!isNaN(path.status)) {
|
if (!isNaN(path.status)) {
|
||||||
if (path.status === 200) {
|
if (path.status === 200) {
|
||||||
$a.append($("<img class='hint' src='" + h5ai.core.image("page") + "' alt='not listable' />"));
|
$a.append($("<img class='hint' src='" + core.image("page") + "' alt='not listable' />"));
|
||||||
} else {
|
} else {
|
||||||
$a.append($("<span class='hint'>(" + path.status + ")</span>"));
|
$a.append($("<span class='hint'>(" + path.status + ")</span>"));
|
||||||
}
|
}
|
||||||
|
@ -52,10 +159,10 @@
|
||||||
updateExtendedHtml = function (path) {
|
updateExtendedHtml = function (path) {
|
||||||
|
|
||||||
var $html, $a, $label,
|
var $html, $a, $label,
|
||||||
formattedDate = path.date ? path.date.toString(h5ai.settings.dateFormat) : "",
|
formattedDate = path.date ? path.date.toString(settings.dateFormat) : "",
|
||||||
imgClass = "",
|
imgClass = "",
|
||||||
icon16 = h5ai.core.icon(path.type),
|
icon16 = core.icon(path.type),
|
||||||
icon48 = h5ai.core.icon(path.type, true);
|
icon48 = core.icon(path.type, true);
|
||||||
|
|
||||||
if (path.html.$extended && path.html.$extended.data("status") === path.status) {
|
if (path.html.$extended && path.html.$extended.data("status") === path.status) {
|
||||||
return path.html.$extended;
|
return path.html.$extended;
|
||||||
|
@ -69,11 +176,11 @@
|
||||||
$html.data("status", path.status);
|
$html.data("status", path.status);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (h5ai.settings.showThumbs === true && $.inArray(path.type, h5ai.settings.thumbTypes) >= 0) {
|
if (settings.showThumbs === true && $.inArray(path.type, settings.thumbTypes) >= 0) {
|
||||||
imgClass = "class='thumb'";
|
imgClass = "class='thumb'";
|
||||||
var escapedHref = path.absHref.replace(/'/g, "%27").replace(/"/g, "%22");
|
var escapedHref = path.absHref.replace(/'/g, "%27").replace(/"/g, "%22");
|
||||||
icon16 = h5ai.core.api() + "?action=thumb&href=" + escapedHref + "&width=16&height=16&mode=square";
|
icon16 = core.api() + "?action=thumb&href=" + escapedHref + "&width=16&height=16&mode=square";
|
||||||
icon48 = h5ai.core.api() + "?action=thumb&href=" + escapedHref + "&width=96&height=46&mode=rational";
|
icon48 = core.api() + "?action=thumb&href=" + escapedHref + "&width=96&height=46&mode=rational";
|
||||||
}
|
}
|
||||||
|
|
||||||
$label = $("<span class='label'>" + path.label + "</span>");
|
$label = $("<span class='label'>" + path.label + "</span>");
|
||||||
|
@ -113,7 +220,7 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
if (path.isParentFolder) {
|
if (path.isParentFolder) {
|
||||||
if (!h5ai.settings.setParentFolderLabels) {
|
if (!settings.setParentFolderLabels) {
|
||||||
$label.addClass("l10n-parentDirectory");
|
$label.addClass("l10n-parentDirectory");
|
||||||
}
|
}
|
||||||
$html.addClass("folder-parent");
|
$html.addClass("folder-parent");
|
||||||
|
@ -122,8 +229,8 @@
|
||||||
if (!isNaN(path.status)) {
|
if (!isNaN(path.status)) {
|
||||||
if (path.status === 200) {
|
if (path.status === 200) {
|
||||||
$html.addClass("page");
|
$html.addClass("page");
|
||||||
$a.find(".icon.small img").attr("src", h5ai.core.icon("folder-page"));
|
$a.find(".icon.small img").attr("src", core.icon("folder-page"));
|
||||||
$a.find(".icon.big img").attr("src", h5ai.core.icon("folder-page", true));
|
$a.find(".icon.big img").attr("src", core.icon("folder-page", true));
|
||||||
} else {
|
} else {
|
||||||
$html.addClass("error");
|
$html.addClass("error");
|
||||||
$label.append($("<span class='hint'> " + path.status + " </span>"));
|
$label.append($("<span class='hint'> " + path.status + " </span>"));
|
||||||
|
@ -132,7 +239,7 @@
|
||||||
|
|
||||||
if (path.html.$extended) {
|
if (path.html.$extended) {
|
||||||
path.html.$extended.replaceWith($html);
|
path.html.$extended.replaceWith($html);
|
||||||
h5ai.localize.formatDates();
|
localize.formatDates();
|
||||||
}
|
}
|
||||||
path.html.$extended = $html;
|
path.html.$extended = $html;
|
||||||
|
|
||||||
|
@ -152,19 +259,19 @@
|
||||||
.attr("href", path.absHref)
|
.attr("href", path.absHref)
|
||||||
.click(function() { onClick(path, "tree"); })
|
.click(function() { onClick(path, "tree"); })
|
||||||
.appendTo($html)
|
.appendTo($html)
|
||||||
.append($("<span class='icon'><img src='" + h5ai.core.icon(path.type) + "' /></span>"))
|
.append($("<span class='icon'><img src='" + core.icon(path.type) + "' /></span>"))
|
||||||
.append($("<span class='label'>" + path.label + "</span>"));
|
.append($("<span class='label'>" + path.label + "</span>"));
|
||||||
|
|
||||||
if (path.isFolder) {
|
if (path.isFolder) {
|
||||||
// indicator
|
// indicator
|
||||||
if (path.status === undefined || !path.isEmpty()) {
|
if (path.status === undefined || !path.isEmpty()) {
|
||||||
$indicator = $("<span class='indicator initiated'><img src='" + h5ai.core.image("tree") + "' /></span>")
|
$indicator = $("<span class='indicator initiated'><img src='" + core.image("tree") + "' /></span>")
|
||||||
.click(function (event) {
|
.click(function (event) {
|
||||||
|
|
||||||
var $entry = $indicator.closest(".entry"); // $html
|
var $entry = $indicator.closest(".entry"); // $html
|
||||||
|
|
||||||
if ($indicator.hasClass("unknown")) {
|
if ($indicator.hasClass("unknown")) {
|
||||||
h5ai.connector.fetchStatusAndContent(path.absHref, false, function (status, content) {
|
fetchStatusAndContent(path.absHref, false, function (status, content) {
|
||||||
|
|
||||||
path.status = status;
|
path.status = status;
|
||||||
path.content = content;
|
path.content = content;
|
||||||
|
@ -205,13 +312,13 @@
|
||||||
// is path the domain?
|
// is path the domain?
|
||||||
if (path.isDomain) {
|
if (path.isDomain) {
|
||||||
$html.addClass("domain");
|
$html.addClass("domain");
|
||||||
$a.find(".icon img").attr("src", h5ai.core.icon("folder-home"));
|
$a.find(".icon img").attr("src", core.icon("folder-home"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// is path the current folder?
|
// is path the current folder?
|
||||||
if (path.isCurrentFolder) {
|
if (path.isCurrentFolder) {
|
||||||
$html.addClass("current");
|
$html.addClass("current");
|
||||||
$a.find(".icon img").attr("src", h5ai.core.icon("folder-open"));
|
$a.find(".icon img").attr("src", core.icon("folder-open"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// does it have subfolders?
|
// does it have subfolders?
|
||||||
|
@ -228,8 +335,8 @@
|
||||||
// reflect folder status
|
// reflect folder status
|
||||||
if (!isNaN(path.status)) {
|
if (!isNaN(path.status)) {
|
||||||
if (path.status === 200) {
|
if (path.status === 200) {
|
||||||
$a.find(".icon img").attr("src", h5ai.core.icon("folder-page"));
|
$a.find(".icon img").attr("src", core.icon("folder-page"));
|
||||||
$a.append($("<span class='hint'><img src='" + h5ai.core.image("page") + "' /></span>"));
|
$a.append($("<span class='hint'><img src='" + core.image("page") + "' /></span>"));
|
||||||
} else {
|
} else {
|
||||||
$html.addClass("error");
|
$html.addClass("error");
|
||||||
$a.append($("<span class='hint'>" + path.status + "</span>"));
|
$a.append($("<span class='hint'>" + path.status + "</span>"));
|
||||||
|
@ -251,11 +358,17 @@
|
||||||
updateTreeHtml(path);
|
updateTreeHtml(path);
|
||||||
};
|
};
|
||||||
|
|
||||||
h5ai.html = {
|
|
||||||
|
|
||||||
|
|
||||||
|
return {
|
||||||
|
getPath: getPath,
|
||||||
|
updatePaths: updatePaths,
|
||||||
|
fetchStatusAndContent: fetchStatusAndContent,
|
||||||
|
|
||||||
updateCrumbHtml: updateCrumbHtml,
|
updateCrumbHtml: updateCrumbHtml,
|
||||||
updateExtendedHtml: updateExtendedHtml,
|
updateExtendedHtml: updateExtendedHtml,
|
||||||
updateTreeHtml: updateTreeHtml,
|
updateTreeHtml: updateTreeHtml,
|
||||||
updateHtml: updateHtml
|
updateHtml: updateHtml
|
||||||
};
|
};
|
||||||
|
});
|
||||||
}(jQuery, h5ai));
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
(function ($, h5ai) {
|
Module.define('context', [jQuery, 'settings'], function ($, settings) {
|
||||||
|
|
||||||
var $context,
|
var $context,
|
||||||
qrCodesSize,
|
qrCodesSize,
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
},
|
},
|
||||||
init = function () {
|
init = function () {
|
||||||
|
|
||||||
qrCodesSize = h5ai.settings.qrCodesSize;
|
qrCodesSize = settings.qrCodesSize;
|
||||||
if (!qrCodesSize) {
|
if (!qrCodesSize) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -44,8 +44,7 @@
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
h5ai.context = {
|
return {
|
||||||
init: init
|
init: init
|
||||||
};
|
};
|
||||||
|
});
|
||||||
}(jQuery, h5ai));
|
|
|
@ -1,8 +1,7 @@
|
||||||
|
|
||||||
(function (window, $, h5ai) {
|
Module.define('core', [jQuery, 'settings', 'types', 'util'], function ($, settings, types, util) {
|
||||||
|
|
||||||
var $window = $(window),
|
var $window = $(window),
|
||||||
settings = h5ai.settings,
|
|
||||||
extToFileType = (function (types) {
|
extToFileType = (function (types) {
|
||||||
var map = {};
|
var map = {};
|
||||||
$.each(types, function (type, exts) {
|
$.each(types, function (type, exts) {
|
||||||
|
@ -11,7 +10,7 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return map;
|
return map;
|
||||||
}(h5ai.config.types)),
|
}(types)),
|
||||||
hash = function (obj) {
|
hash = function (obj) {
|
||||||
|
|
||||||
if ($.isPlainObject(obj)) {
|
if ($.isPlainObject(obj)) {
|
||||||
|
@ -65,7 +64,7 @@
|
||||||
viewmode = amplify.store(settings.store.viewmode);
|
viewmode = amplify.store(settings.store.viewmode);
|
||||||
}
|
}
|
||||||
viewmode = $.inArray(viewmode, settings.viewmodes) >= 0 ? viewmode : settings.viewmodes[0];
|
viewmode = $.inArray(viewmode, settings.viewmodes) >= 0 ? viewmode : settings.viewmodes[0];
|
||||||
h5ai.core.hash({view: viewmode});
|
hash({view: viewmode});
|
||||||
|
|
||||||
$viewDetails.add($viewIcons).removeClass("current");
|
$viewDetails.add($viewIcons).removeClass("current");
|
||||||
if (viewmode === "details") {
|
if (viewmode === "details") {
|
||||||
|
@ -274,7 +273,7 @@
|
||||||
|
|
||||||
var $this = $(this),
|
var $this = $(this),
|
||||||
bytes = $this.data("bytes"),
|
bytes = $this.data("bytes"),
|
||||||
formattedSize = bytes >= 0 ? h5ai.util.formatSize(bytes) : "";
|
formattedSize = bytes >= 0 ? util.formatSize(bytes) : "";
|
||||||
|
|
||||||
$this.text(formattedSize);
|
$this.text(formattedSize);
|
||||||
});
|
});
|
||||||
|
@ -298,7 +297,8 @@
|
||||||
initIndicators();
|
initIndicators();
|
||||||
};
|
};
|
||||||
|
|
||||||
h5ai.core = {
|
return {
|
||||||
|
init: init,
|
||||||
hash: hash,
|
hash: hash,
|
||||||
api: api,
|
api: api,
|
||||||
image: image,
|
image: image,
|
||||||
|
@ -308,7 +308,4 @@
|
||||||
initIndicators: initIndicators,
|
initIndicators: initIndicators,
|
||||||
getFileType: getFileType
|
getFileType: getFileType
|
||||||
};
|
};
|
||||||
|
});
|
||||||
h5ai(init);
|
|
||||||
|
|
||||||
}(window, jQuery, h5ai));
|
|
|
@ -1,27 +1,27 @@
|
||||||
|
|
||||||
(function (document, $, h5ai) {
|
Module.define('extended', [jQuery, 'settings', 'conhtml', 'util', 'core'], function ($, settings, conhtml, util, core) {
|
||||||
|
|
||||||
var initBreadcrumb = function () {
|
var initBreadcrumb = function () {
|
||||||
|
|
||||||
var $ul = $("body > nav ul"),
|
var $ul = $("body > nav ul"),
|
||||||
pathname = "/",
|
pathname = "/",
|
||||||
path = h5ai.connector.getPath(pathname),
|
path = conhtml.getPath(pathname),
|
||||||
pathnameParts = document.location.pathname.split("/"),
|
pathnameParts = document.location.pathname.split("/"),
|
||||||
lastPart = "",
|
lastPart = "",
|
||||||
title = document.domain;
|
title = document.domain;
|
||||||
|
|
||||||
$ul.append(h5ai.html.updateCrumbHtml(path));
|
$ul.append(conhtml.updateCrumbHtml(path));
|
||||||
|
|
||||||
$.each(pathnameParts, function (idx, part) {
|
$.each(pathnameParts, function (idx, part) {
|
||||||
if (part !== "") {
|
if (part !== "") {
|
||||||
pathname += part + "/";
|
pathname += part + "/";
|
||||||
$ul.append(h5ai.html.updateCrumbHtml(h5ai.connector.getPath(pathname)));
|
$ul.append(conhtml.updateCrumbHtml(conhtml.getPath(pathname)));
|
||||||
lastPart = part + " - ";
|
lastPart = part + " - ";
|
||||||
title += " > " + part;
|
title += " > " + part;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
document.title = h5ai.util.checkedDecodeUri(lastPart + title);
|
document.title = util.checkedDecodeUri(lastPart + title);
|
||||||
},
|
},
|
||||||
initExtendedView = function () {
|
initExtendedView = function () {
|
||||||
|
|
||||||
|
@ -37,8 +37,8 @@
|
||||||
|
|
||||||
// entries
|
// entries
|
||||||
$("#table td").closest("tr").each(function () {
|
$("#table td").closest("tr").each(function () {
|
||||||
var path = h5ai.connector.getPath(document.location.pathname, this);
|
var path = conhtml.getPath(document.location.pathname, this);
|
||||||
$ul.append(h5ai.html.updateExtendedHtml(path));
|
$ul.append(conhtml.updateExtendedHtml(path));
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#extended").append($ul);
|
$("#extended").append($ul);
|
||||||
|
@ -53,9 +53,9 @@
|
||||||
},
|
},
|
||||||
customize = function () {
|
customize = function () {
|
||||||
|
|
||||||
if (h5ai.settings.customHeader) {
|
if (settings.customHeader) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: h5ai.settings.customHeader,
|
url: settings.customHeader,
|
||||||
dataType: "html",
|
dataType: "html",
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
$("#content > header").append($(data)).show();
|
$("#content > header").append($(data)).show();
|
||||||
|
@ -63,9 +63,9 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (h5ai.settings.customFooter) {
|
if (settings.customFooter) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: h5ai.settings.customFooter,
|
url: settings.customFooter,
|
||||||
dataType: "html",
|
dataType: "html",
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
$("#content > footer").prepend($(data)).show();
|
$("#content > footer").prepend($(data)).show();
|
||||||
|
@ -75,9 +75,9 @@
|
||||||
},
|
},
|
||||||
fetchPath = function (pathname, callback) {
|
fetchPath = function (pathname, callback) {
|
||||||
|
|
||||||
h5ai.connector.fetchStatusAndContent(pathname, false, function (status, content) {
|
conhtml.fetchStatusAndContent(pathname, false, function (status, content) {
|
||||||
|
|
||||||
var path = h5ai.connector.getPath(pathname);
|
var path = conhtml.getPath(pathname);
|
||||||
|
|
||||||
path.status = status;
|
path.status = status;
|
||||||
path.content = content;
|
path.content = content;
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
|
|
||||||
fetchPath(pathname, function (path) {
|
fetchPath(pathname, function (path) {
|
||||||
|
|
||||||
var parent = h5ai.util.splitPath(pathname).parent;
|
var parent = util.splitPath(pathname).parent;
|
||||||
|
|
||||||
path.treeOpen = true;
|
path.treeOpen = true;
|
||||||
if (childPath) {
|
if (childPath) {
|
||||||
|
@ -105,11 +105,11 @@
|
||||||
|
|
||||||
fetchTree(document.location.pathname, function (path) {
|
fetchTree(document.location.pathname, function (path) {
|
||||||
$("#tree")
|
$("#tree")
|
||||||
.append(h5ai.html.updateTreeHtml(path))
|
.append(conhtml.updateTreeHtml(path))
|
||||||
.scrollpanel()
|
.scrollpanel()
|
||||||
.show();
|
.show();
|
||||||
h5ai.core.shiftTree(false, true);
|
core.shiftTree(false, true);
|
||||||
h5ai.core.linkHoverStates();
|
core.linkHoverStates();
|
||||||
setTimeout(function () { $("#tree").get(0).updateScrollbar(); }, 1);
|
setTimeout(function () { $("#tree").get(0).updateScrollbar(); }, 1);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -118,14 +118,13 @@
|
||||||
initBreadcrumb();
|
initBreadcrumb();
|
||||||
initExtendedView();
|
initExtendedView();
|
||||||
customize();
|
customize();
|
||||||
h5ai.connector.updatePaths();
|
conhtml.updatePaths();
|
||||||
if (h5ai.settings.showTree) {
|
if (settings.showTree) {
|
||||||
populateTree();
|
populateTree();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
h5ai.extended = {
|
return {
|
||||||
init: init
|
init: init
|
||||||
};
|
};
|
||||||
|
});
|
||||||
}(document, jQuery, h5ai));
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
(function ($, h5ai) {
|
Module.define('finder', [jQuery, 'settings', 'util', 'core'], function ($, settings, util, core) {
|
||||||
|
|
||||||
var filter = function (re) {
|
var filter = function (re) {
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
} else {
|
} else {
|
||||||
$filter.removeClass('current');
|
$filter.removeClass('current');
|
||||||
}
|
}
|
||||||
h5ai.core.hash({filter: val});
|
core.hash({filter: val});
|
||||||
},
|
},
|
||||||
parseFilterSequence = function (sequence) {
|
parseFilterSequence = function (sequence) {
|
||||||
|
|
||||||
|
@ -53,20 +53,20 @@
|
||||||
|
|
||||||
sequence = $.map($.trim(sequence).split(/\s+/), function (part) {
|
sequence = $.map($.trim(sequence).split(/\s+/), function (part) {
|
||||||
|
|
||||||
return h5ai.util.reEscape(part);
|
return util.reEscape(part);
|
||||||
}).join('|');
|
}).join('|');
|
||||||
return new RegExp(sequence);
|
return new RegExp(sequence);
|
||||||
},
|
},
|
||||||
init = function () {
|
init = function () {
|
||||||
|
|
||||||
if (h5ai.settings.showFilter) {
|
if (settings.showFilter) {
|
||||||
$('<li id="filter"><span class="element"><img alt="filter" /><input type="text" value="" placeholder="filter" /></span></li>')
|
$('<li id="filter"><span class="element"><img alt="filter" /><input type="text" value="" placeholder="filter" /></span></li>')
|
||||||
.on('click', function () {
|
.on('click', function () {
|
||||||
|
|
||||||
var $input = $(this).find('input');
|
var $input = $(this).find('input');
|
||||||
$input.focus();
|
$input.focus();
|
||||||
})
|
})
|
||||||
.find('img').attr('src', h5ai.core.image('filter')).end()
|
.find('img').attr('src', core.image('filter')).end()
|
||||||
.find('input')
|
.find('input')
|
||||||
.on('focus', function () {
|
.on('focus', function () {
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@
|
||||||
.end()
|
.end()
|
||||||
.appendTo($('#navbar'));
|
.appendTo($('#navbar'));
|
||||||
|
|
||||||
var initialFilter = h5ai.core.hash('filter');
|
var initialFilter = core.hash('filter');
|
||||||
if (initialFilter) {
|
if (initialFilter) {
|
||||||
$('#filter input').val(initialFilter);
|
$('#filter input').val(initialFilter);
|
||||||
checkState(false);
|
checkState(false);
|
||||||
|
@ -99,9 +99,8 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
h5ai.finder = {
|
return {
|
||||||
init: init,
|
init: init,
|
||||||
filter: filter
|
filter: filter
|
||||||
};
|
};
|
||||||
|
});
|
||||||
}(jQuery, h5ai));
|
|
38
src/_h5ai/js/inc/h5ai.js
Normal file
38
src/_h5ai/js/inc/h5ai.js
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
|
||||||
|
Module.define('h5ai', [jQuery, 'core', 'extended', 'localize', 'sort', 'finder', 'zip', 'context', 'splash'], function ($, core, extended, localize, sort, finder, zip, context, splash) {
|
||||||
|
|
||||||
|
var h5ai = {};
|
||||||
|
|
||||||
|
h5ai.init = function () {
|
||||||
|
|
||||||
|
var $html = $('html');
|
||||||
|
|
||||||
|
h5ai.isJs = $html.hasClass('h5ai-js');
|
||||||
|
h5ai.isPhp = $html.hasClass('h5ai-php');
|
||||||
|
h5ai.isSplash = $html.hasClass('h5ai-splash');
|
||||||
|
|
||||||
|
if (h5ai.isJs || h5ai.isPhp) {
|
||||||
|
if (h5ai.isJs) {
|
||||||
|
extended.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
core.init();
|
||||||
|
localize.init();
|
||||||
|
sort.init();
|
||||||
|
finder.init();
|
||||||
|
zip.init();
|
||||||
|
context.init();
|
||||||
|
|
||||||
|
if (h5ai.isPhp) {
|
||||||
|
$('#tree').scrollpanel();
|
||||||
|
core.shiftTree(false, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (h5ai.isSplash) {
|
||||||
|
splash.init();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return h5ai;
|
||||||
|
});
|
0
src/_h5ai/js/inc/html.js
Normal file
0
src/_h5ai/js/inc/html.js
Normal file
|
@ -1,8 +1,7 @@
|
||||||
|
|
||||||
(function ($, h5ai) {
|
Module.define('localize', [jQuery, 'settings', 'langs', 'core'], function ($, settings, langs, core) {
|
||||||
|
|
||||||
var settings = h5ai.settings,
|
var currentDateFormat = settings.dateFormat,
|
||||||
currentDateFormat = settings.dateFormat,
|
|
||||||
formatDates = function (dateFormat) {
|
formatDates = function (dateFormat) {
|
||||||
|
|
||||||
if (dateFormat) {
|
if (dateFormat) {
|
||||||
|
@ -48,7 +47,7 @@
|
||||||
$('.lang').text(lang);
|
$('.lang').text(lang);
|
||||||
$('.langOption').removeClass('current');
|
$('.langOption').removeClass('current');
|
||||||
$('.langOption.' + lang).addClass('current');
|
$('.langOption.' + lang).addClass('current');
|
||||||
h5ai.core.hash({lang: lang});
|
core.hash({lang: lang});
|
||||||
}
|
}
|
||||||
|
|
||||||
formatDates(selected.dateFormat || settings.dateFormat);
|
formatDates(selected.dateFormat || settings.dateFormat);
|
||||||
|
@ -96,13 +95,13 @@
|
||||||
},
|
},
|
||||||
init = function () {
|
init = function () {
|
||||||
|
|
||||||
initLangSelector(h5ai.config.langs);
|
initLangSelector(langs);
|
||||||
localize(h5ai.config.langs, settings.lang, settings.useBrowserLang);
|
localize(langs, settings.lang, settings.useBrowserLang);
|
||||||
};
|
};
|
||||||
|
|
||||||
h5ai.localize = {
|
return {
|
||||||
init: init,
|
init: init,
|
||||||
formatDates: formatDates
|
formatDates: formatDates
|
||||||
};
|
};
|
||||||
|
|
||||||
}(jQuery, h5ai));
|
});
|
36
src/_h5ai/js/inc/main.js
Normal file
36
src/_h5ai/js/inc/main.js
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
/*jslint browser: true, confusion: true, regexp: true, vars: true, white: true */
|
||||||
|
/*global Modernizr, jQuery, amplify, Base64, H5AI_CONFIG */
|
||||||
|
|
||||||
|
// @include "module.js"
|
||||||
|
|
||||||
|
// @include "settings.js"
|
||||||
|
|
||||||
|
// @include "util.js"
|
||||||
|
// @include "core.js"
|
||||||
|
// @include "localize.js"
|
||||||
|
// @include "sort.js"
|
||||||
|
// @include "zip.js"
|
||||||
|
// @include "finder.js"
|
||||||
|
// @include "context.js"
|
||||||
|
|
||||||
|
// @include "path.js"
|
||||||
|
// @include "connector.js"
|
||||||
|
// @include "html.js"
|
||||||
|
// @include "extended.js"
|
||||||
|
|
||||||
|
// @include "splash.js"
|
||||||
|
|
||||||
|
// @include "h5ai.js"
|
||||||
|
|
||||||
|
|
||||||
|
jQuery(function () {
|
||||||
|
|
||||||
|
var h5ai = Module.require('h5ai');
|
||||||
|
|
||||||
|
h5ai.init();
|
||||||
|
});
|
||||||
|
|
||||||
|
}());
|
133
src/_h5ai/js/inc/module.js
Normal file
133
src/_h5ai/js/inc/module.js
Normal file
|
@ -0,0 +1,133 @@
|
||||||
|
|
||||||
|
var Module = window.Module = (function ($) {
|
||||||
|
|
||||||
|
var definitions = {},
|
||||||
|
modules = {},
|
||||||
|
|
||||||
|
err = function (message) {
|
||||||
|
|
||||||
|
$.error('module: ' + message);
|
||||||
|
},
|
||||||
|
|
||||||
|
uniq = function (array) {
|
||||||
|
|
||||||
|
var set = {},
|
||||||
|
uniq = [];
|
||||||
|
|
||||||
|
$.each(array, function (idx, element) {
|
||||||
|
|
||||||
|
if (!set[element]) {
|
||||||
|
set[element] = true;
|
||||||
|
uniq.push(element);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return uniq;
|
||||||
|
},
|
||||||
|
|
||||||
|
deps = function (ids) {
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
var deps = [];
|
||||||
|
|
||||||
|
if (typeof ids === 'string') {
|
||||||
|
|
||||||
|
var def = definitions[ids];
|
||||||
|
if (def) {
|
||||||
|
$.each(def.deps, function (idx, id) {
|
||||||
|
|
||||||
|
deps = deps.concat(deps(id));
|
||||||
|
});
|
||||||
|
deps.push(def.id);
|
||||||
|
} else {
|
||||||
|
deps.push(ids);
|
||||||
|
}
|
||||||
|
} else if ($.isArray(ids)) {
|
||||||
|
|
||||||
|
$.each(ids, function (idx, id) {
|
||||||
|
|
||||||
|
deps = deps.concat(deps(id));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return uniq(deps);
|
||||||
|
},
|
||||||
|
|
||||||
|
checkedDeps = function (ids) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
return deps(ids);
|
||||||
|
} catch (e) {
|
||||||
|
err('cyclic dependencies for ids "' + ids + '"');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
defs = function () {
|
||||||
|
|
||||||
|
return $.extend({}, definitions);
|
||||||
|
},
|
||||||
|
|
||||||
|
mods = function () {
|
||||||
|
|
||||||
|
return $.extend({}, modules);
|
||||||
|
},
|
||||||
|
|
||||||
|
define = function (id, deps, fn) {
|
||||||
|
|
||||||
|
if ($.isFunction(deps)) {
|
||||||
|
fn = deps;
|
||||||
|
deps = [];
|
||||||
|
}
|
||||||
|
if (typeof id !== 'string') {
|
||||||
|
err('id must be a string "' + id + '"');
|
||||||
|
}
|
||||||
|
if (!$.isArray(deps)) {
|
||||||
|
err('dependencies must be an array "' + deps + '"');
|
||||||
|
}
|
||||||
|
if (!$.isFunction(fn)) {
|
||||||
|
err('constructor must be a function "' + fn + '"');
|
||||||
|
}
|
||||||
|
if (definitions[id]) {
|
||||||
|
err('id already defined "' + id + '"');
|
||||||
|
}
|
||||||
|
|
||||||
|
definitions[id] = {
|
||||||
|
id: id,
|
||||||
|
deps: deps,
|
||||||
|
fn: fn
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
require = function (id) {
|
||||||
|
|
||||||
|
if (typeof id !== 'string') {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modules[id]) {
|
||||||
|
return modules[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
var def = definitions[id];
|
||||||
|
if (!def) {
|
||||||
|
err('id not defined "' + id + '"');
|
||||||
|
}
|
||||||
|
|
||||||
|
var deps = $.map(def.deps, function (depId) {
|
||||||
|
|
||||||
|
return require(depId);
|
||||||
|
});
|
||||||
|
|
||||||
|
var obj = def.fn.apply(this, deps);
|
||||||
|
modules[id] = obj;
|
||||||
|
return obj;
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
deps: checkedDeps,
|
||||||
|
defs: defs,
|
||||||
|
mods: mods,
|
||||||
|
define: define,
|
||||||
|
require: require
|
||||||
|
};
|
||||||
|
|
||||||
|
}(jQuery));
|
98
src/_h5ai/js/inc/path.js
Normal file
98
src/_h5ai/js/inc/path.js
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
|
||||||
|
Module.define('path', [jQuery, 'settings', 'util', 'core'], function ($, settings, util, core) {
|
||||||
|
|
||||||
|
var create = function (folder, tableRow) {
|
||||||
|
|
||||||
|
var path = {},
|
||||||
|
$tds, $a, date, size, splits;
|
||||||
|
|
||||||
|
// path.parentFolder: undefined
|
||||||
|
// path.label: undefined
|
||||||
|
// path.type: undefined
|
||||||
|
// path.href: undefined
|
||||||
|
// path.time: undefined
|
||||||
|
// path.size: undefined
|
||||||
|
// path.absHref: undefined
|
||||||
|
// path.isFolder: undefined
|
||||||
|
// path.isParentFolder: undefined
|
||||||
|
// path.isCurrentFolder: undefined
|
||||||
|
// path.isDomain: undefined
|
||||||
|
|
||||||
|
path.status = undefined; // undefined, 'h5ai' or HTTP response code
|
||||||
|
path.content = undefined; // associative array path.absHref -> path
|
||||||
|
path.html = {
|
||||||
|
$crumb: undefined,
|
||||||
|
$extended: undefined,
|
||||||
|
$tree: undefined
|
||||||
|
};
|
||||||
|
path.treeOpen = false;
|
||||||
|
|
||||||
|
if (!util.pathEndsWithSlash(folder)) {
|
||||||
|
folder += '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tableRow) {
|
||||||
|
$tds = $(tableRow).find('td');
|
||||||
|
$a = $tds.eq(1).find('a');
|
||||||
|
date = Date.parse($tds.eq(2).text());
|
||||||
|
size = util.parseSize($tds.eq(3).text());
|
||||||
|
|
||||||
|
path.parentFolder = folder;
|
||||||
|
path.label = $a.text();
|
||||||
|
path.type = util.pathEndsWithSlash(path.label) ? 'folder' : core.getFileType(path.label);
|
||||||
|
path.href = $a.attr('href');
|
||||||
|
path.time = date ? date.getTime() : 0;
|
||||||
|
path.size = size;
|
||||||
|
} else {
|
||||||
|
splits = util.splitPath(folder);
|
||||||
|
|
||||||
|
path.parentFolder = splits.parent || '';
|
||||||
|
path.label = util.checkedDecodeUri(splits.name);
|
||||||
|
if (path.label === '/') {
|
||||||
|
path.label = util.checkedDecodeUri(document.domain);
|
||||||
|
}
|
||||||
|
path.type = 'folder';
|
||||||
|
path.href = splits.name;
|
||||||
|
path.time = 0;
|
||||||
|
path.size = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (util.pathEndsWithSlash(path.label)) {
|
||||||
|
path.label = path.label.slice(0, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
path.isFolder = (path.type === 'folder');
|
||||||
|
path.isParentFolder = (path.label === 'Parent Directory');
|
||||||
|
if (path.isParentFolder) {
|
||||||
|
path.isFolder = true;
|
||||||
|
path.type = 'folder-parent';
|
||||||
|
}
|
||||||
|
path.absHref = path.isParentFolder ? path.href : path.parentFolder + path.href;
|
||||||
|
path.isCurrentFolder = (path.absHref === document.location.pathname);
|
||||||
|
path.isDomain = (path.absHref === '/');
|
||||||
|
|
||||||
|
if (path.isParentFolder && settings.setParentFolderLabels) {
|
||||||
|
if (path.isDomain) {
|
||||||
|
path.label = util.checkedDecodeUri(document.domain);
|
||||||
|
} else {
|
||||||
|
splits = util.splitPath(path.parentFolder);
|
||||||
|
path.label = util.checkedDecodeUri(splits.parentname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
path.isEmpty = function () {
|
||||||
|
|
||||||
|
return !path.content || $.isEmptyObject(path.content);
|
||||||
|
};
|
||||||
|
path.onClick = function (context) {
|
||||||
|
|
||||||
|
core.triggerPathClick(path, context);
|
||||||
|
};
|
||||||
|
|
||||||
|
return path;
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
create: create
|
||||||
|
};
|
||||||
|
});
|
57
src/_h5ai/js/inc/settings.js
Normal file
57
src/_h5ai/js/inc/settings.js
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
|
||||||
|
Module.define('config', [jQuery, H5AI_CONFIG], function ($, config) {
|
||||||
|
|
||||||
|
var defaults = {
|
||||||
|
store: {
|
||||||
|
viewmode: 'h5ai.pref.viewmode',
|
||||||
|
lang: 'h5ai.pref.lang'
|
||||||
|
},
|
||||||
|
callbacks: {
|
||||||
|
pathClick: []
|
||||||
|
},
|
||||||
|
|
||||||
|
rootAbsHref: '/',
|
||||||
|
h5aiAbsHref: '/_h5ai/',
|
||||||
|
customHeader: null,
|
||||||
|
customFooter: null,
|
||||||
|
viewmodes: ['details', 'icons'],
|
||||||
|
sortorder: 'na',
|
||||||
|
showTree: true,
|
||||||
|
slideTree: true,
|
||||||
|
folderStatus: {},
|
||||||
|
lang: 'en',
|
||||||
|
useBrowserLang: true,
|
||||||
|
setParentFolderLabels: true,
|
||||||
|
linkHoverStates: true,
|
||||||
|
dateFormat: 'yyyy-MM-dd HH:mm',
|
||||||
|
showThumbs: false,
|
||||||
|
thumbTypes: ['bmp', 'gif', 'ico', 'image', 'jpg', 'png', 'tiff'],
|
||||||
|
zippedDownload: false,
|
||||||
|
qrCodesSize: null,
|
||||||
|
showFilter: false
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
settings: $.extend({}, defaults, config.options),
|
||||||
|
types: $.extend({}, config.types),
|
||||||
|
langs: $.extend({}, config.langs)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Module.define('settings', ['config'], function (config) {
|
||||||
|
|
||||||
|
return config.settings;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Module.define('types', ['config'], function (config) {
|
||||||
|
|
||||||
|
return config.types;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Module.define('langs', ['config'], function (config) {
|
||||||
|
|
||||||
|
return config.langs;
|
||||||
|
});
|
134
src/_h5ai/js/inc/sort.js
Normal file
134
src/_h5ai/js/inc/sort.js
Normal file
|
@ -0,0 +1,134 @@
|
||||||
|
|
||||||
|
Module.define('sort', [jQuery, 'settings', 'core'], function ($, settings, core) {
|
||||||
|
|
||||||
|
var type = function (entry) {
|
||||||
|
|
||||||
|
var $entry = $(entry);
|
||||||
|
|
||||||
|
if ($entry.hasClass('folder-parent')) {
|
||||||
|
return 0;
|
||||||
|
} else if ($entry.hasClass('folder')) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 2;
|
||||||
|
},
|
||||||
|
|
||||||
|
cmpFn = function (rev, getVal) {
|
||||||
|
|
||||||
|
return function (entry1, entry2) {
|
||||||
|
|
||||||
|
var res, val1, val2;
|
||||||
|
|
||||||
|
res = type(entry1) - type(entry2);
|
||||||
|
if (res !== 0) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
val1 = getVal(entry1);
|
||||||
|
val2 = getVal(entry2);
|
||||||
|
if (val1 < val2) {
|
||||||
|
return rev ? 1 : -1;
|
||||||
|
} else if (val1 > val2) {
|
||||||
|
return rev ? -1 : 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
getName = function (entry) {
|
||||||
|
|
||||||
|
return $(entry).find('.label').text().toLowerCase();
|
||||||
|
},
|
||||||
|
getTime = function (entry) {
|
||||||
|
|
||||||
|
return $(entry).find('.date').data('time');
|
||||||
|
},
|
||||||
|
getSize = function (entry) {
|
||||||
|
|
||||||
|
return $(entry).find('.size').data('bytes');
|
||||||
|
},
|
||||||
|
|
||||||
|
$all, orders,
|
||||||
|
|
||||||
|
sortBy = function (id) {
|
||||||
|
|
||||||
|
var order = orders[id];
|
||||||
|
|
||||||
|
$all.removeClass('ascending').removeClass('descending');
|
||||||
|
order.head.addClass(order.clas);
|
||||||
|
$('#extended .entry').detach().sort(order.fn).appendTo($('#extended > ul'));
|
||||||
|
core.hash({sort: id});
|
||||||
|
},
|
||||||
|
|
||||||
|
init = function () {
|
||||||
|
|
||||||
|
var $ascending = $('<img src="' + core.image('ascending') + '" class="sort ascending" alt="ascending" />'),
|
||||||
|
$descending = $('<img src="' + core.image('descending') + '" class="sort descending" alt="descending" />'),
|
||||||
|
initialOrder = core.hash('sort'),
|
||||||
|
$header = $('#extended li.header'),
|
||||||
|
$label = $header.find('a.label'),
|
||||||
|
$date = $header.find('a.date'),
|
||||||
|
$size = $header.find('a.size');
|
||||||
|
|
||||||
|
$all = $header.find('a.label,a.date,a.size');
|
||||||
|
orders = {
|
||||||
|
na: {
|
||||||
|
head: $label,
|
||||||
|
clas: 'ascending',
|
||||||
|
fn: cmpFn(false, getName)
|
||||||
|
},
|
||||||
|
nd: {
|
||||||
|
head: $label,
|
||||||
|
clas: 'descending',
|
||||||
|
fn: cmpFn(true, getName)
|
||||||
|
},
|
||||||
|
da: {
|
||||||
|
head: $date,
|
||||||
|
clas: 'ascending',
|
||||||
|
fn: cmpFn(false, getTime)
|
||||||
|
},
|
||||||
|
dd: {
|
||||||
|
head: $date,
|
||||||
|
clas: 'descending',
|
||||||
|
fn: cmpFn(true, getTime)
|
||||||
|
},
|
||||||
|
sa: {
|
||||||
|
head: $size,
|
||||||
|
clas: 'ascending',
|
||||||
|
fn: cmpFn(false, getSize)
|
||||||
|
},
|
||||||
|
sd: {
|
||||||
|
head: $size,
|
||||||
|
clas: 'descending',
|
||||||
|
fn: cmpFn(true, getSize)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
sortBy(initialOrder || settings.sortorder);
|
||||||
|
|
||||||
|
$label
|
||||||
|
.append($ascending.clone()).append($descending.clone())
|
||||||
|
.click(function (event) {
|
||||||
|
sortBy('n' + ($label.hasClass('ascending') ? 'd' : 'a'));
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
|
$date
|
||||||
|
.prepend($ascending.clone()).prepend($descending.clone())
|
||||||
|
.click(function (event) {
|
||||||
|
sortBy('d' + ($date.hasClass('ascending') ? 'd' : 'a'));
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
|
$size
|
||||||
|
.prepend($ascending.clone()).prepend($descending.clone())
|
||||||
|
.click(function (event) {
|
||||||
|
sortBy('s' + ($size.hasClass('ascending') ? 'd' : 'a'));
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
init: init
|
||||||
|
};
|
||||||
|
});
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
(function ($, h5ai) {
|
Module.define('splash', [jQuery, 'core'], function ($, core) {
|
||||||
|
|
||||||
var setCheckResult = function (id, result) {
|
var setCheckResult = function (id, result) {
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
checks = function () {
|
checks = function () {
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: h5ai.core.api(),
|
url: core.api(),
|
||||||
data: {
|
data: {
|
||||||
action: 'checks'
|
action: 'checks'
|
||||||
},
|
},
|
||||||
|
@ -38,13 +38,10 @@
|
||||||
},
|
},
|
||||||
init = function () {
|
init = function () {
|
||||||
|
|
||||||
h5ai.isSplash = $('html').hasClass('h5ai-splash');
|
checks();
|
||||||
|
|
||||||
if (h5ai.isSplash) {
|
|
||||||
checks();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$(init);
|
return {
|
||||||
|
init: init
|
||||||
}(jQuery, h5ai));
|
};
|
||||||
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
(function ($, h5ai) {
|
Module.define('util', [jQuery], function ($) {
|
||||||
|
|
||||||
var reSplitPath = /^\/([^\/]+\/?)$/,
|
var reSplitPath = /^\/([^\/]+\/?)$/,
|
||||||
reSplitPath2 = /^(\/(?:.*\/)*?([^\/]+)\/)([^\/]+\/?)$/,
|
reSplitPath2 = /^(\/(?:.*\/)*?([^\/]+)\/)([^\/]+\/?)$/,
|
||||||
|
@ -105,7 +105,7 @@
|
||||||
return sequence.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
return sequence.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
||||||
};
|
};
|
||||||
|
|
||||||
h5ai.util = {
|
return {
|
||||||
splitPath: splitPath,
|
splitPath: splitPath,
|
||||||
pathEndsWithSlash: pathEndsWithSlash,
|
pathEndsWithSlash: pathEndsWithSlash,
|
||||||
getAbsHref: getAbsHref,
|
getAbsHref: getAbsHref,
|
||||||
|
@ -114,5 +114,4 @@
|
||||||
checkedDecodeUri: checkedDecodeUri,
|
checkedDecodeUri: checkedDecodeUri,
|
||||||
reEscape: reEscape
|
reEscape: reEscape
|
||||||
};
|
};
|
||||||
|
});
|
||||||
}(jQuery, h5ai));
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
(function ($, h5ai) {
|
Module.define('zip', [jQuery, 'settings', 'core'], function ($, settings, core) {
|
||||||
|
|
||||||
var x = 0,
|
var x = 0,
|
||||||
y = 0,
|
y = 0,
|
||||||
|
@ -102,11 +102,11 @@
|
||||||
|
|
||||||
|
|
||||||
$download.removeClass('current');
|
$download.removeClass('current');
|
||||||
$img.attr('src', h5ai.core.image("download"));
|
$img.attr('src', core.image("download"));
|
||||||
|
|
||||||
if (response) {
|
if (response) {
|
||||||
if (response.status === 'ok') {
|
if (response.status === 'ok') {
|
||||||
window.location = h5ai.core.api() + '?action=getzip&id=' + response.id;
|
window.location = core.api() + '?action=getzip&id=' + response.id;
|
||||||
} else {
|
} else {
|
||||||
if (response.code === 401) {
|
if (response.code === 401) {
|
||||||
$downloadAuth
|
$downloadAuth
|
||||||
|
@ -126,9 +126,9 @@
|
||||||
requestZipping = function (hrefsStr) {
|
requestZipping = function (hrefsStr) {
|
||||||
|
|
||||||
$download.addClass('current');
|
$download.addClass('current');
|
||||||
$img.attr('src', h5ai.core.image("loading.gif", true));
|
$img.attr('src', core.image("loading.gif", true));
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: h5ai.core.api(),
|
url: core.api(),
|
||||||
data: {
|
data: {
|
||||||
action: 'zip',
|
action: 'zip',
|
||||||
hrefs: selectedHrefsStr
|
hrefs: selectedHrefsStr
|
||||||
|
@ -156,9 +156,9 @@
|
||||||
},
|
},
|
||||||
init = function () {
|
init = function () {
|
||||||
|
|
||||||
if (h5ai.settings.zippedDownload) {
|
if (settings.zippedDownload) {
|
||||||
$('<li id="download"><a href="#"><img alt="download" /><span class="l10n-download">download</span></a></li>')
|
$('<li id="download"><a href="#"><img alt="download" /><span class="l10n-download">download</span></a></li>')
|
||||||
.find('img').attr('src', h5ai.core.image('download')).end()
|
.find('img').attr('src', core.image('download')).end()
|
||||||
.find('a').click(function (event) {
|
.find('a').click(function (event) {
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -181,8 +181,7 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
h5ai.zippedDownload = {
|
return {
|
||||||
init: init
|
init: init
|
||||||
};
|
};
|
||||||
|
});
|
||||||
}(jQuery, h5ai));
|
|
|
@ -16,4 +16,4 @@
|
||||||
|
|
||||||
// h5ai
|
// h5ai
|
||||||
// ----
|
// ----
|
||||||
// @include "inc/H5ai.js"
|
// @include "inc/main.js"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue