Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlireza Ahmadi <alireza7@gmail.com>2023-12-04 21:17:38 +0300
committerAlireza Ahmadi <alireza7@gmail.com>2023-12-04 21:18:53 +0300
commit729d8549e2b536a10c402a88e0d4cfde9e4baf3f (patch)
treed108e2f29516766318ac89e4ee86c719eb14c1a3 /web/assets
parentf734c821d6e62eca5a206b6048f3cd7d65f3e665 (diff)
new frontend and mobile view #1286
Diffstat (limited to 'web/assets')
-rw-r--r--web/assets/js/model/models.js13
-rw-r--r--web/assets/js/util/common.js48
2 files changed, 50 insertions, 11 deletions
diff --git a/web/assets/js/model/models.js b/web/assets/js/model/models.js
index 122145fb..dd602c46 100644
--- a/web/assets/js/model/models.js
+++ b/web/assets/js/model/models.js
@@ -141,6 +141,19 @@ class DBInbound {
return Inbound.fromJson(config);
}
+ isMultiUser() {
+ switch (this.protocol) {
+ case Protocols.VMESS:
+ case Protocols.VLESS:
+ case Protocols.TROJAN:
+ return true;
+ case Protocols.SHADOWSOCKS:
+ return this.toInbound().isSSMultiUser;
+ default:
+ return false;
+ }
+ }
+
hasLink() {
switch (this.protocol) {
case Protocols.VMESS:
diff --git a/web/assets/js/util/common.js b/web/assets/js/util/common.js
index 8e30bce7..b2f15fb2 100644
--- a/web/assets/js/util/common.js
+++ b/web/assets/js/util/common.js
@@ -52,13 +52,15 @@ function safeBase64(str) {
function formatSecond(second) {
if (second < 60) {
- return second.toFixed(0) + ' s';
+ return second.toFixed(0) + 's';
} else if (second < 3600) {
- return (second / 60).toFixed(0) + ' m';
+ return (second / 60).toFixed(0) + 'm';
} else if (second < 3600 * 24) {
- return (second / 3600).toFixed(0) + ' h';
+ return (second / 3600).toFixed(0) + 'h';
} else {
- return (second / 3600 / 24).toFixed(0) + ' d';
+ day = Math.floor(second / 3600 / 24);
+ remain = ((second/3600) - (day*24)).toFixed(0);
+ return day + 'd' + (remain > 0 ? ' ' + remain + 'h' : '');
}
}
@@ -72,7 +74,7 @@ function addZero(num) {
function toFixed(num, n) {
n = Math.pow(10, n);
- return Math.round(num * n) / n;
+ return Math.floor(num * n) / n;
}
function debounce(fn, delay) {
@@ -115,15 +117,39 @@ function setCookie(cname, cvalue, exdays) {
function usageColor(data, threshold, total) {
switch (true) {
case data === null:
- return 'blue';
- case total <= 0:
- return 'blue';
+ return "green";
+ case total < 0:
+ return "blue";
+ case total == 0:
+ return "purple";
case data < total - threshold:
- return 'cyan';
+ return "blue";
case data < total:
- return 'orange';
+ return "orange";
default:
- return 'red';
+ return "red";
+ }
+}
+
+function userExpiryColor(threshold, client, isDark = false) {
+ if (!client.enable) {
+ return isDark ? '#2c3950' : '#bcbcbc';
+ }
+ now = new Date().getTime(),
+ expiry = client.expiryTime;
+ switch (true) {
+ case expiry === null:
+ return "#389e0d";
+ case expiry < 0:
+ return "#0e49b5";
+ case expiry == 0:
+ return "#7a316f";
+ case now < expiry - threshold:
+ return "#0e49b5";
+ case now < expiry:
+ return "#ffa031";
+ default:
+ return "#e04141";
}
}