mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-28 14:04:45 -04:00
Refactor core/settings module.
This commit is contained in:
parent
3d54b886dd
commit
2b26796719
5 changed files with 15 additions and 24 deletions
|
@ -3,13 +3,13 @@ modulejs.define('core/resource', ['core/settings'], function (settings) {
|
||||||
|
|
||||||
var image = function (id) {
|
var image = function (id) {
|
||||||
|
|
||||||
return settings.h5aiAbsHref + 'client/images/' + id + '.svg';
|
return settings.appUrl + 'client/images/' + id + '.svg';
|
||||||
},
|
},
|
||||||
|
|
||||||
icon = function (id) {
|
icon = function (id) {
|
||||||
|
|
||||||
// return settings.h5aiAbsHref + 'client/themes/faenza/icons/' + id + '.png';
|
// return settings.appUrl + 'client/themes/faenza/icons/' + id + '.png';
|
||||||
return settings.h5aiAbsHref + 'client/themes/evolvere/icons/' + id + '.svg';
|
return settings.appUrl + 'client/themes/evolvere/icons/' + id + '.svg';
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -1,17 +1,8 @@
|
||||||
|
|
||||||
modulejs.define('core/settings', ['config', '_', '$'], function (config, _, $) {
|
modulejs.define('core/settings', ['config', '_'], function (config, _) {
|
||||||
|
|
||||||
var filename = 'client/js/scripts.js',
|
return _.extend({}, config.options, {
|
||||||
src = $('script[src$="' + filename + '"]').attr('src'),
|
appUrl: config.setup.APP_URL,
|
||||||
appHref = src.substr(0, src.length - filename.length),
|
rootUrl: config.setup.ROOT_URL
|
||||||
|
});
|
||||||
h5aiAbsHref = src.substr(0, src.length - filename.length).replace(/\/*$/, '/'),
|
|
||||||
rootAbsHref = /^(.*\/)[^\/]+\/?$/.exec(h5aiAbsHref)[1],
|
|
||||||
|
|
||||||
settings = _.extend({}, config.options, {
|
|
||||||
h5aiAbsHref: h5aiAbsHref,
|
|
||||||
rootAbsHref: rootAbsHref
|
|
||||||
});
|
|
||||||
|
|
||||||
return settings;
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -63,11 +63,11 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/event', 'ex
|
||||||
},
|
},
|
||||||
loadSyntaxhighlighter = function (callback) {
|
loadSyntaxhighlighter = function (callback) {
|
||||||
|
|
||||||
loadScript(allsettings.h5aiAbsHref + 'client/js/syntaxhighlighter.js', 'SyntaxHighlighter', callback);
|
loadScript(allsettings.appUrl + 'client/js/syntaxhighlighter.js', 'SyntaxHighlighter', callback);
|
||||||
},
|
},
|
||||||
loadMarkdown = function (callback) {
|
loadMarkdown = function (callback) {
|
||||||
|
|
||||||
loadScript(allsettings.h5aiAbsHref + 'client/js/markdown.js', 'markdown', callback);
|
loadScript(allsettings.appUrl + 'client/js/markdown.js', 'markdown', callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
preloadText = function (absHref, callback) {
|
preloadText = function (absHref, callback) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ modulejs.define('ext/qrcode', ['_', '$', 'modernizr', 'core/settings', 'core/eve
|
||||||
callback();
|
callback();
|
||||||
} else {
|
} else {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: allsettings.h5aiAbsHref + 'client/js/qrcode.js',
|
url: allsettings.appUrl + 'client/js/qrcode.js',
|
||||||
dataType: 'script',
|
dataType: 'script',
|
||||||
complete: function () {
|
complete: function () {
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
|
||||||
if (match) {
|
if (match) {
|
||||||
var split = { parent: match[1], name: match[2] };
|
var split = { parent: match[1], name: match[2] };
|
||||||
|
|
||||||
if (split.parent && !startsWith(split.parent, settings.rootAbsHref)) {
|
if (split.parent && !startsWith(split.parent, settings.rootUrl)) {
|
||||||
split.parent = null;
|
split.parent = null;
|
||||||
}
|
}
|
||||||
return split;
|
return split;
|
||||||
|
@ -45,7 +45,7 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
|
||||||
|
|
||||||
absHref = location.forceEncoding(absHref);
|
absHref = location.forceEncoding(absHref);
|
||||||
|
|
||||||
if (!startsWith(absHref, settings.rootAbsHref)) {
|
if (!startsWith(absHref, settings.rootUrl)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,12 +164,12 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
|
||||||
|
|
||||||
isRoot: function () {
|
isRoot: function () {
|
||||||
|
|
||||||
return this.absHref === settings.rootAbsHref;
|
return this.absHref === settings.rootUrl;
|
||||||
},
|
},
|
||||||
|
|
||||||
isH5ai: function () {
|
isH5ai: function () {
|
||||||
|
|
||||||
return this.absHref === settings.h5aiAbsHref;
|
return this.absHref === settings.appUrl;
|
||||||
},
|
},
|
||||||
|
|
||||||
isEmpty: function () {
|
isEmpty: function () {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue