outsource lib
This commit is contained in:
22
package/contents/ui/lib/helper.js
Normal file
22
package/contents/ui/lib/helper.js
Normal file
@ -0,0 +1,22 @@
|
||||
function batteryColor(batteryPercent) {
|
||||
const colors = [
|
||||
'#f00', '#e21c00', '#c83800', '#a50', '#8d7100',
|
||||
'#718d00', '#6fa100', '#5c8000', '#498000', '#080'
|
||||
];
|
||||
let color;
|
||||
switch(batteryPercent) {
|
||||
case -1: color = "green"; break;
|
||||
case -2: color = "red"; break;
|
||||
default: color = colors[~~(batteryPercent / 10 + 0.5)]; break;
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
function batteryLevel(batteryPercent) {
|
||||
if(batteryPercent == -1)
|
||||
return "charging";
|
||||
else if(batteryPercent == -2)
|
||||
return "not connected";
|
||||
else
|
||||
return batteryPercent + "%";
|
||||
}
|
Reference in New Issue
Block a user