Subversion Repositories ALCASAR

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
2488 lucas.echa 1
function getErrorTranslation(statusCode) {
2
	if(typeof translation == 'undefined') {
3
		return;
4
	}
5
 
6
	var language = (window.navigator.userLanguage || window.navigator.language).toLowerCase().split('-')[0];
7
 
8
	var title = translation['error'][language] + ' ' + statusCode;
9
 
10
	if(!translation.hasOwnProperty(statusCode)) {
11
		// Setting unknown error
12
		statusCode = 0;
13
		title = translation['unknown'][language];
14
	}
15
 
16
	if(!translation[statusCode].hasOwnProperty(language)) {
17
		if(translation[statusCode].hasOwnProperty('en')) {
18
			// Default language : english
19
			language = 'en';
20
		} else {
21
			return;
22
		}
23
	}
24
 
25
	return {
26
		'title': title,
27
		'message': translation[statusCode][language]
28
	}
29
}
30
 
31
function setErrorMessage(data) {
32
	if(typeof data['title'] == 'undefined' || typeof data['message'] == 'undefined') {
33
		return;
34
	}
35
 
36
	var acces_controle = document.getElementById('acces_controle');
37
	var contenu_error = document.getElementById('contenu_error');
38
 
39
	document.title += " " + data['title'];
40
	acces_controle.innerHTML = data['title'];
41
	contenu_error.innerHTML = data['message'];
42
}