Splits settings.js.

This commit is contained in:
Lars Jung 2012-07-14 16:34:12 +02:00
parent 64640ada83
commit f6d24d050f
6 changed files with 89 additions and 84 deletions

View file

@ -0,0 +1,33 @@
modulejs.define('core/langs', ['config', '_'], function (config, _) {
var defaults = {
lang: 'unknown',
details: 'details',
icons: 'icons',
name: 'Name',
lastModified: 'Last modified',
size: 'Size',
parentDirectory: 'Parent Directory',
empty: 'empty',
folders: 'folders',
files: 'files',
download: 'download',
noMatch: 'no match',
dateFormat: 'YYYY-MM-DD HH:mm'
},
translations = {},
parse = function (langs) {
_.each(langs, function (trans, lang) {
translations[lang] = _.extend({}, defaults, trans);
});
};
parse(_.extend({}, config.langs));
return translations;
});

View file

@ -10,6 +10,11 @@ modulejs.define('core/parser', ['$'], function ($) {
return {
id: 'none',
mode: null,
server: {
name: null,
version: null
},
parse: function () {
return [];
}

View file

@ -10,86 +10,3 @@ modulejs.define('core/settings', ['config', '_'], function (config, _) {
return _.extend({}, defaults, config.options);
});
modulejs.define('core/types', ['config', '_'], function (config, _) {
var reEndsWithSlash = /\/$/,
reStartsWithDot = /^\./,
fileExts = {},
fileNames = {},
parse = function (types) {
_.each(types, function (matches, type) {
_.each(matches, function (match) {
match = match.toLowerCase();
if (reStartsWithDot.test(match)) {
fileExts[match] = type;
} else {
fileNames[match] = type;
}
});
});
},
getType = function (sequence) {
if (reEndsWithSlash.test(sequence)) {
return 'folder';
}
sequence = sequence.toLowerCase();
var slashidx = sequence.lastIndexOf('/'),
name = slashidx >= 0 ? sequence.substr(slashidx + 1) : sequence,
dotidx = sequence.lastIndexOf('.'),
ext = dotidx >= 0 ? sequence.substr(dotidx) : sequence;
return fileNames[name] || fileExts[ext] || 'unknown';
};
parse(_.extend({}, config.types));
return {
getType: getType
};
});
modulejs.define('core/langs', ['config', '_'], function (config, _) {
var defaults = {
lang: 'unknown',
details: 'details',
icons: 'icons',
name: 'Name',
lastModified: 'Last modified',
size: 'Size',
parentDirectory: 'Parent Directory',
empty: 'empty',
folders: 'folders',
files: 'files',
download: 'download',
noMatch: 'no match',
dateFormat: 'YYYY-MM-DD HH:mm'
},
translations = {},
parse = function (langs) {
_.each(langs, function (trans, lang) {
translations[lang] = _.extend({}, defaults, trans);
});
};
parse(_.extend({}, config.langs));
return translations;
});

View file

@ -0,0 +1,48 @@
modulejs.define('core/types', ['config', '_'], function (config, _) {
var reEndsWithSlash = /\/$/,
reStartsWithDot = /^\./,
fileExts = {},
fileNames = {},
parse = function (types) {
_.each(types, function (matches, type) {
_.each(matches, function (match) {
match = match.toLowerCase();
if (reStartsWithDot.test(match)) {
fileExts[match] = type;
} else {
fileNames[match] = type;
}
});
});
},
getType = function (sequence) {
if (reEndsWithSlash.test(sequence)) {
return 'folder';
}
sequence = sequence.toLowerCase();
var slashidx = sequence.lastIndexOf('/'),
name = slashidx >= 0 ? sequence.substr(slashidx + 1) : sequence,
dotidx = sequence.lastIndexOf('.'),
ext = dotidx >= 0 ? sequence.substr(dotidx) : sequence;
return fileNames[name] || fileExts[ext] || 'unknown';
};
parse(_.extend({}, config.types));
return {
getType: getType
};
});

View file

@ -4,8 +4,8 @@ modulejs.define('h5ai-main', ['_', 'core/event', 'core/settings'], function (_,
event.pub('beforeView');
modulejs.require('view/extended');
modulejs.require('view/viewmode');
modulejs.require('view/spacing');
modulejs.require('view/viewmode');
event.pub('beforeExt');

View file

@ -7,10 +7,12 @@
// @include "core/entry.js"
// @include "core/event.js"
// @include "core/format.js"
// @include "core/langs.js"
// @include "core/parser.js"
// @include "core/resource.js"
// @include "core/settings.js"
// @include "core/store.js"
// @include "core/types.js"
// @include "model/entry.js"