Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebUI: Show country/region name next to its flag when 'Resolve peer countries' is enabled #21278

Merged
merged 3 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/webui/www/private/css/dynamicTable.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ tr.dynamicTableHeader {
background-image: url("../images/go-down.svg");
}

.dynamicTable td img.flags {
height: 1.25em;
vertical-align: middle;
.dynamicTable span.flags {
background: left center / contain no-repeat;
margin-left: 2px;
padding-left: 25px;
}

.dynamicTableFixedHeaderDiv {
Expand Down
29 changes: 8 additions & 21 deletions src/webui/www/private/scripts/dynamicTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1625,29 +1625,16 @@ window.qBittorrent.DynamicTable ??= (() => {
const country = this.getRowValue(row, 0);
const country_code = this.getRowValue(row, 1);

if (!country_code) {
if (td.getChildren("img").length > 0)
td.getChildren("img")[0].destroy();
return;
let span = td.firstElementChild;
if (span === null) {
span = document.createElement("span");
span.classList.add("flags");
td.append(span);
}

const img_path = "images/flags/" + country_code + ".svg";

if (td.getChildren("img").length > 0) {
const img = td.getChildren("img")[0];
img.src = img_path;
img.className = "flags";
img.alt = country;
img.title = country;
}
else {
td.adopt(new Element("img", {
"src": img_path,
"class": "flags",
"alt": country,
"title": country
}));
}
span.style.backgroundImage = `url('images/flags/${country_code ?? "xx"}.svg')`;
span.textContent = country;
td.title = country;
};

// ip
Expand Down
Loading