mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 02:18:42 +00:00
chore: misc WebUI fixes and cleanup (#7037)
* chore: housekeeping * fix: use `setCurrentPopup` for drag and drop dialogue * fix: minor typo * chore: removed unused timer * fix: correct value in `<input multiple='?'>` * fixup! chore: housekeeping * code review: use `URL.canParse()` * Revert "code review: use `URL.canParse()`" This reverts commit b1a436031ab154d8075762c91dd67d8c9eb954af.
This commit is contained in:
@@ -8,7 +8,7 @@ import { Formatter } from './formatter.js';
|
|||||||
import { createDialogContainer, makeUUID } from './utils.js';
|
import { createDialogContainer, makeUUID } from './utils.js';
|
||||||
|
|
||||||
export class OpenDialog extends EventTarget {
|
export class OpenDialog extends EventTarget {
|
||||||
constructor(controller, remote, url = '', files = []) {
|
constructor(controller, remote, url = '', files = null) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.controller = controller;
|
this.controller = controller;
|
||||||
@@ -18,7 +18,7 @@ export class OpenDialog extends EventTarget {
|
|||||||
this.elements.dismiss.addEventListener('click', () => this._onDismiss());
|
this.elements.dismiss.addEventListener('click', () => this._onDismiss());
|
||||||
this.elements.confirm.addEventListener('click', () => this._onConfirm());
|
this.elements.confirm.addEventListener('click', () => this._onConfirm());
|
||||||
document.body.append(this.elements.root);
|
document.body.append(this.elements.root);
|
||||||
if (files.length > 0) {
|
if (files) {
|
||||||
this.elements.file_input.files = files;
|
this.elements.file_input.files = files;
|
||||||
}
|
}
|
||||||
this._updateFreeSpaceInAddDialog();
|
this._updateFreeSpaceInAddDialog();
|
||||||
@@ -47,8 +47,8 @@ export class OpenDialog extends EventTarget {
|
|||||||
const path = this.elements.folder_input.value;
|
const path = this.elements.folder_input.value;
|
||||||
this.remote.getFreeSpace(path, (dir, bytes) => {
|
this.remote.getFreeSpace(path, (dir, bytes) => {
|
||||||
if (!this.closed) {
|
if (!this.closed) {
|
||||||
const string = bytes > 0 ? `${Formatter.size(bytes)} Free` : '';
|
this.elements.freespace.textContent =
|
||||||
this.elements.freespace.textContent = string;
|
bytes > 0 ? `${Formatter.size(bytes)} Free` : '';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -137,7 +137,7 @@ export class OpenDialog extends EventTarget {
|
|||||||
input.type = 'file';
|
input.type = 'file';
|
||||||
input.name = 'torrent-files[]';
|
input.name = 'torrent-files[]';
|
||||||
input.id = input_id;
|
input.id = input_id;
|
||||||
input.multiple = 'multiple';
|
input.multiple = true;
|
||||||
workarea.append(input);
|
workarea.append(input);
|
||||||
elements.file_input = input;
|
elements.file_input = input;
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
export class PrefsDialog extends EventTarget {
|
export class PrefsDialog extends EventTarget {
|
||||||
static _initTimeDropDown(e) {
|
static _initTimeDropDown(e) {
|
||||||
for (let index = 0; index < 24 * 4; ++index) {
|
for (let index = 0; index < 24 * 4; ++index) {
|
||||||
const hour = Number.parseInt(index / 4, 10);
|
const hour = index / 4;
|
||||||
const mins = (index % 4) * 15;
|
const mins = (index % 4) * 15;
|
||||||
const value = index * 15;
|
const value = index * 15;
|
||||||
const content = `${hour}:${mins || '00'}`;
|
const content = `${hour}:${mins || '00'}`;
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export class Transmission extends EventTarget {
|
|||||||
|
|
||||||
this.boundPopupCloseListener = this.popupCloseListener.bind(this);
|
this.boundPopupCloseListener = this.popupCloseListener.bind(this);
|
||||||
|
|
||||||
this.isTouch = 'ontouchstart' in window ? true : false;
|
this.isTouch = 'ontouchstart' in window;
|
||||||
this.busyclick = false;
|
this.busyclick = false;
|
||||||
|
|
||||||
// listen to actions
|
// listen to actions
|
||||||
@@ -506,7 +506,7 @@ export class Transmission extends EventTarget {
|
|||||||
if (event_.metaKey) {
|
if (event_.metaKey) {
|
||||||
a.push('Meta');
|
a.push('Meta');
|
||||||
}
|
}
|
||||||
if (event_.shitKey) {
|
if (event_.shiftKey) {
|
||||||
a.push('Shift');
|
a.push('Shift');
|
||||||
}
|
}
|
||||||
a.push(event_.key.length === 1 ? event_.key.toUpperCase() : event_.key);
|
a.push(event_.key.length === 1 ? event_.key.toUpperCase() : event_.key);
|
||||||
@@ -622,7 +622,7 @@ export class Transmission extends EventTarget {
|
|||||||
static _isValidURL(string) {
|
static _isValidURL(string) {
|
||||||
try {
|
try {
|
||||||
const url = new URL(string);
|
const url = new URL(string);
|
||||||
return url ? true : false;
|
return Boolean(url);
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -639,9 +639,9 @@ export class Transmission extends EventTarget {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const type = event_.dataTransfer.types
|
const type = event_.dataTransfer.types.findLast((t) =>
|
||||||
.filter((t) => ['text/uri-list', 'text/plain'].includes(t))
|
['text/uri-list', 'text/plain'].includes(t),
|
||||||
.pop();
|
);
|
||||||
for (const uri of event_.dataTransfer
|
for (const uri of event_.dataTransfer
|
||||||
.getData(type)
|
.getData(type)
|
||||||
.split('\n')
|
.split('\n')
|
||||||
@@ -653,7 +653,7 @@ export class Transmission extends EventTarget {
|
|||||||
const { files } = event_.dataTransfer;
|
const { files } = event_.dataTransfer;
|
||||||
|
|
||||||
if (files.length > 0) {
|
if (files.length > 0) {
|
||||||
this.openDialog = new OpenDialog(this, this.remote, '', files);
|
this.setCurrentPopup(new OpenDialog(this, this.remote, '', files));
|
||||||
}
|
}
|
||||||
event_.preventDefault();
|
event_.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
@@ -1026,9 +1026,6 @@ TODO: fix this when notifications get fixed
|
|||||||
|
|
||||||
this._updateFilterSelect();
|
this._updateFilterSelect();
|
||||||
|
|
||||||
clearTimeout(this.refilterTimer);
|
|
||||||
delete this.refilterTimer;
|
|
||||||
|
|
||||||
if (rebuildEverything) {
|
if (rebuildEverything) {
|
||||||
while (list.firstChild) {
|
while (list.firstChild) {
|
||||||
list.firstChild.remove();
|
list.firstChild.remove();
|
||||||
@@ -1127,13 +1124,6 @@ TODO: fix this when notifications get fixed
|
|||||||
this._rows = rows;
|
this._rows = rows;
|
||||||
this.dirtyTorrents.clear();
|
this.dirtyTorrents.clear();
|
||||||
|
|
||||||
// set the odd/even property
|
|
||||||
for (const [index, e] of rows.map((row) => row.getElement()).entries()) {
|
|
||||||
const even = index % 2 === 0;
|
|
||||||
e.classList.toggle('even', even);
|
|
||||||
e.classList.toggle('odd', !even);
|
|
||||||
}
|
|
||||||
|
|
||||||
this._updateStatusbar();
|
this._updateStatusbar();
|
||||||
if (
|
if (
|
||||||
old_sel_count !== countSelectedRows() ||
|
old_sel_count !== countSelectedRows() ||
|
||||||
|
|||||||
Reference in New Issue
Block a user