Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev Author Line No. Line
105 aurelien 1
function nomScientifiqueEstDemande()  {
2
	var boutonRadioNomSci = $('#type_nom_scientifique');
3
	return (boutonRadioNomSci.attr("checked") != "undefined" && boutonRadioNomSci.attr("checked") == "checked");
4
}
5
 
6
function nomVernaculaireEstDemande()  {
7
	var boutonRadioNomSci = $('#type_nom_vernaculaire');
8
	return (boutonRadioNomSci.attr("checked") != "undefined" && boutonRadioNomSci.attr("checked") == "checked");
9
}
10
 
11
function getUrlAutocompletion(baseUrl, requete) {
12
	return baseUrl+"?recherche=etendue&retour.format=oss&navigation.limite=10&masque="+requete;
13
}
14
 
15
function getUrlAutocompletionNomsVerna(requete) {
16
	return getUrlAutocompletion(urlServiceAutocompletionNomsVerna, requete)+"&masque.lg=fra";
17
}
18
 
19
function getUrlAutocompletionNomsSci(requete) {
20
	return getUrlAutocompletion(urlServiceAutocompletionNomsSci, requete);
21
}
22
 
23
function getUrlAppelCompletion(requete) {
24
	var url = getUrlAutocompletionNomsSci(requete);
25
	if(nomVernaculaireEstDemande()) {
26
		requete = requete.replace('  ',' ');
27
		requete = requete.replace(' ','_');
28
		var url = getUrlAutocompletionNomsVerna(requete);
29
	}
30
 
31
	return url;
32
}
33
 
34
$(document).ready(function() {
35
	$('#nom').autocomplete({
36
        source: function(req, add){
37
            // la variable de requête doit être vidée car sinon le parametre "term" est ajouté
38
        	req = "";
39
            $.getJSON(getUrlAppelCompletion($('#nom').val()), req, function(data) {
40
 
41
                var suggestions = [];
42
                $.each(data[1], function(i, val){
43
                	suggestions.push(val);
44
                });
45
 
46
                add(suggestions);
47
            });
48
        }
49
	});
50
});
51