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 = $("