From 4c1ed3d1e8e05acfb0039ee0e8006f72916ae6a2 Mon Sep 17 00:00:00 2001
From: Lars Jung
Date: Thu, 29 Sep 2011 13:43:22 +0200
Subject: [PATCH 1/4] Redesigned js.
---
src/h5ai/js/inc/{tree.js => Connector.js} | 37 +-
src/h5ai/js/inc/{extended.js => Extended.js} | 18 +-
src/h5ai/js/inc/{h5ai.js => H5ai.js} | 6 +-
src/h5ai/js/inc/Html.js | 260 ++++++++++++
src/h5ai/js/inc/Path.js | 105 +++++
src/h5ai/js/inc/PathCache.js | 61 +++
src/h5ai/js/inc/path.js | 404 -------------------
src/h5ai/js/main-js.js | 39 +-
src/h5ai/js/main-php.js | 24 +-
9 files changed, 493 insertions(+), 461 deletions(-)
rename src/h5ai/js/inc/{tree.js => Connector.js} (81%)
rename src/h5ai/js/inc/{extended.js => Extended.js} (86%)
rename src/h5ai/js/inc/{h5ai.js => H5ai.js} (99%)
create mode 100644 src/h5ai/js/inc/Html.js
create mode 100644 src/h5ai/js/inc/Path.js
create mode 100644 src/h5ai/js/inc/PathCache.js
delete mode 100644 src/h5ai/js/inc/path.js
diff --git a/src/h5ai/js/inc/tree.js b/src/h5ai/js/inc/Connector.js
similarity index 81%
rename from src/h5ai/js/inc/tree.js
rename to src/h5ai/js/inc/Connector.js
index fa2dc0f9..ab644855 100644
--- a/src/h5ai/js/inc/tree.js
+++ b/src/h5ai/js/inc/Connector.js
@@ -1,13 +1,13 @@
-/*global $, Objects */
+/*global $, H5aiJs */
-Objects.Tree = function (pathCache, h5ai) {
+H5aiJs.factory.Connector = function () {
var contentTypeRegEx = /^text\/html;h5ai=/,
pathnameStatusCache = {},
fetchStatus = function (pathname, callback) {
- if (h5ai.settings.folderStatus[pathname]) {
- callback(h5ai.settings.folderStatus[pathname]);
+ if (H5aiJs.h5ai.settings.folderStatus[pathname]) {
+ callback(H5aiJs.h5ai.settings.folderStatus[pathname]);
return;
} else if (pathnameStatusCache[pathname]) {
callback(pathnameStatusCache[pathname]);
@@ -37,14 +37,14 @@ Objects.Tree = function (pathCache, h5ai) {
if (status !== "h5ai") {
path.status = status;
}
- path.updateHtml();
- h5ai.linkHoverStates();
+ H5aiJs.html.updateHtml(path);
+ H5aiJs.h5ai.linkHoverStates();
});
}
},
updatePaths = function () {
- $.each(pathCache.cache, function (ref, cached) {
+ $.each(H5aiJs.pathCache.cache, function (ref, cached) {
updatePath(cached);
});
},
@@ -76,7 +76,7 @@ Objects.Tree = function (pathCache, h5ai) {
$(html).find("#table td").closest("tr").each(function () {
- var path = pathCache.getPath(pathname, this);
+ var path = H5aiJs.pathCache.getPath(pathname, this);
if (path.isFolder && (!path.isParentFolder || includeParent)) {
content[path.absHref] = path;
@@ -92,7 +92,7 @@ Objects.Tree = function (pathCache, h5ai) {
fetchStatusAndContent(pathname, false, function (status, content) {
- var path = pathCache.getPath(pathname);
+ var path = H5aiJs.pathCache.getPath(pathname);
path.status = status;
path.content = content;
@@ -103,7 +103,7 @@ Objects.Tree = function (pathCache, h5ai) {
fetchPath(pathname, function (path) {
- var parent = pathCache.splitPathname(pathname)[0];
+ var parent = H5aiJs.pathCache.splitPathname(pathname)[0];
path.treeOpen = true;
if (childPath) {
@@ -120,25 +120,24 @@ Objects.Tree = function (pathCache, h5ai) {
fetchTree(document.location.pathname, function (path) {
$("#tree")
- .append(path.updateTreeHtml())
+ .append(H5aiJs.html.updateTreeHtml(path))
.scrollpanel()
.show();
- h5ai.shiftTree(false, true);
- h5ai.linkHoverStates();
+ H5aiJs.h5ai.shiftTree(false, true);
+ H5aiJs.h5ai.linkHoverStates();
setTimeout(function () { $("#tree").get(0).updateScrollbar(); }, 1);
});
},
init = function () {
- if (h5ai.settings.showTree) {
+ if (H5aiJs.h5ai.settings.showTree) {
updatePaths();
populateTree();
}
- },
- tree = {
- fetchStatusAndContent: fetchStatusAndContent,
- init: init
};
- return tree;
+ return {
+ fetchStatusAndContent: fetchStatusAndContent,
+ init: init
+ };
};
diff --git a/src/h5ai/js/inc/extended.js b/src/h5ai/js/inc/Extended.js
similarity index 86%
rename from src/h5ai/js/inc/extended.js
rename to src/h5ai/js/inc/Extended.js
index e741865d..486107c2 100644
--- a/src/h5ai/js/inc/extended.js
+++ b/src/h5ai/js/inc/Extended.js
@@ -1,6 +1,6 @@
-/*global $, Objects */
+/*global $, H5aiJs */
-Objects.Extended = function (pathCache, h5ai) {
+H5aiJs.factory.Extended = function () {
var settings = {
customHeader: "h5ai.header.html",
@@ -17,15 +17,15 @@ Objects.Extended = function (pathCache, h5ai) {
var $ul = $("body > nav ul"),
pathname = "/",
- path = pathCache.getPath(pathname),
+ path = H5aiJs.pathCache.getPath(pathname),
pathnameParts = document.location.pathname.split("/");
- $ul.append(path.updateCrumbHtml());
+ $ul.append(H5aiJs.html.updateCrumbHtml(path));
$.each(pathnameParts, function (idx, part) {
if (part !== "") {
pathname += part + "/";
- $ul.append(pathCache.getPath(pathname).updateCrumbHtml());
+ $ul.append(H5aiJs.html.updateCrumbHtml(H5aiJs.pathCache.getPath(pathname)));
}
});
},
@@ -37,8 +37,8 @@ Objects.Extended = function (pathCache, h5ai) {
$size = $ths.eq(3).find("a"),
sortquery = document.location.search,
order = {
- column: (sortquery.indexOf("C=N") >= 0) ? "name" : (sortquery.indexOf("C=M") >= 0) ? "date" : (sortquery.indexOf("C=S") >= 0) ? "size" : h5ai.settings.sortorder.column,
- ascending: (sortquery.indexOf("O=A") >= 0) ? true : (sortquery.indexOf("O=D") >= 0) ? false : h5ai.settings.sortorder.ascending
+ column: (sortquery.indexOf("C=N") >= 0) ? "name" : (sortquery.indexOf("C=M") >= 0) ? "date" : (sortquery.indexOf("C=S") >= 0) ? "size" : H5aiJs.h5ai.settings.sortorder.column,
+ ascending: (sortquery.indexOf("O=A") >= 0) ? true : (sortquery.indexOf("O=D") >= 0) ? false : H5aiJs.h5ai.settings.sortorder.ascending
},
$icon, $ul, $li;
@@ -66,8 +66,8 @@ Objects.Extended = function (pathCache, h5ai) {
// entries
$("#table td").closest("tr").each(function () {
- var path = pathCache.getPath(document.location.pathname, this);
- $ul.append(path.updateExtendedHtml());
+ var path = H5aiJs.pathCache.getPath(document.location.pathname, this);
+ $ul.append(H5aiJs.html.updateExtendedHtml(path));
});
$("#extended").append($ul);
diff --git a/src/h5ai/js/inc/h5ai.js b/src/h5ai/js/inc/H5ai.js
similarity index 99%
rename from src/h5ai/js/inc/h5ai.js
rename to src/h5ai/js/inc/H5ai.js
index 56cfcfc6..79779d7d 100644
--- a/src/h5ai/js/inc/h5ai.js
+++ b/src/h5ai/js/inc/H5ai.js
@@ -1,6 +1,6 @@
-/*global window, $, Objects, localStorage */
+/*global window, $, H5aiJs, localStorage */
-Objects.H5ai = function (options, langs) {
+H5aiJs.factory.H5ai = function (options, langs) {
var defaults = {
store: {
@@ -256,7 +256,7 @@ Objects.H5ai = function (options, langs) {
if ($indicator.hasClass("unknown")) {
$.get("/h5ai/php/treecontent.php", { "href": $entry.find("> a").attr("href") }, function (html) {
-
+
var $content = $(html);
$indicator.removeClass("unknown");
diff --git a/src/h5ai/js/inc/Html.js b/src/h5ai/js/inc/Html.js
new file mode 100644
index 00000000..79e5977e
--- /dev/null
+++ b/src/h5ai/js/inc/Html.js
@@ -0,0 +1,260 @@
+/*global $, H5aiJs */
+
+H5aiJs.factory.Html = function () {
+
+ var imagesPath = "/h5ai/images",
+ iconsPath = "/h5ai/icons",
+ image = function (id) {
+
+ return imagesPath + "/" + id + ".png";
+ },
+ icon = function (id, big) {
+
+ return iconsPath + "/" + (big ? "48x48" : "16x16") + "/" + id + ".png";
+ },
+ onClick = function (path, context) {
+
+ H5aiJs.h5ai.triggerPathClick(path, context);
+ },
+ updateCrumbHtml = function (path) {
+
+ var $html, $a;
+
+ if (path.html.$crumb && path.html.$crumb.data("status") === path.status) {
+ return path.html.$crumb;
+ }
+
+ $html = $("")
+ .data("path", path)
+ .addClass(path.isFolder ? "folder" : "file");
+
+ if (path.status) {
+ $html.data("status", path.status);
+ }
+
+ $a = $("
" + path.label + "")
+ .appendTo($html)
+ .attr("href", path.absHref)
+ .click(function() { onClick(path, "crumb"); });
+
+ if (path.isDomain) {
+ $html.addClass("domain");
+ $a.find("img").attr("src", image("home"));
+ }
+
+ if (path.isCurrentFolder) {
+ $html.addClass("current");
+ }
+
+ if (!isNaN(path.status)) {
+ if (path.status === 200) {
+ $("
").appendTo($a);
+ } else {
+ $("(" + path.status + ")").appendTo($a);
+ }
+ }
+
+ if (path.html.$crumb) {
+ path.html.$crumb.replaceWith($html);
+ }
+ path.html.$crumb = $html;
+
+ return $html;
+ },
+ updateExtendedHtml = function (path) {
+
+ var $html, $a, $label;
+
+ if (path.html.$extended && path.html.$extended.data("status") === path.status) {
+ return path.html.$extended;
+ }
+
+ $html = $("")
+ .data("path", path)
+ .addClass(path.isFolder ? "folder" : "file");
+
+ if (path.status) {
+ $html.data("status", path.status);
+ }
+
+ $label = $("" + path.label + "");
+ $a = $("")
+ .attr("href", path.absHref)
+ .click(function() { onClick(path, "extended"); })
+ .appendTo($html)
+ .append($("
"))
+ .append($("
"))
+ .append($label)
+ .append($("" + path.date + ""))
+ .append($("" + path.size + ""));
+
+ $a.hover(
+ function () {
+ if ($("#extended").hasClass("icons-view")) {
+ var $this = $(this);
+ $(".status.default").hide();
+ $(".status.dynamic")
+ .empty()
+ .append($this.find(".label").clone())
+ .append($("·"))
+ .append($this.find(".date").clone())
+ .show();
+
+ if (!$this.closest(".entry").hasClass("folder")) {
+ $(".status.dynamic")
+ .append($("·"))
+ .append($this.find(".size").clone());
+ }
+ }
+ },
+ function () {
+ $(".status.default").show();
+ $(".status.dynamic").empty().hide();
+ }
+ );
+
+ if (path.isParentFolder) {
+ if (!H5aiJs.h5ai.settings.setParentFolderLabels) {
+ $label.addClass("l10n-parentDirectory");
+ }
+ $html.addClass("folder-parent");
+ }
+
+ if (!isNaN(path.status)) {
+ if (path.status === 200) {
+ $html.addClass("page");
+ $a.find(".icon.small img").attr("src", icon("folder-page"));
+ $a.find(".icon.big img").attr("src", icon("folder-page", true));
+ } else {
+ $html.addClass("error");
+ $label.append($(" " + path.status + " "));
+ }
+ }
+
+ if (path.html.$extended) {
+ path.html.$extended.replaceWith($html);
+ }
+ path.html.$extended = $html;
+
+ return $html;
+ },
+ updateTreeHtml = function (path) {
+
+ var $html, $blank, $a, $indicator, $ul, idx;
+
+ $html = $("")
+ .data("path", path)
+ .addClass(path.isFolder ? "folder" : "file");
+
+ $blank = $("").appendTo($html);
+
+ $a = $("")
+ .attr("href", path.absHref)
+ .click(function() { path.onClick(path, "tree"); })
+ .appendTo($html)
+ .append($("
"))
+ .append($("" + path.label + ""));
+
+ if (path.isFolder) {
+ // indicator
+ if (path.status === undefined || !path.isEmpty()) {
+ $indicator = $("
")
+ .click(function (event) {
+
+ var $entry = $indicator.closest(".entry"); // $html
+
+ if ($indicator.hasClass("unknown")) {
+ H5aiJs.connector.fetchStatusAndContent(path.absHref, false, function (status, content) {
+
+ path.status = status;
+ path.content = content;
+ path.treeOpen = true;
+ $("#tree").get(0).updateScrollbar(true);
+ updateTreeHtml(path);
+ $("#tree").get(0).updateScrollbar();
+ });
+ } else if ($indicator.hasClass("open")) {
+ path.treeOpen = false;
+ $indicator.removeClass("open");
+ $("#tree").get(0).updateScrollbar(true);
+ $entry.find("> ul.content").slideUp(function() {
+
+ $("#tree").get(0).updateScrollbar();
+ });
+ } else {
+ path.treeOpen = true;
+ $indicator.addClass("open");
+ $("#tree").get(0).updateScrollbar(true);
+ $entry.find("> ul.content").slideDown(function() {
+
+ $("#tree").get(0).updateScrollbar();
+ });
+ }
+
+ });
+
+ if (path.status === undefined) {
+ $indicator.addClass("unknown");
+ } else if (path.treeOpen) {
+ $indicator.addClass("open");
+ }
+
+ $blank.replaceWith($indicator);
+ }
+
+ // is path the domain?
+ if (path.isDomain) {
+ $html.addClass("domain");
+ $a.find(".icon img").attr("src", icon("folder-home"));
+ }
+
+ // is path the current folder?
+ if (path.isCurrentFolder) {
+ $html.addClass("current");
+ $a.find(".icon img").attr("src", icon("folder-open"));
+ }
+
+ // does it have subfolders?
+ if (!path.isEmpty()) {
+ $ul = $("").appendTo($html);
+ $.each(path.content, function (idx, entry) {
+ $("").append(updateTreeHtml(entry)).appendTo($ul);
+ });
+ if (path.status === undefined || !path.treeOpen) {
+ $ul.hide();
+ }
+ }
+
+ // reflect folder status
+ if (!isNaN(path.status)) {
+ if (path.status === 200) {
+ $a.find(".icon img").attr("src", icon("folder-page"));
+ $a.append($("
"));
+ } else {
+ $html.addClass("error");
+ $a.append($("" + path.status + ""));
+ }
+ }
+ }
+
+ if (path.html.$tree) {
+ path.html.$tree.replaceWith($html);
+ }
+ path.html.$tree = $html;
+
+ return $html;
+ },
+ updateHtml = function (path) {
+
+ updateCrumbHtml(path);
+ updateExtendedHtml(path);
+ updateTreeHtml(path);
+ };
+
+ return {
+ updateCrumbHtml: updateCrumbHtml,
+ updateExtendedHtml: updateExtendedHtml,
+ updateTreeHtml: updateTreeHtml,
+ updateHtml: updateHtml
+ };
+};
diff --git a/src/h5ai/js/inc/Path.js b/src/h5ai/js/inc/Path.js
new file mode 100644
index 00000000..923944b4
--- /dev/null
+++ b/src/h5ai/js/inc/Path.js
@@ -0,0 +1,105 @@
+/*global $, H5aiJs */
+
+H5aiJs.factory.Path = function (folder, tableRow) {
+
+ var path,
+ checkedDecodeUri = function (uri) {
+
+ try { return decodeURI(uri); } catch (err) {}
+ return uri;
+ },
+ isEmpty = function () {
+
+ return !path.content || $.isEmptyObject(path.content);
+ },
+ onClick = function (context) {
+
+ H5aiJs.h5ai.triggerPathClick(path, context);
+ },
+ init = function () {
+
+ var $tds, $img, $a, splits;
+
+ path = {
+ // parentFolder: undefined,
+ // label: undefined,
+ // date: undefined,
+ // size: undefined,
+ // href: undefined,
+ // absHref: undefined,
+ // alt: undefined,
+ // icon16: undefined,
+ // icon48: undefined,
+ // isFolder: undefined,
+ // isParentFolder: undefined,
+ // isCurrentFolder: undefined,
+ // isDomain: undefined,
+
+ status: undefined, // undefined, "h5ai" or HTTP response code
+ content: undefined, // associative array path.absHref -> path
+ html: {
+ $crumb: undefined,
+ $extended: undefined,
+ $tree: undefined
+ },
+ treeOpen: false,
+
+ isEmpty: isEmpty,
+ onClick: onClick
+ };
+
+ if (!H5aiJs.pathCache.pathEndsWithSlash(folder)) {
+ folder += "/";
+ }
+
+ if (tableRow) {
+ $tds = $(tableRow).find("td");
+ $img = $tds.eq(0).find("img");
+ $a = $tds.eq(1).find("a");
+
+ path.parentFolder = folder;
+ path.label = $a.text();
+ path.date = $tds.eq(2).text();
+ path.size = $tds.eq(3).text();
+ path.href = $a.attr("href");
+ path.alt = $img.attr("alt");
+ path.icon16 = $img.attr("src");
+ } else {
+ splits = H5aiJs.pathCache.splitPathname(folder);
+
+ path.parentFolder = splits[0];
+ path.label = checkedDecodeUri(splits[1]);
+ if (path.label === "/") {
+ path.label = checkedDecodeUri(document.domain) + "/";
+ }
+ path.date = "";
+ path.size = "";
+ path.href = splits[1];
+ path.alt = "[DIR]";
+ path.icon16 = "/h5ai/icons/16x16/folder.png";
+ }
+
+ if (H5aiJs.pathCache.pathEndsWithSlash(path.label)) {
+ path.label = path.label.slice(0, -1);
+ }
+
+ path.icon48 = path.icon16.replace("16x16", "48x48");
+ path.isFolder = (path.alt === "[DIR]");
+ path.isParentFolder = (path.isFolder && path.label === "Parent Directory");
+ path.absHref = path.isParentFolder ? path.href : path.parentFolder + path.href;
+ path.isCurrentFolder = (path.absHref === document.location.pathname);
+ path.isDomain = (path.absHref === "/");
+
+ if (path.isParentFolder && H5aiJs.h5ai.settings.setParentFolderLabels) {
+ if (path.isDomain) {
+ path.label = checkedDecodeUri(document.domain);
+ } else {
+ path.label = checkedDecodeUri(H5aiJs.pathCache.splitPathname(H5aiJs.pathCache.splitPathname(path.parentFolder)[0])[1].slice(0, -1));
+ }
+ }
+ };
+
+ init();
+
+ return path;
+};
diff --git a/src/h5ai/js/inc/PathCache.js b/src/h5ai/js/inc/PathCache.js
new file mode 100644
index 00000000..90c4edca
--- /dev/null
+++ b/src/h5ai/js/inc/PathCache.js
@@ -0,0 +1,61 @@
+/*global $, H5aiJs */
+
+H5aiJs.factory.PathCache = function () {
+
+ var pathCache,
+ cache = {},
+ rePathnameSplit = /^(\/(.*\/)*)([^\/]+\/?)$/,
+ rePathEndsWithSlash = /\/$/,
+ splitPathname = function (pathname) {
+
+ var match;
+
+ if (pathname === "/") {
+ return ["", "/"];
+ }
+ match = rePathnameSplit.exec(pathname);
+ return [match[1], match[3]];
+ },
+ pathEndsWithSlash = function (pathname) {
+
+ return rePathEndsWithSlash.test(pathname);
+ },
+ getAbsHref = function (folder, tableRow) {
+
+ var $a, isParentFolder, href;
+
+ if (!pathEndsWithSlash(folder)) {
+ folder += "/";
+ }
+ if (!tableRow) {
+ return folder;
+ }
+ $a = $(tableRow).find("td").eq(1).find("a");
+ isParentFolder = ($a.text() === "Parent Directory");
+ href = $a.attr("href");
+ return isParentFolder ? undefined : folder + href;
+ },
+ getPath = function (folder, tableRow) {
+
+ var absHref = getAbsHref(folder, tableRow),
+ path = cache[absHref];
+
+ if (!path) {
+ path = new H5aiJs.factory.Path(folder, tableRow);
+ if (!path.isParentFolder) {
+ cache[path.absHref] = path;
+ }
+ }
+
+ return path;
+ };
+
+ pathCache = {
+ splitPathname: splitPathname,
+ pathEndsWithSlash: pathEndsWithSlash,
+ getPath: getPath,
+ cache: cache
+ };
+
+ return pathCache;
+};
diff --git a/src/h5ai/js/inc/path.js b/src/h5ai/js/inc/path.js
deleted file mode 100644
index 23a08673..00000000
--- a/src/h5ai/js/inc/path.js
+++ /dev/null
@@ -1,404 +0,0 @@
-/*global $, Objects */
-
-Objects.Path = function (pathCache, folder, tableRow) {
-
- var path,
- checkedDecodeUri = function (uri) {
-
- try { return decodeURI(uri); } catch (err) {}
- return uri;
- },
- isEmpty = function () {
-
- return !path.content || $.isEmptyObject(path.content);
- },
- onClick = function (context) {
-
- h5ai.triggerPathClick(path, context);
- },
- updateHtml = function () {
-
- path.updateCrumbHtml();
- path.updateExtendedHtml();
- path.updateTreeHtml();
- },
- updateCrumbHtml = function () {
-
- var $html, $a;
-
- if (path.html.$crumb && path.html.$crumb.data("status") === path.status) {
- return path.html.$crumb;
- }
-
- $html = $("")
- .data("path", path)
- .addClass(path.isFolder ? "folder" : "file");
-
- if (path.status) {
- $html.data("status", path.status);
- }
-
- $a = $("
" + path.label + "")
- .appendTo($html)
- .attr("href", path.absHref)
- .click(function() { onClick("crumb"); });
-
- if (path.isDomain) {
- $html.addClass("domain");
- $a.find("img").attr("src", "/h5ai/images/home.png");
- }
-
- if (path.isCurrentFolder) {
- $html.addClass("current");
- }
-
- if (!isNaN(path.status)) {
- if (path.status === 200) {
- $("
").appendTo($a);
- } else {
- $("(" + path.status + ")").appendTo($a);
- }
- }
-
- if (path.html.$crumb) {
- path.html.$cpathreplaceWith($html);
- }
- path.html.$crumb = $html;
-
- return $html;
- },
- updateExtendedHtml = function () {
-
- var $html, $a, $label;
-
- if (path.html.$extended && path.html.$extended.data("status") === path.status) {
- return path.html.$extended;
- }
-
- $html = $("")
- .data("path", path)
- .addClass(path.isFolder ? "folder" : "file");
-
- if (path.status) {
- $html.data("status", path.status);
- }
-
- $label = $("" + path.label + "");
- $a = $("")
- .attr("href", path.absHref)
- .click(function() { onClick("extended"); })
- .appendTo($html)
- .append($("
"))
- .append($("
"))
- .append($label)
- .append($("" + path.date + ""))
- .append($("" + path.size + ""));
-
- $a.hover(
- function () {
- if ($("#extended").hasClass("icons-view")) {
- var $this = $(this);
- $(".status.default").hide();
- $(".status.dynamic")
- .empty()
- .append($this.find(".label").clone())
- .append($("·"))
- .append($this.find(".date").clone())
- .show();
-
- if (!$this.closest(".entry").hasClass("folder")) {
- $(".status.dynamic")
- .append($("·"))
- .append($this.find(".size").clone());
- }
- }
- },
- function () {
- $(".status.default").show();
- $(".status.dynamic").empty().hide();
- }
- );
-
- if (path.isParentFolder) {
- if (!h5ai.settings.setParentFolderLabels) {
- $label.addClass("l10n-parentDirectory");
- }
- $html.addClass("folder-parent");
- }
-
- if (!isNaN(path.status)) {
- if (path.status === 200) {
- $html.addClass("page");
- $a.find(".icon.small img").attr("src", "/h5ai/icons/16x16/folder-page.png");
- $a.find(".icon.big img").attr("src", "/h5ai/icons/48x48/folder-page.png");
- } else {
- $html.addClass("error");
- $label.append($(" " + path.status + " "));
- }
- }
-
- if (path.html.$extended) {
- path.html.$extended.replaceWith($html);
- }
- path.html.$extended = $html;
-
- return $html;
- },
- updateTreeHtml = function () {
-
- var $html, $blank, $a, $indicator, $ul, idx;
-
- $html = $("")
- .data("path", path)
- .addClass(path.isFolder ? "folder" : "file");
-
- $blank = $("").appendTo($html);
-
- $a = $("")
- .attr("href", path.absHref)
- .click(function() { path.onClick("tree"); })
- .appendTo($html)
- .append($("
"))
- .append($("" + path.label + ""));
-
- if (path.isFolder) {
- // indicator
- if (path.status === undefined || !path.isEmpty()) {
- $indicator = $("
");
- if (path.status === undefined) {
- $indicator.addClass("unknown");
- } else if (path.treeOpen) {
- $indicator.addClass("open");
- }
-
- $indicator.click(function(event) {
-
- if ($indicator.hasClass("unknown")) {
- tree.fetchStatusAndContent(path.absHref, false, function (status, content) {
-
- path.status = status;
- path.content = content;
- path.treeOpen = true;
- $("#tree").get(0).updateScrollbar(true);
- path.updateTreeHtml(function() {
-
- $("#tree").get(0).updateScrollbar();
- });
- });
- } else if ($indicator.hasClass("open")) {
- path.treeOpen = false;
- $indicator.removeClass("open");
- $("#tree").get(0).updateScrollbar(true);
- $html.find("> ul.content").slideUp(function() {
-
- $("#tree").get(0).updateScrollbar();
- });
- } else {
- path.treeOpen = true;
- $indicator.addClass("open");
- $("#tree").get(0).updateScrollbar(true);
- $html.find("> ul.content").slideDown(function() {
-
- $("#tree").get(0).updateScrollbar();
- });
- }
- });
- $html.addClass("initiatedIndicator");
-
- $blank.replaceWith($indicator);
- }
-
- // is path the domain?
- if (path.isDomain) {
- $html.addClass("domain");
- $a.find(".icon img").attr("src", "/h5ai/icons/16x16/folder-home.png");
- }
-
- // is path the current folder?
- if (path.isCurrentFolder) {
- $html.addClass("current");
- $a.find(".icon img").attr("src", "/h5ai/icons/16x16/folder-open.png");
- }
-
- // does it have subfolders?
- if (!path.isEmpty()) {
- $ul = $("").appendTo($html);
- $.each(path.content, function (idx, entry) {
- $("").append(entry.updateTreeHtml()).appendTo($ul);
- });
- if (path.status === undefined || !path.treeOpen) {
- $ul.hide();
- }
- }
-
- // reflect folder status
- if (!isNaN(path.status)) {
- if (path.status === 200) {
- $a.find(".icon img").attr("src", "/h5ai/icons/16x16/folder-page.png");
- $a.append($("
"));
- } else {
- $html.addClass("error");
- $a.append($("" + path.status + ""));
- }
- }
- }
-
- if (path.html.$tree) {
- path.html.$tree.replaceWith($html);
- }
- path.html.$tree = $html;
-
- return $html;
- },
- init = function () {
-
- var $tds, $img, $a, splits;
-
- path = {
- // parentFolder: undefined,
- // label: undefined,
- // date: undefined,
- // size: undefined,
- // href: undefined,
- // absHref: undefined,
- // alt: undefined,
- // icon16: undefined,
- // icon48: undefined,
- // isFolder: undefined,
- // isParentFolder: undefined,
- // isCurrentFolder: undefined,
- // isDomain: undefined,
-
- status: undefined, // undefined, "h5ai" or HTTP response code
- content: undefined, // associative array path.absHref -> path
- html: {
- $crumb: undefined,
- $extended: undefined,
- $tree: undefined
- },
- treeOpen: false,
-
- isEmpty: isEmpty,
- onClick: onClick,
- updateHtml: updateHtml,
- updateCrumbHtml: updateCrumbHtml,
- updateExtendedHtml: updateExtendedHtml,
- updateTreeHtml: updateTreeHtml
- };
-
- if (!pathCache.pathEndsWithSlash(folder)) {
- folder += "/";
- }
-
- if (tableRow) {
- $tds = $(tableRow).find("td");
- $img = $tds.eq(0).find("img");
- $a = $tds.eq(1).find("a");
-
- path.parentFolder = folder;
- path.label = $a.text();
- path.date = $tds.eq(2).text();
- path.size = $tds.eq(3).text();
- path.href = $a.attr("href");
- path.alt = $img.attr("alt");
- path.icon16 = $img.attr("src");
- } else {
- splits = pathCache.splitPathname(folder);
-
- path.parentFolder = splits[0];
- path.label = checkedDecodeUri(splits[1]);
- if (path.label === "/") {
- path.label = checkedDecodeUri(document.domain) + "/";
- }
- path.date = "";
- path.size = "";
- path.href = splits[1];
- path.alt = "[DIR]";
- path.icon16 = "/h5ai/icons/16x16/folder.png";
- }
-
- if (pathCache.pathEndsWithSlash(path.label)) {
- path.label = path.label.slice(0, -1);
- }
-
- path.icon48 = path.icon16.replace("16x16", "48x48");
- path.isFolder = (path.alt === "[DIR]");
- path.isParentFolder = (path.isFolder && path.label === "Parent Directory");
- 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 = checkedDecodeUri(document.domain);
- } else {
- path.label = checkedDecodeUri(pathCache.splitPathname(pathCache.splitPathname(path.parentFolder)[0])[1].slice(0, -1));
- }
- }
- };
-
- init();
-
- return path;
-};
-
-
-Objects.PathCache = function () {
-
- var pathCache,
- cache = {},
- rePathnameSplit = /^(\/(.*\/)*)([^\/]+\/?)$/,
- rePathEndsWithSlash = /\/$/,
- splitPathname = function (pathname) {
-
- var match;
-
- if (pathname === "/") {
- return ["", "/"];
- }
- match = rePathnameSplit.exec(pathname);
- return [match[1], match[3]];
- },
- pathEndsWithSlash = function (pathname) {
-
- return rePathEndsWithSlash.test(pathname);
- },
- getAbsHref = function (folder, tableRow) {
-
- var $a, isParentFolder, href;
-
- if (!pathEndsWithSlash(folder)) {
- folder += "/";
- }
- if (!tableRow) {
- return folder;
- }
- $a = $(tableRow).find("td").eq(1).find("a");
- isParentFolder = ($a.text() === "Parent Directory");
- href = $a.attr("href");
- return isParentFolder ? undefined : folder + href;
- },
- getPath = function (folder, tableRow) {
-
- var absHref = getAbsHref(folder, tableRow),
- path = cache[absHref];
-
- if (!path) {
- path = new Objects.Path(pathCache, folder, tableRow);
- if (!path.isParentFolder) {
- cache[path.absHref] = path;
- }
- }
-
- return path;
- };
-
- pathCache = {
- splitPathname: splitPathname,
- pathEndsWithSlash: pathEndsWithSlash,
- getPath: getPath,
- cache: cache
- };
-
- return pathCache;
-};
diff --git a/src/h5ai/js/main-js.js b/src/h5ai/js/main-js.js
index ff51664c..9aca265f 100644
--- a/src/h5ai/js/main-js.js
+++ b/src/h5ai/js/main-js.js
@@ -6,28 +6,35 @@
(function($) {
"use strict";
- var Objects = {},
- pathCache, h5ai, extended, tree;
+ var H5aiJs = {
+ factory: {},
+ init: function () {
+ this.h5ai = new this.factory.H5ai(h5aiOptions, h5aiLangs);
+ this.pathCache = new this.factory.PathCache();
+ this.connector = new this.factory.Connector();
+ this.html = new this.factory.Html();
+ this.extended = new this.factory.Extended();
- // @include "inc/h5ai.js"
- // @include "inc/path.js"
- // @include "inc/extended.js"
- // @include "inc/tree.js"
+ this.extended.init();
+ this.connector.init();
+ this.h5ai.init();
- pathCache = new Objects.PathCache();
- h5ai = new Objects.H5ai(h5aiOptions, h5aiLangs);
- extended = new Objects.Extended(pathCache, h5ai);
- tree = new Objects.Tree(pathCache, h5ai);
+ $.h5ai = {
+ click: $.proxy(this.h5ai.pathClick, this.h5ai)
+ };
+ }
+ };
- $.h5ai = {
- click: $.proxy(h5ai.pathClick, h5ai)
- };
+ // @include "inc/H5ai.js"
+ // @include "inc/Path.js"
+ // @include "inc/PathCache.js"
+ // @include "inc/Connector.js"
+ // @include "inc/Html.js"
+ // @include "inc/Extended.js"
$(function () {
- extended.init();
- tree.init();
- h5ai.init();
+ H5aiJs.init();
});
}(jQuery));
diff --git a/src/h5ai/js/main-php.js b/src/h5ai/js/main-php.js
index 77e5fb6d..570b01cf 100644
--- a/src/h5ai/js/main-php.js
+++ b/src/h5ai/js/main-php.js
@@ -6,22 +6,26 @@
(function($) {
"use strict";
- var Objects = {},
- h5ai;
+ var H5aiJs = {
+ factory: {},
+ init: function () {
+ this.h5ai = new this.factory.H5ai(h5aiOptions, h5aiLangs);
- // @include "inc/h5ai.js"
+ this.h5ai.init();
+ $("#tree").scrollpanel();
+ this.h5ai.shiftTree(false, true);
- h5ai = new Objects.H5ai(h5aiOptions, h5aiLangs);
+ $.h5ai = {
+ click: $.proxy(this.h5ai.pathClick, this.h5ai)
+ };
+ }
+ };
- $.h5ai = {
- click: $.proxy(h5ai.pathClick, h5ai)
- };
+ // @include "inc/H5ai.js"
$(function () {
- h5ai.init();
- $("#tree").scrollpanel();
- h5ai.shiftTree(false, true);
+ H5aiJs.init();
});
}(jQuery));
From caced60eaa2f6d7208c910aa14b07884ec365c28 Mon Sep 17 00:00:00 2001
From: Lars Jung
Date: Thu, 6 Oct 2011 05:12:29 +0200
Subject: [PATCH 2/4] More refactorings.
---
build.properties | 2 +-
src/h5ai/js/inc/Extended.js | 20 ++-
src/h5ai/js/inc/H5ai.js | 44 +++----
src/h5ai/js/inc/Path.js | 167 ++++++++++++--------------
src/h5ai/js/inc/PathCache.js | 15 +--
src/h5ai/js/inc/jquery.scrollpanel.js | 40 +++---
src/h5ai/js/inc/jquery.utils.js | 21 ++--
src/h5ai/js/main-js.js | 1 +
src/h5ai/js/main-php.js | 1 +
tools/wepp.ant.xml | 4 +-
10 files changed, 150 insertions(+), 165 deletions(-)
diff --git a/build.properties b/build.properties
index 9ea727a9..061dc895 100644
--- a/build.properties
+++ b/build.properties
@@ -16,5 +16,5 @@ release.dir = release
# tools
-wepp = tools/wepp
+tool.wepp = tools/wepp
diff --git a/src/h5ai/js/inc/Extended.js b/src/h5ai/js/inc/Extended.js
index 486107c2..d5acd5a4 100644
--- a/src/h5ai/js/inc/Extended.js
+++ b/src/h5ai/js/inc/Extended.js
@@ -99,18 +99,14 @@ H5aiJs.factory.Extended = function () {
$(".folderCount").text($("#extended .entry.folder:not(.parentfolder)").size());
$(".fileCount").text($("#extended .entry.file").size());
- },
- init = function () {
-
- initTitle();
- initBreadcrumb();
- initExtendedView();
- customize();
- initCounts();
- },
- extended = {
- init: init
};
- return extended;
+ this.init = function () {
+
+ initTitle();
+ initBreadcrumb();
+ initExtendedView();
+ customize();
+ initCounts();
+ };
};
diff --git a/src/h5ai/js/inc/H5ai.js b/src/h5ai/js/inc/H5ai.js
index 79779d7d..70a4df45 100644
--- a/src/h5ai/js/inc/H5ai.js
+++ b/src/h5ai/js/inc/H5ai.js
@@ -2,7 +2,8 @@
H5aiJs.factory.H5ai = function (options, langs) {
- var defaults = {
+ var $window = $(window),
+ defaults = {
store: {
viewmode: "h5ai.viewmode",
lang: "h5ai.lang"
@@ -41,7 +42,7 @@ H5aiJs.factory.H5ai = function (options, langs) {
triggerPathClick = function (path, context) {
$.each(settings.callbacks.pathClick, function (idx, callback) {
- callback.call(window, path, context);
+ callback(path, context);
});
},
getViewmode = function () {
@@ -82,7 +83,7 @@ H5aiJs.factory.H5ai = function (options, langs) {
var adjustTopSpace = function () {
- var winHeight = $(window).height(),
+ var winHeight = $window.height(),
navHeight = $("body > nav").outerHeight(),
footerHeight = $("body > footer").outerHeight(),
contentSpacing = 50,
@@ -103,7 +104,7 @@ H5aiJs.factory.H5ai = function (options, langs) {
} catch (err) {}
};
- $(window).resize(function () {
+ $window.resize(function () {
adjustTopSpace();
});
adjustTopSpace();
@@ -141,7 +142,7 @@ H5aiJs.factory.H5ai = function (options, langs) {
$(".status.default").show();
$(".status.dynamic").empty().hide();
}
- );
+ );
},
shiftTree = function (forceVisible, dontAnimate) {
@@ -168,7 +169,7 @@ H5aiJs.factory.H5ai = function (options, langs) {
function () { shiftTree(true); },
function () { shiftTree(); }
);
- $(window).resize(function () { shiftTree(); });
+ $window.resize(function () { shiftTree(); });
shiftTree(false, true);
},
linkHoverStates = function () {
@@ -266,7 +267,9 @@ H5aiJs.factory.H5ai = function (options, langs) {
$indicator.addClass("open");
$entry.find("> .content").replaceWith($content);
$("#tree").get(0).updateScrollbar();
- initIndicators();
+ $content.find(".indicator:not(.initiated)")
+ .click(onIndicatorClick)
+ .addClass("initiated");
}
});
} else if ($indicator.hasClass("open")) {
@@ -285,16 +288,14 @@ H5aiJs.factory.H5ai = function (options, langs) {
},
initIndicators = function () {
- $("#tree .entry.folder .indicator:not(.initiated)").each(function () {
-
- $(this).addClass("initiated").click(onIndicatorClick);
- });
+ $("#tree .entry.folder .indicator:not(.initiated)")
+ .click(onIndicatorClick)
+ .addClass("initiated");
},
initZippedDownload = function () {
var x = 0,
y = 0,
- $window = $(window),
selected = function (hrefs) {
var query, idx;
@@ -377,16 +378,15 @@ H5aiJs.factory.H5ai = function (options, langs) {
localize(langs, settings.lang, settings.useBrowserLang);
initIndicators();
initZippedDownload();
- },
- h5ai = {
- settings: settings,
- shiftTree: shiftTree,
- linkHoverStates: linkHoverStates,
- pathClick: pathClick,
- triggerPathClick: triggerPathClick,
- initIndicators: initIndicators,
- init: init
};
- return h5ai;
+ return {
+ settings: settings,
+ shiftTree: shiftTree,
+ linkHoverStates: linkHoverStates,
+ pathClick: pathClick,
+ triggerPathClick: triggerPathClick,
+ initIndicators: initIndicators,
+ init: init
+ };
};
diff --git a/src/h5ai/js/inc/Path.js b/src/h5ai/js/inc/Path.js
index 923944b4..03c1d5ba 100644
--- a/src/h5ai/js/inc/Path.js
+++ b/src/h5ai/js/inc/Path.js
@@ -2,104 +2,95 @@
H5aiJs.factory.Path = function (folder, tableRow) {
- var path,
- checkedDecodeUri = function (uri) {
+ var checkedDecodeUri = function (uri) {
try { return decodeURI(uri); } catch (err) {}
return uri;
},
- isEmpty = function () {
+ $tds, $img, $a, splits;
- return !path.content || $.isEmptyObject(path.content);
- },
- onClick = function (context) {
+ // parentFolder: undefined,
+ // label: undefined,
+ // date: undefined,
+ // size: undefined,
+ // href: undefined,
+ // absHref: undefined,
+ // alt: undefined,
+ // icon16: undefined,
+ // icon48: undefined,
+ // isFolder: undefined,
+ // isParentFolder: undefined,
+ // isCurrentFolder: undefined,
+ // isDomain: undefined,
- H5aiJs.h5ai.triggerPathClick(path, context);
- },
- init = function () {
+ this.status = undefined; // undefined, "h5ai" or HTTP response code
+ this.content = undefined; // associative array path.absHref -> path
+ this.html = {
+ $crumb: undefined,
+ $extended: undefined,
+ $tree: undefined
+ };
+ this.treeOpen = false;
+
+ if (!H5aiJs.pathCache.pathEndsWithSlash(folder)) {
+ folder += "/";
+ }
- var $tds, $img, $a, splits;
+ if (tableRow) {
+ $tds = $(tableRow).find("td");
+ $img = $tds.eq(0).find("img");
+ $a = $tds.eq(1).find("a");
- path = {
- // parentFolder: undefined,
- // label: undefined,
- // date: undefined,
- // size: undefined,
- // href: undefined,
- // absHref: undefined,
- // alt: undefined,
- // icon16: undefined,
- // icon48: undefined,
- // isFolder: undefined,
- // isParentFolder: undefined,
- // isCurrentFolder: undefined,
- // isDomain: undefined,
+ this.parentFolder = folder;
+ this.label = $a.text();
+ this.date = $tds.eq(2).text();
+ this.size = $tds.eq(3).text();
+ this.href = $a.attr("href");
+ this.alt = $img.attr("alt");
+ this.icon16 = $img.attr("src");
+ } else {
+ splits = H5aiJs.pathCache.splitPathname(folder);
- status: undefined, // undefined, "h5ai" or HTTP response code
- content: undefined, // associative array path.absHref -> path
- html: {
- $crumb: undefined,
- $extended: undefined,
- $tree: undefined
- },
- treeOpen: false,
+ this.parentFolder = splits[0];
+ this.label = checkedDecodeUri(splits[1]);
+ if (this.label === "/") {
+ this.label = checkedDecodeUri(document.domain) + "/";
+ }
+ this.date = "";
+ this.size = "";
+ this.href = splits[1];
+ this.alt = "[DIR]";
+ this.icon16 = "/h5ai/icons/16x16/folder.png";
+ }
- isEmpty: isEmpty,
- onClick: onClick
- };
+ if (H5aiJs.pathCache.pathEndsWithSlash(this.label)) {
+ this.label = this.label.slice(0, -1);
+ }
- if (!H5aiJs.pathCache.pathEndsWithSlash(folder)) {
- folder += "/";
- }
+ this.icon48 = this.icon16.replace("16x16", "48x48");
+ this.isFolder = (this.alt === "[DIR]");
+ this.isParentFolder = (this.isFolder && this.label === "Parent Directory");
+ this.absHref = this.isParentFolder ? this.href : this.parentFolder + this.href;
+ this.isCurrentFolder = (this.absHref === document.location.pathname);
+ this.isDomain = (this.absHref === "/");
- if (tableRow) {
- $tds = $(tableRow).find("td");
- $img = $tds.eq(0).find("img");
- $a = $tds.eq(1).find("a");
-
- path.parentFolder = folder;
- path.label = $a.text();
- path.date = $tds.eq(2).text();
- path.size = $tds.eq(3).text();
- path.href = $a.attr("href");
- path.alt = $img.attr("alt");
- path.icon16 = $img.attr("src");
- } else {
- splits = H5aiJs.pathCache.splitPathname(folder);
-
- path.parentFolder = splits[0];
- path.label = checkedDecodeUri(splits[1]);
- if (path.label === "/") {
- path.label = checkedDecodeUri(document.domain) + "/";
- }
- path.date = "";
- path.size = "";
- path.href = splits[1];
- path.alt = "[DIR]";
- path.icon16 = "/h5ai/icons/16x16/folder.png";
- }
-
- if (H5aiJs.pathCache.pathEndsWithSlash(path.label)) {
- path.label = path.label.slice(0, -1);
- }
-
- path.icon48 = path.icon16.replace("16x16", "48x48");
- path.isFolder = (path.alt === "[DIR]");
- path.isParentFolder = (path.isFolder && path.label === "Parent Directory");
- path.absHref = path.isParentFolder ? path.href : path.parentFolder + path.href;
- path.isCurrentFolder = (path.absHref === document.location.pathname);
- path.isDomain = (path.absHref === "/");
-
- if (path.isParentFolder && H5aiJs.h5ai.settings.setParentFolderLabels) {
- if (path.isDomain) {
- path.label = checkedDecodeUri(document.domain);
- } else {
- path.label = checkedDecodeUri(H5aiJs.pathCache.splitPathname(H5aiJs.pathCache.splitPathname(path.parentFolder)[0])[1].slice(0, -1));
- }
- }
- };
-
- init();
-
- return path;
+ if (this.isParentFolder && H5aiJs.h5ai.settings.setParentFolderLabels) {
+ if (this.isDomain) {
+ this.label = checkedDecodeUri(document.domain);
+ } else {
+ this.label = checkedDecodeUri(H5aiJs.pathCache.splitPathname(H5aiJs.pathCache.splitPathname(this.parentFolder)[0])[1].slice(0, -1));
+ }
+ }
+};
+
+H5aiJs.factory.Path.prototype = {
+
+ isEmpty: function () {
+
+ return !this.content || $.isEmptyObject(this.content);
+ },
+ onClick: function (context) {
+
+ H5aiJs.h5ai.triggerPathClick(this, context);
+ }
};
diff --git a/src/h5ai/js/inc/PathCache.js b/src/h5ai/js/inc/PathCache.js
index 90c4edca..f0689616 100644
--- a/src/h5ai/js/inc/PathCache.js
+++ b/src/h5ai/js/inc/PathCache.js
@@ -2,8 +2,7 @@
H5aiJs.factory.PathCache = function () {
- var pathCache,
- cache = {},
+ var cache = {},
rePathnameSplit = /^(\/(.*\/)*)([^\/]+\/?)$/,
rePathEndsWithSlash = /\/$/,
splitPathname = function (pathname) {
@@ -50,12 +49,8 @@ H5aiJs.factory.PathCache = function () {
return path;
};
- pathCache = {
- splitPathname: splitPathname,
- pathEndsWithSlash: pathEndsWithSlash,
- getPath: getPath,
- cache: cache
- };
-
- return pathCache;
+ this.splitPathname = splitPathname;
+ this.pathEndsWithSlash = pathEndsWithSlash;
+ this.getPath = getPath;
+ this.cache = cache;
};
diff --git a/src/h5ai/js/inc/jquery.scrollpanel.js b/src/h5ai/js/inc/jquery.scrollpanel.js
index af039ce7..78b5af6e 100644
--- a/src/h5ai/js/inc/jquery.scrollpanel.js
+++ b/src/h5ai/js/inc/jquery.scrollpanel.js
@@ -4,15 +4,15 @@
"use strict";
var init = function (htmlElement) {
-
+
var $element = $(htmlElement),
$scrollbar, $drag, $wrapper, $content, mouseOffsetY, updateId,
update, scroll;
-
+
if (!$element.css("position") || $element.css("position") === "static") {
$element.css("position", "relative");
}
-
+
$scrollbar = $("");
$drag = $("").appendTo($scrollbar);
$element
@@ -21,25 +21,25 @@
$wrapper = $element.find("> .wrapper");
$content = $wrapper.find("> .content");
mouseOffsetY = 0;
-
+
update = function (repeat) {
-
+
var visibleHeight, contentHeight, scrollTop, scrollTopFrac, visVertFrac;
-
+
if (updateId && !repeat) {
clearInterval(updateId);
updateId = undefined;
} else if (!updateId && repeat) {
updateId = setInterval(function() { update(true); }, 50);
}
-
+
$wrapper.css("height", $element.height());
visibleHeight = $element.height();
contentHeight = $content.outerHeight();
scrollTop = $wrapper.scrollTop();
scrollTopFrac = scrollTop / contentHeight;
visVertFrac = Math.min(visibleHeight / contentHeight, 1);
-
+
if (visVertFrac < 1) {
$scrollbar
.fadeIn(50)
@@ -55,19 +55,19 @@
$scrollbar.fadeOut(50);
}
};
-
+
scroll = function (event) {
-
+
var clickFrac = (event.pageY - $scrollbar.offset().top - mouseOffsetY) / $scrollbar.height();
-
+
$wrapper.scrollTop($content.outerHeight() * clickFrac);
update();
event.preventDefault();
};
-
+
$element
.mousewheel(function (event, delta) {
-
+
$wrapper.scrollTop($wrapper.scrollTop() - 50 * delta);
update();
event.stopPropagation();
@@ -90,14 +90,14 @@
cursor: "pointer"
})
.mousedown(function (event) {
-
+
mouseOffsetY = $drag.outerHeight() / 2;
scroll(event);
$scrollbar.addClass("dragOn");
$(window)
.bind("mousemove", scroll)
.one("mouseup", function (event) {
-
+
$scrollbar.removeClass("dragOn");
$(window).unbind("mousemove", scroll);
scroll(event);
@@ -106,9 +106,9 @@
event.preventDefault();
})
.each(function () {
-
+
this.onselectstart = function () {
-
+
return false;
};
});
@@ -119,14 +119,14 @@
width: "100%"
})
.mousedown(function (event) {
-
+
mouseOffsetY = event.pageY - $drag.offset().top;
scroll(event);
$scrollbar.addClass("dragOn");
$(window)
.bind("mousemove", scroll)
.one("mouseup", function (event) {
-
+
$scrollbar.removeClass("dragOn");
$(window).unbind("mousemove", scroll);
scroll(event);
@@ -134,7 +134,7 @@
});
event.stopPropagation();
});
-
+
update();
};
diff --git a/src/h5ai/js/inc/jquery.utils.js b/src/h5ai/js/inc/jquery.utils.js
index 3d74e21b..02d9dac0 100644
--- a/src/h5ai/js/inc/jquery.utils.js
+++ b/src/h5ai/js/inc/jquery.utils.js
@@ -6,6 +6,7 @@
// http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
// modified
$.log = function () {
+
$.log.history = $.log.history || [];
$.log.history.push(arguments);
if (window.console) {
@@ -14,17 +15,17 @@
};
$.timer = (function () {
- var start = $.now(),
- last = start,
- timer = {
- log: function (label) {
- var now = $.now();
- $.log("timer", label, "+" + (now - last), "=" + (now - start));
- last = now;
- }
- };
- return timer;
+ var start = $.now(),
+ last = start;
+
+ return {
+ log: function (label) {
+ var now = $.now();
+ $.log("timer", label, "+" + (now - last), "=" + (now - start));
+ last = now;
+ }
+ };
}());
}(jQuery));
diff --git a/src/h5ai/js/main-js.js b/src/h5ai/js/main-js.js
index 9aca265f..d4275fd1 100644
--- a/src/h5ai/js/main-js.js
+++ b/src/h5ai/js/main-js.js
@@ -9,6 +9,7 @@
var H5aiJs = {
factory: {},
init: function () {
+
this.h5ai = new this.factory.H5ai(h5aiOptions, h5aiLangs);
this.pathCache = new this.factory.PathCache();
this.connector = new this.factory.Connector();
diff --git a/src/h5ai/js/main-php.js b/src/h5ai/js/main-php.js
index 570b01cf..13e02424 100644
--- a/src/h5ai/js/main-php.js
+++ b/src/h5ai/js/main-php.js
@@ -9,6 +9,7 @@
var H5aiJs = {
factory: {},
init: function () {
+
this.h5ai = new this.factory.H5ai(h5aiOptions, h5aiLangs);
this.h5ai.init();
diff --git a/tools/wepp.ant.xml b/tools/wepp.ant.xml
index 7bbb8d93..2339652e 100644
--- a/tools/wepp.ant.xml
+++ b/tools/wepp.ant.xml
@@ -6,7 +6,7 @@
-
+
@@ -20,7 +20,7 @@
-
+
From 3c23c7e95680728632103f22301076875a6d9157 Mon Sep 17 00:00:00 2001
From: Lars Jung
Date: Fri, 7 Oct 2011 16:38:30 +0200
Subject: [PATCH 3/4] Changes default language from to .
---
src/h5ai/options.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/h5ai/options.js b/src/h5ai/options.js
index 163b3298..02221cb7 100644
--- a/src/h5ai/options.js
+++ b/src/h5ai/options.js
@@ -57,7 +57,7 @@ h5aiOptions = {
* possible values. Adjust it to your needs. If lang is not found in
* h5aiLangs it defaults to "en".
*/
- "lang": null,
+ "lang": "en",
/*
* Try to use browser language, falls back to previous specified lang.
From 4a65ce61df83ec6d8afdae46873130c53e2fdfdd Mon Sep 17 00:00:00 2001
From: Lars Jung
Date: Sun, 30 Oct 2011 21:50:25 +0100
Subject: [PATCH 4/4] Improves file selection for zipped download. Zipped
download is now disabled by default.
---
src/h5ai/css/inc/extended.less | 4 +-
src/h5ai/footer.html | 4 +-
src/h5ai/header.html | 2 +-
src/h5ai/header.php | 6 +-
src/h5ai/js/inc/Extended.js | 4 +-
src/h5ai/js/inc/H5ai.js | 111 ++++++++++++------
src/h5ai/js/inc/jquery.utils.js | 31 -----
src/h5ai/js/inc/lib/amplify.min.js | 10 ++
.../js/{ => inc}/lib/jquery.fracs-core.min.js | 0
src/h5ai/js/{ => inc}/lib/jquery.min.js | 0
.../js/{ => inc}/lib/jquery.mousewheel.min.js | 0
.../js/inc/{ => lib}/jquery.scrollpanel.js | 2 +-
src/h5ai/js/lib/modernizr.min.js | 4 -
src/h5ai/js/libs.js | 7 ++
src/h5ai/js/main-js.js | 4 -
src/h5ai/js/main-php.js | 4 -
src/h5ai/js/modernizr.min.js | 4 +
src/h5ai/options.js | 4 +-
src/h5ai/php/zipcontent.php | 5 +-
src/js.htaccess | 3 +-
20 files changed, 109 insertions(+), 100 deletions(-)
delete mode 100644 src/h5ai/js/inc/jquery.utils.js
create mode 100644 src/h5ai/js/inc/lib/amplify.min.js
rename src/h5ai/js/{ => inc}/lib/jquery.fracs-core.min.js (100%)
rename src/h5ai/js/{ => inc}/lib/jquery.min.js (100%)
rename src/h5ai/js/{ => inc}/lib/jquery.mousewheel.min.js (100%)
rename src/h5ai/js/inc/{ => lib}/jquery.scrollpanel.js (99%)
delete mode 100644 src/h5ai/js/lib/modernizr.min.js
create mode 100644 src/h5ai/js/libs.js
create mode 100644 src/h5ai/js/modernizr.min.js
diff --git a/src/h5ai/css/inc/extended.less b/src/h5ai/css/inc/extended.less
index 6aa5b6d0..a89a2c1b 100644
--- a/src/h5ai/css/inc/extended.less
+++ b/src/h5ai/css/inc/extended.less
@@ -45,7 +45,7 @@
background-color: #f6f6f6;
color: #e80;
}
- &.selected {
+ &.selected:not(.selecting), &.selecting:not(.selected) {
border-color: rgba(240,100,0,0.2);
background-color: rgba(240,100,0,0.2);
}
@@ -193,7 +193,7 @@
border-color: #eee;
background-color: #f6f6f6;
}
- &.selected {
+ &.selected:not(.selecting), &.selecting:not(.selected) {
border-color: rgba(240,100,0,0.2);
background-color: rgba(240,100,0,0.2);
}
diff --git a/src/h5ai/footer.html b/src/h5ai/footer.html
index 1d81b3f8..07167e41 100644
--- a/src/h5ai/footer.html
+++ b/src/h5ai/footer.html
@@ -27,9 +27,7 @@
-
-
-
+
diff --git a/src/h5ai/header.php b/src/h5ai/header.php
index 79ec5817..6e645106 100644
--- a/src/h5ai/header.php
+++ b/src/h5ai/header.php
@@ -15,7 +15,7 @@
-
+
@@ -60,9 +60,7 @@
-
-
-
+
diff --git a/src/h5ai/js/inc/Extended.js b/src/h5ai/js/inc/Extended.js
index d5acd5a4..1de1bec1 100644
--- a/src/h5ai/js/inc/Extended.js
+++ b/src/h5ai/js/inc/Extended.js
@@ -95,7 +95,7 @@ H5aiJs.factory.Extended = function () {
}
});
},
- initCounts = function () {
+ initTotals = function () {
$(".folderCount").text($("#extended .entry.folder:not(.parentfolder)").size());
$(".fileCount").text($("#extended .entry.file").size());
@@ -107,6 +107,6 @@ H5aiJs.factory.Extended = function () {
initBreadcrumb();
initExtendedView();
customize();
- initCounts();
+ initTotals();
};
};
diff --git a/src/h5ai/js/inc/H5ai.js b/src/h5ai/js/inc/H5ai.js
index 70a4df45..6b3d1adb 100644
--- a/src/h5ai/js/inc/H5ai.js
+++ b/src/h5ai/js/inc/H5ai.js
@@ -1,12 +1,13 @@
-/*global window, $, H5aiJs, localStorage */
H5aiJs.factory.H5ai = function (options, langs) {
+ /*global window, $, amplify*/
var $window = $(window),
+ $document = $(document),
defaults = {
store: {
- viewmode: "h5ai.viewmode",
- lang: "h5ai.lang"
+ viewmode: "h5ai.pref.viewmode",
+ lang: "h5ai.pref.lang"
},
callbacks: {
pathClick: []
@@ -47,14 +48,14 @@ H5aiJs.factory.H5ai = function (options, langs) {
},
getViewmode = function () {
- var viewmode = localStorage.getItem(settings.store.viewmode);
+ var viewmode = amplify.store(settings.store.viewmode);
return $.inArray(viewmode, settings.viewmodes) >= 0 ? viewmode : settings.viewmodes[0];
},
applyViewmode = function (viewmode) {
if (viewmode) {
- localStorage.setItem(settings.store.viewmode, viewmode);
+ amplify.store(settings.store.viewmode, viewmode);
}
viewmode = getViewmode();
@@ -189,7 +190,7 @@ H5aiJs.factory.H5ai = function (options, langs) {
},
localize = function (langs, lang, useBrowserLang) {
- var storedLang = localStorage.getItem(settings.store.lang),
+ var storedLang = amplify.store(settings.store.lang),
browserLang, selected, key;
if (langs[storedLang]) {
@@ -219,7 +220,7 @@ H5aiJs.factory.H5ai = function (options, langs) {
},
initLangSelector = function (langs) {
- var idx, lang,
+ var $langOptions = $(".langOptions"),
sortedLangsKeys = [],
$ul;
@@ -235,18 +236,22 @@ H5aiJs.factory.H5ai = function (options, langs) {
.text(lang + " - " + langs[lang].lang)
.appendTo($ul)
.click(function () {
- localStorage.setItem(settings.store.lang, lang);
+ amplify.store(settings.store.lang, lang);
localize(langs, lang, false);
});
});
$("#langSelector .langOptions").append($ul);
$("#langSelector").hover(
function () {
- var $ele = $(".langOptions");
- $ele.css("top", "-" + $ele.outerHeight() + "px").stop(true, true).fadeIn();
+ $langOptions
+ .css("top", "-" + $langOptions.outerHeight() + "px")
+ .stop(true, true)
+ .fadeIn();
},
function () {
- $(".langOptions").stop(true, true).fadeOut();
+ $langOptions
+ .stop(true, true)
+ .fadeOut();
}
);
},
@@ -296,14 +301,23 @@ H5aiJs.factory.H5ai = function (options, langs) {
var x = 0,
y = 0,
- selected = function (hrefs) {
+ ctrl = false,
+ updateDownloadBtn = function () {
- var query, idx;
- $.each(hrefs, function (idx, href) {
- query = query ? query + ":" + href : href;
- });
- query = "/h5ai/php/zipcontent.php?hrefs=" + query;
- $("#download").show().find("a").attr("href", query);
+ var query,
+ href,
+ $selected = $("#extended a.selected");
+
+ if ($selected.size() > 0) {
+ $selected.each(function () {
+ href = $(this).attr("href");
+ query = query ? query + ":" + href : href;
+ });
+ query = "/h5ai/php/zipcontent.php?hrefs=" + query;
+ $("#download").show().find("a").attr("href", query);
+ } else {
+ $("#download").hide().find("a").attr("href", "#");
+ }
},
selectionUpdate = function (event) {
@@ -317,41 +331,45 @@ H5aiJs.factory.H5ai = function (options, langs) {
$("#selection-rect").css({left: l, top: t, width: w, height: h});
sel = $("#selection-rect").fracs("rect");
- $("#extended a").removeClass("selected").each(function () {
+ $("#extended a").removeClass("selecting").each(function () {
var $a = $(this),
rect = $a.fracs("rect"),
inter = sel.intersection(rect);
if (inter && !$a.closest(".entry").hasClass("folder-parent")) {
- $a.addClass("selected");
+ $a.addClass("selecting");
}
});
},
selectionEnd = function (event) {
event.preventDefault();
+ $document.unbind("mousemove", selectionUpdate);
$("#selection-rect").hide().css({left: 0, top: 0, width: 0, height: 0});
-
- $window.unbind("mousemove", selectionUpdate);
-
- var hrefs = [];
- $("#extended a.selected").each(function () {
- hrefs.push($(this).attr("href"));
- });
- if (hrefs.length > 0) {
- selected(hrefs);
- }
+ $("#extended a.selecting.selected").removeClass("selecting").removeClass("selected");
+ $("#extended a.selecting").removeClass("selecting").addClass("selected");
+ updateDownloadBtn();
},
selectionStart = function (event) {
- event.preventDefault();
+ var view = $.fracs.viewport();
+
x = event.pageX;
y = event.pageY;
- $("#download").hide().find("a").attr("href", "#");
- $("#extended a").removeClass("selected");
- $("#selection-rect").show().css({left: x, top: y, width: 0, height: 0});
+ if (x >= view.right || y >= view.bottom) {
+ // don't block the scrollbars
+ return;
+ }
- $window
+ event.preventDefault();
+ if (!ctrl) {
+ $("#extended a").removeClass("selected");
+ updateDownloadBtn();
+ }
+ $("#selection-rect").show().css({left: x, top: y, width: 0, height: 0});
+ selectionUpdate(event);
+
+ $document
.bind("mousemove", selectionUpdate)
.one("mouseup", selectionEnd);
},
@@ -359,12 +377,29 @@ H5aiJs.factory.H5ai = function (options, langs) {
event.stopPropagation();
return false;
+ },
+ noSelectionUnlessCtrl = function (event) {
+
+ if (!ctrl) {
+ noSelection(event);
+ }
};
if (settings.zippedDownload) {
- $("body>nav,body>footer,#tree,#extended a").bind("mousedown", noSelection);
- $("#extended a").live("mousedown", noSelection);
- $window.bind("mousedown", selectionStart);
+ $("body>nav,body>footer,#tree").bind("mousedown", noSelection);
+ $("#extended .entry a").bind("mousedown", noSelectionUnlessCtrl).live("mousedown", noSelectionUnlessCtrl);
+ $document
+ .bind("mousedown", selectionStart)
+ .keydown(function (event) {
+ if (event.keyCode === 17) {
+ ctrl = true;
+ }
+ })
+ .keyup(function (event) {
+ if (event.keyCode === 17) {
+ ctrl = false;
+ }
+ });
}
},
init = function () {
diff --git a/src/h5ai/js/inc/jquery.utils.js b/src/h5ai/js/inc/jquery.utils.js
deleted file mode 100644
index 02d9dac0..00000000
--- a/src/h5ai/js/inc/jquery.utils.js
+++ /dev/null
@@ -1,31 +0,0 @@
-/*global window, jQuery */
-
-(function ($) {
- "use strict";
-
- // http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
- // modified
- $.log = function () {
-
- $.log.history = $.log.history || [];
- $.log.history.push(arguments);
- if (window.console) {
- window.console.log(Array.prototype.slice.call(arguments));
- }
- };
-
- $.timer = (function () {
-
- var start = $.now(),
- last = start;
-
- return {
- log: function (label) {
- var now = $.now();
- $.log("timer", label, "+" + (now - last), "=" + (now - start));
- last = now;
- }
- };
- }());
-
-}(jQuery));
diff --git a/src/h5ai/js/inc/lib/amplify.min.js b/src/h5ai/js/inc/lib/amplify.min.js
new file mode 100644
index 00000000..6e6a9a95
--- /dev/null
+++ b/src/h5ai/js/inc/lib/amplify.min.js
@@ -0,0 +1,10 @@
+/*!
+ * AmplifyJS 1.0.0 - Core, Store, Request
+ *
+ * Copyright 2011 appendTo LLC. (http://appendto.com/team)
+ * Dual licensed under the MIT or GPL licenses.
+ * http://appendto.com/open-source-licenses
+ *
+ * http://amplifyjs.com
+ */
+(function(a,b){var c=[].slice,d={},e=a.amplify={publish:function(a){var b=c.call(arguments,1),e,f,g=0,h;if(!d[a])return!0;for(f=d[a].length;g=0;i--)if(d[a][i].priority<=e){d[a].splice(i+1,0,j);return c}d[a].unshift(j)}return c},unsubscribe:function(a,b){if(!!d[a]){var c=d[a].length,e=0;for(;e",a,""].join(""),k.id=i,k.innerHTML+=f,g.appendChild(k),h=c(k,a),k.parentNode.removeChild(k);return!!h},w=function(b){if(a.matchMedia)return matchMedia(b).matches;var c;v("@media "+b+" { #"+i+" { position: absolute; } }",function(b){c=(a.getComputedStyle?getComputedStyle(b,null):b.currentStyle).position=="absolute"});return c},x=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=D(e[d],"function"),D(e[d],c)||(e[d]=c),e.removeAttribute(d))),e=null;return f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),y,z={}.hasOwnProperty,A;!D(z,c)&&!D(z.call,c)?A=function(a,b){return z.call(a,b)}:A=function(a,b){return b in a&&D(a.constructor.prototype[b],c)};var H=function(c,d){var f=c.join(""),g=d.length;v(f,function(c,d){var f=b.styleSheets[b.styleSheets.length-1],h=f.cssRules&&f.cssRules[0]?f.cssRules[0].cssText:f.cssText||"",i=c.childNodes,j={};while(g--)j[i[g].id]=i[g];e.touch="ontouchstart"in a||j.touch.offsetTop===9,e.csstransforms3d=j.csstransforms3d.offsetLeft===9,e.generatedcontent=j.generatedcontent.offsetHeight>=1,e.fontface=/src/i.test(h)&&h.indexOf(d.split(" ")[0])===0},g,d)}(['@font-face {font-family:"font";src:url("https://")}',["@media (",o.join("touch-enabled),("),i,")","{#touch{top:9px;position:absolute}}"].join(""),["@media (",o.join("transform-3d),("),i,")","{#csstransforms3d{left:9px;position:absolute}}"].join(""),['#generatedcontent:after{content:"',m,'"}'].join("")],["fontface","touch","csstransforms3d","generatedcontent"]);r.flexbox=function(){function c(a,b,c,d){a.style.cssText=o.join(b+":"+c+";")+(d||"")}function a(a,b,c,d){b+=":",a.style.cssText=(b+o.join(c+";"+b)).slice(0,-b.length)+(d||"")}var d=b.createElement("div"),e=b.createElement("div");a(d,"display","box","width:42px;padding:0;"),c(e,"box-flex","1","width:10px;"),d.appendChild(e),g.appendChild(d);var f=e.offsetWidth===42;d.removeChild(e),g.removeChild(d);return f},r.canvas=function(){var a=b.createElement("canvas");return!!a.getContext&&!!a.getContext("2d")},r.canvastext=function(){return!!e.canvas&&!!D(b.createElement("canvas").getContext("2d").fillText,"function")},r.webgl=function(){return!!a.WebGLRenderingContext},r.touch=function(){return e.touch},r.geolocation=function(){return!!navigator.geolocation},r.postmessage=function(){return!!a.postMessage},r.websqldatabase=function(){var b=!!a.openDatabase;return b},r.indexedDB=function(){for(var b=-1,c=p.length;++b7)},r.history=function(){return!!a.history&&!!history.pushState},r.draganddrop=function(){return x("dragstart")&&x("drop")},r.websockets=function(){for(var b=-1,c=p.length;++b";return(a.firstChild&&a.firstChild.namespaceURI)==q.svg},r.smil=function(){return!!b.createElementNS&&/SVG/.test(n.call(b.createElementNS(q.svg,"animate")))},r.svgclippaths=function(){return!!b.createElementNS&&/SVG/.test(n.call(b.createElementNS(q.svg,"clipPath")))};for(var J in r)A(r,J)&&(y=J.toLowerCase(),e[y]=r[J](),u.push((e[y]?"":"no-")+y));e.input||I(),e.addTest=function(a,b){if(typeof a=="object")for(var d in a)A(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return;b=typeof b=="boolean"?b:!!b(),g.className+=" "+(b?"":"no-")+a,e[a]=b}return e},B(""),j=l=null,a.attachEvent&&function(){var a=b.createElement("div");a.innerHTML="";return a.childNodes.length!==1}()&&function(a,b){function s(a){var b=-1;while(++b=u.minw)&&(!u.maxw||u.maxw&&l<=u.maxw))m[u.media]||(m[u.media]=[]),m[u.media].push(f[u.rules])}for(var t in g)g[t]&&g[t].parentNode===j&&j.removeChild(g[t]);for(var t in m){var v=c.createElement("style"),w=m[t].join("\n");v.type="text/css",v.media=t,v.styleSheet?v.styleSheet.cssText=w:v.appendChild(c.createTextNode(w)),n.appendChild(v),g.push(v)}j.insertBefore(n,o.nextSibling)}},s=function(a,b){var c=t();if(!!c){c.open("GET",a,!0),c.onreadystatechange=function(){c.readyState==4&&(c.status==200||c.status==304)&&b(c.responseText)};if(c.readyState==4)return;c.send()}},t=function(){var a=!1,b=[function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new XMLHttpRequest}],c=b.length;while(c--){try{a=b[c]()}catch(d){continue}break}return function(){return a}}();m(),respond.update=m,a.addEventListener?a.addEventListener("resize",u,!1):a.attachEvent&&a.attachEvent("onresize",u)}}(this,Modernizr.mq("only all")),function(a,b,c){function k(a){return!a||a=="loaded"||a=="complete"}function j(){var a=1,b=-1;while(p.length- ++b)if(p[b].s&&!(a=p[b].r))break;a&&g()}function i(a){var c=b.createElement("script"),d;c.src=a.s,c.onreadystatechange=c.onload=function(){!d&&k(c.readyState)&&(d=1,j(),c.onload=c.onreadystatechange=null)},m(function(){d||(d=1,j())},H.errorTimeout),a.e?c.onload():n.parentNode.insertBefore(c,n)}function h(a){var c=b.createElement("link"),d;c.href=a.s,c.rel="stylesheet",c.type="text/css",!a.e&&(w||r)?function a(b){m(function(){if(!d)try{b.sheet.cssRules.length?(d=1,j()):a(b)}catch(c){c.code==1e3||c.message=="security"||c.message=="denied"?(d=1,m(function(){j()},0)):a(b)}},0)}(c):(c.onload=function(){d||(d=1,m(function(){j()},0))},a.e&&c.onload()),m(function(){d||(d=1,j())},H.errorTimeout),!a.e&&n.parentNode.insertBefore(c,n)}function g(){var a=p.shift();q=1,a?a.t?m(function(){a.t=="c"?h(a):i(a)},0):(a(),j()):q=0}function f(a,c,d,e,f,h){function i(){!o&&k(l.readyState)&&(r.r=o=1,!q&&j(),l.onload=l.onreadystatechange=null,m(function(){u.removeChild(l)},0))}var l=b.createElement(a),o=0,r={t:d,s:c,e:h};l.src=l.data=c,!s&&(l.style.display="none"),l.width=l.height="0",a!="object"&&(l.type=d),l.onload=l.onreadystatechange=i,a=="img"?l.onerror=i:a=="script"&&(l.onerror=function(){r.e=r.r=1,g()}),p.splice(e,0,r),u.insertBefore(l,s?null:n),m(function(){o||(u.removeChild(l),r.r=r.e=o=1,j())},H.errorTimeout)}function e(a,b,c){var d=b=="c"?z:y;q=0,b=b||"j",C(a)?f(d,a,b,this.i++,l,c):(p.splice(this.i++,0,a),p.length==1&&g());return this}function d(){var a=H;a.loader={load:e,i:0};return a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=r&&!s,u=s?l:n.parentNode,v=a.opera&&o.call(a.opera)=="[object Opera]",w="webkitAppearance"in l.style,x=w&&"async"in b.createElement("script"),y=r?"object":v||x?"img":"script",z=w?"img":y,A=Array.isArray||function(a){return o.call(a)=="[object Array]"},B=function(a){return typeof a=="object"},C=function(a){return typeof a=="string"},D=function(a){return o.call(a)=="[object Function]"},E=[],F={},G,H;H=function(a){function f(a){var b=a.split("!"),c=E.length,d=b.pop(),e=b.length,f={url:d,origUrl:d,prefixes:b},g,h;for(h=0;h",a,""].join(""),k.id=i,k.innerHTML+=f,g.appendChild(k),h=c(k,a),k.parentNode.removeChild(k);return!!h},v=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=B(e[d],"function"),B(e[d],c)||(e[d]=c),e.removeAttribute(d))),e=null;return f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),w,x={}.hasOwnProperty,y;!B(x,c)&&!B(x.call,c)?y=function(a,b){return x.call(a,b)}:y=function(a,b){return b in a&&B(a.constructor.prototype[b],c)};var F=function(a,c){var d=a.join(""),f=c.length;u(d,function(a,c){var d=b.styleSheets[b.styleSheets.length-1],g=d.cssRules&&d.cssRules[0]?d.cssRules[0].cssText:d.cssText||"",h=a.childNodes,i={};while(f--)i[h[f].id]=h[f];e.csstransforms3d=i.csstransforms3d.offsetLeft===9,e.generatedcontent=i.generatedcontent.offsetHeight>=1,e.fontface=/src/i.test(g)&&g.indexOf(c.split(" ")[0])===0},f,c)}(['@font-face {font-family:"font";src:url("https://")}',["@media (",o.join("transform-3d),("),i,")","{#csstransforms3d{left:9px;position:absolute}}"].join(""),['#generatedcontent:after{content:"',m,'";visibility:hidden}'].join("")],["fontface","csstransforms3d","generatedcontent"]);q.flexbox=function(){function c(a,b,c,d){a.style.cssText=o.join(b+":"+c+";")+(d||"")}function a(a,b,c,d){b+=":",a.style.cssText=(b+o.join(c+";"+b)).slice(0,-b.length)+(d||"")}var d=b.createElement("div"),e=b.createElement("div");a(d,"display","box","width:42px;padding:0;"),c(e,"box-flex","1","width:10px;"),d.appendChild(e),g.appendChild(d);var f=e.offsetWidth===42;d.removeChild(e),g.removeChild(d);return f},q.canvas=function(){var a=b.createElement("canvas");return!!a.getContext&&!!a.getContext("2d")},q.canvastext=function(){return!!e.canvas&&!!B(b.createElement("canvas").getContext("2d").fillText,"function")},q.postmessage=function(){return!!a.postMessage},q.websqldatabase=function(){var b=!!a.openDatabase;return b},q.indexedDB=function(){for(var b=-1,c=p.length;++b7)},q.history=function(){return!!a.history&&!!history.pushState},q.draganddrop=function(){return v("dragstart")&&v("drop")},q.websockets=function(){for(var b=-1,c=p.length;++b";return a.childNodes.length!==1}()&&function(a,b){function s(a){var b=-1;while(++bzip($hrefs);
if ($zipFile !== false) {
@@ -22,7 +21,7 @@ if ($zipFile !== false) {
header("Connection: close");
readfile($zipFile);
} else {
- echo "sorry, something went wrong while building the zip.";
+ echo "2: something went wrong while building the zip";
}
?>
\ No newline at end of file
diff --git a/src/js.htaccess b/src/js.htaccess
index 39436a20..d18f8cff 100644
--- a/src/js.htaccess
+++ b/src/js.htaccess
@@ -27,7 +27,8 @@ IndexIgnore h5ai h5ai.header.html h5ai.footer.html
# table options
################################
-# syntax for default sort order is: IndexOrderDefault Ascending|Descending Name|Date|Size
+# syntax for default sort order is:
+# IndexOrderDefault Ascending|Descending Name|Date|Size
IndexOrderDefault Ascending Name
IndexOptions Type=text/html;h5ai=%BUILD_VERSION%