From 65946832e590639a6e540122c679c683920254ee Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Fri, 6 Oct 2017 23:22:20 +0200 Subject: [PATCH] add device name to upload info, remove last pieces of OSM upload functionality --- index.html | 15 +++++++-------- js/ui.js | 42 ++++++++++++++---------------------------- style/lantea.css | 44 +++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 62 insertions(+), 39 deletions(-) diff --git a/index.html b/index.html index 5cb6382..969178f 100644 --- a/index.html +++ b/index.html @@ -49,7 +49,7 @@

Public Domain tracks can be forwarded by the server operator to any other services, e.g. OpenStreetMap.

- +

-
-

OpenStreetMap Track Upload:

- -
- - +

Track Upload:

+ + +

The device name enables you to tell apart tracks you may +upload from multiple devices.

diff --git a/js/ui.js b/js/ui.js index a44a462..22e46a1 100644 --- a/js/ui.js +++ b/js/ui.js @@ -14,13 +14,6 @@ var gTrackUpdateInterval; var gAction, gActionLabel; var gBackendURL = "https://backend.lantea.kairo.at"; var gAuthClientID = "lantea"; -var gOSMAPIURL = "https://api.openstreetmap.org/"; -var gOSMOAuthData = { - oauth_consumer_key: "6jjWwlbhGqyYeCdlFE1lTGG6IRGOv1yKpFxkcq2z", - oauth_secret: "A21gUeDM6mdoQgbA9uF7zJ13sbUQrNG7QQ4oSrKA", - url: "https://www.openstreetmap.org", - landing: "auth-done.html", -} window.onload = function() { if (/\/login\.html/.test(window.location)) { @@ -85,11 +78,6 @@ window.onload = function() { // Call any UI preparation that needs the backend. }); - if (gDebug) { - // Note that GPX upload returns an error 500 on the dev API right now. - gOSMAPIURL = "http://api06.dev.openstreetmap.org/"; - } - gAction.addEventListener("dbinit-done", initMap, false); gAction.addEventListener("mapinit-done", postInit, false); console.log("starting DB init..."); @@ -106,17 +94,11 @@ function postInit(aEvent) { gActionLabel.textContent = ""; gAction.style.display = "none"; setTracking(document.getElementById("trackCheckbox")); - gPrefs.get(gDebug ? "osm_dev_user" : "osm_user", function(aValue) { + gPrefs.get("devicename", function(aValue) { if (aValue) { - document.getElementById("uploadUser").value = aValue; - document.getElementById("uploadTrackButton").disabled = false; + document.getElementById("uploadDevName").value = aValue; } }); - gPrefs.get(gDebug ? "osm_dev_pwd" : "osm_pwd", function(aValue) { - var upwd = document.getElementById("uploadPwd"); - if (aValue) - document.getElementById("uploadPwd").value = aValue; - }); } window.onresize = function() { @@ -400,12 +382,8 @@ var uiEvHandler = { function setUploadField(aField) { switch (aField.id) { - case "uploadUser": - gPrefs.set(gDebug ? "osm_dev_user" : "osm_user", aField.value); - document.getElementById("uploadTrackButton").disabled = !aField.value.length; - break; - case "uploadPwd": - gPrefs.set(gDebug ? "osm_dev_pwd" : "osm_pwd", aField.value); + case "uploadDevName": + gPrefs.set("devicename", aField.value); break; } } @@ -497,7 +475,8 @@ function uploadTrack() { var desc = document.getElementById("uploadDesc").value; formData.append("comment", desc.length ? desc : "Track recorded via Lantea Maps"); - //formData.append("devicename", ""); + formData.append("devicename", + document.getElementById("uploadDevName").value); formData.append("public", document.getElementById("uploadPublic").value); @@ -673,7 +652,14 @@ function fetchBackend(aEndpoint, aMethod, aSendData, aCallback, aCallbackForward var result = {}; if (XHR.getResponseHeader("Content-Type") == "application/json") { // Got a JSON object, see if we have success. - result = JSON.parse(XHR.responseText); + try { + result = JSON.parse(XHR.responseText); + } + catch (e) { + console.log(e); + result = {"error": e, + "message": XHR.responseText}; + } } else { result = XHR.responseText; diff --git a/style/lantea.css b/style/lantea.css index c13f814..8abba24 100644 --- a/style/lantea.css +++ b/style/lantea.css @@ -283,6 +283,45 @@ h1 { color: #404040; } +.menuDrawer input[type="text"], +.menuDrawer input[type="number"] { + vertical-align: middle; + background-image: none; + background-color: rgba(204, 204, 204, .7); + color: #404040; + padding: 1px .5em; + margin: 1px 0; + border: 1px solid #CCCCCC; + border-radius: 3px; +} + +.menuDrawer input[type="text"] { + text-align: left; +} + +.menuDrawer input[type="number"] { + text-align: right; +} + +.menuDrawer input[type="text"]:disabled, +.menuDrawer input[type="number"]:disabled { + background-color: rgba(204, 204, 204, .1); + color: rgba(204, 204, 204, .5); + border: 1px solid rgba(255, 255, 255, .5); +} + +.menuDrawer input[type="text"]:not(:disabled):hover, +.menuDrawer input[type="number"]:not(:disabled):hover { + border: 1px solid #FFFFFF; +} + +.menuDrawer input[type="text"]:not(:disabled):focus, +.menuDrawer input[type="number"]:not(:disabled):focus { + background-color: rgba(204, 204, 255, .8); + border: 1px solid #FFFFFF; + color: #202020; +} + #trackData { margin: 0; } @@ -332,7 +371,7 @@ h1 { bottom: 5px; right: .5em; margin: 0; - font-size: small; + font-size: .8em; opacity: .66; z-index: 2; background-color: rgba(255, 255, 255, 1); @@ -371,7 +410,7 @@ h1 { .dialogHelp { margin: .5em 0; - font-size: small; + font-size: .8em; opacity: .66; } @@ -399,6 +438,5 @@ h1 { #copyright { bottom: 1px; right: 1px; - font-size: 8px; } } -- 2.43.0