Skip to content

Commit 848b791

Browse files
committed
Show loading message on startup
1 parent a73cff8 commit 848b791

File tree

1 file changed

+45
-22
lines changed

1 file changed

+45
-22
lines changed

packages/web-container/index.html.ejs

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,58 @@
1010
<link href="<%- data.bundle.css[s] %>" rel="stylesheet">
1111
<% }); %>
1212
<script src="js/require.js"></script>
13-
<noscript>
14-
<style>
15-
#enable-js-banner {
16-
display: flex;
17-
flex-direction: row;
18-
justify-content: center;
19-
padding: 0.5rem;
20-
background-color: #467391;
21-
}
22-
#banner-content {
23-
color: white;
24-
}
25-
</style>
26-
</noscript>
13+
<style>
14+
.splash-banner {
15+
display: flex;
16+
flex-direction: row;
17+
justify-content: center;
18+
align-items: center;
19+
padding: 0.5rem;
20+
height: 100%;
21+
}
22+
#splash-loading{
23+
height: 100%;
24+
}
25+
.splash-loading-hide {
26+
display: none;
27+
}
28+
</style>
2729
</head>
2830
<body>
31+
<div id="splash-loading" class="splash-banner splash-loading splash-loading-hide"><h3>Loading... Please wait.</h3></div>
2932
<div id="owncloud"></div>
3033
<noscript>
31-
<div id="enable-js-banner"><h3 id="banner-content">Please enable JavaScript</h3></div>
34+
<div class="splash-banner"><h3>Please enable JavaScript</h3></div>
3235
</noscript>
3336
<script>
34-
requirejs.config({
35-
baseUrl: <%- JSON.stringify(data.roots.js) %>,
36-
paths: <%- JSON.stringify(data.bundle.js) %>
37-
})
37+
var loader = document.getElementById('splash-loading')
38+
var loaderTimer = setTimeout(function () {
39+
loader.classList.remove('splash-loading-hide')
40+
}, 1000);
41+
42+
function displayError() {
43+
loader.classList.remove('splash-loading-hide')
44+
loader.innerHTML = "<h3>Oops. Something went wrong.</h3>"
45+
}
46+
47+
if (typeof requirejs === 'undefined') {
48+
displayError()
49+
} else {
50+
requirejs.config({
51+
baseUrl: <%- JSON.stringify(data.roots.js) %>,
52+
paths: <%- JSON.stringify(data.bundle.js) %>
53+
})
3854
39-
requirejs(['web-runtime'], function (runtime) {
40-
runtime.bootstrap('config.json').then(runtime.renderSuccess).catch(runtime.renderFailure)
41-
})
55+
requirejs(['web-runtime'], function (runtime) {
56+
clearTimeout(loaderTimer)
57+
document.getElementById('splash-loading').classList.add('splash-loading-hide')
58+
runtime.bootstrap('config.json').then(runtime.renderSuccess).catch(runtime.renderFailure)
59+
}, function(e) {
60+
displayError()
61+
throw e
62+
})
63+
}
64+
4265
</script>
4366
</body>
4467
</html>

0 commit comments

Comments
 (0)