From 2e2851dc13d73352530dd4495c7e05603b2e520d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 Apr 2024 23:38:38 +0200 Subject: Adding upstream version 2.1.2~dev0+20240219. Signed-off-by: Daniel Baumann --- deluge/ui/web/js/deluge-all/details/DetailsTab.js | 100 ++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 deluge/ui/web/js/deluge-all/details/DetailsTab.js (limited to 'deluge/ui/web/js/deluge-all/details/DetailsTab.js') diff --git a/deluge/ui/web/js/deluge-all/details/DetailsTab.js b/deluge/ui/web/js/deluge-all/details/DetailsTab.js new file mode 100644 index 0000000..f1da178 --- /dev/null +++ b/deluge/ui/web/js/deluge-all/details/DetailsTab.js @@ -0,0 +1,100 @@ +/** + * Deluge.Details.Details.js + * The details tab displayed in the details panel. + * + * Copyright (c) Damien Churchill 2009-2010 + * + * This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with + * the additional special exception to link portions of this program with the OpenSSL library. + * See LICENSE for more details. + */ + +Deluge.details.DetailsTab = Ext.extend(Ext.Panel, { + title: _('Details'), + + fields: {}, + autoScroll: true, + queuedItems: {}, + + oldData: {}, + + initComponent: function () { + Deluge.details.DetailsTab.superclass.initComponent.call(this); + this.addItem('torrent_name', _('Name:')); + this.addItem('hash', _('Hash:')); + this.addItem('path', _('Download Folder:')); + this.addItem('size', _('Total Size:')); + this.addItem('files', _('Total Files:')); + this.addItem('comment', _('Comment:')); + this.addItem('status', _('Status:')); + this.addItem('tracker', _('Tracker:')); + this.addItem('creator', _('Created By:')); + }, + + onRender: function (ct, position) { + Deluge.details.DetailsTab.superclass.onRender.call(this, ct, position); + this.body.setStyle('padding', '10px'); + this.dl = Ext.DomHelper.append(this.body, { tag: 'dl' }, true); + + for (var id in this.queuedItems) { + this.doAddItem(id, this.queuedItems[id]); + } + }, + + addItem: function (id, label) { + if (!this.rendered) { + this.queuedItems[id] = label; + } else { + this.doAddItem(id, label); + } + }, + + // private + doAddItem: function (id, label) { + Ext.DomHelper.append(this.dl, { tag: 'dt', cls: id, html: label }); + this.fields[id] = Ext.DomHelper.append( + this.dl, + { tag: 'dd', cls: id, html: '' }, + true + ); + }, + + clear: function () { + if (!this.fields) return; + for (var k in this.fields) { + this.fields[k].dom.innerHTML = ''; + } + this.oldData = {}; + }, + + update: function (torrentId) { + deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Details, { + success: this.onRequestComplete, + scope: this, + torrentId: torrentId, + }); + }, + + onRequestComplete: function (torrent, request, response, options) { + var data = { + torrent_name: torrent.name, + hash: options.options.torrentId, + path: torrent.download_location, + size: fsize(torrent.total_size), + files: torrent.num_files, + status: torrent.message, + tracker: torrent.tracker_host, + comment: torrent.comment, + creator: torrent.creator, + }; + + for (var field in this.fields) { + if (!Ext.isDefined(data[field])) continue; // This is a field we are not responsible for. + if (data[field] == this.oldData[field]) continue; + this.fields[field].dom.innerHTML = Ext.util.Format.htmlEncode( + data[field] + ); + } + this.oldData = data; + }, +}); -- cgit v1.2.3