2016-02-25 14:47:07 +00:00
|
|
|
define(function () {
|
|
|
|
return function (config, el, router, d) {
|
|
|
|
var h2 = document.createElement("h2")
|
|
|
|
h2.textContent = "Location: " + d.toString()
|
|
|
|
el.appendChild(h2)
|
|
|
|
|
|
|
|
getJSON("https://nominatim.openstreetmap.org/reverse?format=json&lat=" + d.lat + "&lon=" + d.lng + "&zoom=18&addressdetail=0")
|
|
|
|
.then(function(result) {
|
|
|
|
h2.textContent = result.display_name
|
|
|
|
})
|
|
|
|
|
2016-02-25 20:03:33 +00:00
|
|
|
var latDiv = document.createElement("div")
|
2016-02-25 14:47:07 +00:00
|
|
|
var h3lat = document.createElement("h3")
|
|
|
|
h3lat.textContent = "Breitengrad"
|
2016-02-25 20:03:33 +00:00
|
|
|
h3lat.id = "h3-latitude"
|
|
|
|
latDiv.appendChild(h3lat)
|
2016-02-25 14:47:07 +00:00
|
|
|
var txt1 = document.createElement("textarea")
|
|
|
|
txt1.id = "location-latitude"
|
|
|
|
txt1.value = d.lat.toFixed(9)
|
|
|
|
var p = document.createElement("p")
|
|
|
|
p.appendChild(txt1)
|
|
|
|
p.appendChild(createCopyButton(txt1.id))
|
2016-02-25 20:03:33 +00:00
|
|
|
latDiv.appendChild(p)
|
|
|
|
el.appendChild(latDiv)
|
2016-02-25 14:47:07 +00:00
|
|
|
|
2016-02-25 20:03:33 +00:00
|
|
|
var longDiv = document.createElement("div")
|
2016-02-25 14:47:07 +00:00
|
|
|
var h3lng = document.createElement("h3")
|
|
|
|
h3lng.textContent = "Längengrad"
|
2016-02-25 20:03:33 +00:00
|
|
|
longDiv.appendChild(h3lng)
|
2016-02-25 14:47:07 +00:00
|
|
|
var txt2 = document.createElement("textarea")
|
|
|
|
txt2.id = "location-longitude"
|
|
|
|
txt2.value = d.lng.toFixed(9)
|
|
|
|
var p2 = document.createElement("p")
|
|
|
|
p2.appendChild(txt2)
|
|
|
|
p2.appendChild(createCopyButton(txt2.id))
|
2016-02-25 20:03:33 +00:00
|
|
|
longDiv.appendChild(p2)
|
|
|
|
longDiv.id = "div-longitude"
|
|
|
|
el.appendChild(longDiv)
|
2016-02-25 14:47:07 +00:00
|
|
|
|
|
|
|
var a1 = document.createElement("a")
|
|
|
|
a1.textContent = "plain"
|
|
|
|
a1.onclick = function() {
|
2016-02-25 20:03:33 +00:00
|
|
|
switch2plain()
|
|
|
|
return false
|
2016-02-25 14:47:07 +00:00
|
|
|
}
|
2016-02-25 20:20:25 +00:00
|
|
|
a1.href = "#"
|
2016-02-25 14:47:07 +00:00
|
|
|
var a2 = document.createElement("a")
|
|
|
|
a2.textContent = "uci"
|
|
|
|
a2.onclick = function() {
|
2016-02-25 20:03:33 +00:00
|
|
|
switch2uci()
|
|
|
|
return false
|
2016-02-25 14:47:07 +00:00
|
|
|
}
|
2016-02-25 20:03:33 +00:00
|
|
|
a2.href = "#"
|
2016-02-25 14:47:07 +00:00
|
|
|
|
|
|
|
var p3 = document.createElement("p")
|
|
|
|
p3.textContent = "Du kannst zwischen "
|
|
|
|
p3.appendChild(a1)
|
|
|
|
var t1 = document.createTextNode(" und ")
|
|
|
|
p3.appendChild(t1)
|
|
|
|
p3.appendChild(a2)
|
|
|
|
var t2 = document.createTextNode(" wechseln.")
|
|
|
|
p3.appendChild(t2)
|
|
|
|
el.appendChild(p3)
|
|
|
|
|
|
|
|
function createCopyButton(id) {
|
2016-02-25 20:03:33 +00:00
|
|
|
var btn = document.createElement("button")
|
|
|
|
btn.className = "ion-ios-copy"
|
|
|
|
btn.title = "Kopieren"
|
|
|
|
btn.onclick = function() {
|
|
|
|
copy2clip(id)
|
|
|
|
}
|
|
|
|
return btn
|
2016-02-25 14:47:07 +00:00
|
|
|
}
|
2016-02-25 20:03:33 +00:00
|
|
|
|
2016-02-25 14:47:07 +00:00
|
|
|
function copy2clip(id) {
|
2016-02-25 20:03:33 +00:00
|
|
|
var copyTextarea = document.querySelector("#" + id)
|
|
|
|
copyTextarea.select()
|
|
|
|
try {
|
|
|
|
document.execCommand("copy")
|
|
|
|
} catch (err) {
|
|
|
|
console.log(err)
|
|
|
|
}
|
2016-02-25 14:47:07 +00:00
|
|
|
}
|
2016-02-25 20:03:33 +00:00
|
|
|
|
2016-02-25 14:47:07 +00:00
|
|
|
function switch2plain() {
|
2016-02-25 20:03:33 +00:00
|
|
|
var box1 = document.getElementById("location-latitude")
|
|
|
|
box1.value = d.lat.toFixed(9)
|
|
|
|
var box2 = document.getElementById("location-longitude")
|
|
|
|
box2.value = d.lng.toFixed(9)
|
|
|
|
document.getElementById("h3-latitude").textContent = "Breitengrad"
|
|
|
|
document.getElementById("div-longitude").style.display = "block"
|
2016-02-25 14:47:07 +00:00
|
|
|
}
|
2016-02-25 20:03:33 +00:00
|
|
|
|
2016-02-25 14:47:07 +00:00
|
|
|
function switch2uci() {
|
2016-03-02 09:45:41 +00:00
|
|
|
document.getElementById("location-latitude").value = "gluon-node-info.@location[0]='location'; gluon-node-info.@location[0].share_location='1'; uci set gluon-node-info.@location[0].latitude='" + d.lat.toFixed(9) + "'; uci set gluon-node-info.@location[0].longitude='" + d.lng.toFixed(9) + "'; uci commit gluon-node-info"
|
2016-02-25 20:03:33 +00:00
|
|
|
document.getElementById("h3-latitude").textContent = "Befehl"
|
|
|
|
document.getElementById("div-longitude").style.display = "none"
|
2016-02-25 14:47:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|