irgendwas mit json

This commit is contained in:
2024-06-07 01:56:43 +02:00
parent 6290a78666
commit b2e7b948fe
3 changed files with 35 additions and 32 deletions

View File

@ -1,12 +1,13 @@
const batteryLevel = batteryPercent => ({
"-2": "not connected",
"-1": "charging"
})[batteryPercent] ?? batteryPercent + "%";
const batteryLevel = (batteryStatus, batteryPercent) => ({
"BATTERY_UNAVAILABLE": "not connected",
"BATTERY_CHARGING": "charging (" + batteryPercent + "%)"
})[batteryStatus] ?? batteryPercent + "%";
const batteryIcon = batteryPercent => ({
"-2": "action-unavailable",
"-1": "reload"
})[batteryPercent] ?? "audio-headphones-symbolic";
const batteryIcon = batteryStatus => ({
"BATTERY_UNAVAILABLE": "action-unavailable",
"BATTERY_AVAILABLE": "audio-headphones-symbolic",
"BATTERY_CHARGING": "reload"
})[batteryStatus] ?? "audio-headphones-symbolic";
const hex2rgb = (hex, h = hex.replace('#', '0x')) => ({ r: h >> 16 & 255, g: h >> 8 & 255, b: h & 255 });
const rgb2Hex = rgb => "#" + ((1 << 24) + (rgb.r << 16) + (rgb.g << 8) + rgb.b).toString(16).slice(1);