Skip to content

Commit 1abbf21

Browse files
committed
Added a check for the configuration file to see if it is valid json. If not error message will appear now. Added timeout to remove loading wheel if there is an error in the application code and the line to remove the wheel is not executed. If this happens a warning message will appear. Closes #23
1 parent 4351ca0 commit 1abbf21

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

app/scripts/main.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
],
6060
function ( Backbone, App ) {
6161

62-
$.get("scripts/config.json", function(values) {
63-
62+
$.getJSON("scripts/config.json", function(values) {
63+
6464
// Configure Debug options
6565
setuplogging(values.debug);
6666

@@ -95,8 +95,26 @@
9595
});
9696

9797

98+
//Timeout for loading wheel if there is an error in the application and the loading wheel is not removed
99+
setTimeout(function() {
100+
if($('#loadscreen').length){
101+
102+
$('#loadscreen').remove();
103+
$("#error-messages").append(
104+
'<div class="alert alert-warning alert-danger">'+
105+
'<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
106+
'<strong>Warning!</strong> <p>There was a problem loading the application, some functionality might not be available.</p>' +
107+
'<p>Please contact the website administrator if you have any problems.</p>' +
108+
'</div>'
109+
);
110+
}
111+
}, 10000);
98112

99113

114+
})
115+
.fail(function() {
116+
$('#loadscreen').empty();
117+
$('#loadscreen').html('<p class="warninglabel">There was a problem loading the configuration file, please contact the site administrator</p>');
100118
});
101119

102120
});

app/styles/main.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ body.wait *, body.wait {
107107
top: calc(50%);
108108
}
109109

110+
111+
#loadscreen .warninglabel {
112+
position:relative;
113+
top: calc(50%);
114+
}
115+
110116
div#preload {
111117
display: none;
112118
}

0 commit comments

Comments
 (0)