mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
Improve boot script
This commit is contained in:
parent
a655b94aba
commit
e3fa252cf2
17 changed files with 2595 additions and 125 deletions
163
dev/Common/Booter.jsx
Normal file
163
dev/Common/Booter.jsx
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
|
||||
import window from 'window';
|
||||
import $ from '$';
|
||||
|
||||
import rainLoopStorage from 'Storage/RainLoop';
|
||||
|
||||
window.__rlah = () => {
|
||||
return rainLoopStorage ? rainLoopStorage.getHash() : null;
|
||||
};
|
||||
|
||||
window.__rlah_set = () => {
|
||||
if (rainLoopStorage)
|
||||
{
|
||||
rainLoopStorage.setHash();
|
||||
}
|
||||
};
|
||||
|
||||
window.__rlah_clear = () => {
|
||||
if (rainLoopStorage)
|
||||
{
|
||||
rainLoopStorage.clearHash();
|
||||
}
|
||||
};
|
||||
|
||||
window.__includeScr = (src) => {
|
||||
window.document.write(unescape('%3Csc' + 'ript data-cfasync="false" type="text/jav' + 'ascr' + 'ipt" sr' + 'c="' + src + '"%3E%3C/' + 'scr' + 'ipt%3E'));
|
||||
};
|
||||
|
||||
window.__includeStyle = (styles) => {
|
||||
window.document.write(unescape('%3Csty' + 'le%3E' + styles + '"%3E%3C/' + 'sty' + 'le%3E'));
|
||||
};
|
||||
|
||||
window.__showError = (additionalError) => {
|
||||
|
||||
const
|
||||
oR = window.document.getElementById('rl-loading'),
|
||||
oL = window.document.getElementById('rl-loading-error'),
|
||||
oLA = window.document.getElementById('rl-loading-error-additional')
|
||||
;
|
||||
|
||||
if (oR)
|
||||
{
|
||||
oR.style.display = 'none';
|
||||
}
|
||||
|
||||
if (oL)
|
||||
{
|
||||
oL.style.display = 'block';
|
||||
}
|
||||
|
||||
if (oLA && additionalError)
|
||||
{
|
||||
oLA.style.display = 'block';
|
||||
oLA.innerHTML = additionalError;
|
||||
}
|
||||
|
||||
if (window.rainloopProgressJs)
|
||||
{
|
||||
window.rainloopProgressJs.set(100);
|
||||
}
|
||||
};
|
||||
|
||||
window.__showDescription = (description) => {
|
||||
|
||||
const
|
||||
oE = window.document.getElementById('rl-loading'),
|
||||
oElDesc = window.document.getElementById('rl-loading-desc')
|
||||
;
|
||||
|
||||
if (oElDesc && description)
|
||||
{
|
||||
oElDesc.innerHTML = description;
|
||||
}
|
||||
|
||||
if (oE && oE.style)
|
||||
{
|
||||
oE.style.opacity = 0;
|
||||
window.setTimeout(() => {
|
||||
oE.style.opacity = 1;
|
||||
}, 300);
|
||||
}
|
||||
};
|
||||
|
||||
window.__runBoot = (withError, additionalError) => {
|
||||
if (window.__APP_BOOT && !withError) {
|
||||
window.__APP_BOOT(function (bV) {
|
||||
if (!bV) {
|
||||
window.__showError(additionalError);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
window.__showError(additionalError);
|
||||
}
|
||||
};
|
||||
|
||||
window.__runApp = (BaseAppLibsScriptLink, BaseAppMainScriptLink, BaseAppEditorScriptLink) => {
|
||||
|
||||
const appData = window.rainloopAppData;
|
||||
|
||||
if (window.$LAB && window.progressJs && appData && appData.TemplatesLink && appData.LangLink)
|
||||
{
|
||||
const p = window.progressJs();
|
||||
window.rainloopProgressJs = p;
|
||||
|
||||
p.setOptions({theme: 'rainloop'});
|
||||
p.start().set(5);
|
||||
|
||||
window.$LAB
|
||||
.script(function () {
|
||||
return [
|
||||
{src: BaseAppLibsScriptLink, type: 'text/javascript', charset: 'utf-8'}
|
||||
];
|
||||
})
|
||||
.wait(function () {
|
||||
|
||||
p.set(20);
|
||||
|
||||
if (appData.IncludeBackground && $) {
|
||||
$('#rl-bg').attr('style', 'background-image: none !important;')
|
||||
.backstretch(appData.IncludeBackground.replace('{{USER}}',
|
||||
(window.__rlah ? window.__rlah() || '0' : '0')), {fade: 100, centeredX: true, centeredY: true})
|
||||
.removeAttr('style')
|
||||
;
|
||||
}
|
||||
})
|
||||
.script(function () {
|
||||
return [
|
||||
{src: appData.TemplatesLink, type: 'text/javascript', charset: 'utf-8'},
|
||||
{src: appData.LangLink, type: 'text/javascript', charset: 'utf-8'}
|
||||
];
|
||||
})
|
||||
.wait(function () {
|
||||
p.set(30);
|
||||
})
|
||||
.script(function () {
|
||||
return {src: BaseAppMainScriptLink, type: 'text/javascript', charset: 'utf-8'};
|
||||
})
|
||||
.wait(function () {
|
||||
p.set(50);
|
||||
})
|
||||
.script(function () {
|
||||
return appData.PluginsLink ? {src: appData.PluginsLink, type: 'text/javascript', charset: 'utf-8'} : null;
|
||||
})
|
||||
.wait(function () {
|
||||
p.set(70);
|
||||
window.__runBoot(false);
|
||||
})
|
||||
.script(function () {
|
||||
return {src: BaseAppEditorScriptLink, type: 'text/javascript', charset: 'utf-8'};
|
||||
})
|
||||
.wait(function () {
|
||||
if (window.CKEDITOR && window.__initEditor) {
|
||||
window.__initEditor();
|
||||
window.__initEditor = null;
|
||||
}
|
||||
})
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
window.__runBoot(true);
|
||||
}
|
||||
};
|
||||
62
dev/Storage/RainLoop.jsx
Normal file
62
dev/Storage/RainLoop.jsx
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
|
||||
import window from 'window';
|
||||
|
||||
const STORAGE_KEY = '__rlA';
|
||||
|
||||
class RainLoopStorage
|
||||
{
|
||||
s = null;
|
||||
t = null;
|
||||
|
||||
constructor()
|
||||
{
|
||||
this.s = window.sessionStorage || null;
|
||||
this.t = window.top || window;
|
||||
}
|
||||
|
||||
getHash() {
|
||||
let result = null;
|
||||
if (this.s)
|
||||
{
|
||||
result = this.s.getItem(STORAGE_KEY) || null;
|
||||
}
|
||||
else if (this.t && JSON)
|
||||
{
|
||||
const data = this.t.name && '{' === this.t.name.toString().substr(0, 1) ? JSON.parse(this.t.name.toString()) : null;
|
||||
result = data ? (data[STORAGE_KEY] || null) : null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
setHash() {
|
||||
const
|
||||
key = 'AuthAccountHash',
|
||||
appData = window.rainloopAppData
|
||||
;
|
||||
if (this.s)
|
||||
{
|
||||
this.s.setItem(STORAGE_KEY, appData && appData[key] ? appData[key] : '');
|
||||
}
|
||||
else if (this.t && JSON)
|
||||
{
|
||||
let data = {};
|
||||
data[STORAGE_KEY] = appData && appData[key] ? appData[key] : '';
|
||||
|
||||
this.t.name = JSON.stringify(data);
|
||||
}
|
||||
}
|
||||
|
||||
clearHash() {
|
||||
if (this.s)
|
||||
{
|
||||
this.s.setItem(STORAGE_KEY, '');
|
||||
}
|
||||
else if (this.t)
|
||||
{
|
||||
this.t.name = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new RainLoopStorage();
|
||||
|
|
@ -51,7 +51,7 @@ select:focus {
|
|||
outline: none;
|
||||
}
|
||||
|
||||
html.mobile * {
|
||||
html.mobile *, html.rl-mobile * {
|
||||
-webkit-tap-highlight-color: rgba(0,0,0,0);
|
||||
}
|
||||
|
||||
|
|
|
|||
12
dev/boot.jsx
Normal file
12
dev/boot.jsx
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
import window from 'window';
|
||||
|
||||
require('json2/json2.js');
|
||||
require('modernizr/modernizr-custom.js');
|
||||
require('Common/Booter.jsx');
|
||||
|
||||
import {$LAB} from 'labjs/LAB.src.js';
|
||||
import {progressJs} from 'progress.js/src/progress.js';
|
||||
|
||||
window.$LAB = $LAB;
|
||||
window.progressJs = progressJs;
|
||||
Loading…
Add table
Add a link
Reference in a new issue