Improve resource loaders

This commit is contained in:
RainLoop Team 2020-03-15 23:14:52 +03:00
parent a250d84025
commit 151646f990
6 changed files with 66 additions and 56 deletions

View file

@ -66,7 +66,17 @@ function getComputedStyle(id, name) {
* @returns {void}
*/
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}
*/
function includeScr(src) {
window.document.write(
unescape(
'%3Csc' +
'ript type="text/jav' +
'ascr' +
'ipt" data-cfasync="false" sr' +
'c="' +
src +
'"%3E%3C/' +
'scr' +
'ipt%3E'
)
); // eslint-disable-line no-useless-concat
const script = window.document.createElement('script');
script.type = 'text/javascript';
script.src = src;
window.document.getElementsByTagName('head')[0].appendChild(script);
}
/**
@ -217,7 +219,6 @@ function runApp() {
jassl &&
progressJs &&
appData &&
appData.TemplatesLink &&
appData.LangLink &&
appData.StaticLibJsLink &&
appData.StaticAppJsLink &&
@ -250,7 +251,7 @@ function runApp() {
libs()
.then(() => {
p.set(20);
return window.Promise.all([jassl(appData.TemplatesLink), jassl(appData.LangLink)]);
return jassl(appData.LangLink);
})
.then(() => {
p.set(30);

19
dev/bootstrap.js vendored
View file

@ -33,17 +33,22 @@ export default (App) => {
window.rl = rl;
const start = () => {
window.setTimeout(() => {
$html.removeClass('no-js rl-booted-trigger').addClass('rl-booted');
App.bootstart();
}, Enums.Magics.Time10ms);
};
window.__APP_BOOT = (fErrorCallback) => {
domReady(() => {
window.setTimeout(() => {
if (window.rainloopTEMPLATES && window.rainloopTEMPLATES[0]) {
if (window.document.getElementById('rainloop-templates-id')) {
start();
} else if (window.rainloopTEMPLATES && window.rainloopTEMPLATES[0]) {
window.document.getElementById('rl-templates').innerHTML = window.rainloopTEMPLATES[0];
window.setTimeout(() => {
$html.removeClass('no-js rl-booted-trigger').addClass('rl-booted');
App.bootstart();
}, Enums.Magics.Time10ms);
start();
} else {
fErrorCallback();
}

View file

@ -1525,7 +1525,7 @@ class Actions
/*
required by Index.html and rl.js:
NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBackground PluginsLink AuthAccountHash
NewThemeLink IncludeCss LoadingDescriptionEsc LangLink IncludeBackground PluginsLink AuthAccountHash
*/
$aResult = array(
@ -1973,7 +1973,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$aResult['LangLink'] = './?/Lang/0/'.($bAdmin ? 'Admin' : 'App').'/'.
($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);

View file

@ -213,7 +213,7 @@ class Service
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 = \RainLoop\Utils::ClearHtmlOutput($sResult);

View file

@ -1302,7 +1302,7 @@ class ServiceActions
$this->oActions->Plugins()->CompileTemplate($aTemplates, $bAdmin);
$sHtml = '';
$sHtml = '<script id="rainloop-templates-id"></script>';
foreach ($aTemplates as $sName => $sFile)
{
$sName = \preg_replace('/[^a-zA-Z0-9]/', '', $sName);

View file

@ -1,33 +1,37 @@
<!DOCTYPE html>
<html class="no-js rl-booted-trigger rl-started-trigger glass" dir="{{BaseDir}}">
<head>
<noscript>
<meta http-equiv="refresh" content="0; URL=./?/NoScript" />
</noscript>
<!--[if lte IE 8]>
<head>
<noscript>
<meta http-equiv="refresh" content="0; URL=./?/NoScript" />
</noscript>
<!--[if lte IE 8]>
<meta http-equiv="refresh" content="0; URL=./?/BadBrowser" />
<![endif]-->
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="{{BaseViewport}}">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="google" content="notranslate" />
<meta name="robots" content="noindex,nofollow,noodp" />
<meta name="AppBootData" content='{{RainloopBootData}}' id="app-boot-data" />
<script type="text/javascript" data-cfasync="false" src="{{BaseAppPolyfillsScriptLink}}"></script>
{{BaseContentSecurityPolicy}}
<title></title>
{{BaseAppHeadScriptLink}}
{{BaseAppFaviconPngLinkTag}}
{{BaseAppFaviconTouchLinkTag}}
<link type="text/css" rel="stylesheet" href="{{BaseAppMainCssLink}}" />
<link type="text/css" rel="stylesheet" href="{{BaseAppThemeCssLink}}" id="app-theme-link" />
<link rel="manifest" href="{{BaseAppManifestLink}}" />
</head>
<body>
<div id="rl-app"></div>
<div id="rl-check"></div>
{{BaseAppBodyScript}}
<script type="text/javascript" data-cfasync="false" src="{{BaseAppBootScriptLink}}"></script>
</body>
</html>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="{{BaseViewport}}">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="google" content="notranslate" />
<meta name="robots" content="noindex,nofollow,noodp" />
<meta name="AppBootData" content='{{RainloopBootData}}' id="app-boot-data" />
<script type="text/javascript" data-cfasync="false" src="{{BaseAppPolyfillsScriptLink}}"></script>
{{BaseContentSecurityPolicy}}
<title></title>
{{BaseAppHeadScriptLink}}
{{BaseAppFaviconPngLinkTag}}
{{BaseAppFaviconTouchLinkTag}}
<link type="text/css" rel="stylesheet" href="{{BaseAppMainCssLink}}" />
<link type="text/css" rel="stylesheet" href="{{BaseAppThemeCssLink}}" id="app-theme-link" />
<link rel="manifest" href="{{BaseAppManifestLink}}" />
</head>
<body>
<div id="rl-app"></div>
<div id="rl-check"></div>
{{BaseTemplates}}
{{BaseAppBodyScript}}
<script type="text/javascript" data-cfasync="false" src="{{BaseAppBootScriptLink}}"></script>
</body>
</html>