mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-10-08 12:46:22 +08:00
Improve resource loaders
This commit is contained in:
parent
a250d84025
commit
151646f990
6 changed files with 66 additions and 56 deletions
|
@ -66,7 +66,17 @@ function getComputedStyle(id, name) {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function includeStyle(styles) {
|
function includeStyle(styles) {
|
||||||
window.document.write(unescape('%3Csty' + 'le%3E' + styles + '"%3E%3C/' + 'sty' + 'le%3E')); // eslint-disable-line no-useless-concat
|
const style = window.document.createElement('style');
|
||||||
|
style.type = 'text/css';
|
||||||
|
style.text = styles;
|
||||||
|
|
||||||
|
if (style.styleSheet) {
|
||||||
|
style.styleSheet.cssText = styles;
|
||||||
|
} else {
|
||||||
|
style.appendChild(window.document.createTextNode(styles));
|
||||||
|
}
|
||||||
|
|
||||||
|
window.document.getElementsByTagName('head')[0].appendChild(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,19 +84,11 @@ function includeStyle(styles) {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function includeScr(src) {
|
function includeScr(src) {
|
||||||
window.document.write(
|
const script = window.document.createElement('script');
|
||||||
unescape(
|
script.type = 'text/javascript';
|
||||||
'%3Csc' +
|
script.src = src;
|
||||||
'ript type="text/jav' +
|
|
||||||
'ascr' +
|
window.document.getElementsByTagName('head')[0].appendChild(script);
|
||||||
'ipt" data-cfasync="false" sr' +
|
|
||||||
'c="' +
|
|
||||||
src +
|
|
||||||
'"%3E%3C/' +
|
|
||||||
'scr' +
|
|
||||||
'ipt%3E'
|
|
||||||
)
|
|
||||||
); // eslint-disable-line no-useless-concat
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -217,7 +219,6 @@ function runApp() {
|
||||||
jassl &&
|
jassl &&
|
||||||
progressJs &&
|
progressJs &&
|
||||||
appData &&
|
appData &&
|
||||||
appData.TemplatesLink &&
|
|
||||||
appData.LangLink &&
|
appData.LangLink &&
|
||||||
appData.StaticLibJsLink &&
|
appData.StaticLibJsLink &&
|
||||||
appData.StaticAppJsLink &&
|
appData.StaticAppJsLink &&
|
||||||
|
@ -250,7 +251,7 @@ function runApp() {
|
||||||
libs()
|
libs()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
p.set(20);
|
p.set(20);
|
||||||
return window.Promise.all([jassl(appData.TemplatesLink), jassl(appData.LangLink)]);
|
return jassl(appData.LangLink);
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
p.set(30);
|
p.set(30);
|
||||||
|
|
17
dev/bootstrap.js
vendored
17
dev/bootstrap.js
vendored
|
@ -33,17 +33,22 @@ export default (App) => {
|
||||||
|
|
||||||
window.rl = rl;
|
window.rl = rl;
|
||||||
|
|
||||||
window.__APP_BOOT = (fErrorCallback) => {
|
const start = () => {
|
||||||
domReady(() => {
|
|
||||||
window.setTimeout(() => {
|
|
||||||
if (window.rainloopTEMPLATES && window.rainloopTEMPLATES[0]) {
|
|
||||||
window.document.getElementById('rl-templates').innerHTML = window.rainloopTEMPLATES[0];
|
|
||||||
|
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
$html.removeClass('no-js rl-booted-trigger').addClass('rl-booted');
|
$html.removeClass('no-js rl-booted-trigger').addClass('rl-booted');
|
||||||
|
|
||||||
App.bootstart();
|
App.bootstart();
|
||||||
}, Enums.Magics.Time10ms);
|
}, Enums.Magics.Time10ms);
|
||||||
|
};
|
||||||
|
|
||||||
|
window.__APP_BOOT = (fErrorCallback) => {
|
||||||
|
domReady(() => {
|
||||||
|
window.setTimeout(() => {
|
||||||
|
if (window.document.getElementById('rainloop-templates-id')) {
|
||||||
|
start();
|
||||||
|
} else if (window.rainloopTEMPLATES && window.rainloopTEMPLATES[0]) {
|
||||||
|
window.document.getElementById('rl-templates').innerHTML = window.rainloopTEMPLATES[0];
|
||||||
|
start();
|
||||||
} else {
|
} else {
|
||||||
fErrorCallback();
|
fErrorCallback();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1525,7 +1525,7 @@ class Actions
|
||||||
|
|
||||||
/*
|
/*
|
||||||
required by Index.html and rl.js:
|
required by Index.html and rl.js:
|
||||||
NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBackground PluginsLink AuthAccountHash
|
NewThemeLink IncludeCss LoadingDescriptionEsc LangLink IncludeBackground PluginsLink AuthAccountHash
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$aResult = array(
|
$aResult = array(
|
||||||
|
@ -1973,7 +1973,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
|
||||||
$aResult['LangLink'] = './?/Lang/0/'.($bAdmin ? 'Admin' : 'App').'/'.
|
$aResult['LangLink'] = './?/Lang/0/'.($bAdmin ? 'Admin' : 'App').'/'.
|
||||||
($bAdmin ? $aResult['LanguageAdmin'] : $aResult['Language']).'/'.$sStaticCache.'/';
|
($bAdmin ? $aResult['LanguageAdmin'] : $aResult['Language']).'/'.$sStaticCache.'/';
|
||||||
|
|
||||||
$aResult['TemplatesLink'] = './?/Templates/0/'.($bAdmin ? 'Admin' : 'App').'/'.$sStaticCache.'/';
|
// $aResult['TemplatesLink'] = './?/Templates/0/'.($bAdmin ? 'Admin' : 'App').'/'.$sStaticCache.'/';
|
||||||
|
|
||||||
$bAppJsDebug = !!$this->Config()->Get('labs', 'use_app_debug_js', false);
|
$bAppJsDebug = !!$this->Config()->Get('labs', 'use_app_debug_js', false);
|
||||||
|
|
||||||
|
|
|
@ -213,7 +213,7 @@ class Service
|
||||||
|
|
||||||
if (0 === \strlen($sResult))
|
if (0 === \strlen($sResult))
|
||||||
{
|
{
|
||||||
// $aTemplateParameters['{{BaseTemplates}}'] = $this->oServiceActions->compileTemplates($bAdmin, false);
|
$aTemplateParameters['{{BaseTemplates}}'] = $this->oServiceActions->compileTemplates($bAdmin, false);
|
||||||
$sResult = \strtr(\file_get_contents(APP_VERSION_ROOT_PATH.'app/templates/Index.html'), $aTemplateParameters);
|
$sResult = \strtr(\file_get_contents(APP_VERSION_ROOT_PATH.'app/templates/Index.html'), $aTemplateParameters);
|
||||||
|
|
||||||
$sResult = \RainLoop\Utils::ClearHtmlOutput($sResult);
|
$sResult = \RainLoop\Utils::ClearHtmlOutput($sResult);
|
||||||
|
|
|
@ -1302,7 +1302,7 @@ class ServiceActions
|
||||||
|
|
||||||
$this->oActions->Plugins()->CompileTemplate($aTemplates, $bAdmin);
|
$this->oActions->Plugins()->CompileTemplate($aTemplates, $bAdmin);
|
||||||
|
|
||||||
$sHtml = '';
|
$sHtml = '<script id="rainloop-templates-id"></script>';
|
||||||
foreach ($aTemplates as $sName => $sFile)
|
foreach ($aTemplates as $sName => $sFile)
|
||||||
{
|
{
|
||||||
$sName = \preg_replace('/[^a-zA-Z0-9]/', '', $sName);
|
$sName = \preg_replace('/[^a-zA-Z0-9]/', '', $sName);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html class="no-js rl-booted-trigger rl-started-trigger glass" dir="{{BaseDir}}">
|
<html class="no-js rl-booted-trigger rl-started-trigger glass" dir="{{BaseDir}}">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<noscript>
|
<noscript>
|
||||||
<meta http-equiv="refresh" content="0; URL=./?/NoScript" />
|
<meta http-equiv="refresh" content="0; URL=./?/NoScript" />
|
||||||
|
@ -24,10 +25,13 @@
|
||||||
<link type="text/css" rel="stylesheet" href="{{BaseAppThemeCssLink}}" id="app-theme-link" />
|
<link type="text/css" rel="stylesheet" href="{{BaseAppThemeCssLink}}" id="app-theme-link" />
|
||||||
<link rel="manifest" href="{{BaseAppManifestLink}}" />
|
<link rel="manifest" href="{{BaseAppManifestLink}}" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="rl-app"></div>
|
<div id="rl-app"></div>
|
||||||
<div id="rl-check"></div>
|
<div id="rl-check"></div>
|
||||||
|
{{BaseTemplates}}
|
||||||
{{BaseAppBodyScript}}
|
{{BaseAppBodyScript}}
|
||||||
<script type="text/javascript" data-cfasync="false" src="{{BaseAppBootScriptLink}}"></script>
|
<script type="text/javascript" data-cfasync="false" src="{{BaseAppBootScriptLink}}"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
Loading…
Add table
Reference in a new issue