psassist/js/lineassist.html
2020-11-15 12:55:13 +07:00

63 lines
No EOL
2.9 KiB
HTML

<html>
<head>
<title>Line Assist</title>
</head>
<body>
<h2>Line Assist</h2>
<noscript>Please enable the javascript for LineAssist to work!</noscript>
<form action="" id="searchbar">
<label for="search" id="search1">URL:</label>
<input type="text" id="search2" name="url" value="https://storage.googleapis.com/navigator-media-usa/media/connected_line/v2/site/www/draw/metadata-converted.json">
<button type="button" id="search3">Go!</button>
</form>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
font-size: larger;
}
</style>
<div id="results"></div>
<script>
var loading = false;
var res = document.getElementById("results")
function start() {
loading = true
let s = new XMLHttpRequest()
s.open("GET", document.getElementById("search2").value)
s.onreadystatechange = function() {
if (this.readyState == 4 && this.status <= 399) {
o = ""
data = JSON.parse(this.response)
for (k in data) {
lldata = data[k].url.split("@")[1].split(",")
lat = lldata[0]; lng = lldata[1]; url = "getmaplace.html?lat="+lat+"&lng="+lng
title = data[k]["line-1"] + ", " + data[k]["line-2"] + ": " + lat + "," + lng
o += `<a href="`+url+`">`+title+`</a> <a href="`+url+"&cors=true"+`">CORS</a> - <button onclick="navigator.clipboard.writeText('`+lat+", "+lng+`')">Copy Coords</button> - <button onclick="navigator.clipboard.writeText('geo:`+lat+","+lng+`')">Copy geoURI</button><br>`
}
loading = false
res.innerHTML = o
}
}
s.onerror = function() {
loading = false
}
s.send()
}
window.addEventListener('keydown', function(e) {
if (e.keyIdentifier == 'U+000A' || e.keyIdentifier == 'Enter' || e.keyCode == 13) {
if (e.target.nodeName == 'INPUT' && e.target.type == 'text') {
e.preventDefault()
document.getElementById("search3").onclick()
return false
}
}
}, true)
document.getElementById("search3").onclick = function() {
res.innerHTML = ""
start()
}
start()
</script>
</body>
</html>