Fix start/pause buttons
Magnet is still broken
This commit is contained in:
@@ -25,19 +25,16 @@ class trdom_torrentcontrol {
|
||||
if (e.currentTarget.hasAttributeNS('trweb', 'torrentlistfield')) {
|
||||
switch (e.currentTarget.getAttributeNS('trweb', 'torrentlistfield')) {
|
||||
case 'start':
|
||||
hash = e.currentTarget.getAttributeNS('trweb', 'torrent');
|
||||
this.#server.torrent_start(hash);
|
||||
this.#server.torrent_start(this.#hash);
|
||||
e.stopPropagation();
|
||||
break;
|
||||
case 'pause':
|
||||
hash = e.currentTarget.getAttributeNS('trweb', 'torrent');
|
||||
this.#server.torrent_pause(hash);
|
||||
this.#server.torrent_pause(this.#hash);
|
||||
e.stopPropagation();
|
||||
break;
|
||||
case 'magnet':
|
||||
let magneturl;
|
||||
hash = e.currentTarget.getAttributeNS('trweb', 'torrent');
|
||||
for (const [srv, data] of Object.entries(this.#getKnownTorrents()[hash].servers)) {
|
||||
for (const [srv, data] of Object.entries(this.#getKnownTorrents()[this.#hash].servers)) {
|
||||
if (data.magnetLink != null) {
|
||||
magneturl = data.magnetLink;
|
||||
break;
|
||||
@@ -47,7 +44,7 @@ class trdom_torrentcontrol {
|
||||
this.#server.torrent_add_url(magneturl, false, null);
|
||||
}
|
||||
else {
|
||||
this.#log(3, `Couldn't find magnet link! ${JSON.stringify(this.#getKnownTorrents()[hash].servers)}`);
|
||||
this.#log(3, `Couldn't find magnet link! ${JSON.stringify(this.#getKnownTorrents()[this.#hash].servers)}`);
|
||||
}
|
||||
e.stopPropagation();
|
||||
break;
|
||||
@@ -81,7 +78,7 @@ class trdom_torrentcontrol {
|
||||
let element_start = document.createElement('div');
|
||||
element_start.classList.add('trweb_torrentlistcontrol', 'col-4');
|
||||
element_start.setAttributeNS('trweb', 'server', srv);
|
||||
element_start.setAttributeNS('trweb', 'torrent', hash);
|
||||
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));
|
||||
@@ -89,7 +86,7 @@ class trdom_torrentcontrol {
|
||||
let element_pause = document.createElement('div');
|
||||
element_pause.classList.add('trweb_torrentlistcontrol', 'col-4');
|
||||
element_pause.setAttributeNS('trweb', 'server', srv);
|
||||
element_pause.setAttributeNS('trweb', 'torrent', hash);
|
||||
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));
|
||||
@@ -98,7 +95,7 @@ class trdom_torrentcontrol {
|
||||
let element_magnet = document.createElement('div');
|
||||
element_magnet.classList.add('trweb_torrentlistmagnet', 'col');
|
||||
element_magnet.setAttributeNS('trweb', 'server', srv);
|
||||
element_magnet.setAttributeNS('trweb', 'torrent', hash);
|
||||
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));
|
||||
@@ -107,7 +104,7 @@ class trdom_torrentcontrol {
|
||||
let element_download = document.createElement('div');
|
||||
element_download.classList.add('trweb_torrentlistdownload', 'col');
|
||||
element_download.setAttributeNS('trweb', 'server', srv);
|
||||
element_download.setAttributeNS('trweb', 'torrent', hash);
|
||||
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));
|
||||
|
||||
Reference in New Issue
Block a user