Code improvements

This commit is contained in:
RainLoop Team 2016-05-24 00:56:48 +03:00
parent c43e35530e
commit 06d3dac310
13 changed files with 121 additions and 50 deletions

View file

@ -28,6 +28,12 @@ window.__rlah_clear = () => {
}
};
function getComputedStyle(id, name)
{
var element = window.document.getElementById(id);
return element.currentStyle ? element.currentStyle[name] : (window.getComputedStyle ? window.getComputedStyle(element, null).getPropertyValue(name) : null);
}
function includeStyle(styles)
{
window.document.write(unescape('%3Csty' + 'le%3E' + styles + '"%3E%3C/' + 'sty' + 'le%3E'));
@ -41,10 +47,16 @@ function includeScr(src)
function includeLayout()
{
const
css = require('Styles/@Boot.css'),
layout = require('Html/Layout.html'),
app = window.document.getElementById('rl-app')
;
if (css)
{
includeStyle(css);
}
if (app && layout)
{
app.innerHTML = layout.replace(/[\r\n\t]+/g, '');
@ -163,12 +175,6 @@ function runApp()
libs = window.jassl(appData.StaticLibJsLink).then(() => {
if (window.$)
{
if (!window.$('#rl-check').is(':visible'))
{
window.$('html').addClass('no-css');
throw new Error('no-css');
}
window.$('#rl-check').remove();
if (appData.IncludeBackground)
@ -224,7 +230,7 @@ window.__initAppData = function(data) {
if (rlAppDataStorage.NewThemeLink)
{
window.document.getElementById('app-theme-link').href = rlAppDataStorage.NewThemeLink;
(window.document.getElementById('app-theme-link') || {}).href = rlAppDataStorage.NewThemeLink;
}
if (rlAppDataStorage.IncludeCss)
@ -244,6 +250,12 @@ window.__runBoot = function() {
window.document.location.replace('./?/NoCookie');
}
if ('none' !== getComputedStyle('rl-check', 'display'))
{
const root = document.documentElement;
root.className += ' no-css';
}
if (includeLayout())
{
includeAppScr(getRainloopBootData());