annotate env/ui/field/location.lua @ 1331:5bbec1fd769d
Added missing brackets
 | author | bsw | 
 | date | Fri Aug 03 17:10:46 2018 +0200 (2018-08-03) | 
 | parents | 32cc544d5a5b | 
 | children | 056bccb61eee | 
 
 | rev | line source | 
| bsw/jbe@1309 | 1 function ui.field.location(args) | 
| bsw/jbe@1309 | 2   if config.map then | 
| bsw/jbe@1309 | 3     ui.form_element(args, {fetch_value = true}, function(args) | 
| bsw/jbe@1309 | 4       ui.tag{ | 
| bsw/jbe@1309 | 5         tag = "input", | 
| bsw/jbe@1309 | 6         attr = { type = "hidden", name = args.name, value = args.value, id = "ui_field_location_value" } | 
| bsw/jbe@1309 | 7       } | 
| bsw/jbe@1309 | 8     end) | 
| bsw/jbe@1309 | 9     ui.map({}, "ui_field_location_value") | 
| bsw/jbe@1309 | 10   elseif config.firstlife then | 
| bsw/jbe@1309 | 11     ui.form_element(args, {fetch_value = true}, function(args) | 
| bsw/jbe@1309 | 12       ui.tag{ | 
| bsw/jbe@1309 | 13         tag = "input", | 
| bsw/jbe@1309 | 14         attr = { type = "hidden", name = args.name, value = args.value, id = "ui_field_location_value" } | 
| bsw/jbe@1309 | 15       } | 
| bsw/jbe@1309 | 16       ui.tag{ tag = "iframe", attr = { src = config.firstlife.inputmap_url .. "/src/index.html?domain=" .. request.get_absolute_baseurl() .. "&" .. config.firstlife.coordinates .. "&lightArea=false&contrast=false&mode=lite", id = "ui_field_location", class = "ui_field_location" }, content = "" } | 
| bsw/jbe@1309 | 17 | 
| bsw/jbe@1309 | 18       ui.script{ script = [[ | 
| bsw/jbe@1309 | 19 | 
| bsw/jbe@1309 | 20         window.addEventListener("message", function (e) { | 
| bsw/jbe@1309 | 21           if (e.origin !== "]] .. config.firstlife.inputmap_url .. [[") return; | 
| bsw/jbe@1309 | 22           var data = e.data; | 
| bsw/jbe@1309 | 23           if (data.src == "InputMap") { | 
| bsw/jbe@1309 | 24             var el = document.getElementById("ui_field_location_value"); | 
| bsw/jbe@1309 | 25             el.value = JSON.stringify({ "type": "Point", "coordinates": [data.lng, data.lat], "zoom_level": data.zoom_level }); | 
| bsw/jbe@1309 | 26             console.log(el.value); | 
| bsw/jbe@1309 | 27           } | 
| bsw/jbe@1309 | 28         }); | 
| bsw/jbe@1309 | 29 | 
| bsw/jbe@1309 | 30       ]] } | 
| bsw/jbe@1309 | 31     end) | 
| bsw/jbe@1309 | 32   end | 
| bsw/jbe@1309 | 33 end |