Skip to content

Commit

Permalink
Handle request error and display error message
Browse files Browse the repository at this point in the history
  • Loading branch information
piRstone committed Aug 21, 2020
1 parent 70ea199 commit 2ba038f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
17 changes: 17 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,23 @@ p, label {
display: inline-block;
}

#server-error {
font-size: 12px;
color: #b3b3b3;
text-align: center;
margin: 60px 10px;
}

#server-error span {
display: block;
}

#server-error span:first-child {
font-size: 14px;
color: #f90000;
margin-bottom: 10px;
}

#settings {
display: inline-block;
height: 15px;
Expand Down
8 changes: 6 additions & 2 deletions js/popup.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
var stations = [];

function getStations(success) {
function getStations(success, error) {
var url = "https://bql.pirstone.com/webapps/bql/stations.php";
$.get(url, function(data) {
var data = JSON.parse(data);
console.log(data);
// Sort stations by id
data.sort(function(a, b) {
if (a.number < b.number)
Expand All @@ -14,7 +15,8 @@ function getStations(success) {
});
stations = data;
success();
});
})
.fail(error);
}

function displayInfos(data) {
Expand Down Expand Up @@ -296,6 +298,8 @@ document.addEventListener('DOMContentLoaded', function() {

$('#settings').click(openOptions);
$('#add-station').click(showStationsList);
}, function() {
$("#server-error").removeClass("hide");
});
});

Expand Down
4 changes: 4 additions & 0 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ <h1>Bicloo Quick Look</h1>
</div>
<div id="main">
<p id="empty-stations">Ajoutez vos stations pour commencer &#8599;</p>
<p id="server-error" class="hide">
<span>Une erreur s'est produite pendant la récupération des stations.</span>
<span>Si l'erreur persiste, envoyez un email à <strong>contact@pirstone.com</strong>.</span>
</p>
<div id="fav-journee" class="hide">
<h5 class="fav-j-title">Mon trajet préféré</h5>
<ul>
Expand Down

0 comments on commit 2ba038f

Please sign in to comment.