mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-07-22 14:30:58 -04:00
add badges
This commit is contained in:
parent
390b50353f
commit
35360e2069
4 changed files with 239 additions and 17 deletions
|
@ -10,6 +10,7 @@ const iconv = require("iconv-lite");
|
|||
const chardet = require("chardet");
|
||||
const fs = require("fs");
|
||||
const nodeJsUtil = require("util");
|
||||
const chroma = require("chroma-js");
|
||||
|
||||
// From ping-lite
|
||||
exports.WIN = /^win/.test(process.platform);
|
||||
|
@ -370,3 +371,12 @@ exports.errorLog = (error, outputToConsole = true) => {
|
|||
}
|
||||
} catch (_) { }
|
||||
};
|
||||
|
||||
exports.percentageToColor = (percentage, maxHue = 90, minHue = 10) => {
|
||||
const hue = percentage * (maxHue - minHue) + minHue;
|
||||
try {
|
||||
return chroma(`hsl(${hue}, 90%, 40%)`).hex();
|
||||
} catch (err) {
|
||||
return "grey";
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue