Modifiche per il documento Homeopaths

Ultima modifica di Jip-jan Alunkel il marzo 14, 20:13

Dalla versione 8.42
modificato da Jip-jan Alunkel
il dicembre 08, 15:04
Cambia il commento: Renamed from xwiki:practices.WebHome
Alla versione 8.44
modificato da Jip-jan Alunkel
il dicembre 08, 15:47
Cambia il commento: Renamed from xwiki:practices.WebHome

Summary

Details

Page properties
Content
... ... @@ -11,6 +11,29 @@
11 11  All about homeopaths.
12 12  </p>
13 13  <div id="homeopaths_map"></div>
14 +
15 + #set($query = $services.query.xwql("from doc.object('homeopaths.Code.homeopathsClass') as homeopathObj"))
16 + #set($result = $query.execute())
17 + #set($map = {})
18 + #foreach($item in $result)
19 + #set($result_doc = $xwiki.getDocument("${item}"))
20 + #set($spaceReference = $services.model.resolveDocument('', 'default', $result_doc.documentReference.lastSpaceReference).parent)
21 + #set($spaceName = $spaceReference.getName())
22 + #set($result_obj = $result_doc.getObject("homeopaths.Code.homeopathsClass"))
23 + #set($addressArray = $result_obj.getProperty("address").value).split(","))
24 + #set($address = "")
25 + #foreach($address_item in $addressArray)
26 + #set($address = "${address}<li>${address_item.trim()}</li>")
27 + #end
28 + #set($info = "<h4>${result_doc.getName()}</h4><ul>${address}</ul>")
29 + #set($discard = $map.put("${result_doc.getName()}", $result_obj.getProperty("latlong").value))
30 + #end
31 + #if($objecttool.allNull($map))
32 + #set($mapJSON = {})
33 + #else
34 + #set($mapJSON = $jsontool.serialize(${map}))
35 + #end
36 +$mapJSON
14 14  <h2>Add your practice to the map</h2>
15 15  #set($form_start = {
16 16   "id": "homeoworld_form",
XWiki.JavaScriptExtension[0]
Codice
... ... @@ -10,8 +10,15 @@
10 10   #set($map = {})
11 11   #foreach($item in $result)
12 12   #set($result_doc = $xwiki.getDocument("${item}"))
13 - #set($result_doc_title = $result_doc.getName())
13 + #set($spaceReference = $services.model.resolveDocument('', 'default', $result_doc.documentReference.lastSpaceReference).parent)
14 + #set($spaceName = $spaceReference.getName())
14 14   #set($result_obj = $result_doc.getObject("homeopaths.Code.homeopathsClass"))
16 + #set($addressArray = $result_obj.getProperty("address").value).split(","))
17 + #set($address = "")
18 + #foreach($address_item in $addressArray)
19 + #set($address = "${address}<li>${address_item.trim()}</li>")
20 + #end
21 + #set($info = "<h4>${result_doc.getName()}</h4><ul>${address}</ul>")
15 15   #set($discard = $map.put("${result_doc.getName()}", $result_obj.getProperty("latlong").value))
16 16   #end
17 17   #if($objecttool.allNull($map))
... ... @@ -23,21 +23,14 @@
23 23   var mapJSON = $jsontool.parse($mapJSON),
24 24   markers = [];
25 25  
26 - console.log(mapJSON);
27 -
28 28   for(const property in mapJSON) {
29 29   let latlong = mapJSON[property].split("/"),
30 30   lat = latlong[0],
31 - long = latlong[1];
36 + long = latlong[1],
32 32   latlongArray = [long, lat, property];
33 33   markers.push(latlongArray)
34 34   }
35 35  
36 - var madrkers = [
37 - [ -0.1244324, 51.5006728, "Big Ben" ],
38 - [ -0.119623, 51.503308, "London Eye" ],
39 - [ -0.1279688, 51.5077286, "Nelson's Column<br><a href=\"https://en.wikipedia.org/wiki/Nelson's_Column\">wp</a>" ]
40 - ];
41 41   for (var i=0; i<markers.length; i++) {
42 42   let lon = markers[i][0],
43 43   lat = markers[i][1],