[] wp_editor: reindent, minor cleanups.

master
Pavel Machek 2023-11-03 21:56:10 +01:00
parent 73375ebe96
commit dbde4923c6
1 changed files with 42 additions and 45 deletions

View File

@ -31,7 +31,7 @@ function mainMenu() {
print("(no waypoints)"); print("(no waypoints)");
} else for (let id in wp) { } else for (let id in wp) {
let i = id; let i = id;
menu[wp[id]["name"]]=()=>{ decode(i); }; menu[wp[id]["name"]]=()=>{ show(i); };
} }
menu["Add"]=addCard; menu["Add"]=addCard;
menu["Remove"]=removeCard; menu["Remove"]=removeCard;
@ -78,17 +78,17 @@ function stopGps() {
function confirmGps(s) { function confirmGps(s) {
key = s; key = s;
var la = new Layout ( var la = new Layout (
{type:"v", c: [ {type:"v", c: [
{type:"txt", font:"15%", pad:1, fillx:1, filly:1, label:""}, {type:"txt", font:"15%", pad:1, fillx:1, filly:1, label:""},
{type:"txt", font:"15%", pad:1, fillx:1, filly:1, label:""}, {type:"txt", font:"15%", pad:1, fillx:1, filly:1, label:""},
{type:"h", c: [ {type:"h", c: [
{type:"btn", font:"15%", pad:1, fillx:1, filly:1, label: "YES", cb:l=>{ {type:"btn", font:"15%", pad:1, fillx:1, filly:1, label: "YES", cb:l=>{
print("should mark", key, fix); createWP(fix.lat, fix.lon, key); cancel_gps=true; mainMenu(); print("should mark", key, fix); createWP(fix.lat, fix.lon, key); cancel_gps=true; mainMenu();
}}, }},
{type:"btn", font:"15%", pad:1, fillx:1, filly:1, label: " NO", cb:l=>{ cancel_gps=true; mainMenu(); }} {type:"btn", font:"15%", pad:1, fillx:1, filly:1, label: " NO", cb:l=>{ cancel_gps=true; mainMenu(); }}
]} ]}
], lazy:true}); ], lazy:true});
g.clear(); g.clear();
la.render(); la.render();
updateGps(); updateGps();
@ -105,12 +105,12 @@ function markGps() {
function setFormat() { function setFormat() {
var la = new Layout ( var la = new Layout (
{type:"v", c: [ {type:"v", c: [
{type:"txt", font:"15%", pad:1, fillx:1, filly:1, label:"Format"}, {type:"txt", font:"15%", pad:1, fillx:1, filly:1, label:"Format"},
{type:"btn", font:"15%", pad:1, fillx:1, filly:1, label: "DD.dddd", cb:l=>{ mode = 0; mainMenu(); }}, {type:"btn", font:"15%", pad:1, fillx:1, filly:1, label: "DD.dddd", cb:l=>{ mode = 0; mainMenu(); }},
{type:"btn", font:"15%", pad:1, fillx:1, filly:1, label: "DD MM.mmm'", cb:l=>{ mode = 1; mainMenu(); }}, {type:"btn", font:"15%", pad:1, fillx:1, filly:1, label: "DD MM.mmm'", cb:l=>{ mode = 1; mainMenu(); }},
{type:"btn", font:"15%", pad:1, fillx:1, filly:1, label: "DD MM'ss"+'"', cb:l=>{ mode = 2; mainMenu(); }}, {type:"btn", font:"15%", pad:1, fillx:1, filly:1, label: "DD MM'ss"+'"', cb:l=>{ mode = 2; mainMenu(); }},
], lazy:true}); ], lazy:true});
g.clear(); g.clear();
la.render(); la.render();
} }
@ -134,7 +134,6 @@ function format(x) {
return "" + d + " " + mf + "'" + s + '"'; return "" + d + " " + mf + "'" + s + '"';
} }
} }
function lat(x) { function lat(x) {
c = "N"; c = "N";
if (x<0) { if (x<0) {
@ -143,7 +142,6 @@ function lat(x) {
} }
return c+format(x); return c+format(x);
} }
function lon(x) { function lon(x) {
c = "E"; c = "E";
if (x<0) { if (x<0) {
@ -153,17 +151,17 @@ function lon(x) {
return c+format(x); return c+format(x);
} }
function decode(pin) { function show(pin) {
print(pin); print(pin);
var i = wp[pin]; var i = wp[pin];
var l = i["name"] + "\n" + lat(i["lat"]) + "\n" + lon(i["lon"]); var l = i["name"] + "\n" + lat(i["lat"]) + "\n" + lon(i["lon"]);
var la = new Layout ({ var la = new Layout ({
type:"v", c: [ type:"v", c: [
{type:"txt", font:"10%", pad:1, fillx:1, filly:1, label: l}, {type:"txt", font:"10%", pad:1, fillx:1, filly:1, label: l},
{type:"btn", font:"10%", pad:1, fillx:1, filly:1, label:"OK", cb:l=>{mainMenu();}} {type:"btn", font:"10%", pad:1, fillx:1, filly:1, label:"OK", cb:l=>{mainMenu();}}
], lazy:true}); ], lazy:true});
g.clear(); g.clear();
la.render(); la.render();
} }
function showNumpad(text, key_, callback) { function showNumpad(text, key_, callback) {
@ -307,22 +305,22 @@ function askPosition(callback) {
} }
function createWP(lat, lon, name) { function createWP(lat, lon, name) {
let n = {}; let n = {};
n["name"] = name; n["name"] = name;
n["lat"] = lat; n["lat"] = lat;
n["lon"] = lon; n["lon"] = lon;
wp.push(n); wp.push(n);
print("add -- waypoints", wp); print("add -- waypoints", wp);
writeWP(); writeWP();
} }
function addCardName(name) { function addCardName(name) {
g.clear(); g.clear();
askPosition(function(lat, lon) { askPosition(function(lat, lon) {
print("position -- ", lat, lon); print("position -- ", lat, lon);
createWP(lat, lon, result); createWP(lat, lon, result);
mainMenu(); mainMenu();
}); });
} }
function addCard() { function addCard() {
@ -346,7 +344,6 @@ function addCard() {
}); });
} }
g.reset(); g.reset();
Bangle.setUI(); Bangle.setUI();
mainMenu(); mainMenu();