Skip to content

Commit

Permalink
chore: refine
Browse files Browse the repository at this point in the history
  • Loading branch information
vernesong committed Jan 4, 2025
1 parent 802a869 commit f4c7670
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
11 changes: 5 additions & 6 deletions luci-app-openclash/luasrc/view/openclash/dlercloud.htm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
.card .general h1 {
color: #ffffff;
}

.card .additional .user-card::after {
border-left: 2px solid #bbbbbb;
}
}

.center {
Expand Down Expand Up @@ -76,7 +80,7 @@
top: 10%;
right: -2px;
height: 80%;
border-left: 2px solid rgba(0,0,0,0.025);*/
border-left: 2px solid rgba(0,0,0,0.025);
}

.card .additional .user-card img {
Expand Down Expand Up @@ -315,11 +319,6 @@ <h1 id="dler-plan" ></h1>
var more_info = document.getElementById("more_info");
var dler_logo = document.getElementById("dler_logo");
var showmore=1;
var rootStyles = getComputedStyle(document.documentElement);

if (rootStyles.getPropertyValue('--bar-bg') == rootStyles.getPropertyValue('--dark-primary') && rootStyles.getPropertyValue('--bar-bg') != "") {
document.documentElement.setAttribute('data-darkmode', 'true');
}

XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "dler_info")%>', null, function(x, status) {
if (x && x.status == 200 && status.dler_info != "error") {
Expand Down
30 changes: 30 additions & 0 deletions luci-app-openclash/luasrc/view/openclash/sub_info_show.htm
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,36 @@
var s_<%=idname%>;
sub_info_get_<%=idname%>();

function isDarkBackground(element) {
var style = window.getComputedStyle(element);
var bgColor = style.backgroundColor;
let r, g, b;
if (/rgb\(/.test(bgColor)) {
var rgb = bgColor.match(/\d+/g);
r = parseInt(rgb);
g = parseInt(rgb);
b = parseInt(rgb);
} else if (/#/.test(bgColor)) {
if (bgColor.length === 4) {
r = parseInt(bgColor + bgColor, 16);
g = parseInt(bgColor + bgColor, 16);
b = parseInt(bgColor + bgColor, 16);
} else {
r = parseInt(bgColor.slice(1, 3), 16);
g = parseInt(bgColor.slice(3, 5), 16);
b = parseInt(bgColor.slice(5, 7), 16);
}
} else {
return false;
}
var luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b;
return luminance < 128;
}

if (isDarkBackground(document.body)) {
document.documentElement.setAttribute('data-darkmode', 'true');
}

function progressbar_<%=idname%>(v, m, pc, np, f, t, tr) {
return String.format(
'<div style="width:250px; max-width:500px; position:relative; border:1px solid #999999; border-radius: 6px">' +
Expand Down

0 comments on commit f4c7670

Please sign in to comment.