Added error message for api refresh failure.

This commit is contained in:
neviyn 2015-10-05 23:49:59 +01:00
parent fe5596cd64
commit af1b647b5d
4 changed files with 21 additions and 6 deletions

View File

@ -67,8 +67,10 @@ $("#get-help").click (e) ->
$("#api-refresh").click (e) -> $("#api-refresh").click (e) ->
e.preventDefault(); e.preventDefault();
$.post("/refresh"); $.post("/refresh").success(() -> refreshQuestion()).fail(() -> $('#error-area').show());
refreshQuestion()
$('#error-area').find('button').click () ->
$('#error-area').hide()
$ -> $ ->
$(document).ready -> $(document).ready ->

View File

@ -90,8 +90,15 @@
$("#api-refresh").click(function(e) { $("#api-refresh").click(function(e) {
e.preventDefault(); e.preventDefault();
$.post("/refresh"); return $.post("/refresh").success(function() {
return refreshQuestion(); return refreshQuestion();
}).fail(function() {
return $('#error-area').show();
});
});
$('#error-area').find('button').click(function() {
return $('#error-area').hide();
}); });
$(function() { $(function() {

View File

@ -25,7 +25,7 @@
<!-- Optional theme --> <!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<!-- Latest compiled and minified JavaScript --> <!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">

View File

@ -27,6 +27,12 @@
</div> </div>
</nav> </nav>
<div class="container-fluid"> <div class="container-fluid">
<div class="row">
<div class="col-md-12 text-center">
<div id="error-area" class="alert alert-danger alert-dismissible collapse" role="alert">
<button type="button" class="close" aria-label="Close"><span aria-hidden="true">&times;</span></button>Cannot refresh API. Try again later.</div>
</div>
</div>
<div class="row"> <div class="row">
<div class="col-md-12 text-center"><p class="question-size" id="question-area"></p><img id="question-image" src=""></div> <div class="col-md-12 text-center"><p class="question-size" id="question-area"></p><img id="question-image" src=""></div>
</div> </div>