mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-06-06 09:41:14 -04:00
Cleans code.
This commit is contained in:
parent
885ce9e9e9
commit
910312f7ce
5 changed files with 35 additions and 104 deletions
|
@ -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';
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
|
|
@ -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();
|
||||
});
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue