liquid_feedback_frontend
view env/ui/field/location.lua @ 1439:c4b235433733
Show requested unit, added missing space char
| author | bsw | 
|---|---|
| date | Thu Oct 18 13:02:02 2018 +0200 (2018-10-18) | 
| parents | 32cc544d5a5b | 
| children | 056bccb61eee | 
 line source
     1 function ui.field.location(args)
     2   if config.map then
     3     ui.form_element(args, {fetch_value = true}, function(args)
     4       ui.tag{
     5         tag = "input",
     6         attr = { type = "hidden", name = args.name, value = args.value, id = "ui_field_location_value" }
     7       }
     8     end)
     9     ui.map({}, "ui_field_location_value")
    10   elseif config.firstlife then
    11     ui.form_element(args, {fetch_value = true}, function(args)
    12       ui.tag{
    13         tag = "input",
    14         attr = { type = "hidden", name = args.name, value = args.value, id = "ui_field_location_value" }
    15       }
    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 = "" }
    18       ui.script{ script = [[
    20         window.addEventListener("message", function (e) {
    21           if (e.origin !== "]] .. config.firstlife.inputmap_url .. [[") return;
    22           var data = e.data;
    23           if (data.src == "InputMap") {
    24             var el = document.getElementById("ui_field_location_value");
    25             el.value = JSON.stringify({ "type": "Point", "coordinates": [data.lng, data.lat], "zoom_level": data.zoom_level });
    26             console.log(el.value);
    27           }
    28         });
    30       ]] }
    31     end)
    32   end
    33 end
