Hardcoded Styles/@Boot.css dropped some webpack KB overhead. We are going more mobile!

Also replaced some charAt() with []
This commit is contained in:
djmaze 2020-08-08 17:20:35 +02:00
parent 0d81b2ce88
commit ba8a566c69
5 changed files with 47 additions and 43 deletions

View file

@ -44,10 +44,10 @@ const Base64 = {
output =
output +
BASE_64_CHR.charAt(enc1) +
BASE_64_CHR.charAt(enc2) +
BASE_64_CHR.charAt(enc3) +
BASE_64_CHR.charAt(enc4);
BASE_64_CHR[enc1] +
BASE_64_CHR[enc2] +
BASE_64_CHR[enc3] +
BASE_64_CHR[enc4];
}
return output;
@ -68,10 +68,10 @@ const Base64 = {
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');
while (i < input.length) {
enc1 = BASE_64_CHR.indexOf(input.charAt(i++));
enc2 = BASE_64_CHR.indexOf(input.charAt(i++));
enc3 = BASE_64_CHR.indexOf(input.charAt(i++));
enc4 = BASE_64_CHR.indexOf(input.charAt(i++));
enc1 = BASE_64_CHR.indexOf(input[i++]);
enc2 = BASE_64_CHR.indexOf(input[i++]);
enc3 = BASE_64_CHR.indexOf(input[i++]);
enc4 = BASE_64_CHR.indexOf(input[i++]);
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);

View file

@ -6,7 +6,6 @@ import { getHash, setHash, clearHash } from 'Storage/RainLoop';
let RL_APP_DATA_STORAGE = null;
/* eslint-disable camelcase,spaced-comment */
window.__rlah = () => getHash();
window.__rlah_set = () => setHash();
window.__rlah_clear = () => clearHash();
window.__rlah_data = () => RL_APP_DATA_STORAGE;
@ -45,6 +44,16 @@ function runMainBoot(withError) {
}
}
const doc = window.document;
function writeCSS(css) {
const style = doc.createElement('style');
style.type = 'text/css';
style.textContent = css;
// style.appendChild(doc.createTextNode(styles));
doc.head.appendChild(style);
}
/**
* @param {mixed} data
* @returns {void}
@ -54,8 +63,6 @@ window.__initAppData = data => {
window.__rlah_set();
const doc = window.document;
if (RL_APP_DATA_STORAGE) {
const css = RL_APP_DATA_STORAGE.IncludeCss,
theme = RL_APP_DATA_STORAGE.NewThemeLink,
@ -67,13 +74,7 @@ window.__initAppData = data => {
(doc.getElementById('app-theme-link') || {}).href = theme;
}
if (css) {
const style = doc.createElement('style');
style.type = 'text/css';
style.textContent = css;
// style.appendChild(doc.createTextNode(styles));
doc.head.appendChild(style);
}
css && writeCSS(css);
if (oElDesc && description) {
oElDesc.innerHTML = description;
@ -97,11 +98,12 @@ window.__initAppData = data => {
) {
p.start().set(5);
const libs = () =>
jassl(appData.StaticLibJsLink).then(() => {
const loadScript = jassl,
libs = () =>
loadScript(appData.StaticLibJsLink).then(() => {
doc.getElementById('rl-check').remove();
if (appData.IncludeBackground) {
const img = appData.IncludeBackground.replace('{{USER}}', window.__rlah ? window.__rlah() || '0' : '0');
const img = appData.IncludeBackground.replace('{{USER}}', getHash() || '0');
if (img) {
doc.documentElement.classList.add('UserBackground');
doc.body.style.backgroundImage = "url("+img+")";
@ -112,15 +114,15 @@ window.__initAppData = data => {
libs()
.then(() => {
p.set(20);
return window.Promise.all([jassl(appData.TemplatesLink), jassl(appData.LangLink)]);
return window.Promise.all([loadScript(appData.TemplatesLink), loadScript(appData.LangLink)]);
})
.then(() => {
p.set(30);
return jassl(appData.StaticAppJsLink);
return loadScript(appData.StaticAppJsLink);
})
.then(() => {
p.set(50);
return appData.PluginsLink ? jassl(appData.PluginsLink) : window.Promise.resolve();
return appData.PluginsLink ? loadScript(appData.PluginsLink) : window.Promise.resolve();
})
.then(() => {
p.set(70);
@ -130,7 +132,7 @@ window.__initAppData = data => {
runMainBoot(true);
throw e;
})
.then(() => jassl(appData.StaticEditorJsLink))
.then(() => loadScript(appData.StaticEditorJsLink))
.then(() => {
if (window.CKEDITOR && window.__initEditor) {
window.__initEditor();
@ -153,7 +155,8 @@ window.__runBoot = () => {
doc.location.replace('./?/NoCookie');
}
require('Styles/@Boot.css');
// require('Styles/@Boot.css');
writeCSS('#rl-content{display:none;}.internal-hiddden{display:none !important;}');
if (app) {
const layout = require('Html/Layout.html'),
@ -170,7 +173,7 @@ window.__runBoot = () => {
+ (options.mobile ? 'mobile' : 'no-mobile')
+ (options.mobileDevice ? '-1' : '-0')
+ '/'
+ (window.__rlah ? window.__rlah() || '0' : '0')
+ (getHash() || '0')
+ '/'
+ window.Math.random().toString().substr(2)
+ '/';

View file

@ -13,7 +13,8 @@ export function jassl(src, async = false) {
}
return new window.Promise((resolve, reject) => {
const element = window.document.createElement('script');
const doc = window.document,
element = doc.createElement('script');
element.onload = () => {
resolve(src);
@ -26,7 +27,7 @@ export function jassl(src, async = false) {
element.async = !!async;
element.src = src;
window.document.body.appendChild(element);
doc.body.appendChild(element);
}) /* .then((s) => {
const found = s && rainloopCaches ? s.match(/rainloop\/v\/([^\/]+)\/static\//) : null;

View file

@ -37,9 +37,9 @@ const __get = (key) => {
let result = null;
if (SESS_STORAGE) {
result = SESS_STORAGE.getItem(key) || null;
} else if (WIN_STORAGE && window.JSON) {
} else if (WIN_STORAGE) {
const data =
WIN_STORAGE.name && '{' === WIN_STORAGE.name.toString().substr(0, 1)
WIN_STORAGE.name && '{' === WIN_STORAGE.name.toString()[0]
? window.JSON.parse(WIN_STORAGE.name.toString())
: null;
result = data ? data[key] || null : null;
@ -53,7 +53,7 @@ const __set = (key, value) => {
SESS_STORAGE.setItem(key, value);
} else if (WIN_STORAGE) {
let data =
WIN_STORAGE.name && '{' === WIN_STORAGE.name.toString().substr(0, 1)
WIN_STORAGE.name && '{' === WIN_STORAGE.name.toString()[0]
? JSON.parse(WIN_STORAGE.name.toString())
: null;
data = data || {};
@ -102,7 +102,7 @@ export function clearHash() {
* @returns {boolean}
*/
export function checkTimestamp() {
if (timestamp() > getTimestamp() + 1000 * 60 * 60) {
if (timestamp() > getTimestamp() + 3600000) {
// 60m
clearHash();
return true;
@ -111,4 +111,4 @@ export function checkTimestamp() {
}
// init section
setInterval(setTimestamp, 1000 * 60); // 1m
setInterval(setTimestamp, 60000); // 1m