DEL Old file.
[appart.git] / script.js
1 /**
2 * Affiche les données de l'appart soit en mode éditable soit en mode de consultation.
3 */
4 function rafraichirFormulaire()
5 {
6 var mode = document.getElementById("modeFormulaire")
7
8 var edition = mode.value == "enEdition"
9
10 document.getElementById("urlConsultation").style.display = edition ? "none" : "inline";
11 document.getElementById("urlEdition").style.display = edition ? "inline" : "none";
12
13 //document.getElementById("urlmapConsultation").style.display = edition ? "none" : "inline";
14 //document.getElementById("urlmapEdition").style.display = edition ? "inline" : "none";
15
16 document.getElementById("boutonsEdition").style.display = edition ? "block" : "none";
17
18 var tab = document.getElementById("tableauFormulaire")
19 var inputs = tab.getElementsByTagName("input");
20 var areas = tab.getElementsByTagName("textarea");
21
22 for (var i = 0; i < inputs.length; i++)
23 if (edition) inputs[i].removeAttribute("readonly");
24 else inputs[i].setAttribute("readonly","readonly");
25
26 for (var i = 0; i < areas.length; i++)
27 if (edition) areas[i].removeAttribute("readonly");
28 else areas[i].setAttribute("readonly","readonly");
29
30 document.getElementById("boutonEditer").style.display = edition ? "none" : "inline";
31
32 document.getElementById("editionStatut").style.display = edition ? "inline" : "none";
33 document.getElementById("consultationStatut").style.display = edition ? "none" : "inline";
34 }
35
36 /**
37 * passe les données sous la forme éditable.
38 */
39 function editer()
40 {
41 var mode = document.getElementById("modeFormulaire").value = "enEdition"
42 rafraichirFormulaire()
43 }
44
45 function supprimer(id, rue)
46 {
47 return confirm("Voulez vous vraiment supprimer l'appartement n°" + id + " : " + rue);
48 }
49
50 function endroitTrouve(position)
51 {
52 var marker = new GMarker(position);
53
54 var map = new GMap2(document.getElementById("map"));
55 map.addControl(new GSmallMapControl());
56 map.addControl(new GMapTypeControl());
57 map.setCenter(position, 14);
58 map.addOverlay(marker)
59
60 var map2 = new GMap2(document.getElementById("map2"));
61 map2.addControl(new GSmallMapControl());
62 map2.addControl(new GMapTypeControl());
63 map2.setCenter(position, 16);
64 map2.addOverlay(marker)
65 }
66
67 // voir : http://www.google.com/apis/maps/documentation/reference.html
68 function loadGMap()
69 {
70 if (GBrowserIsCompatible())
71 {
72 var geocoder = new GClientGeocoder();
73
74 geocoder.setViewport(new GLatLngBounds(new GLatLng(46.8333, 7.1166), new GLatLng(46.7333, 7.2166)));
75 geocoder.getLatLng(document.getElementById("inputRue").value + " " + document.getElementById("inputLocalite").value, endroitTrouve);
76 }
77 }