Skip to content

Commit 19e74d9

Browse files
committed
add loading page
1 parent 46c9c91 commit 19e74d9

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

index.html

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010
<!-- Bootstrap -->
1111
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
12-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
13-
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
14-
1512
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
1613
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
1714
<!--[if lt IE 9]>
@@ -29,7 +26,12 @@
2926

3027
</head>
3128
<body>
32-
<div class="container">
29+
<div id="loading" class="container text-center">
30+
<br>
31+
<p class="lead">Loading...</p>
32+
</div>
33+
34+
<div id="main" class="container hide">
3335
<h2>Gist HTML Preview</h2>
3436
<p class="lead">If `File Name` is blank, it would preview index.html or the first file as default.</p>
3537
<div class="form-inline" role="form">
@@ -45,12 +47,12 @@ <h2>Gist HTML Preview</h2>
4547
</div>
4648
<br/>
4749
<div id="alert-box"></div>
50+
<a href="https://github.com/gistpreview/gistpreview.github.io"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/a6677b08c955af8400f44c6298f40e7d19cc5b2d/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677261795f3664366436642e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png"></a>
4851
</div>
4952

50-
<a href="https://github.com/gistpreview/gistpreview.github.io"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/a6677b08c955af8400f44c6298f40e7d19cc5b2d/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677261795f3664366436642e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png"></a>
51-
53+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
54+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
5255
<script src="https://cdn.rawgit.com/github/fetch/master/fetch.js"></script>
5356
<script src="./main.js"></script>
5457
</body>
5558
</html>
56-

main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
(function () {
2+
function showMainPage () {
3+
document.getElementById('main').className = 'container'; // remove class 'hide'
4+
document.getElementById('loading').className += ' hide'; // add class 'hide'
5+
}
6+
27
function showError (message) {
38
document.getElementById('alert-box').innerHTML
49
+= '<div class="alert alert-danger">'
@@ -25,6 +30,7 @@
2530
// 1. check query string
2631
var query = location.search.substring(1);
2732
if (query.length === 0) {
33+
showMainPage();
2834
return;
2935
}
3036

@@ -67,6 +73,7 @@
6773
document.write(content);
6874
})
6975
.catch(function (err) {
76+
showMainPage();
7077
showError(err.message);
7178
});
7279
})();

0 commit comments

Comments
 (0)