You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
977 B

const lib_msg = {
6 years ago
// Extracts jqxhr error message
extractJqxhrErrorMsg: function(jqxhr) {
let hasErrorMsg = ('responseJSON' in jqxhr) &&
(jqxhr['responseJSON'] != null) &&
('error' in jqxhr['responseJSON'])
6 years ago
return hasErrorMsg ? jqxhr['responseJSON']['error'] : jqxhr.statusText
6 years ago
},
6 years ago
// UI functions
addTextinID: function(text, id){
$(id).html(text.toUpperCase())
6 years ago
},
displayMessage: function(text){
this.addTextinID('', '#errors')
this.addTextinID('', '#info')
this.addTextinID(text, '#msg')
6 years ago
},
displayErrors: function(text){
this.addTextinID('', '#msg')
this.addTextinID('', '#info')
this.addTextinID(text, '#errors')
6 years ago
},
displayInfo: function(text){
this.addTextinID('', '#msg')
this.addTextinID('', '#errors')
this.addTextinID(text, '#info')
6 years ago
},
6 years ago
cleanMessagesUi: function() {
this.addTextinID('', '#msg')
this.addTextinID('', '#errors')
this.addTextinID('', '#info')
6 years ago
}
}