WebUI: Use vanilla JS to create elements

All elements are now created using createElement() method:
https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement

PR #21975.

---------

Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
This commit is contained in:
skomerko
2024-12-14 20:31:44 +01:00
committed by GitHub
parent 4c6dd8e68d
commit 14684c8c83
7 changed files with 167 additions and 190 deletions

View File

@@ -61,23 +61,20 @@ window.qBittorrent.PiecesBar ??= (() => {
Object.append(vals, parameters);
vals.height = Math.max(vals.height, 12);
const obj = new Element("div", {
"id": vals.id,
"class": "piecesbarWrapper",
"styles": {
"border": vals.borderSize.toString() + "px solid " + vals.borderColor,
"height": vals.height.toString() + "px",
}
});
const obj = document.createElement("div");
obj.id = vals.id;
obj.className = "piecesbarWrapper";
obj.style.border = `${vals.borderSize}px solid ${vals.borderColor}`;
obj.style.height = `${vals.height}px`;
obj.vals = vals;
obj.vals.pieces = [pieces, []].pick();
obj.vals.canvas = new Element("canvas", {
"id": vals.id + "_canvas",
"class": "piecesbarCanvas",
"width": (vals.width - (2 * vals.borderSize)).toString(),
"height": "1" // will stretch vertically to take up the height of the parent
});
const canvas = document.createElement("canvas");
canvas.id = `${vals.id}_canvas`;
canvas.className = "piecesbarCanvas";
canvas.width = `${vals.width - (2 * vals.borderSize)}`;
canvas.height = "1"; // will stretch vertically to take up the height of the parent
obj.vals.canvas = canvas;
obj.appendChild(obj.vals.canvas);
obj.setPieces = setPieces;