diff --git a/src/_h5ai/client/css/inc/bottombar.less b/src/_h5ai/client/css/inc/bottombar.less index 9d9658ac..9d3b57df 100644 --- a/src/_h5ai/client/css/inc/bottombar.less +++ b/src/_h5ai/client/css/inc/bottombar.less @@ -24,18 +24,19 @@ } } .left { + position: absolute; + left: 0; display: block; padding: 0 8px; - float: left } .center { display: block; - margin: 0 100px; } .right { + position: absolute; + right: 0; display: block; padding: 0 8px; - float: right } .noJsMsg { color: #c33; diff --git a/src/_h5ai/client/css/inc/fallback-table.less b/src/_h5ai/client/css/inc/fallback-table.less index 963775f8..c2180336 100644 --- a/src/_h5ai/client/css/inc/fallback-table.less +++ b/src/_h5ai/client/css/inc/fallback-table.less @@ -57,6 +57,8 @@ td:nth-child(1), th:nth-child(1) { text-align: center; width: 16px; + color: #ccc; + font-size: 0.9em; img { width: 16px; diff --git a/src/_h5ai/client/js/inc/core/entry.js b/src/_h5ai/client/js/inc/core/entry.js index 289ab15c..128e736b 100644 --- a/src/_h5ai/client/js/inc/core/entry.js +++ b/src/_h5ai/client/js/inc/core/entry.js @@ -4,12 +4,7 @@ modulejs.define('core/entry', ['$', 'core/parser', 'model/entry'], function ($, var entry = Entry.get(); parser.parse(entry.absHref, $('body')); - $('#data-apache-autoindex').remove(); - - entry.status = 'h5ai'; - if (entry.parent) { - entry.parent.isParentFolder = true; - } + entry.status = '=h5ai='; return entry; }); diff --git a/src/_h5ai/client/js/inc/core/format.js b/src/_h5ai/client/js/inc/core/format.js index 72ba5ead..edebc71d 100644 --- a/src/_h5ai/client/js/inc/core/format.js +++ b/src/_h5ai/client/js/inc/core/format.js @@ -12,6 +12,8 @@ modulejs.define('core/format', ['_', 'moment'], function (_, moment) { k: 1024.0, u: ['B', 'KiB', 'MiB', 'GiB', 'TiB'] }, + defaultMetric = decimalMetric, + defaultDateFormat = 'YYYY-MM-DD HH:mm', parseSize = function (str) { @@ -37,8 +39,6 @@ modulejs.define('core/format', ['_', 'moment'], function (_, moment) { return val; }, - defaultMetric = decimalMetric, - setDefaultMetric = function (metric) { if (!metric) { @@ -68,8 +68,6 @@ modulejs.define('core/format', ['_', 'moment'], function (_, moment) { return (i <= 1 ? Math.round(size) : size.toFixed(1)).toString() + ' ' + metric.u[i]; }, - defaultDateFormat = 'YYYY-MM-DD HH:mm', - setDefaultDateFormat = function (dateFormat) { defaultDateFormat = dateFormat; diff --git a/src/_h5ai/client/js/inc/core/location.js b/src/_h5ai/client/js/inc/core/location.js new file mode 100644 index 00000000..0ebcb24e --- /dev/null +++ b/src/_h5ai/client/js/inc/core/location.js @@ -0,0 +1,52 @@ + +modulejs.define('core/location', ['$', 'core/event'], function ($, event) { + + var doc = document, + + forceEncoding = function (href) { + + return href + .replace(/\/+/g, '/') + .replace(/ /g, '%20') + .replace(/'/g, '%27') + .replace(/\[/g, '%5B') + .replace(/\]/g, '%5D') + .replace(/\(/g, '%28') + .replace(/\)/g, '%29') + .replace(/\+/g, '%2B') + .replace(/\=/g, '%3D'); + }, + + absHref = (function () { + + var rePrePathname = /.*:\/\/[^\/]*/, + rePostPathname = /[^\/]*$/, + + uriToPathname = function (uri) { + + return uri.replace(rePrePathname, '').replace(rePostPathname, ''); + }, + + testpathname = '/a b', + a = doc.createElement('a'), + isDecoded, location; + + a.href = testpathname; + isDecoded = uriToPathname(a.href) === testpathname; + + a.href = doc.location.href; + location = uriToPathname(a.href); + + if (isDecoded) { + location = encodeURIComponent(location).replace(/%2F/ig, '/'); + } + + return forceEncoding(location); + }()); + + return { + domain: doc.domain, + absHref: absHref, + forceEncoding: forceEncoding + }; +}); diff --git a/src/_h5ai/client/js/inc/core/resource.js b/src/_h5ai/client/js/inc/core/resource.js index fd866a1d..1be1a4cc 100644 --- a/src/_h5ai/client/js/inc/core/resource.js +++ b/src/_h5ai/client/js/inc/core/resource.js @@ -1,11 +1,7 @@ modulejs.define('core/resource', ['core/settings'], function (settings) { - var api = function () { - - return settings.h5aiAbsHref + 'server/php/api.php'; - }, - image = function (id, noPngExt) { + var image = function (id, noPngExt) { return settings.h5aiAbsHref + 'client/images/' + id + (noPngExt ? '' : '.png'); }, @@ -15,7 +11,6 @@ modulejs.define('core/resource', ['core/settings'], function (settings) { }; return { - api: api, image: image, icon: icon }; diff --git a/src/_h5ai/client/js/inc/core/server.js b/src/_h5ai/client/js/inc/core/server.js index c371af0e..440e96ef 100644 --- a/src/_h5ai/client/js/inc/core/server.js +++ b/src/_h5ai/client/js/inc/core/server.js @@ -5,41 +5,24 @@ modulejs.define('core/server', ['$', '_', 'config'], function ($, _, config) { request: function (data, callback) { - if (!server.apiHref) { + if (server.apiHref) { + $.ajax({ + url: server.apiHref, + data: data, + type: 'POST', + dataType: 'json', + success: function (json) { + + callback(json); + }, + error: function () { + + callback(); + } + }); + } else { callback(); - return; } - - $.ajax({ - url: server.apiHref, - data: data, - type: 'POST', - dataType: 'json', - success: function (json) { - - callback(json); - }, - error: function () { - - callback(); - } - }); - }, - - requestThumbSmall: function (type, href, callback) { - - server.request({action: 'getthumbsrc', type: type, href: href, mode: 'square', width: 16, height: 16}, function (json) { - - callback(json && json.code === 0 ? json.absHref : null); - }); - }, - - requestThumbBig: function (type, href, callback) { - - server.request({action: 'getthumbsrc', type: type, href: href, mode: 'rational', width: 100, height: 48}, function (json) { - - callback(json && json.code === 0 ? json.absHref : null); - }); } }); diff --git a/src/_h5ai/client/js/inc/ext/dropbox.js b/src/_h5ai/client/js/inc/ext/dropbox.js index ea56047f..e0f27dc0 100644 --- a/src/_h5ai/client/js/inc/ext/dropbox.js +++ b/src/_h5ai/client/js/inc/ext/dropbox.js @@ -1,5 +1,5 @@ -modulejs.define('ext/dropbox', ['_', '$', 'core/settings', 'core/entry', 'core/resource', 'core/refresh'], function (_, $, allsettings, entry, resource, refresh) { +modulejs.define('ext/dropbox', ['_', '$', 'core/settings', 'core/entry', 'core/refresh', 'core/server'], function (_, $, allsettings, entry, refresh, server) { var settings = _.extend({ enabled: false, @@ -17,7 +17,7 @@ modulejs.define('ext/dropbox', ['_', '$', 'core/settings', 'core/entry', 'core/r init = function () { - if (!settings.enabled) { + if (!settings.enabled || !server.apiHref) { return; } @@ -47,7 +47,7 @@ modulejs.define('ext/dropbox', ['_', '$', 'core/settings', 'core/entry', 'core/r maxfiles: settings.maxfiles, maxfilesize: settings.maxfilesize, - url: resource.api(), + url: server.apiHref, data: { action: 'upload', href: entry.absHref diff --git a/src/_h5ai/client/js/inc/ext/l10n.js b/src/_h5ai/client/js/inc/ext/l10n.js index 69350366..eebc0b99 100644 --- a/src/_h5ai/client/js/inc/ext/l10n.js +++ b/src/_h5ai/client/js/inc/ext/l10n.js @@ -24,7 +24,8 @@ modulejs.define('ext/l10n', ['_', '$', 'core/settings', 'core/langs', 'core/form download: 'download', noMatch: 'no match', dateFormat: 'YYYY-MM-DD HH:mm', - filter: 'filter' + filter: 'filter', + 'delete': 'delete' }, template = '' + diff --git a/src/_h5ai/client/js/inc/ext/statusbar.js b/src/_h5ai/client/js/inc/ext/statusbar.js index 7a0d0982..c292525b 100644 --- a/src/_h5ai/client/js/inc/ext/statusbar.js +++ b/src/_h5ai/client/js/inc/ext/statusbar.js @@ -67,7 +67,7 @@ modulejs.define('ext/statusbar', ['_', '$', 'core/settings', 'core/format', 'cor event.sub('entry.mouseenter', function (entry) { - if (entry.isParentFolder) { + if (entry.isCurrentParentFolder()) { return; } diff --git a/src/_h5ai/client/js/inc/ext/thumbnails.js b/src/_h5ai/client/js/inc/ext/thumbnails.js index f1430165..cdb46a89 100644 --- a/src/_h5ai/client/js/inc/ext/thumbnails.js +++ b/src/_h5ai/client/js/inc/ext/thumbnails.js @@ -9,6 +9,22 @@ modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/entry', 'core/eve delay: 1000 }, allsettings.thumbnails), + requestThumbSmall = function (type, href, callback) { + + server.request({action: 'getthumbsrc', type: type, href: href, mode: 'square', width: 16, height: 16}, function (json) { + + callback(json && json.code === 0 ? json.absHref : null); + }); + }, + + requestThumbBig = function (type, href, callback) { + + server.request({action: 'getthumbsrc', type: type, href: href, mode: 'rational', width: 100, height: 48}, function (json) { + + callback(json && json.code === 0 ? json.absHref : null); + }); + }, + checkEntry = function (entry) { if (entry.$extended) { @@ -24,13 +40,13 @@ modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/entry', 'core/eve } if (type) { - server.requestThumbSmall(type, entry.absHref, function (src) { + requestThumbSmall(type, entry.absHref, function (src) { if (src) { entry.$extended.find('.icon.small img').addClass('thumb').attr('src', src); } }); - server.requestThumbBig(type, entry.absHref, function (src) { + requestThumbBig(type, entry.absHref, function (src) { if (src) { entry.$extended.find('.icon.big img').addClass('thumb').attr('src', src); @@ -42,7 +58,7 @@ modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/entry', 'core/eve init = function (entry) { - if (!settings.enabled) { + if (!settings.enabled || !server.apiHref) { return; } diff --git a/src/_h5ai/client/js/inc/ext/tree.js b/src/_h5ai/client/js/inc/ext/tree.js index 91875ca9..ef30d301 100644 --- a/src/_h5ai/client/js/inc/ext/tree.js +++ b/src/_h5ai/client/js/inc/ext/tree.js @@ -17,6 +17,8 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e '', statusHintTemplate = '', + magicSequence = '=h5ai=', + // updates the tree for this single entry update = function (entry) { @@ -40,11 +42,11 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e var subfolders = entry.getSubfolders(); // indicator - if (!entry.status || (entry.status === 'h5ai' && !entry.isContentFetched) || subfolders.length) { + if (!entry.status || (entry.status === magicSequence && !entry.isContentFetched) || subfolders.length) { $indicator.removeClass('none'); - if (!entry.status || (entry.status === 'h5ai' && !entry.isContentFetched)) { + if (!entry.status || (entry.status === magicSequence && !entry.isContentFetched)) { $indicator.addClass('unknown'); } else if (entry.isContentVisible) { $indicator.addClass('open'); @@ -73,7 +75,7 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/e // does it have subfolders? if (subfolders.length) { - var $ul = $('
Name | Last modified | Size | |||
---|---|---|---|---|---|
[^] | Parent Directory | ||||
UP | Parent Directory | ||||
" . ($entry->is_folder ? "[D]" : "[F]") . " | "; - $html .= "abs_href . "\">" . basename($entry->abs_path) . ($entry->is_folder ? "/" : "") . " | "; + $html .= "" . ($entry->is_folder ? "DIR" : "FILE") . " | "; + $html .= "abs_href . "\">" . basename($entry->abs_path) . " | "; $html .= "" . date("Y-m-d H:i", $entry->date) . " | "; $html .= "" . ($entry->size !== null ? intval($entry->size / 1000) . " KB" : "" ) . " | "; $html .= "