Pre-bind methods

This commit is contained in:
2025-10-09 10:27:23 +02:00
parent b17ecb2961
commit 46e7f7540b
3 changed files with 22 additions and 22 deletions

View File

@@ -19,7 +19,7 @@ class trdom_torrentcontrol {
//TODO: remove
#getKnownTorrents;
#handler(e) {
#handler = function(e) {
switch (e.type) {
case 'click':
if (e.currentTarget.hasAttributeNS('trweb', 'torrentlistfield')) {
@@ -55,7 +55,7 @@ class trdom_torrentcontrol {
}
}
}
}
}.bind(this);
constructor(hash, server, logcb, getKnownTorrents) {
this.#hash = hash;
@@ -81,7 +81,7 @@ class trdom_torrentcontrol {
element_start.setAttributeNS('trweb', 'torrent', this.#hash);
element_start.setAttributeNS('trweb', 'torrentlistfield', 'start');
element_start.appendChild(document.createTextNode("Start"));
element_start.addEventListener("click", this.#handler.bind(this));
element_start.addEventListener("click", this.#handler);
let element_pause = document.createElement('div');
element_pause.classList.add('trweb_torrentlistcontrol', 'col-4');
@@ -89,7 +89,7 @@ class trdom_torrentcontrol {
element_pause.setAttributeNS('trweb', 'torrent', this.#hash);
element_pause.setAttributeNS('trweb', 'torrentlistfield', 'pause');
element_pause.appendChild(document.createTextNode("Pause"));
element_pause.addEventListener("click", this.#handler.bind(this));
element_pause.addEventListener("click", this.#handler);
// Download by magnet
let element_magnet = document.createElement('div');
@@ -98,7 +98,7 @@ class trdom_torrentcontrol {
element_magnet.setAttributeNS('trweb', 'torrent', this.#hash);
element_magnet.setAttributeNS('trweb', 'torrentlistfield', 'magnet');
element_magnet.appendChild(document.createTextNode(`[${srv}] Magnet`));
element_magnet.addEventListener("click", this.#handler.bind(this));
element_magnet.addEventListener("click", this.#handler);
// Download by torrent file
let element_download = document.createElement('div');
@@ -107,7 +107,7 @@ class trdom_torrentcontrol {
element_download.setAttributeNS('trweb', 'torrent', this.#hash);
element_download.setAttributeNS('trweb', 'torrentlistfield', 'download');
element_download.appendChild(document.createTextNode(`[${srv}] Get torrent`));
element_download.addEventListener("click", this.#handler.bind(this));
element_download.addEventListener("click", this.#handler);
// row container
let element_serverrow = document.createElement('div');