mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-01-18 05:38:35 +01:00
Refactor win.js into globals.js.
This commit is contained in:
parent
58cbad2bfd
commit
1cba9290b6
2
ghu.js
2
ghu.js
@ -68,7 +68,7 @@ ghu.task('build:scripts', runtime => {
|
|||||||
|
|
||||||
return read(`${SRC}/_h5ai/public/js/scripts.js`)
|
return read(`${SRC}/_h5ai/public/js/scripts.js`)
|
||||||
.then(newerThan(mapper, `${SRC}/_h5ai/public/js/**`))
|
.then(newerThan(mapper, `${SRC}/_h5ai/public/js/**`))
|
||||||
.then(webpack(webpackConfig, {showStats: true}))
|
.then(webpack(webpackConfig, {showStats: false}))
|
||||||
.then(wrap('\n\n// @include "global.js"\n\n'))
|
.then(wrap('\n\n// @include "global.js"\n\n'))
|
||||||
.then(includeit())
|
.then(includeit())
|
||||||
.then(ife(() => runtime.args.production, uglify()))
|
.then(ife(() => runtime.args.production, uglify()))
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
(function check(win) {
|
/* eslint-disable func-names,no-var */
|
||||||
/* eslint-disable func-names,no-console,no-var */
|
(function (win) {
|
||||||
|
|
||||||
if (typeof win !== 'object' || win.window !== win || !win.document) {
|
if (typeof win !== 'object' || win.window !== win || !win.document) {
|
||||||
throw new Error('no-window');
|
throw new Error('no-window');
|
||||||
}
|
}
|
||||||
@ -14,7 +13,6 @@
|
|||||||
docEl.className = noBrowser;
|
docEl.className = noBrowser;
|
||||||
throw new Error(noBrowser + ': ' + msg);
|
throw new Error(noBrowser + ': ' + msg);
|
||||||
}
|
}
|
||||||
win.console.log('checked: ' + msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert('console', win.console && typeof win.console.log === 'function');
|
assert('console', win.console && typeof win.console.log === 'function');
|
||||||
@ -37,9 +35,8 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}()));
|
}()));
|
||||||
|
|
||||||
/* eslint-enable no-var */
|
|
||||||
}(this));
|
}(this));
|
||||||
|
/* eslint-enable */
|
||||||
|
|
||||||
|
|
||||||
// @include "vendor/*.js"
|
// @include "vendor/*.js"
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
const {request} = require('./core/server');
|
const {request} = require('./core/server');
|
||||||
|
|
||||||
const config = module.exports = {
|
const config = module.exports = {
|
||||||
_update: data => {
|
_update: query => {
|
||||||
return request(data).then(newConfig => {
|
return request(query).then(response => {
|
||||||
Object.assign(config, newConfig);
|
Object.assign(config, response);
|
||||||
return config;
|
return config;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {_: lo} = require('../win');
|
const {lo} = require('../globals');
|
||||||
|
|
||||||
const subscriptions = {};
|
const subscriptions = {};
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {_: lo} = require('../win');
|
const {lo} = require('../globals');
|
||||||
|
|
||||||
const decimalMetric = {
|
const decimalMetric = {
|
||||||
t: 1000.0,
|
t: 1000.0,
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
const config = require('../config');
|
const {langs} = require('../config');
|
||||||
module.exports = Object.assign({}, config.langs);
|
module.exports = Object.assign({}, langs);
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
const {window: win, document: doc, _: lo} = require('../win');
|
const {win, lo} = require('../globals');
|
||||||
const {request} = require('./server');
|
const {request} = require('./server');
|
||||||
const allsettings = require('./settings');
|
const allsettings = require('./settings');
|
||||||
const event = require('./event');
|
const event = require('./event');
|
||||||
|
|
||||||
const notification = require('../view/notification');
|
const notification = require('../view/notification');
|
||||||
|
|
||||||
|
const doc = win.document;
|
||||||
const settings = lo.extend({
|
const settings = lo.extend({
|
||||||
fastBrowsing: true,
|
fastBrowsing: true,
|
||||||
unmanagedInNewWindow: true
|
unmanagedInNewWindow: true
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {_: lo} = require('../win');
|
const {lo} = require('../globals');
|
||||||
const config = require('../config');
|
const config = require('../config');
|
||||||
const settings = require('./settings');
|
const settings = require('./settings');
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {jQuery: jq, _: lo} = require('../win');
|
const {jq, lo} = require('../globals');
|
||||||
|
|
||||||
function request(data) {
|
function request(data) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const win = require('../win');
|
const {win} = require('../globals');
|
||||||
|
|
||||||
const store = win.localStorage;
|
const store = win.localStorage;
|
||||||
const storekey = '_h5ai';
|
const storekey = '_h5ai';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {_: lo} = require('../win');
|
const {lo} = require('../globals');
|
||||||
const config = require('../config');
|
const config = require('../config');
|
||||||
|
|
||||||
const reEndsWithSlash = /\/$/;
|
const reEndsWithSlash = /\/$/;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {_: lo} = require('../win');
|
const {lo} = require('../globals');
|
||||||
|
|
||||||
function regularCmpFn(val1, val2) {
|
function regularCmpFn(val1, val2) {
|
||||||
if (val1 < val2) {
|
if (val1 < val2) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {setTimeout} = require('../win');
|
const {win} = require('../globals');
|
||||||
const event = require('../core/event');
|
const event = require('../core/event');
|
||||||
const location = require('../core/location');
|
const location = require('../core/location');
|
||||||
const allsettings = require('../core/settings');
|
const allsettings = require('../core/settings');
|
||||||
@ -16,12 +16,12 @@ function heartbeat() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function before() {
|
function before() {
|
||||||
clearTimeout(timeoutId);
|
win.clearTimeout(timeoutId);
|
||||||
}
|
}
|
||||||
|
|
||||||
function after() {
|
function after() {
|
||||||
clearTimeout(timeoutId);
|
win.clearTimeout(timeoutId);
|
||||||
timeoutId = setTimeout(heartbeat, settings.interval);
|
timeoutId = win.setTimeout(heartbeat, settings.interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
const {document: doc, jQuery: jq, _: lo} = require('../win');
|
const {win, jq, lo} = require('../globals');
|
||||||
const resource = require('../core/resource');
|
const resource = require('../core/resource');
|
||||||
const allsettings = require('../core/settings');
|
const allsettings = require('../core/settings');
|
||||||
|
|
||||||
|
const doc = win.document;
|
||||||
const settings = lo.extend({
|
const settings = lo.extend({
|
||||||
enabled: false
|
enabled: false
|
||||||
}, allsettings.contextmenu);
|
}, allsettings.contextmenu);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {jQuery: jq, _: lo} = require('../win');
|
const {jq, lo} = require('../globals');
|
||||||
const event = require('../core/event');
|
const event = require('../core/event');
|
||||||
const location = require('../core/location');
|
const location = require('../core/location');
|
||||||
const resource = require('../core/resource');
|
const resource = require('../core/resource');
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {jQuery: jq, _: lo, marked} = require('../win');
|
const {jq, lo, marked} = require('../globals');
|
||||||
const event = require('../core/event');
|
const event = require('../core/event');
|
||||||
const server = require('../core/server');
|
const server = require('../core/server');
|
||||||
const allsettings = require('../core/settings');
|
const allsettings = require('../core/settings');
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {jQuery: jq, _: lo} = require('../win');
|
const {jq, lo} = require('../globals');
|
||||||
const event = require('../core/event');
|
const event = require('../core/event');
|
||||||
const location = require('../core/location');
|
const location = require('../core/location');
|
||||||
const resource = require('../core/resource');
|
const resource = require('../core/resource');
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {jQuery: jq, _: lo} = require('../win');
|
const {jq, lo} = require('../globals');
|
||||||
const event = require('../core/event');
|
const event = require('../core/event');
|
||||||
const location = require('../core/location');
|
const location = require('../core/location');
|
||||||
const resource = require('../core/resource');
|
const resource = require('../core/resource');
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {window: win, _: lo} = require('../win');
|
const {win, lo} = require('../globals');
|
||||||
const event = require('../core/event');
|
const event = require('../core/event');
|
||||||
const allsettings = require('../core/settings');
|
const allsettings = require('../core/settings');
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {window: win, jQuery: jq, _: lo} = require('../win');
|
const {win, jq, lo} = require('../globals');
|
||||||
const event = require('../core/event');
|
const event = require('../core/event');
|
||||||
const format = require('../core/format');
|
const format = require('../core/format');
|
||||||
const resource = require('../core/resource');
|
const resource = require('../core/resource');
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {navigator, jQuery: jq, _: lo} = require('../win');
|
const {win, jq, lo} = require('../globals');
|
||||||
const event = require('../core/event');
|
const event = require('../core/event');
|
||||||
const format = require('../core/format');
|
const format = require('../core/format');
|
||||||
const langs = require('../core/langs');
|
const langs = require('../core/langs');
|
||||||
@ -89,7 +89,7 @@ function localize(languages, isoCode, useBrowserLang) {
|
|||||||
if (languages[storedIsoCode]) {
|
if (languages[storedIsoCode]) {
|
||||||
isoCode = storedIsoCode;
|
isoCode = storedIsoCode;
|
||||||
} else if (useBrowserLang) {
|
} else if (useBrowserLang) {
|
||||||
const browserLang = navigator.language || navigator.browserLanguage;
|
const browserLang = win.navigator.language || win.navigator.browserLanguage;
|
||||||
if (browserLang) {
|
if (browserLang) {
|
||||||
if (languages[browserLang]) {
|
if (languages[browserLang]) {
|
||||||
isoCode = browserLang;
|
isoCode = browserLang;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {window: win, jQuery: jq, _: lo} = require('../win');
|
const {win, jq, lo} = require('../globals');
|
||||||
const allsettings = require('../core/settings');
|
const allsettings = require('../core/settings');
|
||||||
|
|
||||||
const settings = lo.extend({
|
const settings = lo.extend({
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {window: win, jQuery: jq, _: lo} = require('../win');
|
const {win, jq, lo} = require('../globals');
|
||||||
const event = require('../core/event');
|
const event = require('../core/event');
|
||||||
const allsettings = require('../core/settings');
|
const allsettings = require('../core/settings');
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {setTimeout, jQuery: jq, _: lo} = require('../win');
|
const {win, jq, lo} = require('../globals');
|
||||||
const event = require('../core/event');
|
const event = require('../core/event');
|
||||||
const format = require('../core/format');
|
const format = require('../core/format');
|
||||||
const allsettings = require('../core/settings');
|
const allsettings = require('../core/settings');
|
||||||
@ -13,7 +13,7 @@ function preloadAudio(src, callback) {
|
|||||||
const $audio = jq('<audio/>')
|
const $audio = jq('<audio/>')
|
||||||
.one('loadedmetadata', () => {
|
.one('loadedmetadata', () => {
|
||||||
callback($audio);
|
callback($audio);
|
||||||
// setTimeout(function () { callback($img); }, 1000); // for testing
|
// win.setTimeout(function () { callback($img); }, 1000); // for testing
|
||||||
})
|
})
|
||||||
.attr('autoplay', 'autoplay')
|
.attr('autoplay', 'autoplay')
|
||||||
.attr('controls', 'controls')
|
.attr('controls', 'controls')
|
||||||
@ -46,7 +46,7 @@ function onEnter(items, idx) {
|
|||||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||||
currentItem = currentItems[currentIdx];
|
currentItem = currentItems[currentIdx];
|
||||||
|
|
||||||
const spinnerTimeout = setTimeout(() => preview.showSpinner(true), 200);
|
const spinnerTimeout = win.setTimeout(() => preview.showSpinner(true), 200);
|
||||||
|
|
||||||
if (jq('#pv-aud-audio').length) {
|
if (jq('#pv-aud-audio').length) {
|
||||||
jq('#pv-aud-audio')[0].pause();
|
jq('#pv-aud-audio')[0].pause();
|
||||||
@ -61,11 +61,11 @@ function onEnter(items, idx) {
|
|||||||
function swap(nuContent) {
|
function swap(nuContent) {
|
||||||
jq('#pv-content').empty().append(nuContent.attr('id', 'pv-vid-audio')).fadeIn(200);
|
jq('#pv-content').empty().append(nuContent.attr('id', 'pv-vid-audio')).fadeIn(200);
|
||||||
// small timeout, so nuContent is visible and therefore its width is available
|
// small timeout, so nuContent is visible and therefore its width is available
|
||||||
setTimeout(updateMeta, 10);
|
win.setTimeout(updateMeta, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onReady($preloadedContent) {
|
function onReady($preloadedContent) {
|
||||||
clearTimeout(spinnerTimeout);
|
win.clearTimeout(spinnerTimeout);
|
||||||
preview.showSpinner(false);
|
preview.showSpinner(false);
|
||||||
|
|
||||||
jq('#pv-content').fadeOut(100, () => swap($preloadedContent));
|
jq('#pv-content').fadeOut(100, () => swap($preloadedContent));
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {setTimeout, jQuery: jq, _: lo} = require('../win');
|
const {win, jq, lo} = require('../globals');
|
||||||
const event = require('../core/event');
|
const event = require('../core/event');
|
||||||
const server = require('../core/server');
|
const server = require('../core/server');
|
||||||
const allsettings = require('../core/settings');
|
const allsettings = require('../core/settings');
|
||||||
@ -42,7 +42,7 @@ function preloadImage(item, callback) {
|
|||||||
callback(item, ev.target);
|
callback(item, ev.target);
|
||||||
|
|
||||||
// for testing
|
// for testing
|
||||||
// setTimeout(function () { callback(item, ev.target); }, 1000);
|
// win.setTimeout(function () { callback(item, ev.target); }, 1000);
|
||||||
})
|
})
|
||||||
.attr('src', src);
|
.attr('src', src);
|
||||||
});
|
});
|
||||||
@ -81,8 +81,8 @@ function onIdxChange(rel) {
|
|||||||
if (preview.isSpinnerVisible()) {
|
if (preview.isSpinnerVisible()) {
|
||||||
preview.showSpinner(true, currentItem.thumbSquare);
|
preview.showSpinner(true, currentItem.thumbSquare);
|
||||||
} else {
|
} else {
|
||||||
clearTimeout(spinnerTimeoutId);
|
win.clearTimeout(spinnerTimeoutId);
|
||||||
spinnerTimeoutId = setTimeout(() => {
|
spinnerTimeoutId = win.setTimeout(() => {
|
||||||
preview.showSpinner(true, currentItem.thumbSquare);
|
preview.showSpinner(true, currentItem.thumbSquare);
|
||||||
}, spinnerThreshold);
|
}, spinnerThreshold);
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ function onIdxChange(rel) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearTimeout(spinnerTimeoutId);
|
win.clearTimeout(spinnerTimeoutId);
|
||||||
preview.showSpinner(false);
|
preview.showSpinner(false);
|
||||||
jq('#pv-content')
|
jq('#pv-content')
|
||||||
.empty()
|
.empty()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {setTimeout, jQuery: jq, _: lo, marked, Prism: prism} = require('../win');
|
const {win, jq, lo, marked, prism} = require('../globals');
|
||||||
const event = require('../core/event');
|
const event = require('../core/event');
|
||||||
const allsettings = require('../core/settings');
|
const allsettings = require('../core/settings');
|
||||||
const preview = require('./preview');
|
const preview = require('./preview');
|
||||||
@ -26,7 +26,7 @@ function preloadText(item, callback) {
|
|||||||
callback(item, content);
|
callback(item, content);
|
||||||
|
|
||||||
// for testing
|
// for testing
|
||||||
// setTimeout(function () { callback(item, content); }, 1000);
|
// win.setTimeout(function () { callback(item, content); }, 1000);
|
||||||
})
|
})
|
||||||
.fail((jqXHR, textStatus) => {
|
.fail((jqXHR, textStatus) => {
|
||||||
callback(item, '[ajax error] ' + textStatus);
|
callback(item, '[ajax error] ' + textStatus);
|
||||||
@ -57,8 +57,8 @@ function onIdxChange(rel) {
|
|||||||
if (preview.isSpinnerVisible()) {
|
if (preview.isSpinnerVisible()) {
|
||||||
preview.showSpinner(true, currentItem.icon);
|
preview.showSpinner(true, currentItem.icon);
|
||||||
} else {
|
} else {
|
||||||
clearTimeout(spinnerTimeoutId);
|
win.clearTimeout(spinnerTimeoutId);
|
||||||
spinnerTimeoutId = setTimeout(() => {
|
spinnerTimeoutId = win.setTimeout(() => {
|
||||||
preview.showSpinner(true, currentItem.icon);
|
preview.showSpinner(true, currentItem.icon);
|
||||||
}, spinnerThreshold);
|
}, spinnerThreshold);
|
||||||
}
|
}
|
||||||
@ -86,13 +86,13 @@ function onIdxChange(rel) {
|
|||||||
$code.empty().html(prism.highlight(textContent, prism.languages[type]));
|
$code.empty().html(prism.highlight(textContent, prism.languages[type]));
|
||||||
} else {
|
} else {
|
||||||
$code.empty().text(textContent);
|
$code.empty().text(textContent);
|
||||||
setTimeout(() => {
|
win.setTimeout(() => {
|
||||||
$code.empty().html(prism.highlight(textContent, prism.languages[type]));
|
$code.empty().html(prism.highlight(textContent, prism.languages[type]));
|
||||||
}, 300);
|
}, 300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clearTimeout(spinnerTimeoutId);
|
win.clearTimeout(spinnerTimeoutId);
|
||||||
preview.showSpinner(false);
|
preview.showSpinner(false);
|
||||||
jq('#pv-content')
|
jq('#pv-content')
|
||||||
.empty()
|
.empty()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {setTimeout, jQuery: jq, _: lo} = require('../win');
|
const {win, jq, lo} = require('../globals');
|
||||||
const event = require('../core/event');
|
const event = require('../core/event');
|
||||||
const allsettings = require('../core/settings');
|
const allsettings = require('../core/settings');
|
||||||
const preview = require('./preview');
|
const preview = require('./preview');
|
||||||
@ -12,7 +12,7 @@ function preloadVideo(src, callback) {
|
|||||||
const $video = jq('<video/>')
|
const $video = jq('<video/>')
|
||||||
.one('loadedmetadata', () => {
|
.one('loadedmetadata', () => {
|
||||||
callback($video);
|
callback($video);
|
||||||
// setTimeout(function () { callback($video); }, 1000); // for testing
|
// win.setTimeout(function () { callback($video); }, 1000); // for testing
|
||||||
})
|
})
|
||||||
.attr('autoplay', 'autoplay')
|
.attr('autoplay', 'autoplay')
|
||||||
.attr('controls', 'controls')
|
.attr('controls', 'controls')
|
||||||
@ -46,7 +46,7 @@ function onEnter(items, idx) {
|
|||||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||||
currentItem = currentItems[currentIdx];
|
currentItem = currentItems[currentIdx];
|
||||||
|
|
||||||
const spinnerTimeout = setTimeout(() => preview.showSpinner(true), 200);
|
const spinnerTimeout = win.setTimeout(() => preview.showSpinner(true), 200);
|
||||||
|
|
||||||
if (jq('#pv-vid-video').length) {
|
if (jq('#pv-vid-video').length) {
|
||||||
jq('#pv-vid-video')[0].pause();
|
jq('#pv-vid-video')[0].pause();
|
||||||
@ -61,11 +61,11 @@ function onEnter(items, idx) {
|
|||||||
function swap(nuContent) {
|
function swap(nuContent) {
|
||||||
jq('#pv-content').empty().append(nuContent.attr('id', 'pv-vid-video')).fadeIn(200);
|
jq('#pv-content').empty().append(nuContent.attr('id', 'pv-vid-video')).fadeIn(200);
|
||||||
// small timeout, so nuContent is visible and therefore its width is available
|
// small timeout, so nuContent is visible and therefore its width is available
|
||||||
setTimeout(updateMeta, 10);
|
win.setTimeout(updateMeta, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onReady($preloadedContent) {
|
function onReady($preloadedContent) {
|
||||||
clearTimeout(spinnerTimeout);
|
win.clearTimeout(spinnerTimeout);
|
||||||
preview.showSpinner(false);
|
preview.showSpinner(false);
|
||||||
|
|
||||||
jq('#pv-content').fadeOut(100, () => swap($preloadedContent));
|
jq('#pv-content').fadeOut(100, () => swap($preloadedContent));
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {window: win, setTimeout, jQuery: jq, _: lo} = require('../win');
|
const {win, jq, lo} = require('../globals');
|
||||||
const resource = require('../core/resource');
|
const resource = require('../core/resource');
|
||||||
const allsettings = require('../core/settings');
|
const allsettings = require('../core/settings');
|
||||||
const store = require('../core/store');
|
const store = require('../core/store');
|
||||||
@ -89,11 +89,11 @@ function onPrevious() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function userAlive() {
|
function userAlive() {
|
||||||
clearTimeout(userAliveTimeoutId);
|
win.clearTimeout(userAliveTimeoutId);
|
||||||
jq('#pv-overlay .hof').stop(true, true).fadeIn(200);
|
jq('#pv-overlay .hof').stop(true, true).fadeIn(200);
|
||||||
|
|
||||||
if (isFullscreen) {
|
if (isFullscreen) {
|
||||||
userAliveTimeoutId = setTimeout(() => {
|
userAliveTimeoutId = win.setTimeout(() => {
|
||||||
jq('#pv-overlay .hof').stop(true, true).fadeOut(2000);
|
jq('#pv-overlay .hof').stop(true, true).fadeOut(2000);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {jQuery: jq, _: lo} = require('../win');
|
const {jq, lo} = require('../globals');
|
||||||
const event = require('../core/event');
|
const event = require('../core/event');
|
||||||
const location = require('../core/location');
|
const location = require('../core/location');
|
||||||
const resource = require('../core/resource');
|
const resource = require('../core/resource');
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
const {document: doc, jQuery: jq, _: lo} = require('../win');
|
const {win, jq, lo} = require('../globals');
|
||||||
const event = require('../core/event');
|
const event = require('../core/event');
|
||||||
const resource = require('../core/resource');
|
const resource = require('../core/resource');
|
||||||
const allsettings = require('../core/settings');
|
const allsettings = require('../core/settings');
|
||||||
|
|
||||||
|
|
||||||
|
const doc = win.document;
|
||||||
const settings = lo.extend({
|
const settings = lo.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
clickndrag: false,
|
clickndrag: false,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {jQuery: jq, _: lo} = require('../win');
|
const {jq, lo} = require('../globals');
|
||||||
const event = require('../core/event');
|
const event = require('../core/event');
|
||||||
const resource = require('../core/resource');
|
const resource = require('../core/resource');
|
||||||
const allsettings = require('../core/settings');
|
const allsettings = require('../core/settings');
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {_: lo} = require('../win');
|
const {lo} = require('../globals');
|
||||||
const event = require('../core/event');
|
const event = require('../core/event');
|
||||||
const server = require('../core/server');
|
const server = require('../core/server');
|
||||||
const allsettings = require('../core/settings');
|
const allsettings = require('../core/settings');
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
const {document: doc, _: lo} = require('../win');
|
const {win, lo} = require('../globals');
|
||||||
const event = require('../core/event');
|
const event = require('../core/event');
|
||||||
const allsettings = require('../core/settings');
|
const allsettings = require('../core/settings');
|
||||||
|
|
||||||
|
|
||||||
|
const doc = win.document;
|
||||||
const settings = lo.extend({
|
const settings = lo.extend({
|
||||||
enabled: false
|
enabled: false
|
||||||
}, allsettings.title);
|
}, allsettings.title);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {jQuery: jq, _: lo} = require('../win');
|
const {jq, lo} = require('../globals');
|
||||||
const event = require('../core/event');
|
const event = require('../core/event');
|
||||||
const location = require('../core/location');
|
const location = require('../core/location');
|
||||||
const resource = require('../core/resource');
|
const resource = require('../core/resource');
|
||||||
|
14
src/_h5ai/public/js/lib/globals.js
Normal file
14
src/_h5ai/public/js/lib/globals.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
const globals = module.exports = {};
|
||||||
|
|
||||||
|
const publish = (id, name) => {
|
||||||
|
if (!global[id]) {
|
||||||
|
throw new Error(`no-global: ${id}`);
|
||||||
|
}
|
||||||
|
globals[name] = global[id];
|
||||||
|
};
|
||||||
|
|
||||||
|
publish('window', 'win');
|
||||||
|
publish('_', 'lo');
|
||||||
|
publish('jQuery', 'jq');
|
||||||
|
publish('marked', 'marked');
|
||||||
|
publish('Prism', 'prism');
|
@ -1,8 +1,8 @@
|
|||||||
// const {jQuery: jq} = require('./win');
|
// const {jq} = require('./globals');
|
||||||
// const config = require('./config');
|
// const config = require('./config');
|
||||||
//
|
//
|
||||||
// const name = jq('script[data-module]').data('module');
|
// const name = jq('script[data-module]').data('module');
|
||||||
// const request = {
|
// const query = {
|
||||||
// action: 'get',
|
// action: 'get',
|
||||||
// setup: true,
|
// setup: true,
|
||||||
// options: true,
|
// options: true,
|
||||||
@ -10,26 +10,26 @@
|
|||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// if (name === 'index') {
|
// if (name === 'index') {
|
||||||
// request.theme = true;
|
// query.theme = true;
|
||||||
// request.langs = true;
|
// query.langs = true;
|
||||||
// } else if (name === 'info') {
|
// } else if (name === 'info') {
|
||||||
// request.refresh = true;
|
// query.refresh = true;
|
||||||
// } else {
|
// } else {
|
||||||
// throw new Error(`no-main-module: '${name}'`);
|
// throw new Error(`no-main-module: '${name}'`);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// config._update(request).then(() => {
|
// config._update(query).then(() => {
|
||||||
// jq(() => require(`./main/${name}`));
|
// jq(() => require(`./main/${name}`));
|
||||||
// });
|
// });
|
||||||
|
|
||||||
module.exports = (deps = {}) => {
|
module.exports = (deps = {}) => {
|
||||||
const {
|
const {
|
||||||
jq = require('./win').jQuery,
|
jq = require('./globals').jq,
|
||||||
config = require('./config')
|
config = require('./config')
|
||||||
} = deps;
|
} = deps;
|
||||||
|
|
||||||
const name = jq('script[data-module]').data('module');
|
const name = jq('script[data-module]').data('module');
|
||||||
const request = {
|
const query = {
|
||||||
action: 'get',
|
action: 'get',
|
||||||
setup: true,
|
setup: true,
|
||||||
options: true,
|
options: true,
|
||||||
@ -37,15 +37,15 @@ module.exports = (deps = {}) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (name === 'index') {
|
if (name === 'index') {
|
||||||
request.theme = true;
|
query.theme = true;
|
||||||
request.langs = true;
|
query.langs = true;
|
||||||
} else if (name === 'info') {
|
} else if (name === 'info') {
|
||||||
request.refresh = true;
|
query.refresh = true;
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`no-main-module: '${name}'`);
|
throw new Error(`no-main-module: '${name}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
config._update(request).then(() => {
|
config._update(query).then(() => {
|
||||||
jq(() => require(`./main/${name}`));
|
jq(() => require(`./main/${name}`));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {document: doc} = require('../win');
|
const {win} = require('../globals');
|
||||||
const location = require('../core/location');
|
const location = require('../core/location');
|
||||||
|
|
||||||
require('../view/viewmode');
|
require('../view/viewmode');
|
||||||
@ -25,4 +25,4 @@ require('../ext/thumbnails');
|
|||||||
require('../ext/title');
|
require('../ext/title');
|
||||||
require('../ext/tree');
|
require('../ext/tree');
|
||||||
|
|
||||||
location.setLocation(doc.location.href, true);
|
location.setLocation(win.document.location.href, true);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {window: win, jQuery: jq} = require('../win');
|
const {win, jq} = require('../globals');
|
||||||
const config = require('../config');
|
const config = require('../config');
|
||||||
const resource = require('../core/resource');
|
const resource = require('../core/resource');
|
||||||
const server = require('../core/server');
|
const server = require('../core/server');
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {_: lo} = require('../win');
|
const {lo} = require('../globals');
|
||||||
const location = require('../core/location');
|
const location = require('../core/location');
|
||||||
const server = require('../core/server');
|
const server = require('../core/server');
|
||||||
const settings = require('../core/settings');
|
const settings = require('../core/settings');
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {jQuery: jq} = require('../win');
|
const {jq} = require('../globals');
|
||||||
const mainrow = require('./mainrow');
|
const mainrow = require('./mainrow');
|
||||||
|
|
||||||
const $el = jq('<div id="content"/>').appendTo(mainrow.$el);
|
const $el = jq('<div id="content"/>').appendTo(mainrow.$el);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {jQuery: jq} = require('../win');
|
const {jq} = require('../globals');
|
||||||
const root = require('./root');
|
const root = require('./root');
|
||||||
|
|
||||||
const $el = jq('<div id="mainrow"/>').appendTo(root.$el);
|
const $el = jq('<div id="mainrow"/>').appendTo(root.$el);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {jQuery: jq} = require('../win');
|
const {jq} = require('../globals');
|
||||||
const root = require('./root');
|
const root = require('./root');
|
||||||
|
|
||||||
const $el = jq('<div id="notification"/>').hide().appendTo(root.$el);
|
const $el = jq('<div id="notification"/>').hide().appendTo(root.$el);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {jQuery: jq} = require('../win');
|
const {jq} = require('../globals');
|
||||||
|
|
||||||
const $el = jq('body').attr('id', 'root');
|
const $el = jq('body').attr('id', 'root');
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {jQuery: jq} = require('../win');
|
const {jq} = require('../globals');
|
||||||
const resource = require('../core/resource');
|
const resource = require('../core/resource');
|
||||||
const store = require('../core/store');
|
const store = require('../core/store');
|
||||||
const mainrow = require('./mainrow');
|
const mainrow = require('./mainrow');
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {jQuery: jq} = require('../win');
|
const {jq} = require('../globals');
|
||||||
const root = require('./root');
|
const root = require('./root');
|
||||||
|
|
||||||
const tplTopbar =
|
const tplTopbar =
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {jQuery: jq, _: lo} = require('../win');
|
const {jq, lo} = require('../globals');
|
||||||
const event = require('../core/event');
|
const event = require('../core/event');
|
||||||
const format = require('../core/format');
|
const format = require('../core/format');
|
||||||
const location = require('../core/location');
|
const location = require('../core/location');
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {jQuery: jq, _: lo} = require('../win');
|
const {jq, lo} = require('../globals');
|
||||||
const event = require('../core/event');
|
const event = require('../core/event');
|
||||||
const resource = require('../core/resource');
|
const resource = require('../core/resource');
|
||||||
const allsettings = require('../core/settings');
|
const allsettings = require('../core/settings');
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
const win = module.exports = global.window;
|
|
||||||
|
|
||||||
if (typeof win !== 'object' || win.window !== win || !win.document) {
|
|
||||||
throw new Error('no-window');
|
|
||||||
}
|
|
@ -15,29 +15,8 @@
|
|||||||
uniq: false
|
uniq: false
|
||||||
sinon: false
|
sinon: false
|
||||||
|
|
||||||
ecmaFeatures:
|
parserOptions:
|
||||||
arrowFunctions: false
|
ecmaVersion: 6
|
||||||
binaryLiterals: false
|
|
||||||
blockBindings: false
|
|
||||||
classes: false
|
|
||||||
defaultParams: false
|
|
||||||
destructuring: false
|
|
||||||
forOf: false
|
|
||||||
generators: false
|
|
||||||
globalReturn: false
|
|
||||||
jsx: false
|
|
||||||
modules: false
|
|
||||||
objectLiteralComputedProperties: false
|
|
||||||
objectLiteralDuplicateProperties: false
|
|
||||||
objectLiteralShorthandMethods: false
|
|
||||||
objectLiteralShorthandProperties: false
|
|
||||||
octalLiterals: false
|
|
||||||
regexUFlag: false
|
|
||||||
regexYFlag: false
|
|
||||||
spread: false
|
|
||||||
superInFunctions: false
|
|
||||||
templateStrings: false
|
|
||||||
unicodeCodePointEscapes: false
|
|
||||||
|
|
||||||
rules:
|
rules:
|
||||||
consistent-this: 0
|
consistent-this: 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user