      1 /*
      2 Script: Deluge.Details.Details.js
      3     The details tab displayed in the details panel.
      4
      5 Copyright:
      6 	(C) Damien Churchill 2009 <damoxc@gmail.com>
      7 	This program is free software; you can redistribute it and/or modify
      8 	it under the terms of the GNU General Public License as published by
      9 	the Free Software Foundation; either version 3, or (at your option)
     10 	any later version.
     11
     12 	This program is distributed in the hope that it will be useful,
     13 	but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 	GNU General Public License for more details.
     16
     17 	You should have received a copy of the GNU General Public License
     18 	along with this program.  If not, write to:
     19 		The Free Software Foundation, Inc.,
     20 		51 Franklin Street, Fifth Floor
     21 		Boston, MA  02110-1301, USA.
     22 #
     23 #    In addition, as a special exception, the copyright holders give
     24 #    permission to link the code of portions of this program with the OpenSSL
     25 #    library.
     26 #    You must obey the GNU General Public License in all respects for all of
     27 #    the code used other than OpenSSL. If you modify file(s) with this
     28 #    exception, you may extend this exception to your version of the file(s),
     29 #    but you are not obligated to do so. If you do not wish to do so, delete
     30 #    this exception statement from your version. If you delete this exception
     31 #    statement from all source files in the program, then also delete it here.
     32 #
     33 */
     34
     35 Ext.deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
     36 	title: _('Details'),
     37 	cls: 'x-deluge-status',
     38
     39 	onRender: function(ct, position) {
     40 		Ext.deluge.details.DetailsTab.superclass.onRender.call(this, ct, position);
     41 		this.load({
     42 			url: '/render/tab_details.html',
     43 			text: _('Loading') + '...'
     44 		});
     45 		this.getUpdater().on('update', this.onPanelUpdate, this);
     46 	},
     47
     48 	clear: function() {
     49 		if (!this.fields) return;
     50 		for (var k in this.fields) {
     51 			this.fields[k].innerHTML = '';
     52 		}
     53 	},
     54
     55 	update: function(torrentId) {
     56 		Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Details, {
     57 			success: this.onRequestComplete,
     58 			scope: this,
     59 			torrentId: torrentId
     60 		});
     61 	},
     62
     63 	onPanelUpdate: function(el, response) {
     64 		this.fields = {};
     65 		Ext.each(Ext.query('dd', this.body.dom), function(field) {
     66 			this.fields[field.className] = field;
     67 		}, this);
     68 	},
     69
     70 	onRequestComplete: function(torrent, options) {
     71 		var data = {
     72 			torrent_name: torrent.name,
     73 			hash: options.torrentId,
     74 			path: torrent.save_path,
     75 			size: fsize(torrent.total_size),
     76 			files: torrent.num_files,
     77 			status: torrent.tracker_status,
     78 			tracker: torrent.tracker,
     79 			comment: torrent.comment
     80 		};
     81
     82 		for (var field in this.fields) {
     83 			this.fields[field].innerHTML = data[field];
     84 		}
     85 	}
     86 });
     87 Deluge.Details.add(new Ext.deluge.details.DetailsTab());