');function addGeosignet (newValue,newLibelle)
{
if (document.getElementById('geosignet'))
{
listGeosignet = document.getElementById('geosignet');
o = new Option(newLibelle,newValue); // libelle, value
listGeosignet[listGeosignet.options.length]=o;
}
}
var tabPriv=new Array();
//Classe gerant les geosignets
var GeoSign=Class.create();
GeoSign.prototype={
//constructeur
initialize: function(tabPriv) {
if($('btnajG_perso')){
this.onE='btnajG_perso';
this.offE='btnenlG_perso';
Element.hide('btnajG');
Element.hide('btnenlG');
}else{
this.onE='btnajG';
this.offE='btnenlG' ;
}
// Attend le chargment de carte avant de pouvoir lancer un geosignet
this.varcanLanceGeo = false;
//tabPriv est une liste des geosignets prives
this.tabPriv=tabPriv;
//$F recupere la valeur d'un select; ici on recuepte donc la valeur courante du select geosignet
this.valcourant=$F("GeoSign");
//on stocke le select par $, fonction qui recupere un element dom par son id
this.obSel=$("GeoSign");
//si on a pas de valeur courante, c'est qu'on a pas de geosignet, on cache donc la balise select
if(!this.valcourant){
Element.hide("GeoSign");
}
//par defaut on cache les boutons + et -
Element.hide(this.onE);
Element.hide(this.offE);
//GEstionnaire d'evenement js: on lie le onchange du select a notre methode LanceGEo
this.obSel.onchange= this.lanceGeo.bindAsEventListener(this);
//Event.observe(document.getElementById('GeoSign'), "change", this.lanceGeo.bindAsEventListener(this));
btonplus=$(this.onE);
btonmoins=$(this.offE);
//on lie aussi les methodes ajouteGeo et enleveGeoSignet aux boutons
btonplus.onclick= this.ajouteGeo.bindAsEventListener(this);
btonmoins.onclick= this.enleveGeoSignet.bindAsEventListener(this);
//On utilise le gestionnaire d'evenement dynmap en liant les methodes recupereGeoSignet et gereUtilisateur
GestEvtDyn.ajouteEcouteur("AJOUTGEOSIGNET",this.recupereGeoSignet,this);
GestEvtDyn.ajouteEcouteur("USERLOGGED",this.gereUtilisateur,this);
GestEvtDyn.ajouteEcouteur("LOADMAPDATAFIN",this.canLanceGeo,this);
GestEvtDyn.ajouteEcouteur("MAPINIT",this.canLanceGeo,this);
GestEvtDyn.addEventType('ENLEVEGEOSIGNET');
},
canLanceGeo:function(param)
{
this.varcanLanceGeo = true;
},
//fonction appellee quand on change de geosignet
lanceGeo:function()
{
if (this.varcanLanceGeo==true)
{
//on enleve le moins si le geosignet est publique
libelle=this.obSel.options[this.obSel.selectedIndex].text;
if(this.tabPriv[libelle]=="0"||this.obSel.selectedIndex==0){
Element.hide(this.offE);
}else{
if(this.idu!="-1"){Element.show(this.offE);}
}
this.valcourant=$F("GeoSign");
if(this.valcourant!="-1"){
if(this.valcourant == 'init'){
mainCarte.goToInitPosition();
} else {
var cc = this.valcourant.split(',');
doZoom(cc[0],cc[1],cc[2],cc[3],cc[4]);
}
}
}else
{
//this.obSel.options[this.obSel.selectedIndex]=null;
this.obSel.selectedIndex=0;
}
},
//lorsque on clique sur le bouton plus on appelle makegeosignet de dynmap
ajouteGeo:function(){
makeGeosignet();
},
//cette fonction se lance quand le moteur dynmap ajoute un nouveau geosignet
//elle met a jour la liste, et affiche le select geosignet s'il ne l'a pas encore ete
recupereGeoSignet:function(msg,valeur,libelle){
var tailleCur=this.obSel.length;
Element.show("GeoSign");
if(this.idu!=-1){
Element.show(this.offE);
}
new_option = new Option(libelle,valeur);
this.tabPriv[libelle]="1";
this.obSel.options[tailleCur]=new_option;
this.obSel.selectedIndex=tailleCur ;
//alert("geosignet recupere");
},
enleveGeoSignet:function(){
libelle=this.obSel.options[this.obSel.selectedIndex].text;
if(libelle!='-- --'){
sURL = dynmap_url + '?method=RMGEOSIGNET&args=' + escape(libelle) + '&path_application=' + path_application;
var myAjax = new Ajax.Request(sURL, {method: 'get',onComplete: showResponse});
this.obSel.options[this.obSel.selectedIndex]=null;
this.obSel.selectedIndex=0;
}
GestEvtDyn.triggerEvent('ENLEVEGEOSIGNET',[]);
},
//cette fonction recupere l'initialisation de l'utilisateur faite par le svg
//on doit connaitre l'utilisateur courant pour gerer les geosignets publique/prive
gereUtilisateur:function(idu){
//alert('gereUtilisateur');
Element.hide(this.onE);
if(idu!="-1"){
//idu stocke l'id de l'utilisateur
this.idu=idu;
Element.show(this.onE);
}
}
}
//fonction test ajax
function showResponse(retour){
//alert(retour.responseText);
}
tabPriv["Vue initiale"]='0';tabPriv["ALPES-DE-HAUTE-PROVENCE"]=0;
tabPriv["ALPES-MARITIMES"]=0;
tabPriv["BOUCHES DU RHONE"]=0;
tabPriv["HAUTES-ALPES"]=0;
tabPriv["VAR"]=0;
tabPriv["VAUCLUSE"]=0;
//initialisation de notre objet javascript