Cleans code.

This commit is contained in:
Lars Jung 2012-10-17 01:54:05 +02:00
parent 885ce9e9e9
commit 910312f7ce
5 changed files with 35 additions and 104 deletions

View file

@ -5,6 +5,7 @@ modulejs.define('core/resource', ['core/settings'], function (settings) {
return settings.h5aiAbsHref + 'client/images/' + id + (noPngExt ? '' : '.png'); return settings.h5aiAbsHref + 'client/images/' + id + (noPngExt ? '' : '.png');
}, },
icon = function (id, big) { icon = function (id, big) {
return settings.h5aiAbsHref + 'client/icons/' + (big ? '48x48' : '16x16') + '/' + id + '.png'; return settings.h5aiAbsHref + 'client/icons/' + (big ? '48x48' : '16x16') + '/' + id + '.png';

View file

@ -1,16 +1,17 @@
modulejs.define('core/settings', ['config', '_', '$'], function (config, _, $) { modulejs.define('core/settings', ['config', '_', '$'], function (config, _, $) {
var settings = _.extend({ var filename = 'client/js/scripts.js',
h5aiAbsHref: '/_h5ai/'
}, config.options),
filename = 'client/js/scripts.js',
src = $('script[src$="' + filename + '"]').attr('src'), src = $('script[src$="' + filename + '"]').attr('src'),
appHref = src.substr(0, src.length - filename.length); appHref = src.substr(0, src.length - filename.length),
settings.h5aiAbsHref = src.substr(0, src.length - filename.length).replace(/\/*$/, '/'); h5aiAbsHref = src.substr(0, src.length - filename.length).replace(/\/*$/, '/'),
settings.rootAbsHref = /^(.*\/)[^\/]+\/?$/.exec(settings.h5aiAbsHref)[1]; rootAbsHref = /^(.*\/)[^\/]+\/?$/.exec(h5aiAbsHref)[1],
settings = _.extend({}, config.options, {
h5aiAbsHref: h5aiAbsHref,
rootAbsHref: rootAbsHref
});
return settings; return settings;
}); });

View file

@ -1,30 +0,0 @@
modulejs.define('ext/folderstatus', ['_', '$', 'core/settings', 'core/event', 'core/entry'], function (_, $, allsettings, event, entry) {
var settings = _.extend({
enabled: false,
maxChecks: 16,
delay: 2000
}, allsettings.folderstatus),
init = function () {
if (!settings.enabled) {
return;
}
event.sub('ready', function () {
var count = 0;
_.each(entry.content, function (e) {
if (e.isFolder() && e.status === null && count <= settings.maxChecks) {
count += 1;
setTimeout(function () { e.fetchStatus(); }, settings.delay);
}
});
});
};
init();
});

View file

@ -106,30 +106,6 @@ modulejs.define('model/entry', ['$', '_', 'core/types', 'core/event', 'core/sett
} }
}, },
fetchStatus = function (absHref, callback) {
var self = getEntry(absHref);
if (!_.isFunction(callback)) {
callback = function () {};
}
if (self.status !== null) {
callback(self);
} else {
server.request({action: 'get', entries: true, entriesHref: self.absHref, entriesWhat: 0}, function (response) {
if (response.entries) {
_.each(response.entries, function (entry) {
getEntry(entry.absHref, entry.time, entry.size, entry.status, entry.content);
});
}
callback(self);
});
}
},
fetchContent = function (absHref, callback) { fetchContent = function (absHref, callback) {
var self = getEntry(absHref); var self = getEntry(absHref);
@ -224,11 +200,6 @@ modulejs.define('model/entry', ['$', '_', 'core/types', 'core/event', 'core/sett
return _.keys(this.content).length === 0; return _.keys(this.content).length === 0;
}, },
fetchStatus: function (callback) {
return fetchStatus(this.absHref, callback);
},
fetchContent: function (callback) { fetchContent: function (callback) {
return fetchContent(this.absHref, callback); return fetchContent(this.absHref, callback);

View file

@ -6,7 +6,7 @@ Options
*/ */
{ {
/* [all] /*
Spacing of the main content. Spacing of the main content.
Left and right will be added to a minimum of 30px. Top and bottom Left and right will be added to a minimum of 30px. Top and bottom
@ -20,7 +20,7 @@ Options
"left": "auto" "left": "auto"
}, },
/* [all] /*
General view options. General view options.
- modes: array of "details", "icons", "grid" and/or "list" - modes: array of "details", "icons", "grid" and/or "list"
@ -45,7 +45,7 @@ Options
/*** Extensions (in alphabetical order) ***/ /*** Extensions (in alphabetical order) ***/
/* [php] /*
Watch and update current folder content. Watch and update current folder content.
- interval: number, update interval in milliseconds, at least 1000 - interval: number, update interval in milliseconds, at least 1000
@ -55,14 +55,14 @@ Options
"interval": 5000 "interval": 5000
}, },
/* [all] /*
Show a clickable breadcrumb. Show a clickable breadcrumb.
*/ */
"crumb": { "crumb": {
"enabled": true "enabled": true
}, },
/* [all] /*
Filenames of customized header and footer files to look for Filenames of customized header and footer files to look for
in each folder. in each folder.
*/ */
@ -72,14 +72,14 @@ Options
"footer": "_{{pkg.name}}.footer.html" "footer": "_{{pkg.name}}.footer.html"
}, },
/* [php, EXPERIMENTAL] /* [EXPERIMENTAL]
Allow file deletion. Allow file deletion.
*/ */
"delete": { "delete": {
"enabled": false "enabled": false
}, },
/* [php, EXPERIMENTAL] /* [EXPERIMENTAL]
File upload via drag'n'drop. Folders are not supported. File upload via drag'n'drop. Folders are not supported.
The working file size seems to be very browser dependent. The working file size seems to be very browser dependent.
@ -92,7 +92,7 @@ Options
"maxfilesize": 1000 "maxfilesize": 1000
}, },
/* [php] /*
Enable packaged download of selected entries. Enable packaged download of selected entries.
- execution: "php" or "shell" - execution: "php" or "shell"
@ -106,7 +106,7 @@ Options
"packageName": null "packageName": null
}, },
/* [all] /*
Allow filtering the displayed files and folders. Allow filtering the displayed files and folders.
Will check entries for right order of characters, i.e. Will check entries for right order of characters, i.e.
"ab" matches "ab", "axb", "xaxbx" but not "ba". "ab" matches "ab", "axb", "xaxbx" but not "ba".
@ -119,26 +119,14 @@ Options
"enabled": true "enabled": true
}, },
/* [php] /*
Calc the size of folders. Calc the size of folders.
*/ */
"foldersize": { "foldersize": {
"enabled": true "enabled": true
}, },
/* [aai] /*
Fetch status for subfolders of the current folder.
- maxChecks: number, max number of status requests in the current folder
- delay: number, delay in milliseconds after "dom-ready" before starting the requests
*/
"folderstatus": {
"enabled": false,
"maxChecks": 16,
"delay": 2000
},
/* [all]
Adds Google Analytics asynchronous tracking code. Adds Google Analytics asynchronous tracking code.
for example: for example:
@ -156,7 +144,7 @@ Options
"gaq": [] "gaq": []
}, },
/* [all] /*
Localization, for example "en", "de" etc. - see "langs" below for Localization, for example "en", "de" etc. - see "langs" below for
possible values. Adjust it to your needs. If lang is not found in possible values. Adjust it to your needs. If lang is not found in
"langs" it defaults to "en". "langs" it defaults to "en".
@ -170,14 +158,14 @@ Options
"useBrowserLang": true "useBrowserLang": true
}, },
/* [all] /*
Link the hover effects between crumb, main view and tree. Link the hover effects between crumb, main view and tree.
*/ */
"link-hover-states": { "link-hover-states": {
"enabled": true "enabled": true
}, },
/* [all] /*
Shows the server mode in the bottom left corner. Shows the server mode in the bottom left corner.
- display: - display:
@ -190,7 +178,7 @@ Options
"display": 2 "display": 2
}, },
/* [all] /*
Adds Piwik tracker javascript code. Adds Piwik tracker javascript code.
- baseURL: do not include the protocol, e.g. "mydomain.tld/piwik" - baseURL: do not include the protocol, e.g. "mydomain.tld/piwik"
@ -202,7 +190,7 @@ Options
"idSite": 1 "idSite": 1
}, },
/* [all] /*
Show an image preview on click. Show an image preview on click.
- types: array of types - types: array of types
@ -212,7 +200,7 @@ Options
"types": ["bmp", "gif", "ico", "image", "jpg", "png", "tiff"] "types": ["bmp", "gif", "ico", "image", "jpg", "png", "tiff"]
}, },
/* [all] /*
Show text file preview on click. Show text file preview on click.
"types" maps file types to SyntaxHighligher brushes. Special case: "markdown" will "types" maps file types to SyntaxHighligher brushes. Special case: "markdown" will
be rendered as HTML. be rendered as HTML.
@ -250,7 +238,7 @@ Options
} }
}, },
/* [all] /*
Show QRCodes on hovering files. Show QRCodes on hovering files.
- size: width and height in pixel - size: width and height in pixel
@ -260,7 +248,7 @@ Options
"size": 150 "size": 150
}, },
/* [php, EXPERIMENTAL] /* [EXPERIMENTAL]
Allow to rename files. Allow to rename files.
No GUI yet. No GUI yet.
*/ */
@ -268,14 +256,14 @@ Options
"enabled": false "enabled": false
}, },
/* [all] /*
Make entries selectable. At the moment only needed for packaged download and delete. Make entries selectable. At the moment only needed for packaged download and delete.
*/ */
"select": { "select": {
"enabled": true "enabled": true
}, },
/* [all] /*
Default sort order is a two letter code. The first letter specifies Default sort order is a two letter code. The first letter specifies
the column: "n" for "Name", "d" for "Date" or "s" for "Size". The the column: "n" for "Name", "d" for "Date" or "s" for "Size". The
second letter specifies the sort order: "a" for "ascending" or "d" second letter specifies the sort order: "a" for "ascending" or "d"
@ -288,14 +276,14 @@ Options
"order": "na" "order": "na"
}, },
/* [all] /*
Show additional info in a statusbar. Show additional info in a statusbar.
*/ */
"statusbar": { "statusbar": {
"enabled": true "enabled": true
}, },
/* [php] /*
Show thumbnails for image files. Needs the "/_{{pkg.name}}/cache" folder to be Show thumbnails for image files. Needs the "/_{{pkg.name}}/cache" folder to be
writable for the web Server. writable for the web Server.
@ -312,14 +300,14 @@ Options
"delay": 1 "delay": 1
}, },
/* [all] /*
Replace window title with current breadcrumb. Replace window title with current breadcrumb.
*/ */
"title": { "title": {
"enabled": true "enabled": true
}, },
/* [all] /*
Show a folder tree. Show a folder tree.
Note that this might affect performance significantly. Note that this might affect performance significantly.