diff --git a/src/_h5ai/js/inc/Connector.js b/src/_h5ai/js/inc/Connector.js
index 1398c7fe..70d9a7fe 100644
--- a/src/_h5ai/js/inc/Connector.js
+++ b/src/_h5ai/js/inc/Connector.js
@@ -20,8 +20,8 @@
},
fetchStatus = function (pathname, callback) {
- if (h5ai.core.settings.folderStatus[pathname]) {
- callback(h5ai.core.settings.folderStatus[pathname]);
+ if (h5ai.settings.folderStatus[pathname]) {
+ callback(h5ai.settings.folderStatus[pathname]);
return;
} else if (pathnameStatusCache[pathname]) {
callback(pathnameStatusCache[pathname]);
@@ -30,13 +30,13 @@
$.ajax({
url: pathname,
- type: "HEAD",
+ type: 'HEAD',
complete: function (xhr) {
var status = xhr.status;
- if (status === 200 && contentTypeRegEx.test(xhr.getResponseHeader("Content-Type"))) {
- status = "h5ai";
+ if (status === 200 && contentTypeRegEx.test(xhr.getResponseHeader('Content-Type'))) {
+ status = 'h5ai';
}
pathnameStatusCache[pathname] = status;
callback(status);
@@ -48,7 +48,7 @@
if (path.isFolder && !path.isParentFolder && path.status === undefined) {
fetchStatus(path.absHref, function (status) {
- if (status !== "h5ai") {
+ if (status !== 'h5ai') {
path.status = status;
}
h5ai.html.updateHtml(path);
@@ -66,15 +66,15 @@
fetchStatus(pathname, function (status) {
- if (status !== "h5ai") {
+ if (status !== 'h5ai') {
callback(status, {});
return;
}
$.ajax({
url: pathname,
- type: "GET",
- dataType: "html",
+ type: 'GET',
+ dataType: 'html',
error: function (xhr) {
callback(xhr.status, {}); // since it was checked before this should never happen
@@ -83,12 +83,12 @@
var content = {};
- if (!contentTypeRegEx.test(xhr.getResponseHeader("Content-Type"))) {
+ 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 () {
+ $(html).find('#table td').closest('tr').each(function () {
var path = getPath(pathname, this);
@@ -97,7 +97,7 @@
updatePath(path);
}
});
- callback("h5ai", content);
+ callback('h5ai', content);
}
});
});
diff --git a/src/_h5ai/js/inc/Context.js b/src/_h5ai/js/inc/Context.js
index 60961e2b..f62bbeab 100644
--- a/src/_h5ai/js/inc/Context.js
+++ b/src/_h5ai/js/inc/Context.js
@@ -18,7 +18,7 @@
},
init = function () {
- qrCodesSize = h5ai.core.settings.qrCodesSize;
+ qrCodesSize = h5ai.settings.qrCodesSize;
if (!qrCodesSize) {
return;
}
diff --git a/src/_h5ai/js/inc/Core.js b/src/_h5ai/js/inc/Core.js
index 07f9909d..b325fb18 100644
--- a/src/_h5ai/js/inc/Core.js
+++ b/src/_h5ai/js/inc/Core.js
@@ -1,38 +1,8 @@
-(function (window, $, h5ai, config) {
+(function (window, $, h5ai) {
var $window = $(window),
- 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
- },
- settings = $.extend({}, defaults, config.options),
- currentDateFormat = settings.dateFormat,
+ settings = h5ai.settings,
extToFileType = (function (types) {
var map = {};
$.each(types, function (type, exts) {
@@ -41,7 +11,7 @@
});
});
return map;
- }(config.types)),
+ }(h5ai.config.types)),
hash = function (obj) {
if ($.isPlainObject(obj)) {
@@ -248,97 +218,6 @@
});
}
},
- formatDates = function (dateFormat) {
-
- if (dateFormat) {
- currentDateFormat = dateFormat;
- }
-
- $("#extended .entry .date").each(function () {
-
- var $this = $(this),
- time = $this.data("time"),
- formattedDate = time ? new Date(time).toString(currentDateFormat) : "";
-
- $this.text(formattedDate);
- });
- },
- localize = function (langs, lang, useBrowserLang) {
-
- var storedLang = amplify.store(settings.store.lang),
- browserLang, selected, key;
-
- if (langs[storedLang]) {
- lang = storedLang;
- } else if (useBrowserLang) {
- browserLang = navigator.language || navigator.browserLanguage;
- if (browserLang) {
- if (langs[browserLang]) {
- lang = browserLang;
- } else if (browserLang.length > 2 && langs[browserLang.substr(0, 2)]) {
- lang = browserLang.substr(0, 2);
- }
- }
- }
-
- if (!langs[lang]) {
- lang = "en";
- }
-
- selected = langs[lang];
- if (selected) {
- $.each(selected, function (key, value) {
- $(".l10n-" + key).text(value);
- });
- $(".lang").text(lang);
- $(".langOption").removeClass("current");
- $(".langOption." + lang).addClass("current");
- h5ai.core.hash({lang: lang});
- }
-
- formatDates(selected.dateFormat || settings.dateFormat);
- },
- initLangSelector = function (langs) {
-
- var $langOptions = $("#langSelector .langOptions"),
- sortedLangsKeys = [],
- $ul;
-
- $.each(langs, function (lang) {
- sortedLangsKeys.push(lang);
- });
- sortedLangsKeys.sort();
-
- $ul = $("
");
- $.each(sortedLangsKeys, function (idx, lang) {
- $("")
- .addClass(lang)
- .text(lang + " - " + langs[lang].lang)
- .appendTo($ul)
- .click(function () {
- amplify.store(settings.store.lang, lang);
- localize(langs, lang, false);
- });
- });
- $langOptions
- .append($ul)
- .scrollpanel();
-
- $("#langSelector").hover(
- function () {
- $langOptions
- .css("top", "-" + $langOptions.outerHeight() + "px")
- .stop(true, true)
- .fadeIn();
- $langOptions.get(0).updateScrollbar();
- },
- function () {
- $langOptions
- .stop(true, true)
- .fadeOut();
- }
- );
- },
onIndicatorClick = function (event) {
var $indicator = $(this),
@@ -414,15 +293,12 @@
initTopSpace();
initTree();
linkHoverStates();
- initLangSelector(config.langs);
- localize(config.langs, settings.lang, settings.useBrowserLang);
formatSizes();
setTotals();
initIndicators();
};
h5ai.core = {
- settings: settings,
hash: hash,
api: api,
image: image,
@@ -430,9 +306,8 @@
shiftTree: shiftTree,
linkHoverStates: linkHoverStates,
initIndicators: initIndicators,
- formatDates: formatDates,
getFileType: getFileType,
init: init
};
-}(window, jQuery, h5ai, H5AI_CONFIG));
+}(window, jQuery, h5ai));
diff --git a/src/_h5ai/js/inc/Extended.js b/src/_h5ai/js/inc/Extended.js
index 4adc8cc5..10c6dc5e 100644
--- a/src/_h5ai/js/inc/Extended.js
+++ b/src/_h5ai/js/inc/Extended.js
@@ -51,9 +51,9 @@
},
customize = function () {
- if (h5ai.core.settings.customHeader) {
+ if (h5ai.settings.customHeader) {
$.ajax({
- url: h5ai.core.settings.customHeader,
+ url: h5ai.settings.customHeader,
dataType: "html",
success: function (data) {
$("#content > header").append($(data)).show();
@@ -61,9 +61,9 @@
});
}
- if (h5ai.core.settings.customFooter) {
+ if (h5ai.settings.customFooter) {
$.ajax({
- url: h5ai.core.settings.customFooter,
+ url: h5ai.settings.customFooter,
dataType: "html",
success: function (data) {
$("#content > footer").prepend($(data)).show();
@@ -117,7 +117,7 @@
initExtendedView();
customize();
h5ai.connector.updatePaths();
- if (h5ai.core.settings.showTree) {
+ if (h5ai.settings.showTree) {
populateTree();
}
};
diff --git a/src/_h5ai/js/inc/Finder.js b/src/_h5ai/js/inc/Finder.js
index 79ab9380..1b21a2ce 100644
--- a/src/_h5ai/js/inc/Finder.js
+++ b/src/_h5ai/js/inc/Finder.js
@@ -59,15 +59,15 @@
},
init = function () {
- if (h5ai.core.settings.showFilter) {
- $("
")
+ if (h5ai.settings.showFilter) {
+ $('
')
.on('click', function () {
var $input = $(this).find('input');
$input.focus();
})
- .find("img").attr("src", h5ai.core.image("filter")).end()
- .find("input")
+ .find('img').attr('src', h5ai.core.image('filter')).end()
+ .find('input')
.on('focus', function () {
checkState(true);
@@ -89,7 +89,7 @@
checkState($input.is(':focus'));
})
.end()
- .appendTo($("#navbar"));
+ .appendTo($('#navbar'));
var initialFilter = h5ai.core.hash('filter');
if (initialFilter) {
diff --git a/src/_h5ai/js/inc/H5ai.js b/src/_h5ai/js/inc/H5ai.js
index a1079966..a2233ad2 100644
--- a/src/_h5ai/js/inc/H5ai.js
+++ b/src/_h5ai/js/inc/H5ai.js
@@ -1,40 +1,75 @@
-(function ($) {
+(function ($, config) {
'use strict';
/*jslint browser: true, confusion: true, regexp: true, vars: true, white: true */
/*global Modernizr, jQuery, amplify, Base64, H5AI_CONFIG */
- var h5ai = function () {
+ 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
},
- init = function () {
+ h5ai = function () {
- var $html = $('html');
-
- h5ai.isJs = $html.hasClass('h5ai-js');
- h5ai.isPhp = $html.hasClass('h5ai-php');
-
- if (h5ai.isJs) {
- h5ai.extended.init();
- }
-
- h5ai.core.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.config = config;
+ h5ai.settings = $.extend({}, defaults, config.options);
+
+ h5ai.init = function () {
+
+ var $html = $('html');
+
+ h5ai.isJs = $html.hasClass('h5ai-js');
+ h5ai.isPhp = $html.hasClass('h5ai-php');
+
+ if (h5ai.isJs) {
+ h5ai.extended.init();
+ }
+
+ 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;
+ };
+
// @include "Util.js"
// @include "Core.js"
+ // @include "Localize.js"
// @include "Sort.js"
// @include "ZippedDownload.js"
// @include "Finder.js"
@@ -45,6 +80,6 @@
// @include "Html.js"
// @include "Extended.js"
- $(init);
+ $(h5ai.init);
-}(jQuery));
+}(jQuery, H5AI_CONFIG));
diff --git a/src/_h5ai/js/inc/Html.js b/src/_h5ai/js/inc/Html.js
index e2deff26..62940d6b 100644
--- a/src/_h5ai/js/inc/Html.js
+++ b/src/_h5ai/js/inc/Html.js
@@ -52,7 +52,7 @@
updateExtendedHtml = function (path) {
var $html, $a, $label,
- formattedDate = path.date ? path.date.toString(h5ai.core.settings.dateFormat) : "",
+ formattedDate = path.date ? path.date.toString(h5ai.settings.dateFormat) : "",
imgClass = "",
icon16 = h5ai.core.icon(path.type),
icon48 = h5ai.core.icon(path.type, true);
@@ -69,7 +69,7 @@
$html.data("status", path.status);
}
- if (h5ai.core.settings.showThumbs === true && $.inArray(path.type, h5ai.core.settings.thumbTypes) >= 0) {
+ if (h5ai.settings.showThumbs === true && $.inArray(path.type, h5ai.settings.thumbTypes) >= 0) {
imgClass = "class='thumb'";
var escapedHref = path.absHref.replace(/'/g, "%27").replace(/"/g, "%22");
icon16 = h5ai.core.api() + "?action=thumb&href=" + escapedHref + "&width=16&height=16&mode=square";
@@ -113,7 +113,7 @@
);
if (path.isParentFolder) {
- if (!h5ai.core.settings.setParentFolderLabels) {
+ if (!h5ai.settings.setParentFolderLabels) {
$label.addClass("l10n-parentDirectory");
}
$html.addClass("folder-parent");
diff --git a/src/_h5ai/js/inc/Localize.js b/src/_h5ai/js/inc/Localize.js
new file mode 100644
index 00000000..1d215b6b
--- /dev/null
+++ b/src/_h5ai/js/inc/Localize.js
@@ -0,0 +1,108 @@
+
+(function ($, h5ai) {
+
+ var settings = h5ai.settings,
+ langs = h5ai.config.langs,
+ currentDateFormat = settings.dateFormat,
+ formatDates = function (dateFormat) {
+
+ if (dateFormat) {
+ currentDateFormat = dateFormat;
+ }
+
+ $('#extended .entry .date').each(function () {
+
+ var $this = $(this),
+ time = $this.data('time'),
+ formattedDate = time ? new Date(time).toString(currentDateFormat) : '';
+
+ $this.text(formattedDate);
+ });
+ },
+ localize = function (langs, lang, useBrowserLang) {
+
+ var storedLang = amplify.store(settings.store.lang),
+ browserLang, selected, key;
+
+ if (langs[storedLang]) {
+ lang = storedLang;
+ } else if (useBrowserLang) {
+ browserLang = navigator.language || navigator.browserLanguage;
+ if (browserLang) {
+ if (langs[browserLang]) {
+ lang = browserLang;
+ } else if (browserLang.length > 2 && langs[browserLang.substr(0, 2)]) {
+ lang = browserLang.substr(0, 2);
+ }
+ }
+ }
+
+ if (!langs[lang]) {
+ lang = 'en';
+ }
+
+ selected = langs[lang];
+ if (selected) {
+ $.each(selected, function (key, value) {
+ $('.l10n-' + key).text(value);
+ });
+ $('.lang').text(lang);
+ $('.langOption').removeClass('current');
+ $('.langOption.' + lang).addClass('current');
+ h5ai.core.hash({lang: lang});
+ }
+
+ formatDates(selected.dateFormat || settings.dateFormat);
+ },
+ initLangSelector = function (langs) {
+
+ var $langOptions = $('#langSelector .langOptions'),
+ sortedLangsKeys = [],
+ $ul;
+
+ $.each(langs, function (lang) {
+ sortedLangsKeys.push(lang);
+ });
+ sortedLangsKeys.sort();
+
+ $ul = $('');
+ $.each(sortedLangsKeys, function (idx, lang) {
+ $('')
+ .addClass(lang)
+ .text(lang + ' - ' + langs[lang].lang)
+ .appendTo($ul)
+ .click(function () {
+ amplify.store(settings.store.lang, lang);
+ localize(langs, lang, false);
+ });
+ });
+ $langOptions
+ .append($ul)
+ .scrollpanel();
+
+ $('#langSelector').hover(
+ function () {
+ $langOptions
+ .css('top', '-' + $langOptions.outerHeight() + 'px')
+ .stop(true, true)
+ .fadeIn();
+ $langOptions.get(0).updateScrollbar();
+ },
+ function () {
+ $langOptions
+ .stop(true, true)
+ .fadeOut();
+ }
+ );
+ },
+ init = function () {
+
+ initLangSelector(langs);
+ localize(langs, settings.lang, settings.useBrowserLang);
+ };
+
+ h5ai.localize = {
+ init: init
+ };
+
+}(jQuery, h5ai));
diff --git a/src/_h5ai/js/inc/Path.js b/src/_h5ai/js/inc/Path.js
index 444a24d0..0154a2b7 100644
--- a/src/_h5ai/js/inc/Path.js
+++ b/src/_h5ai/js/inc/Path.js
@@ -18,7 +18,7 @@
// path.isCurrentFolder: undefined
// path.isDomain: undefined
- path.status = undefined; // undefined, "h5ai" or HTTP response code
+ path.status = undefined; // undefined, 'h5ai' or HTTP response code
path.content = undefined; // associative array path.absHref -> path
path.html = {
$crumb: undefined,
@@ -28,30 +28,30 @@
path.treeOpen = false;
if (!h5ai.util.pathEndsWithSlash(folder)) {
- folder += "/";
+ folder += '/';
}
if (tableRow) {
- $tds = $(tableRow).find("td");
- $a = $tds.eq(1).find("a");
+ $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.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.parentFolder = splits.parent || '';
path.label = h5ai.util.checkedDecodeUri(splits.name);
- if (path.label === "/") {
+ if (path.label === '/') {
path.label = h5ai.util.checkedDecodeUri(document.domain);
}
- path.type = "folder";
+ path.type = 'folder';
path.href = splits.name;
path.time = 0;
path.size = -1;
@@ -61,17 +61,17 @@
path.label = path.label.slice(0, -1);
}
- path.isFolder = (path.type === "folder");
- path.isParentFolder = (path.label === "Parent Directory");
+ path.isFolder = (path.type === 'folder');
+ path.isParentFolder = (path.label === 'Parent Directory');
if (path.isParentFolder) {
path.isFolder = true;
- path.type = "folder-parent";
+ 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 === "/");
+ path.isDomain = (path.absHref === '/');
- if (path.isParentFolder && h5ai.core.settings.setParentFolderLabels) {
+ if (path.isParentFolder && h5ai.settings.setParentFolderLabels) {
if (path.isDomain) {
path.label = h5ai.util.checkedDecodeUri(document.domain);
} else {
diff --git a/src/_h5ai/js/inc/Sort.js b/src/_h5ai/js/inc/Sort.js
index eff01262..df315301 100644
--- a/src/_h5ai/js/inc/Sort.js
+++ b/src/_h5ai/js/inc/Sort.js
@@ -5,9 +5,9 @@
var $entry = $(entry);
- if ($entry.hasClass("folder-parent")) {
+ if ($entry.hasClass('folder-parent')) {
return 0;
- } else if ($entry.hasClass("folder")) {
+ } else if ($entry.hasClass('folder')) {
return 1;
}
return 2;
@@ -33,117 +33,117 @@
cmpName = function (entry1, entry2) {
return cmp(entry1, entry2, false, function (entry) {
- return $(entry).find(".label").text().toLowerCase();
+ return $(entry).find('.label').text().toLowerCase();
});
},
cmpTime = function (entry1, entry2) {
return cmp(entry1, entry2, false, function (entry) {
- return $(entry).find(".date").data("time");
+ return $(entry).find('.date').data('time');
});
},
cmpSize = function (entry1, entry2) {
return cmp(entry1, entry2, false, function (entry) {
- return $(entry).find(".size").data("bytes");
+ return $(entry).find('.size').data('bytes');
});
},
cmpNameRev = function (entry1, entry2) {
return cmp(entry1, entry2, true, function (entry) {
- return $(entry).find(".label").text().toLowerCase();
+ return $(entry).find('.label').text().toLowerCase();
});
},
cmpTimeRev = function (entry1, entry2) {
return cmp(entry1, entry2, true, function (entry) {
- return $(entry).find(".date").data("time");
+ return $(entry).find('.date').data('time');
});
},
cmpSizeRev = function (entry1, entry2) {
return cmp(entry1, entry2, true, function (entry) {
- return $(entry).find(".size").data("bytes");
+ return $(entry).find('.size').data('bytes');
});
},
sort = function (fn) {
- $("#extended .entry").detach().sort(fn).appendTo($("#extended > ul"));
+ $('#extended .entry').detach().sort(fn).appendTo($('#extended > ul'));
},
$all, orders,
sortBy = function (id) {
var order = orders[id];
- $all.removeClass("ascending").removeClass("descending");
+ $all.removeClass('ascending').removeClass('descending');
order.head.addClass(order.clas);
sort(order.fn);
h5ai.core.hash({sort: id});
},
init = function () {
- var $ascending = $("
"),
- $descending = $("
"),
+ var $ascending = $('
'),
+ $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");
+ $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");
+ $all = $header.find('a.label,a.date,a.size');
orders = {
na: {
head: $label,
- clas: "ascending",
+ clas: 'ascending',
fn: cmpName
},
nd: {
head: $label,
- clas: "descending",
+ clas: 'descending',
fn: cmpNameRev
},
da: {
head: $date,
- clas: "ascending",
+ clas: 'ascending',
fn: cmpTime
},
dd: {
head: $date,
- clas: "descending",
+ clas: 'descending',
fn: cmpTimeRev
},
sa: {
head: $size,
- clas: "ascending",
+ clas: 'ascending',
fn: cmpSize
},
sd: {
head: $size,
- clas: "descending",
+ clas: 'descending',
fn: cmpSizeRev
}
};
- sortBy(initialOrder ? initialOrder : h5ai.core.settings.sortorder);
+ sortBy(initialOrder ? initialOrder : h5ai.settings.sortorder);
$label
.append($ascending.clone()).append($descending.clone())
.click(function (event) {
- sortBy("n" + ($label.hasClass("ascending") ? "d" : "a"));
+ 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"));
+ 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"));
+ sortBy('s' + ($size.hasClass('ascending') ? 'd' : 'a'));
event.preventDefault();
});
};
diff --git a/src/_h5ai/js/inc/Util.js b/src/_h5ai/js/inc/Util.js
index eceac243..5b40374b 100644
--- a/src/_h5ai/js/inc/Util.js
+++ b/src/_h5ai/js/inc/Util.js
@@ -3,15 +3,20 @@
var reSplitPath = /^\/([^\/]+\/?)$/,
reSplitPath2 = /^(\/(?:.*\/)*?([^\/]+)\/)([^\/]+\/?)$/,
+ rePathEndsWithSlash = /\/$/,
+ reParseSize = /^\s*([\.\d]+)\s*([kmg]?)b?\s*$/i,
+ kilo = 1000.0,
+ sizeUnits = ['B', 'KB', 'MB', 'GB', 'TB'],
+
splitPath = function (pathname) {
var match;
- if (pathname === "/") {
+ if (pathname === '/') {
return {
parent: null,
parentname: null,
- name: "/"
+ name: '/'
};
}
match = reSplitPath2.exec(pathname);
@@ -25,13 +30,12 @@
match = reSplitPath.exec(pathname);
if (match) {
return {
- parent: "/",
- parentname: "/",
+ parent: '/',
+ parentname: '/',
name: match[1]
};
}
},
- rePathEndsWithSlash = /\/$/,
pathEndsWithSlash = function (pathname) {
return rePathEndsWithSlash.test(pathname);
@@ -41,18 +45,16 @@
var $a, isParentFolder, href;
if (!pathEndsWithSlash(folder)) {
- folder += "/";
+ folder += '/';
}
if (!tableRow) {
return folder;
}
- $a = $(tableRow).find("td").eq(1).find("a");
- isParentFolder = ($a.text() === "Parent Directory");
- href = $a.attr("href");
+ $a = $(tableRow).find('td').eq(1).find('a');
+ isParentFolder = ($a.text() === 'Parent Directory');
+ href = $a.attr('href');
return isParentFolder ? undefined : folder + href;
},
- kilo = 1000.0,
- reParseSize = /^\s*([\.\d]+)\s*([kmg]?)b?\s*$/i,
parseSize = function (str) {
var match = reParseSize.exec(str),
@@ -64,18 +66,17 @@
val = parseFloat(match[1]);
unit = match[2].toLowerCase();
- if (unit === "k") {
+ if (unit === 'k') {
val *= kilo;
- } else if (unit === "m") {
+ } else if (unit === 'm') {
val *= kilo * kilo;
- } else if (unit === "g") {
+ } else if (unit === 'g') {
val *= kilo * kilo * kilo;
- } else if (unit === "t") {
+ } else if (unit === 't') {
val *= kilo * kilo * kilo * kilo;
}
return val;
},
- sizeUnits = ["B", "KB", "MB", "GB", "TB"],
formatSize = function (size) {
var th = 1000.0,
@@ -90,7 +91,7 @@
size /= kilo;
i += 1;
}
- return (i <= 1 ? Math.round(size) : size.toFixed(1)).toString() + " " + sizeUnits[i];
+ return (i <= 1 ? Math.round(size) : size.toFixed(1)).toString() + ' ' + sizeUnits[i];
},
checkedDecodeUri = function (uri) {
diff --git a/src/_h5ai/js/inc/ZippedDownload.js b/src/_h5ai/js/inc/ZippedDownload.js
index ed44b1a1..d37e79f9 100644
--- a/src/_h5ai/js/inc/ZippedDownload.js
+++ b/src/_h5ai/js/inc/ZippedDownload.js
@@ -4,21 +4,21 @@
var x = 0,
y = 0,
$document = $(document),
- $selectionRect = $("#selection-rect"),
- selectedHrefsStr = "",
+ $selectionRect = $('#selection-rect'),
+ selectedHrefsStr = '',
$download, $img, $downloadAuth, $downloadUser, $downloadPassword,
updateDownloadBtn = function () {
- var $selected = $("#extended a.selected"),
- $downloadBtn = $("#download");
+ var $selected = $('#extended a.selected'),
+ $downloadBtn = $('#download');
- selectedHrefsStr = "";
+ selectedHrefsStr = '';
if ($selected.length) {
$selected.each(function () {
- var href = $(this).attr("href");
- selectedHrefsStr = selectedHrefsStr ? selectedHrefsStr + ":" + href : href;
+ var href = $(this).attr('href');
+ selectedHrefsStr = selectedHrefsStr ? selectedHrefsStr + ':' + href : href;
});
$downloadBtn.show();
} else {
@@ -37,24 +37,24 @@
event.preventDefault();
$selectionRect.css({left: l, top: t, width: w, height: h});
- selRect = $selectionRect.fracs("rect");
- $("#extended a").removeClass("selecting").each(function () {
+ selRect = $selectionRect.fracs('rect');
+ $('#extended a').removeClass('selecting').each(function () {
var $a = $(this),
- rect = $a.fracs("rect"),
+ rect = $a.fracs('rect'),
inter = selRect.intersection(rect);
- if (inter && !$a.closest(".entry").hasClass("folder-parent")) {
- $a.addClass("selecting");
+ if (inter && !$a.closest('.entry').hasClass('folder-parent')) {
+ $a.addClass('selecting');
}
});
},
selectionEnd = function (event) {
event.preventDefault();
- $document.off("mousemove", selectionUpdate);
+ $document.off('mousemove', selectionUpdate);
$selectionRect.hide().css({left: 0, top: 0, width: 0, height: 0});
- $("#extended a.selecting.selected").removeClass("selecting").removeClass("selected");
- $("#extended a.selecting").removeClass("selecting").addClass("selected");
+ $('#extended a.selecting.selected').removeClass('selecting').removeClass('selected');
+ $('#extended a.selecting').removeClass('selecting').addClass('selected');
updateDownloadBtn();
},
selectionStart = function (event) {
@@ -156,18 +156,18 @@
},
init = function () {
- if (h5ai.core.settings.zippedDownload) {
- $("
download")
- .find("img").attr("src", h5ai.core.image("download")).end()
- .find("a").click(function (event) {
+ if (h5ai.settings.zippedDownload) {
+ $('
download')
+ .find('img').attr('src', h5ai.core.image('download')).end()
+ .find('a').click(function (event) {
event.preventDefault();
$downloadAuth.hide();
requestZipping(selectedHrefsStr);
}).end()
- .appendTo($("#navbar"));
- $("")
- .appendTo($("body"));
+ .appendTo($('#navbar'));
+ $('')
+ .appendTo($('body'));
$download = $('#download');
$downloadAuth = $('#download-auth');
@@ -175,9 +175,9 @@
$downloadPassword = $('#download-auth-password');
$img = $download.find('img');
- $("body>nav,body>footer,#tree,input").on("mousedown", noSelection);
- $("#content").on("mousedown", "a", noSelectionUnlessCtrl);
- $document.on("mousedown", selectionStart);
+ $('body>nav,body>footer,#tree,input').on('mousedown', noSelection);
+ $('#content').on('mousedown', 'a', noSelectionUnlessCtrl);
+ $document.on('mousedown', selectionStart);
}
};
diff --git a/src/_h5ai/js/scripts.js b/src/_h5ai/js/scripts.js
index 63b5558c..3482f896 100644
--- a/src/_h5ai/js/scripts.js
+++ b/src/_h5ai/js/scripts.js
@@ -14,6 +14,6 @@
// @include "inc/lib/base64.js"
// @include "inc/lib/date.js"
-// app scripts
-// -----------
+// h5ai
+// ----
// @include "inc/H5ai.js"