Close #10, improve loading experience on slow connections

Framework7
Skylar Ittner 7 years ago
parent 968498894d
commit fb4895b6aa

@ -10,7 +10,7 @@ html, body {
.app-dock {
margin: 0 auto 10px auto;
display: flex;
justify-content: space-around;
justify-content: space-evenly;
flex-wrap: wrap;
align-items: center;
justify-content: center;
@ -79,3 +79,7 @@ span.navbar-brand {
#navbar {
min-height: 56px;
}
.loading-text {
font-size: 18px;
}

@ -38,6 +38,8 @@
<circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle>
</svg>
</div>
<div style="width: 100%;"></div>
<p class="loading-text">Loading...</p>
</div>
</div>
</div>

@ -30,6 +30,7 @@ document.addEventListener("deviceready", function () {
* succeeds.
*/
function getuserinfo(callback) {
$(".loading-text").text("Loading account...");
$.post(localStorage.getItem("syncurl"), {
username: localStorage.getItem("username"),
key: localStorage.getItem("key"),
@ -37,6 +38,7 @@ function getuserinfo(callback) {
action: "user_info"
}, function (data) {
if (data.status === 'OK') {
$(".loading-text").text("Loading...");
userinfo = data.info;
if (typeof callback == 'function') {
callback();
@ -196,7 +198,12 @@ function restartApplication() {
// Handle back button to close things
document.addEventListener("backbutton", function (event) {
if (localStorage.getItem("setupcomplete")) {
if (_returnscreen != null) {
if ($("#appframe").length && historyctr > 0) {
console.log("going back");
var iframe = document.getElementById("appframe");
iframe.contentWindow.postMessage("goback", "*");
historyctr--;
} else if (_returnscreen != null) {
openscreen(_returnscreen, "FADE");
_returnscreen = null;
} else {

File diff suppressed because one or more lines are too long

@ -1,7 +1,9 @@
<iframe id="appframe" src="views/appspinner.html" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0px;"></iframe>
<iframe id="appframe" src="" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0px;"></iframe>
<iframe id="loadframe" src="views/appspinner.html" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0px; z-index: 999999;"></iframe>
<script src="js/material-palette.js"></script>
<script>
var historyctr = -1;
/**
* Open an app with native Android UI elements
* @param String id Application ID
@ -27,10 +29,17 @@
action: "start_session"
}, function (data) {
if (data.status === 'OK') {
document.getElementById("loadframe").contentWindow.postMessage("loginok", "*");
if (typeof injectcode === 'undefined' || injectcode === true) {
$('#appframe').on("load", function () {
$("#loadframe").fadeOut(300);
historyctr++;
$.get("css/sidemenu.css", function (style) {
$('#appframe').contents().find('head').append("<style>" + style + "</style>");
$.get("js/jquery-ui.min.js", function (script) {
$('#appframe').contents().find('body').append("<script>" + script + "<\/script>");
$.get("js/hammer.min.js", function (script) {
$('#appframe').contents().find('body').append("<script>" + script + "<\/script>");
$.get("js/sidemenu.js", function (script) {
script = script.replace("%%JQUERYFXOFF%%", !(localStorage.getItem("animations") === null || localStorage.getItem("animations") === "true"));
script = script.replace("%%USERNAME%%", userinfo.realname);
@ -39,6 +48,8 @@
});
});
});
});
});
} else {
// Only inject minimal CSS
$('#appframe').on("load", function () {
@ -59,10 +70,20 @@
}
var scanningactive = false;
var dedup = false;
window.addEventListener('message', function (event) {
console.log("app event: " + event.data);
setTimeout(function () {
dedup = false;
}, 500);
if (dedup) {
return;
}
dedup = true;
if (event.data == "quit") {
openscreen("home");
} else if (event.data == "goneback") {
historyctr -= 1;
} else if (event.data.startsWith("setcolor ")) {
var color = event.data.split(" ", 2)[1];
if (cordova.platformId == 'android') {

@ -1,12 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>Loading</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
<title>Loading</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
html, body {
height: 100%;
background-color: white;
font-family: "Roboto","Helvetica Neue",Helvetica,Arial,sans-serif;
}
body {
@ -84,13 +84,58 @@
}
}
</style>
</head>
<body>
<svg class="spinner" width="65px" height="65px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
<circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle>
</svg>
#statustext {
text-align: center;
}
#giveup {
display: none;
margin-top: 5px;
border: none;
border-radius: 3px;
box-shadow: 1px 1px 4px rgba(0,0,0,0.4);
padding: 6px 16px;
font-size: 13px;
line-height: 1.846;
color: #fff;
background-color: #2196f3;
text-align: center;
vertical-align: middle;
touch-action: manipulation;
white-space: nowrap;
text-decoration: none;
box-sizing: border-box;
text-transform: uppercase;
position: relative;
}
</style>
<svg class="spinner" width="65px" height="65px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
<circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle>
</svg>
<p>Logging in...</p>
</body>
</html>
<p id="statustext">Logging in...</p>
<br />
<div id="giveup" onclick="parent.postMessage('quit', '*');">Give up</div>
<script>
window.addEventListener('message', function (event) {
if (event.data == "loginok") {
document.getElementById("statustext").innerHTML = "Loading...";
setTimeout(function () {
document.getElementById("statustext").innerHTML = "Still loading...";
}, 5000);
setTimeout(function () {
document.getElementById("statustext").innerHTML = "Just a moment...";
document.getElementById("giveup").style.display = "inline-block";
}, 10000);
setTimeout(function () {
document.getElementById("statustext").innerHTML = "Well this is awkward.";
}, 20000);
setTimeout(function () {
document.getElementById("statustext").innerHTML = "[fidgets nervously]";
}, 25000);
setTimeout(function () {
document.getElementById("statustext").innerHTML = "Either something is broken or your connection is too slow.";
}, 30000);
}
});
</script>

@ -5,17 +5,21 @@
<circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle>
</svg>
</div>
<div style="width: 100%;"></div>
<p class="loading-text">Loading...</p>
</div>
</div>
<script>
function loadapps() {
$(".loading-text").html("Loading Apps...");
$.post(localStorage.getItem("syncurl"), {
username: localStorage.getItem("username"),
key: localStorage.getItem("key"),
action: "listapps"
}, function (data) {
if (data.status === 'OK') {
$("#loading-text").text("One moment...");
$('#app-dock').html("");
Object.keys(data.apps).forEach(function (k) {
var app = data.apps[k];

Loading…
Cancel
Save