Skip to content

Commit

Permalink
Fixed instability
Browse files Browse the repository at this point in the history
  • Loading branch information
kvizdos committed Apr 3, 2019
1 parent 7e3d2e7 commit 44b25b7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 29 deletions.
52 changes: 24 additions & 28 deletions assets/MainHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,30 @@ function getUrlVars() {
}

window.onload = () => {


var meta = info['meta'];
for(m in meta) {
let newMeta = document.createElement('meta');
newMeta.name = meta[m].name;
newMeta.content = meta[m].content;
document.querySelector('head').appendChild(newMeta);
}



// Register SW & Manifest
let manifest = document.createElement('link');
manifest.rel = "manifest";
if(window.location.href == "http://localhost:5500/") manifest.href = "/manifest-dev.json";
if(window.location.href !== "http://localhost:5500/") manifest.href = "/manifest.json";

// let sw = document.createElement('script');
// sw.src = "../sw-register.js";

document.getElementsByTagName('head')[0].appendChild(manifest);
// document.getElementsByTagName('body')[0].appendChild(sw);

let urlParams = getUrlVars();
if(urlParams['pwa'] == undefined || urlParams['pwa'] !== 'true') {
document.getElementsByTagName('body')[0].style.backgroundColor = "#F69F0C";
Expand All @@ -25,14 +49,6 @@ window.onload = () => {

document.getElementsByTagName('body')[0].style.height = "100vh";

var meta = info['meta'];
for(m in meta) {
let newMeta = document.createElement('meta');
newMeta.name = meta[m].name;
newMeta.content = meta[m].content;
document.querySelector('head').appendChild(newMeta);
}

document.getElementsByTagName('body')[0].innerText = "Hello, please install the app by adding this page to your home screen!";
return;
}
Expand Down Expand Up @@ -94,33 +110,13 @@ window.onload = () => {
var css = info['css'];
var meta = info['meta'];


for(m in meta) {
let newMeta = document.createElement('meta');
newMeta.name = meta[m].name;
newMeta.content = meta[m].content;
document.querySelector('head').appendChild(newMeta);
}

for(style in css) {
let newCSS = document.createElement('link');
newCSS.rel = "stylesheet";
newCSS.href = css[style];
document.querySelector('head').appendChild(newCSS);
}

// Register SW & Manifest
let manifest = document.createElement('link');
manifest.rel = "manifest";
if(window.location.href == "http://localhost:5500/") manifest.href = "/manifest-dev.json";
if(window.location.href !== "http://localhost:5500/") manifest.href = "/manifest.json";

// let sw = document.createElement('script');
// sw.src = "../sw-register.js";

document.getElementsByTagName('head')[0].appendChild(manifest);
// document.getElementsByTagName('body')[0].appendChild(sw);

var numOfScripts = scripts.length;
var loadedScripts = 0;

Expand Down
2 changes: 1 addition & 1 deletion getversion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

VERSION=`git rev-parse --short HEAD`
echo "Latest: $VERSION";
echo "const _LASTCOMMIT = '$VERSION';console.log('Current Version: ' + _LASTCOMMIT);" > version.js
echo "const _LASTCOMMIT = '$VERSION';console.warn('Current Version: ' + _LASTCOMMIT);" > version.js

0 comments on commit 44b25b7

Please sign in to comment.