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');
},
icon = function (id, big) {
return settings.h5aiAbsHref + 'client/icons/' + (big ? '48x48' : '16x16') + '/' + id + '.png';

View File

@ -1,16 +1,17 @@
modulejs.define('core/settings', ['config', '_', '$'], function (config, _, $) {
var settings = _.extend({
h5aiAbsHref: '/_h5ai/'
}, config.options),
filename = 'client/js/scripts.js',
var filename = 'client/js/scripts.js',
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(/\/*$/, '/');
settings.rootAbsHref = /^(.*\/)[^\/]+\/?$/.exec(settings.h5aiAbsHref)[1];
h5aiAbsHref = src.substr(0, src.length - filename.length).replace(/\/*$/, '/'),
rootAbsHref = /^(.*\/)[^\/]+\/?$/.exec(h5aiAbsHref)[1],
settings = _.extend({}, config.options, {
h5aiAbsHref: h5aiAbsHref,
rootAbsHref: rootAbsHref
});
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) {
var self = getEntry(absHref);
@ -224,11 +200,6 @@ modulejs.define('model/entry', ['$', '_', 'core/types', 'core/event', 'core/sett
return _.keys(this.content).length === 0;
},
fetchStatus: function (callback) {
return fetchStatus(this.absHref, callback);
},
fetchContent: function (callback) {
return fetchContent(this.absHref, callback);

View File

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