diff options
Diffstat (limited to 'web/assets/js/util')
| -rw-r--r-- | web/assets/js/util/common.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/web/assets/js/util/common.js b/web/assets/js/util/common.js index a695f081..20df4f4e 100644 --- a/web/assets/js/util/common.js +++ b/web/assets/js/util/common.js @@ -91,6 +91,21 @@ function setCookie(cname, cvalue, exdays) { document.cookie = cname + '=' + cvalue + ';' + expires + ';path=/'; } +function usageColor(data, threshold, total) { + switch (true) { + case data === null: + return 'blue'; + case total <= 0: + return 'blue'; + case data < total - threshold: + return 'cyan'; + case data < total: + return 'orange'; + default: + return 'red'; + } +} + function doAllItemsExist(array1, array2) { for (let i = 0; i < array1.length; i++) { if (!array2.includes(array1[i])) { @@ -98,4 +113,4 @@ function doAllItemsExist(array1, array2) { } } return true; -}
\ No newline at end of file +} |
