Modified the json format and colon color
parent
441980f45a
commit
dff1259813
|
|
@ -115,34 +115,29 @@ let loadJson = function() {
|
||||||
const vals = getVal(now, location);
|
const vals = getVal(now, location);
|
||||||
//vals.steps = null; // For testing; uncomment to see the steps not appear
|
//vals.steps = null; // For testing; uncomment to see the steps not appear
|
||||||
//location.location = null; // For testing, if null, the time becomes an struct to take up sun's struct
|
//location.location = null; // For testing, if null, the time becomes an struct to take up sun's struct
|
||||||
let raw;
|
const hasLoc = location.location !== null;
|
||||||
|
let raw = {
|
||||||
if (location.location !== null) {
|
time: hasLoc
|
||||||
raw = {
|
? vals.time
|
||||||
time: vals.time,
|
: {
|
||||||
dt: vals.date,
|
|
||||||
sun: {
|
|
||||||
rise: vals.rise,
|
|
||||||
set: vals.set,
|
|
||||||
},
|
|
||||||
"batt_%": vals.batt_pct,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
raw = {
|
|
||||||
time: {
|
|
||||||
hr: getHr(now.getHours())[0],
|
hr: getHr(now.getHours())[0],
|
||||||
min: now.getMinutes(),
|
min: now.getMinutes(),
|
||||||
},
|
},
|
||||||
dt: vals.date,
|
dt: vals.date,
|
||||||
"batt_%": vals.batt_pct,
|
"batt_%": vals.batt_pct,
|
||||||
};
|
};
|
||||||
|
if (vals.steps != null) {
|
||||||
|
raw.steps = vals.steps;
|
||||||
|
}
|
||||||
|
if (hasLoc) {
|
||||||
|
raw.sun = {
|
||||||
|
rise: vals.rise,
|
||||||
|
set: vals.set,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vals.steps != null) raw.steps = vals.steps;
|
|
||||||
|
|
||||||
jsonText = JSON.stringify(raw, null, 2);
|
jsonText = JSON.stringify(raw, null, 2);
|
||||||
lines = jsonText.split("\n");
|
lines = jsonText.split("\n");
|
||||||
};
|
};
|
||||||
|
|
||||||
let draw = function() {
|
let draw = function() {
|
||||||
g.clear();
|
g.clear();
|
||||||
|
|
@ -190,10 +185,10 @@ let redraw = function() {
|
||||||
|
|
||||||
// Key
|
// Key
|
||||||
g.setColor(clrs.keys);
|
g.setColor(clrs.keys);
|
||||||
g.drawString(indent + `"${key}"`, numWidth, y);
|
const keyText = indent + `"${key}": `
|
||||||
const keyWidth = g.stringWidth(indent + `"${key}"`);
|
g.drawString(keyText, numWidth, y);
|
||||||
|
const keyWidth = g.stringWidth(keyText);
|
||||||
const valueX = numWidth + keyWidth;
|
const valueX = numWidth + keyWidth;
|
||||||
const valueText = ": " + value;
|
|
||||||
|
|
||||||
// Value color
|
// Value color
|
||||||
if (value.startsWith('"')) {
|
if (value.startsWith('"')) {
|
||||||
|
|
@ -203,7 +198,7 @@ let redraw = function() {
|
||||||
} else {
|
} else {
|
||||||
g.setColor(clrs.ints);
|
g.setColor(clrs.ints);
|
||||||
}
|
}
|
||||||
g.drawString(valueText, valueX, y);
|
g.drawString(value, valueX, y);
|
||||||
|
|
||||||
valuePositions.push({
|
valuePositions.push({
|
||||||
key,
|
key,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue