2008-07-10 23:57:46 +00:00
|
|
|
/*
|
2011-03-10 01:37:58 +00:00
|
|
|
* Copyright © Dave Perrett, Malcolm Jarvis and Bruno Bierbaumer
|
2008-07-10 23:57:46 +00:00
|
|
|
* This code is licensed under the GPL version 2.
|
|
|
|
* For details, see http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
*
|
|
|
|
* Class Transmission
|
|
|
|
*/
|
2009-08-12 14:40:32 +00:00
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
function Transmission()
|
|
|
|
{
|
2008-07-10 23:57:46 +00:00
|
|
|
this.initialize();
|
2009-08-12 14:40:32 +00:00
|
|
|
}
|
|
|
|
|
2008-07-10 23:57:46 +00:00
|
|
|
Transmission.prototype =
|
|
|
|
{
|
2011-08-24 02:04:35 +00:00
|
|
|
/****
|
|
|
|
*****
|
|
|
|
***** STARTUP
|
|
|
|
*****
|
|
|
|
****/
|
2008-07-10 23:57:46 +00:00
|
|
|
|
|
|
|
initialize: function()
|
|
|
|
{
|
|
|
|
// Initialize the helper classes
|
|
|
|
this.remote = new TransmissionRemote(this);
|
2011-09-02 19:29:41 +00:00
|
|
|
this.inspector = new Inspector(this, this.remote);
|
2008-07-10 23:57:46 +00:00
|
|
|
|
|
|
|
// Initialize the implementation fields
|
2011-08-27 21:35:19 +00:00
|
|
|
this.filterText = '';
|
|
|
|
this._torrents = { };
|
|
|
|
this._rows = [ ];
|
|
|
|
this.dirtyTorrents = { };
|
2010-06-21 13:14:33 +00:00
|
|
|
|
2008-07-10 23:57:46 +00:00
|
|
|
// Initialize the clutch preferences
|
2011-08-24 02:04:35 +00:00
|
|
|
Prefs.getClutchPrefs(this);
|
2010-06-21 13:14:33 +00:00
|
|
|
|
2008-07-10 23:57:46 +00:00
|
|
|
this.preloadImages();
|
2010-06-21 13:14:33 +00:00
|
|
|
|
2008-07-10 23:57:46 +00:00
|
|
|
// Set up user events
|
2009-05-22 22:45:09 +00:00
|
|
|
var tr = this;
|
2011-08-21 05:54:02 +00:00
|
|
|
$(".numberinput").forceNumeric();
|
2011-08-24 02:04:35 +00:00
|
|
|
$('#pause_all_link').click(function(e) { tr.stopAllClicked(e); });
|
|
|
|
$('#resume_all_link').click(function(e) { tr.startAllClicked(e); });
|
|
|
|
$('#pause_selected_link').click(function(e) { tr.stopSelectedClicked(e); });
|
|
|
|
$('#resume_selected_link').click(function(e) { tr.startSelectedClicked(e); });
|
|
|
|
$('#remove_link').click(function(e) { tr.removeClicked(e); });
|
|
|
|
$('#prefs_save_button').click(function(e) { tr.savePrefsClicked(e); return false;});
|
2011-08-31 14:24:35 +00:00
|
|
|
$('#prefs_cancel_button').click(function() { tr.hidePrefsDialog(); return false; });
|
|
|
|
$('#block_update_button').click(function() { tr.remote.updateBlocklist(); return false; });
|
|
|
|
$('#stats_close_button').click(function() { tr.hideStatsDialog(); return false; });
|
2011-08-24 02:04:35 +00:00
|
|
|
$('#open_link').click(function(e) { tr.openTorrentClicked(e); });
|
|
|
|
$('#upload_confirm_button').click(function(e) { tr.confirmUploadClicked(e); return false;});
|
2011-08-31 14:24:35 +00:00
|
|
|
$('#upload_cancel_button').click(function() { tr.hideUploadDialog(); return false; });
|
2011-08-30 00:16:34 +00:00
|
|
|
$('#turtle-button').click(function() { tr.toggleTurtleClicked(); });
|
|
|
|
$('#compact-button').click(function() { tr.toggleCompactClicked(); });
|
2011-08-25 08:03:19 +00:00
|
|
|
$('#prefs-tab-general').click(function() { tr.selectPrefsTab('general'); });
|
|
|
|
$('#prefs-tab-speed').click(function() { tr.selectPrefsTab('speed'); });
|
|
|
|
$('#prefs-tab-peers').click(function() { tr.selectPrefsTab('peers'); });
|
|
|
|
$('#prefs-tab-network').click(function() { tr.selectPrefsTab('network'); });
|
2011-08-24 02:04:35 +00:00
|
|
|
$('#torrent_upload_form').submit(function() { $('#upload_confirm_button').click(); return false; });
|
|
|
|
$('#torrent_container').bind('dragover', function(e) { return tr.dragenter(e); });
|
|
|
|
$('#torrent_container').bind('dragenter', function(e) { return tr.dragenter(e); });
|
|
|
|
$('#torrent_container').bind('drop', function(e) { return tr.drop(e); });
|
2011-05-30 15:12:42 +00:00
|
|
|
// tell jQuery to copy the dataTransfer property from events over if it exists
|
|
|
|
jQuery.event.props.push("dataTransfer");
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
$('#torrent_upload_form').submit(function() { $('#upload_confirm_button').click(); return false; });
|
2009-11-10 05:43:14 +00:00
|
|
|
|
2011-08-28 17:24:56 +00:00
|
|
|
if (isMobileDevice) {
|
2011-08-25 23:06:41 +00:00
|
|
|
$('#inspector_close').bind('click', function() { tr.setInspectorVisible(false); });
|
2011-08-24 02:04:35 +00:00
|
|
|
$('#preferences_link').bind('click', function(e) { tr.releaseClutchPreferencesButton(e); });
|
2008-07-10 23:57:46 +00:00
|
|
|
} else {
|
2011-08-28 16:33:22 +00:00
|
|
|
$(document).bind('keydown', function(e) { return tr.keyDown(e); });
|
|
|
|
$(document).bind('keyup', function(e) { tr.keyUp(e); });
|
|
|
|
$(document).delegate('#torrent_container', 'click', function() { tr.deselectAll(); });
|
2011-08-25 23:06:41 +00:00
|
|
|
$('#inspector_link').click(function(e) { tr.toggleInspector(); });
|
2010-06-21 13:14:33 +00:00
|
|
|
|
2008-07-10 23:57:46 +00:00
|
|
|
this.setupSearchBox();
|
|
|
|
this.createContextMenu();
|
|
|
|
this.createSettingsMenu();
|
|
|
|
}
|
2009-11-10 05:42:57 +00:00
|
|
|
this.initTurtleDropDowns();
|
2009-05-23 18:09:56 +00:00
|
|
|
|
2009-05-24 15:48:18 +00:00
|
|
|
this._torrent_list = $('#torrent_list')[0];
|
2011-08-24 02:04:35 +00:00
|
|
|
this._toolbar_buttons = $('#toolbar ul li');
|
|
|
|
this._toolbar_pause_button = $('#toolbar #pause_selected')[0];
|
|
|
|
this._toolbar_pause_all_button = $('#toolbar #pause_all')[0];
|
|
|
|
this._toolbar_start_button = $('#toolbar #resume_selected')[0];
|
|
|
|
this._toolbar_start_all_button = $('#toolbar #resume_all')[0];
|
|
|
|
this._toolbar_remove_button = $('#toolbar #remove')[0];
|
2009-05-24 15:48:18 +00:00
|
|
|
this._context_pause_button = $('li#context_pause_selected')[0];
|
|
|
|
this._context_start_button = $('li#context_resume_selected')[0];
|
2011-08-01 22:24:24 +00:00
|
|
|
this._context_start_now_button = $('li#context_resume_now_selected')[0];
|
2011-08-06 15:19:29 +00:00
|
|
|
this._context_move_top = $('li#context_move_top')[0];
|
|
|
|
this._context_move_up = $('li#context_move_up')[0];
|
|
|
|
this._context_move_down = $('li#context_move_down')[0];
|
|
|
|
this._context_move_bottom = $('li#context_move_bottom')[0];
|
2009-05-24 18:39:21 +00:00
|
|
|
|
2008-07-10 23:57:46 +00:00
|
|
|
// Setup the prefs gui
|
2011-08-24 02:04:35 +00:00
|
|
|
this.initializeSettings();
|
2010-06-21 13:14:33 +00:00
|
|
|
|
2008-07-10 23:57:46 +00:00
|
|
|
// Get preferences & torrents from the daemon
|
2009-07-28 04:53:08 +00:00
|
|
|
var async = false;
|
2011-08-24 02:04:35 +00:00
|
|
|
this.loadDaemonPrefs(async);
|
|
|
|
this.loadDaemonStats(async);
|
2011-08-26 22:49:57 +00:00
|
|
|
this.initializeTorrents();
|
2011-08-26 19:42:07 +00:00
|
|
|
this.refreshTorrents();
|
2011-08-24 02:04:35 +00:00
|
|
|
this.togglePeriodicSessionRefresh(true);
|
|
|
|
|
|
|
|
this.filterSetup();
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
2011-08-25 08:03:19 +00:00
|
|
|
selectPrefsTab: function(name) {
|
|
|
|
$('#prefs-tab-'+name).addClass('selected').siblings('.prefs-tab').removeClass('selected');
|
|
|
|
$('#prefs-page-'+name).show().siblings('.prefs-page').hide();
|
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
loadDaemonPrefs: function(async) {
|
|
|
|
this.remote.loadDaemonPrefs(function(data) {
|
2011-08-24 13:17:45 +00:00
|
|
|
var o = data['arguments'];
|
2011-08-24 02:04:35 +00:00
|
|
|
Prefs.getClutchPrefs(o);
|
2011-08-28 06:05:46 +00:00
|
|
|
this.updatePrefs(o);
|
|
|
|
}, this, async);
|
2009-07-28 04:53:04 +00:00
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
loadDaemonStats: function(async) {
|
|
|
|
this.remote.loadDaemonStats(function(data) {
|
2011-08-28 06:05:46 +00:00
|
|
|
this.updateStats(data['arguments']);
|
|
|
|
}, this, async);
|
2010-03-11 04:50:04 +00:00
|
|
|
},
|
2011-08-24 02:04:35 +00:00
|
|
|
checkPort: function(async) {
|
|
|
|
$('#port_test').text('checking ...');
|
|
|
|
this.remote.checkPort(function(data) {
|
2011-08-28 06:05:46 +00:00
|
|
|
this.updatePortStatus(data['arguments']);
|
|
|
|
}, this, async);
|
2011-03-10 01:37:58 +00:00
|
|
|
},
|
2010-03-11 04:50:04 +00:00
|
|
|
|
2008-07-10 23:57:46 +00:00
|
|
|
preloadImages: function() {
|
2011-08-28 17:24:56 +00:00
|
|
|
if (isMobileDevice) {
|
2008-07-10 23:57:46 +00:00
|
|
|
this.loadImages(
|
|
|
|
'images/buttons/info_general.png',
|
2009-03-14 21:33:08 +00:00
|
|
|
'images/buttons/info_activity.png',
|
|
|
|
'images/buttons/info_files.png',
|
2008-07-10 23:57:46 +00:00
|
|
|
'images/buttons/toolbar_buttons.png',
|
|
|
|
'images/graphics/filter_bar.png',
|
|
|
|
'images/graphics/iphone_chrome.png',
|
2009-03-14 21:33:08 +00:00
|
|
|
'images/graphics/logo.png'
|
2008-07-10 23:57:46 +00:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
this.loadImages(
|
|
|
|
'images/buttons/info_general.png',
|
2009-03-14 21:33:08 +00:00
|
|
|
'images/buttons/info_activity.png',
|
|
|
|
'images/buttons/info_files.png',
|
2008-07-10 23:57:46 +00:00
|
|
|
'images/buttons/tab_backgrounds.png',
|
|
|
|
'images/buttons/toolbar_buttons.png',
|
|
|
|
'images/buttons/torrent_buttons.png',
|
2009-03-14 21:33:08 +00:00
|
|
|
'images/buttons/file_wanted_buttons.png',
|
|
|
|
'images/buttons/file_priority_buttons.png',
|
2008-07-10 23:57:46 +00:00
|
|
|
'images/graphics/chrome.png',
|
|
|
|
'images/graphics/filter_bar.png',
|
|
|
|
'images/graphics/logo.png',
|
|
|
|
'images/graphics/transfer_arrows.png',
|
|
|
|
'images/progress/progress.png'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
loadImages: function() {
|
2011-08-24 02:04:35 +00:00
|
|
|
for (var i=0, row; row=arguments[i]; ++i)
|
2009-05-24 16:05:28 +00:00
|
|
|
jQuery("<img>").attr("src", row);
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
2009-08-12 14:40:32 +00:00
|
|
|
|
2008-07-10 23:57:46 +00:00
|
|
|
/*
|
|
|
|
* Load the clutch prefs and init the GUI according to those prefs
|
|
|
|
*/
|
2011-08-24 02:04:35 +00:00
|
|
|
initializeSettings: function()
|
2008-07-10 23:57:46 +00:00
|
|
|
{
|
2011-08-24 02:04:35 +00:00
|
|
|
Prefs.getClutchPrefs(this);
|
2008-07-10 23:57:46 +00:00
|
|
|
|
|
|
|
// iPhone conditions in the section allow us to not
|
|
|
|
// include transmenu js to save some bandwidth; if we
|
2011-08-28 17:24:56 +00:00
|
|
|
// start using prefs on mobile devices we need to weed
|
2008-07-10 23:57:46 +00:00
|
|
|
// transmenu refs out of that too.
|
2011-08-28 17:24:56 +00:00
|
|
|
if (!isMobileDevice)
|
2011-08-26 18:36:09 +00:00
|
|
|
{
|
|
|
|
$('#sort_by_' + this[Prefs._SortMethod]).selectMenuItem();
|
2010-06-21 13:14:33 +00:00
|
|
|
|
2011-08-26 18:36:09 +00:00
|
|
|
if (this[Prefs._SortDirection] === Prefs._SortDescending)
|
|
|
|
$('#reverse_sort_order').selectMenuItem();
|
|
|
|
}
|
2008-07-10 23:57:46 +00:00
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
this.initCompactMode();
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up the search box
|
|
|
|
*/
|
|
|
|
setupSearchBox: function()
|
|
|
|
{
|
|
|
|
var tr = this;
|
|
|
|
var search_box = $('#torrent_search');
|
2011-08-27 21:35:19 +00:00
|
|
|
search_box.bind('keyup click', function() {
|
|
|
|
tr.setFilterText(this.value);
|
|
|
|
});
|
2008-08-09 04:38:51 +00:00
|
|
|
if (!$.browser.safari)
|
|
|
|
{
|
2008-09-18 21:25:23 +00:00
|
|
|
search_box.addClass('blur');
|
2008-08-09 04:38:51 +00:00
|
|
|
search_box[0].value = 'Filter';
|
2011-08-24 02:04:35 +00:00
|
|
|
search_box.bind('blur', function() {
|
2008-08-09 04:38:51 +00:00
|
|
|
if (this.value == '') {
|
|
|
|
$(this).addClass('blur');
|
|
|
|
this.value = 'Filter';
|
2011-08-27 21:35:19 +00:00
|
|
|
tr.setFilterText(null);
|
2008-08-09 04:38:51 +00:00
|
|
|
}
|
2011-08-24 02:04:35 +00:00
|
|
|
}).bind('focus', function() {
|
2008-08-09 04:38:51 +00:00
|
|
|
if ($(this).is('.blur')) {
|
|
|
|
this.value = '';
|
|
|
|
$(this).removeClass('blur');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create the torrent right-click menu
|
|
|
|
*/
|
|
|
|
createContextMenu: function() {
|
2009-05-23 02:28:04 +00:00
|
|
|
var tr = this;
|
2008-07-10 23:57:46 +00:00
|
|
|
var bindings = {
|
2011-08-24 02:04:35 +00:00
|
|
|
context_pause_selected: function() { tr.stopSelectedTorrents(); },
|
|
|
|
context_resume_selected: function() { tr.startSelectedTorrents(false); },
|
|
|
|
context_resume_now_selected: function() { tr.startSelectedTorrents(true); },
|
|
|
|
context_remove: function() { tr.removeSelectedTorrents(); },
|
|
|
|
context_removedata: function() { tr.removeSelectedTorrentsAndData(); },
|
|
|
|
context_verify: function() { tr.verifySelectedTorrents(); },
|
|
|
|
context_reannounce: function() { tr.reannounceSelectedTorrents(); },
|
|
|
|
context_toggle_inspector: function() { tr.toggleInspector(); },
|
|
|
|
context_select_all: function() { tr.selectAll(); },
|
|
|
|
context_deselect_all: function() { tr.deselectAll(); },
|
|
|
|
context_move_top: function() { tr.moveTop(); },
|
|
|
|
context_move_up: function() { tr.moveUp(); },
|
|
|
|
context_move_down: function() { tr.moveDown(); },
|
|
|
|
context_move_bottom: function() { tr.moveBottom(); }
|
2008-07-10 23:57:46 +00:00
|
|
|
};
|
2010-06-21 13:14:33 +00:00
|
|
|
|
2008-07-10 23:57:46 +00:00
|
|
|
// Setup the context menu
|
|
|
|
$('ul#torrent_list').contextMenu('torrent_context_menu', {
|
|
|
|
bindings: bindings,
|
|
|
|
menuStyle: Menu.context.menu_style,
|
|
|
|
itemStyle: Menu.context.item_style,
|
|
|
|
itemHoverStyle: Menu.context.item_hover_style,
|
|
|
|
itemDisabledStyle: Menu.context.item_disabled_style,
|
|
|
|
shadow: false,
|
|
|
|
boundingElement: $('div#torrent_container'),
|
|
|
|
boundingRightPad: 20,
|
2009-05-25 15:46:25 +00:00
|
|
|
boundingBottomPad: 5,
|
2011-08-29 20:29:45 +00:00
|
|
|
onContextMenu: function(ev) {
|
|
|
|
var element = $(ev.target).closest('.torrent')[0];
|
|
|
|
var i = $('#torrent_list > li').index(element);
|
|
|
|
if ((i!==-1) && !tr._rows[i].isSelected())
|
|
|
|
tr.setSelectedRow(tr._rows[i]);
|
2010-06-21 13:14:33 +00:00
|
|
|
return true;
|
2009-05-25 15:46:25 +00:00
|
|
|
}
|
2008-07-10 23:57:46 +00:00
|
|
|
});
|
|
|
|
},
|
2009-08-12 14:40:32 +00:00
|
|
|
|
2008-07-10 23:57:46 +00:00
|
|
|
/*
|
|
|
|
* Create the footer settings menu
|
|
|
|
*/
|
|
|
|
createSettingsMenu: function() {
|
|
|
|
$('#settings_menu').transMenu({
|
|
|
|
selected_char: '✔',
|
|
|
|
direction: 'up',
|
2011-08-30 21:55:44 +00:00
|
|
|
onClick: $.proxy(this.processSettingsMenuEvent,this)
|
2008-07-10 23:57:46 +00:00
|
|
|
});
|
2010-06-21 13:14:33 +00:00
|
|
|
|
2008-07-10 23:57:46 +00:00
|
|
|
$('#unlimited_download_rate').selectMenuItem();
|
|
|
|
$('#unlimited_upload_rate').selectMenuItem();
|
|
|
|
},
|
2009-08-12 14:40:32 +00:00
|
|
|
|
2008-07-10 23:57:46 +00:00
|
|
|
|
2009-11-10 05:42:57 +00:00
|
|
|
initTurtleDropDowns: function() {
|
2011-08-24 02:04:35 +00:00
|
|
|
var i, hour, mins, start, end, value, content;
|
2009-11-10 05:42:57 +00:00
|
|
|
// Build the list of times
|
2010-09-03 00:03:21 +00:00
|
|
|
start = $('#turtle_start_time')[0];
|
|
|
|
end = $('#turtle_end_time')[0];
|
2009-11-10 05:42:57 +00:00
|
|
|
for (i = 0; i < 24 * 4; i++) {
|
2011-08-24 02:04:35 +00:00
|
|
|
hour = parseInt(i / 4, 10);
|
2009-11-10 05:42:57 +00:00
|
|
|
mins = ((i % 4) * 15);
|
2009-12-09 04:19:37 +00:00
|
|
|
|
|
|
|
value = (i * 15);
|
|
|
|
content = hour + ":" + (mins == 0 ? "00" : mins);
|
|
|
|
start.options[i] = new Option(content, value);
|
|
|
|
end.options[i] = new Option(content, value);
|
2009-11-10 05:42:57 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
/****
|
|
|
|
*****
|
|
|
|
***** UTILITIES
|
|
|
|
*****
|
|
|
|
****/
|
2008-07-10 23:57:46 +00:00
|
|
|
|
|
|
|
getAllTorrents: function()
|
|
|
|
{
|
2009-06-07 23:55:42 +00:00
|
|
|
var torrents = [];
|
2011-08-24 02:04:35 +00:00
|
|
|
for (var key in this._torrents)
|
2011-08-26 18:36:09 +00:00
|
|
|
torrents.push(this._torrents[key]);
|
2008-07-10 23:57:46 +00:00
|
|
|
return torrents;
|
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
scrollToRow: function(row)
|
2008-07-10 23:57:46 +00:00
|
|
|
{
|
2011-08-28 17:24:56 +00:00
|
|
|
if (isMobileDevice) // FIXME: why?
|
2011-08-24 02:04:35 +00:00
|
|
|
return;
|
2010-06-21 13:14:33 +00:00
|
|
|
|
2011-08-28 13:57:25 +00:00
|
|
|
var list = $('#torrent_container'),
|
|
|
|
scrollTop = list.scrollTop(),
|
|
|
|
innerHeight = list.innerHeight(),
|
|
|
|
offsetTop = row.getElement().offsetTop,
|
|
|
|
offsetHeight = $(row.getElement()).outerHeight();
|
2011-08-16 18:49:26 +00:00
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
if (offsetTop < scrollTop)
|
|
|
|
list.scrollTop(offsetTop);
|
|
|
|
else if (innerHeight + scrollTop < offsetTop + offsetHeight)
|
|
|
|
list.scrollTop(offsetTop + offsetHeight - innerHeight);
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
seedRatioLimit: function() {
|
2011-08-31 14:24:35 +00:00
|
|
|
var p = this._prefs;
|
|
|
|
if (p && p.seedRatioLimited)
|
|
|
|
return p.seedRatioLimit;
|
2011-08-26 18:36:09 +00:00
|
|
|
return -1;
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
setPref: function(key, val)
|
2008-07-10 23:57:46 +00:00
|
|
|
{
|
|
|
|
this[key] = val;
|
2011-08-24 02:04:35 +00:00
|
|
|
Prefs.setValue(key, val);
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
/****
|
|
|
|
*****
|
|
|
|
***** SELECTION
|
|
|
|
*****
|
|
|
|
****/
|
2008-07-10 23:57:46 +00:00
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
getSelectedRows: function() {
|
2011-08-26 18:36:09 +00:00
|
|
|
return $.grep(this._rows, function(r) {return r.isSelected();});
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
getSelectedTorrents: function() {
|
2011-08-31 14:24:35 +00:00
|
|
|
return $.map(this.getSelectedRows(),function(r) {
|
|
|
|
return r.getTorrent();
|
|
|
|
});
|
2009-07-28 04:52:47 +00:00
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
getSelectedTorrentIds: function() {
|
2011-08-31 14:24:35 +00:00
|
|
|
return $.map(this.getSelectedRows(),function(r) {
|
|
|
|
return r.getTorrentId();
|
|
|
|
});
|
2011-08-24 02:04:35 +00:00
|
|
|
},
|
2008-07-10 23:57:46 +00:00
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
setSelectedRow: function(row) {
|
2011-08-30 21:31:10 +00:00
|
|
|
$(this._torrent_list).children('.selected').removeClass('selected');
|
2011-08-24 02:04:35 +00:00
|
|
|
this.selectRow(row);
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
selectRow: function(row) {
|
2011-08-30 21:31:10 +00:00
|
|
|
$(row.getElement()).addClass('selected');
|
2011-08-16 18:49:26 +00:00
|
|
|
this.callSelectionChangedSoon();
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
deselectRow: function(row) {
|
2011-08-30 21:31:10 +00:00
|
|
|
$(row.getElement()).removeClass('selected');
|
2011-08-16 18:49:26 +00:00
|
|
|
this.callSelectionChangedSoon();
|
2009-05-25 13:31:03 +00:00
|
|
|
},
|
2008-07-10 23:57:46 +00:00
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
selectAll: function() {
|
2011-08-30 21:31:10 +00:00
|
|
|
$(this._torrent_list).children().addClass('selected');
|
2011-08-16 18:49:26 +00:00
|
|
|
this.callSelectionChangedSoon();
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
2011-08-24 02:04:35 +00:00
|
|
|
deselectAll: function() {
|
2011-08-30 21:31:10 +00:00
|
|
|
$(this._torrent_list).children('.selected').removeClass('selected');
|
2011-08-16 18:49:26 +00:00
|
|
|
this.callSelectionChangedSoon();
|
2011-08-24 02:04:35 +00:00
|
|
|
delete this._last_torrent_clicked;
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
2011-08-25 10:23:19 +00:00
|
|
|
indexOfLastTorrent: function() {
|
|
|
|
for (var i=0, r; r=this._rows[i]; ++i)
|
2011-08-26 00:43:35 +00:00
|
|
|
if (r.getTorrentId() === this._last_torrent_clicked)
|
2011-08-25 10:23:19 +00:00
|
|
|
return i;
|
|
|
|
return -1;
|
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
/* Select a range from this torrent to the last clicked torrent */
|
|
|
|
selectRange: function(row)
|
2008-07-10 23:57:46 +00:00
|
|
|
{
|
2011-08-25 10:23:19 +00:00
|
|
|
var last = this.indexOfLastTorrent();
|
|
|
|
|
|
|
|
if (last === -1)
|
|
|
|
{
|
2011-08-24 02:04:35 +00:00
|
|
|
this.selectRow(row);
|
2011-08-25 10:23:19 +00:00
|
|
|
}
|
|
|
|
else // select the range between the prevous & current
|
|
|
|
{
|
|
|
|
var next = this._rows.indexOf(row);
|
|
|
|
var min = Math.min(last, next);
|
|
|
|
var max = Math.max(last, next);
|
|
|
|
for (var i=min; i<=max; ++i)
|
|
|
|
this.selectRow(this._rows[i]);
|
2008-07-10 23:57:46 +00:00
|
|
|
}
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
this.callSelectionChangedSoon();
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
2009-03-14 21:33:08 +00:00
|
|
|
|
2008-07-10 23:57:46 +00:00
|
|
|
selectionChanged: function()
|
|
|
|
{
|
|
|
|
this.updateButtonStates();
|
2011-09-02 19:29:41 +00:00
|
|
|
|
|
|
|
this.inspector.setTorrents(this.inspectorIsVisible() ? this.getSelectedTorrents() : []);
|
2011-08-24 02:04:35 +00:00
|
|
|
|
|
|
|
clearTimeout(this.selectionChangedTimer);
|
|
|
|
delete this.selectionChangedTimer;
|
2011-08-30 21:40:18 +00:00
|
|
|
|
2011-08-16 18:49:26 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
callSelectionChangedSoon: function()
|
|
|
|
{
|
2011-08-24 02:04:35 +00:00
|
|
|
if (!this.selectionChangedTimer)
|
2011-08-31 14:24:35 +00:00
|
|
|
this.selectionChangedTimer =
|
|
|
|
setTimeout($.proxy(this.selectionChanged,this),200);
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/*--------------------------------------------
|
2009-08-12 14:40:32 +00:00
|
|
|
*
|
2008-07-10 23:57:46 +00:00
|
|
|
* E V E N T F U N C T I O N S
|
2009-08-12 14:40:32 +00:00
|
|
|
*
|
2008-07-10 23:57:46 +00:00
|
|
|
*--------------------------------------------*/
|
2009-08-12 14:40:32 +00:00
|
|
|
|
2008-07-10 23:57:46 +00:00
|
|
|
/*
|
|
|
|
* Process key event
|
|
|
|
*/
|
2011-08-21 14:02:28 +00:00
|
|
|
keyDown: function(ev)
|
2008-07-10 23:57:46 +00:00
|
|
|
{
|
2011-08-28 16:33:22 +00:00
|
|
|
var handled = false,
|
2011-08-31 14:24:35 +00:00
|
|
|
rows = this._rows,
|
2011-08-28 16:33:22 +00:00
|
|
|
up = ev.keyCode === 38; // up key pressed
|
2011-08-28 13:57:25 +00:00
|
|
|
dn = ev.keyCode === 40, // down key pressed
|
|
|
|
shift = ev.keyCode === 16; // shift key pressed
|
2010-06-21 13:14:33 +00:00
|
|
|
|
2011-08-28 19:30:17 +00:00
|
|
|
if ((up || dn) && rows.length)
|
2008-07-10 23:57:46 +00:00
|
|
|
{
|
2011-08-28 19:30:17 +00:00
|
|
|
var last = this.indexOfLastTorrent(),
|
2011-08-28 13:57:25 +00:00
|
|
|
i = last,
|
2011-08-30 02:03:17 +00:00
|
|
|
anchor = this._shift_index,
|
|
|
|
r,
|
|
|
|
min = 0,
|
|
|
|
max = rows.length - 1;
|
|
|
|
|
|
|
|
if (dn && (i+1 <= max))
|
|
|
|
++i;
|
|
|
|
else if (up && (i-1 >= min))
|
|
|
|
--i;
|
2011-08-24 02:04:35 +00:00
|
|
|
|
2011-08-25 11:25:13 +00:00
|
|
|
var r = rows[i];
|
2011-08-25 10:23:19 +00:00
|
|
|
|
2011-08-26 18:36:09 +00:00
|
|
|
if (anchor >= 0)
|
2011-08-25 10:23:19 +00:00
|
|
|
{
|
2011-08-31 14:24:35 +00:00
|
|
|
// user is extending the selection
|
|
|
|
// with the shift + arrow keys...
|
2011-08-26 18:36:09 +00:00
|
|
|
if ( ((anchor <= last) && (last < i))
|
|
|
|
|| ((anchor >= last) && (last > i)))
|
2011-08-25 10:23:19 +00:00
|
|
|
{
|
|
|
|
this.selectRow(r);
|
|
|
|
}
|
2011-08-26 18:36:09 +00:00
|
|
|
else if (((anchor >= last) && (i > last))
|
|
|
|
|| ((anchor <= last) && (last > i)))
|
2011-08-25 10:23:19 +00:00
|
|
|
{
|
|
|
|
this.deselectRow(rows[last]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ev.shiftKey)
|
|
|
|
this.selectRange(r);
|
|
|
|
else
|
|
|
|
this.setSelectedRow(r);
|
|
|
|
}
|
2011-08-26 00:43:35 +00:00
|
|
|
this._last_torrent_clicked = r.getTorrentId();
|
2011-08-25 10:23:19 +00:00
|
|
|
this.scrollToRow(r);
|
2011-08-28 16:33:22 +00:00
|
|
|
handled = true;
|
2009-05-25 13:31:03 +00:00
|
|
|
}
|
2011-08-25 10:23:19 +00:00
|
|
|
else if (shift)
|
|
|
|
{
|
|
|
|
this._shift_index = this.indexOfLastTorrent();
|
|
|
|
}
|
2011-08-28 16:33:22 +00:00
|
|
|
|
|
|
|
return !handled;
|
2011-08-25 10:23:19 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
keyUp: function(ev)
|
|
|
|
{
|
|
|
|
if (ev.keyCode === 16) // shift key pressed
|
|
|
|
delete this._shift_index;
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
2009-08-12 14:40:32 +00:00
|
|
|
|
2011-08-31 14:24:35 +00:00
|
|
|
isButtonEnabled: function(ev) {
|
|
|
|
var p = (ev.target || ev.srcElement).parentNode;
|
|
|
|
return p.className!=='disabled'
|
|
|
|
&& p.parentNode.className!=='disabled';
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
2011-08-28 13:57:25 +00:00
|
|
|
stopAllClicked: function(ev) {
|
|
|
|
if (this.isButtonEnabled(ev)) {
|
2011-08-24 02:04:35 +00:00
|
|
|
this.stopAllTorrents();
|
2011-08-28 17:24:56 +00:00
|
|
|
this.hideMobileAddressbar();
|
2008-07-10 23:57:46 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-08-28 13:57:25 +00:00
|
|
|
stopSelectedClicked: function(ev) {
|
|
|
|
if (this.isButtonEnabled(ev)) {
|
2011-08-24 02:04:35 +00:00
|
|
|
this.stopSelectedTorrents();
|
2011-08-28 17:24:56 +00:00
|
|
|
this.hideMobileAddressbar();
|
2008-07-10 23:57:46 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-08-28 13:57:25 +00:00
|
|
|
startAllClicked: function(ev) {
|
|
|
|
if (this.isButtonEnabled(ev)) {
|
2011-08-24 02:04:35 +00:00
|
|
|
this.startAllTorrents();
|
2011-08-28 17:24:56 +00:00
|
|
|
this.hideMobileAddressbar();
|
2008-07-10 23:57:46 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-08-28 13:57:25 +00:00
|
|
|
startSelectedClicked: function(ev) {
|
|
|
|
if (this.isButtonEnabled(ev)) {
|
2011-08-24 02:04:35 +00:00
|
|
|
this.startSelectedTorrents(false);
|
2011-08-28 17:24:56 +00:00
|
|
|
this.hideMobileAddressbar();
|
2008-07-10 23:57:46 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-08-28 13:57:25 +00:00
|
|
|
openTorrentClicked: function(ev) {
|
|
|
|
if (this.isButtonEnabled(ev)) {
|
2008-07-10 23:57:46 +00:00
|
|
|
$('body').addClass('open_showing');
|
2011-08-24 02:04:35 +00:00
|
|
|
this.uploadTorrentFile();
|
|
|
|
this.updateButtonStates();
|
2008-07-10 23:57:46 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-08-28 13:57:25 +00:00
|
|
|
dragenter: function(ev) {
|
|
|
|
if (ev.dataTransfer && ev.dataTransfer.types) {
|
2011-05-30 15:12:42 +00:00
|
|
|
var types = ["text/uri-list", "text/plain"];
|
2011-08-24 02:04:35 +00:00
|
|
|
for (var i = 0; i < types.length; ++i) {
|
2011-08-28 13:57:25 +00:00
|
|
|
// it would be better to look at the links here;
|
|
|
|
// sadly, with Firefox, trying would throw.
|
|
|
|
if (ev.dataTransfer.types.contains(types[i])) {
|
|
|
|
ev.stopPropagation();
|
|
|
|
ev.preventDefault();
|
|
|
|
ev.dropEffect = "copy";
|
2011-05-30 15:12:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-08-28 13:57:25 +00:00
|
|
|
else if (ev.dataTransfer) {
|
|
|
|
ev.dataTransfer.dropEffect = "none";
|
2011-05-30 15:12:42 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
drop: function(ev) {
|
|
|
|
if (!ev.dataTransfer || !ev.dataTransfer.types) {
|
2011-05-30 15:12:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
2011-08-24 02:04:35 +00:00
|
|
|
ev.preventDefault();
|
2011-05-30 15:12:42 +00:00
|
|
|
var uris = null;
|
|
|
|
var types = ["text/uri-list", "text/plain"];
|
2011-08-24 02:04:35 +00:00
|
|
|
for (var i = 0; i < types.length; ++i) {
|
|
|
|
if (ev.dataTransfer.types.contains(types[i])) {
|
|
|
|
uris = ev.dataTransfer.getData(types[i]).split("\n");
|
2011-05-30 15:12:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var paused = $('#prefs_form #auto_start')[0].checked;
|
2011-08-24 02:04:35 +00:00
|
|
|
for (i = 0; i < uris.length; ++i) {
|
2011-05-30 15:12:42 +00:00
|
|
|
var uri = uris[i];
|
2011-08-24 02:04:35 +00:00
|
|
|
if (/^#/.test(uri)) {
|
2011-05-30 15:12:42 +00:00
|
|
|
// lines which start with "#" are comments
|
|
|
|
continue;
|
|
|
|
}
|
2011-08-24 02:04:35 +00:00
|
|
|
if (/^[a-z-]+:/i.test(uri)) {
|
2011-05-30 15:12:42 +00:00
|
|
|
// close enough to a url
|
2011-08-24 02:04:35 +00:00
|
|
|
this.remote.addTorrentByUrl(uri, paused);
|
2011-05-30 15:12:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
hideUploadDialog: function() {
|
2008-07-10 23:57:46 +00:00
|
|
|
$('body.open_showing').removeClass('open_showing');
|
2011-08-28 17:24:56 +00:00
|
|
|
$('#upload_container').hide();
|
2009-05-23 02:28:04 +00:00
|
|
|
this.updateButtonStates();
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
confirmUploadClicked: function() {
|
|
|
|
this.uploadTorrentFile(true);
|
|
|
|
this.hideUploadDialog();
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
savePrefsClicked: function()
|
2010-09-03 00:03:21 +00:00
|
|
|
{
|
|
|
|
// handle the clutch prefs locally
|
2011-08-24 02:04:35 +00:00
|
|
|
var rate = parseInt ($('#prefs_form #refresh_rate')[0].value, 10);
|
2011-08-30 21:55:44 +00:00
|
|
|
if (rate != this[Prefs._RefreshRate])
|
|
|
|
this.setPref (Prefs._RefreshRate, rate);
|
2010-09-03 00:03:21 +00:00
|
|
|
|
2011-08-28 13:57:25 +00:00
|
|
|
var up_bytes = parseInt($('#prefs_form #upload_rate').val(), 10),
|
|
|
|
dn_bytes = parseInt($('#prefs_form #download_rate').val(), 10),
|
|
|
|
turtle_up_bytes = parseInt($('#prefs_form #turtle_upload_rate').val(), 10),
|
|
|
|
turtle_dn_bytes = parseInt($('#prefs_form #turtle_download_rate').val(), 10);
|
2010-09-03 00:03:21 +00:00
|
|
|
|
|
|
|
// pass the new prefs upstream to the RPC server
|
|
|
|
var o = { };
|
|
|
|
o[RPC._StartAddedTorrent] = $('#prefs_form #auto_start')[0].checked;
|
2011-08-24 12:49:10 +00:00
|
|
|
o[RPC._PeerPort] = parseInt($('#prefs_form #port').val(), 10);
|
2010-09-03 00:03:21 +00:00
|
|
|
o[RPC._UpSpeedLimit] = up_bytes;
|
|
|
|
o[RPC._DownSpeedLimit] = dn_bytes;
|
2011-08-24 12:49:10 +00:00
|
|
|
o[RPC._DownloadDir] = $('#prefs_form #download_location').val();
|
|
|
|
o[RPC._UpSpeedLimited] = $('#prefs_form #limit_upload').prop('checked');
|
|
|
|
o[RPC._DownSpeedLimited] = $('#prefs_form #limit_download').prop('checked');
|
|
|
|
o[RPC._Encryption] = $('#prefs_form #encryption').prop('checked')
|
2010-09-03 00:03:21 +00:00
|
|
|
? RPC._EncryptionRequired
|
|
|
|
: RPC._EncryptionPreferred;
|
|
|
|
o[RPC._TurtleDownSpeedLimit] = turtle_dn_bytes;
|
|
|
|
o[RPC._TurtleUpSpeedLimit] = turtle_up_bytes;
|
2011-08-24 12:49:10 +00:00
|
|
|
o[RPC._TurtleTimeEnabled] = $('#prefs_form #turtle_schedule').prop('checked');
|
2011-08-24 02:04:35 +00:00
|
|
|
o[RPC._TurtleTimeBegin] = parseInt($('#prefs_form #turtle_start_time').val(), 10);
|
|
|
|
o[RPC._TurtleTimeEnd] = parseInt($('#prefs_form #turtle_end_time').val(), 10);
|
|
|
|
o[RPC._TurtleTimeDay] = parseInt($('#prefs_form #turtle_days').val(), 10);
|
2010-09-03 00:03:21 +00:00
|
|
|
|
2011-03-10 01:37:58 +00:00
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
o[RPC._PeerLimitGlobal] = parseInt($('#prefs_form #conn_global').val(), 10);
|
|
|
|
o[RPC._PeerLimitPerTorrent] = parseInt($('#prefs_form #conn_torrent').val(), 10);
|
2011-08-24 12:49:10 +00:00
|
|
|
o[RPC._PexEnabled] = $('#prefs_form #conn_pex').prop('checked');
|
|
|
|
o[RPC._DhtEnabled] = $('#prefs_form #conn_dht').prop('checked');
|
|
|
|
o[RPC._LpdEnabled] = $('#prefs_form #conn_lpd').prop('checked');
|
|
|
|
o[RPC._BlocklistEnabled] = $('#prefs_form #block_enable').prop('checked');
|
2011-03-10 01:37:58 +00:00
|
|
|
o[RPC._BlocklistURL] = $('#prefs_form #block_url').val();
|
2011-08-24 12:49:10 +00:00
|
|
|
o[RPC._UtpEnabled] = $('#prefs_form #network_utp').prop('checked');
|
|
|
|
o[RPC._PeerPortRandom] = $('#prefs_form #port_rand').prop('checked');
|
|
|
|
o[RPC._PortForwardingEnabled]= $('#prefs_form #port_forward').prop('checked');
|
2011-03-10 01:37:58 +00:00
|
|
|
|
2011-08-30 21:55:44 +00:00
|
|
|
this.remote.savePrefs(o);
|
2010-09-03 00:03:21 +00:00
|
|
|
|
2011-08-30 21:55:44 +00:00
|
|
|
this.hidePrefsDialog();
|
2010-09-03 00:03:21 +00:00
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
removeClicked: function(ev) {
|
2011-08-25 07:15:38 +00:00
|
|
|
if (this.isButtonEnabled(ev)) {
|
|
|
|
this.removeSelectedTorrents();
|
2011-08-28 17:24:56 +00:00
|
|
|
this.hideMobileAddressbar();
|
2008-07-10 23:57:46 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/*
|
2011-08-28 17:24:56 +00:00
|
|
|
* 'Clutch Preferences' was clicked (isMobileDevice only)
|
2008-07-10 23:57:46 +00:00
|
|
|
*/
|
2011-08-24 02:04:35 +00:00
|
|
|
releaseClutchPreferencesButton: function() {
|
2008-07-10 23:57:46 +00:00
|
|
|
$('div#prefs_container div#pref_error').hide();
|
|
|
|
$('div#prefs_container h2.dialog_heading').show();
|
2011-08-24 02:04:35 +00:00
|
|
|
this.showPrefsDialog();
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
getIntervalMsec: function(key, min)
|
|
|
|
{
|
|
|
|
var interval = this[key];
|
|
|
|
if (!interval || (interval < min))
|
|
|
|
interval = min;
|
|
|
|
return interval * 1000;
|
|
|
|
},
|
|
|
|
|
|
|
|
/* Turn the periodic ajax session refresh on & off */
|
|
|
|
togglePeriodicSessionRefresh: function(enabled) {
|
2011-08-31 14:24:35 +00:00
|
|
|
clearInterval(this.sessionInterval);
|
|
|
|
delete this.sessionInterval;
|
2011-08-24 02:04:35 +00:00
|
|
|
if (enabled) {
|
|
|
|
var msec = this.getIntervalMsec(Prefs._SessionRefreshRate, 5);
|
2011-08-31 14:24:35 +00:00
|
|
|
this.sessionInterval = setInterval($.proxy(this.loadDaemonPrefs,this), msec);
|
2009-11-14 14:57:47 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
/* Turn the periodic ajax stats refresh on & off */
|
|
|
|
togglePeriodicStatsRefresh: function(enabled) {
|
2011-08-31 14:24:35 +00:00
|
|
|
clearInterval(this.statsInterval);
|
|
|
|
delete this.statsInterval;
|
2011-08-24 02:04:35 +00:00
|
|
|
if (enabled) {
|
|
|
|
var msec = this.getIntervalMsec(Prefs._SessionRefreshRate, 5);
|
2011-08-31 14:24:35 +00:00
|
|
|
this.statsInterval = setInterval($.proxy(this.loadDaemonStats,this), msec);
|
2010-03-11 04:50:04 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
toggleTurtleClicked: function()
|
|
|
|
{
|
|
|
|
// toggle it
|
|
|
|
var p = Prefs._TurtleState;
|
|
|
|
this[p] = !this[p];
|
|
|
|
|
|
|
|
// send it to the session
|
2010-09-03 00:03:21 +00:00
|
|
|
var args = { };
|
2011-08-24 02:04:35 +00:00
|
|
|
args[RPC._TurtleState] = this[p];
|
|
|
|
this.remote.savePrefs(args);
|
2009-11-10 05:42:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
updateTurtleButton: function() {
|
2011-08-30 00:16:34 +00:00
|
|
|
var enabled = this[Prefs._TurtleState],
|
|
|
|
w = $('#turtle-button'),
|
|
|
|
t = [ 'Click to ', (enabled?'disable':'enable'), ' Temporary Speed Limits',
|
|
|
|
'(', Transmission.fmt.speed(this._prefs[RPC._TurtleUpSpeedLimit]), 'up,',
|
|
|
|
Transmission.fmt.speed(this._prefs[RPC._TurtleDownSpeedLimit]), 'down)' ];
|
|
|
|
w.toggleClass('enabled',enabled);
|
2011-08-24 02:04:35 +00:00
|
|
|
w.attr('title', t.join(' '));
|
2009-11-10 05:42:57 +00:00
|
|
|
},
|
|
|
|
|
2008-07-10 23:57:46 +00:00
|
|
|
/*--------------------------------------------
|
2009-08-12 14:40:32 +00:00
|
|
|
*
|
2008-07-10 23:57:46 +00:00
|
|
|
* I N T E R F A C E F U N C T I O N S
|
2009-08-12 14:40:32 +00:00
|
|
|
*
|
2008-07-10 23:57:46 +00:00
|
|
|
*--------------------------------------------*/
|
2009-08-12 14:40:32 +00:00
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
showPrefsDialog: function() {
|
2011-03-10 01:37:58 +00:00
|
|
|
this.checkPort(true);
|
2010-09-03 00:03:21 +00:00
|
|
|
$('body').addClass('prefs_showing');
|
2011-08-31 05:59:24 +00:00
|
|
|
$('#prefs_container').fadeIn();
|
2011-08-28 17:24:56 +00:00
|
|
|
this.hideMobileAddressbar();
|
2011-08-24 02:04:35 +00:00
|
|
|
this.updateButtonStates();
|
2010-09-03 00:03:21 +00:00
|
|
|
this.togglePeriodicSessionRefresh(false);
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
hidePrefsDialog: function()
|
2008-07-10 23:57:46 +00:00
|
|
|
{
|
2010-09-03 00:03:21 +00:00
|
|
|
$('body.prefs_showing').removeClass('prefs_showing');
|
2011-08-28 17:24:56 +00:00
|
|
|
if (isMobileDevice)
|
|
|
|
this.hideMobileAddressbar();
|
2011-08-31 05:59:24 +00:00
|
|
|
$('#prefs_container').fadeOut();
|
2011-08-24 02:04:35 +00:00
|
|
|
this.updateButtonStates();
|
2010-09-03 00:03:21 +00:00
|
|
|
this.togglePeriodicSessionRefresh(true);
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
2009-08-12 14:40:32 +00:00
|
|
|
|
2008-07-10 23:57:46 +00:00
|
|
|
/*
|
|
|
|
* Process got some new session data from the server
|
|
|
|
*/
|
2011-08-24 12:49:10 +00:00
|
|
|
updatePrefs: function(p)
|
2008-07-10 23:57:46 +00:00
|
|
|
{
|
|
|
|
// remember them for later
|
2011-08-24 12:49:10 +00:00
|
|
|
this._prefs = p;
|
|
|
|
|
|
|
|
var up_limited = p[RPC._UpSpeedLimited];
|
|
|
|
var dn_limited = p[RPC._DownSpeedLimited];
|
|
|
|
var up_limit_k = p[RPC._UpSpeedLimit];
|
|
|
|
var dn_limit_k = p[RPC._DownSpeedLimit];
|
|
|
|
var turtle_up_limit_k = p[RPC._TurtleUpSpeedLimit];
|
|
|
|
var turtle_dn_limit_k = p[RPC._TurtleDownSpeedLimit];
|
|
|
|
|
2011-08-28 13:57:25 +00:00
|
|
|
if (p.units)
|
|
|
|
Transmission.fmt.updateUnits(p.units);
|
2011-08-24 12:49:10 +00:00
|
|
|
|
|
|
|
$('div.download_location input').val( p[RPC._DownloadDir]);
|
|
|
|
$('div.port input').val( p[RPC._PeerPort]);
|
|
|
|
$('div.auto_start input').prop('checked', p[RPC._StartAddedTorrent]);
|
|
|
|
$('input#limit_download').prop('checked', dn_limited);
|
|
|
|
$('input#download_rate').val( dn_limit_k);
|
|
|
|
$('input#limit_upload').prop('checked', up_limited);
|
|
|
|
$('input#upload_rate').val( up_limit_k);
|
|
|
|
$('input#refresh_rate').val( p[Prefs._RefreshRate]);
|
|
|
|
$('div.encryption input').val( p[RPC._Encryption] == RPC._EncryptionRequired);
|
|
|
|
$('input#turtle_download_rate').val( turtle_dn_limit_k);
|
|
|
|
$('input#turtle_upload_rate').val( turtle_up_limit_k);
|
|
|
|
$('input#turtle_schedule').prop('checked', p[RPC._TurtleTimeEnabled]);
|
|
|
|
$('select#turtle_start_time').val( p[RPC._TurtleTimeBegin]);
|
|
|
|
$('select#turtle_end_time').val( p[RPC._TurtleTimeEnd]);
|
|
|
|
$('select#turtle_days').val( p[RPC._TurtleTimeDay]);
|
|
|
|
$('#transmission_version').text( p[RPC._DaemonVersion]);
|
|
|
|
$('#conn_global').val( p[RPC._PeerLimitGlobal]);
|
|
|
|
$('#conn_torrent').val( p[RPC._PeerLimitPerTorrent]);
|
|
|
|
$('#conn_pex').prop('checked', p[RPC._PexEnabled]);
|
|
|
|
$('#conn_dht').prop('checked', p[RPC._DhtEnabled]);
|
|
|
|
$('#conn_lpd').prop('checked', p[RPC._LpdEnabled]);
|
|
|
|
$('#block_enable').prop('checked', p[RPC._BlocklistEnabled]);
|
|
|
|
$('#block_url').val( p[RPC._BlocklistURL]);
|
|
|
|
$('#block_size').text( p[RPC._BlocklistSize]+' IP rules in the list');
|
|
|
|
$('#network_utp').prop('checked', p[RPC._UtpEnabled]);
|
|
|
|
$('#port_rand').prop('checked', p[RPC._PeerPortRandom]);
|
|
|
|
$('#port_forward').prop('checked', p[RPC._PortForwardingEnabled]);
|
2011-03-10 01:37:58 +00:00
|
|
|
|
2011-08-28 17:24:56 +00:00
|
|
|
if (!isMobileDevice)
|
2010-09-03 00:03:21 +00:00
|
|
|
{
|
2011-08-24 02:04:35 +00:00
|
|
|
setInnerHTML($('#limited_download_rate')[0], [ 'Limit (', Transmission.fmt.speed(dn_limit_k), ')' ].join(''));
|
2010-09-03 00:03:21 +00:00
|
|
|
var key = dn_limited ? '#limited_download_rate'
|
|
|
|
: '#unlimited_download_rate';
|
|
|
|
$(key).deselectMenuSiblings().selectMenuItem();
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
setInnerHTML($('#limited_upload_rate')[0], [ 'Limit (', Transmission.fmt.speed(up_limit_k), ')' ].join(''));
|
2010-09-03 00:03:21 +00:00
|
|
|
key = up_limited ? '#limited_upload_rate'
|
|
|
|
: '#unlimited_upload_rate';
|
|
|
|
$(key).deselectMenuSiblings().selectMenuItem();
|
2008-07-10 23:57:46 +00:00
|
|
|
}
|
2009-11-10 05:42:57 +00:00
|
|
|
|
2011-08-24 17:04:59 +00:00
|
|
|
this[Prefs._TurtleState] = p[RPC._TurtleState];
|
2010-09-03 00:03:21 +00:00
|
|
|
this.updateTurtleButton();
|
2011-08-24 17:04:59 +00:00
|
|
|
this.setCompactMode(p[Prefs._CompactDisplayState]);
|
2010-03-11 04:50:04 +00:00
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
updatePortStatus: function(status) {
|
|
|
|
if (status['port-is-open'])
|
2011-03-10 01:37:58 +00:00
|
|
|
$('#port_test').text('Port is open');
|
|
|
|
else
|
|
|
|
$('#port_test').text('Port is closed');
|
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
showStatsDialog: function() {
|
2010-09-03 00:03:21 +00:00
|
|
|
this.loadDaemonStats();
|
|
|
|
$('body').addClass('stats_showing');
|
2011-08-31 05:59:24 +00:00
|
|
|
$('#stats_container').fadeIn();
|
2011-08-28 17:24:56 +00:00
|
|
|
this.hideMobileAddressbar();
|
2011-08-24 02:04:35 +00:00
|
|
|
this.updateButtonStates();
|
2010-09-03 00:03:21 +00:00
|
|
|
this.togglePeriodicStatsRefresh(true);
|
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
hideStatsDialog: function() {
|
2010-09-03 00:03:21 +00:00
|
|
|
$('body.stats_showing').removeClass('stats_showing');
|
2011-08-28 17:24:56 +00:00
|
|
|
if (isMobileDevice)
|
|
|
|
this.hideMobileAddressbar();
|
2011-08-31 05:59:24 +00:00
|
|
|
$('#stats_container').fadeOut();
|
2011-08-24 02:04:35 +00:00
|
|
|
this.updateButtonStates();
|
2010-09-03 00:03:21 +00:00
|
|
|
this.togglePeriodicStatsRefresh(false);
|
2010-03-11 04:50:04 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Process got some new session stats from the server
|
|
|
|
*/
|
2011-08-24 02:04:35 +00:00
|
|
|
updateStats: function(stats)
|
2010-03-11 04:50:04 +00:00
|
|
|
{
|
2010-09-18 23:06:03 +00:00
|
|
|
var fmt = Transmission.fmt;
|
2010-03-11 04:50:04 +00:00
|
|
|
|
2011-08-26 18:36:09 +00:00
|
|
|
var s = stats["current-stats"];
|
|
|
|
$('#stats_session_uploaded').html(fmt.size(s.uploadedBytes));
|
|
|
|
$('#stats_session_downloaded').html(fmt.size(s.downloadedBytes));
|
|
|
|
$('#stats_session_ratio').html(fmt.ratioString(Math.ratio(s.uploadedBytes,s.downloadedBytes)));
|
|
|
|
$('#stats_session_duration').html(fmt.timeInterval(s.secondsActive));
|
|
|
|
|
|
|
|
var t = stats["cumulative-stats"];
|
|
|
|
$('#stats_total_count').html(t.sessionCount + " times");
|
|
|
|
$('#stats_total_uploaded').html(fmt.size(t.uploadedBytes));
|
|
|
|
$('#stats_total_downloaded').html(fmt.size(t.downloadedBytes));
|
|
|
|
$('#stats_total_ratio').html(fmt.ratioString(Math.ratio(t.uploadedBytes,t.downloadedBytes)));
|
|
|
|
$('#stats_total_duration').html(fmt.timeInterval(t.secondsActive));
|
2010-03-11 04:50:04 +00:00
|
|
|
},
|
|
|
|
|
2011-08-27 21:35:19 +00:00
|
|
|
setFilterText: function(search) {
|
|
|
|
this.filterText = search ? search.trim() : null;
|
|
|
|
this.refilter(true);
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
setSortMethod: function(sort_method) {
|
|
|
|
this.setPref(Prefs._SortMethod, sort_method);
|
2011-08-27 21:35:19 +00:00
|
|
|
this.refilter(true);
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
setSortDirection: function(direction) {
|
|
|
|
this.setPref(Prefs._SortDirection, direction);
|
2011-08-27 21:35:19 +00:00
|
|
|
this.refilter(true);
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Process an event in the footer-menu
|
|
|
|
*/
|
2011-08-24 02:04:35 +00:00
|
|
|
processSettingsMenuEvent: function(ev) {
|
2009-05-23 02:28:04 +00:00
|
|
|
var tr = this;
|
2011-08-24 02:04:35 +00:00
|
|
|
var $element = $(ev.target);
|
2010-06-21 13:14:33 +00:00
|
|
|
|
2008-07-10 23:57:46 +00:00
|
|
|
// Figure out which menu has been clicked
|
2009-05-23 02:28:04 +00:00
|
|
|
switch ($element.parent()[0].id) {
|
2010-06-21 13:14:33 +00:00
|
|
|
|
2011-08-16 18:49:26 +00:00
|
|
|
// Display the preferences dialog
|
2008-07-10 23:57:46 +00:00
|
|
|
case 'footer_super_menu':
|
2009-05-23 02:28:04 +00:00
|
|
|
if ($element[0].id == 'preferences') {
|
2008-07-10 23:57:46 +00:00
|
|
|
$('div#prefs_container div#pref_error').hide();
|
|
|
|
$('div#prefs_container h2.dialog_heading').show();
|
2011-08-24 02:04:35 +00:00
|
|
|
tr.showPrefsDialog();
|
2008-07-10 23:57:46 +00:00
|
|
|
}
|
2010-03-11 04:50:04 +00:00
|
|
|
else if ($element[0].id == 'statistics') {
|
|
|
|
$('div#stats_container div#stats_error').hide();
|
|
|
|
$('div#stats_container h2.dialog_heading').show();
|
2011-08-24 02:04:35 +00:00
|
|
|
tr.showStatsDialog();
|
2010-03-11 04:50:04 +00:00
|
|
|
}
|
2010-10-13 19:28:55 +00:00
|
|
|
else if ($element[0].id == 'homepage') {
|
|
|
|
window.open('http://www.transmissionbt.com/');
|
|
|
|
}
|
|
|
|
else if ($element[0].id == 'tipjar') {
|
|
|
|
window.open('http://www.transmissionbt.com/donate.php');
|
|
|
|
}
|
2008-07-10 23:57:46 +00:00
|
|
|
break;
|
2010-06-21 13:14:33 +00:00
|
|
|
|
2008-07-10 23:57:46 +00:00
|
|
|
// Limit the download rate
|
|
|
|
case 'footer_download_rate_menu':
|
2010-09-03 00:03:21 +00:00
|
|
|
var args = { };
|
2009-05-23 02:28:04 +00:00
|
|
|
if ($element.is('#unlimited_download_rate')) {
|
|
|
|
$element.deselectMenuSiblings().selectMenuItem();
|
2010-09-03 00:03:21 +00:00
|
|
|
args[RPC._DownSpeedLimited] = false;
|
2008-07-10 23:57:46 +00:00
|
|
|
} else {
|
2011-08-24 02:04:35 +00:00
|
|
|
var rate_str = $element[0].innerHTML;
|
|
|
|
var rate_val = parseInt(rate_str, 10);
|
|
|
|
setInnerHTML($('#limited_download_rate')[0], [ 'Limit (', Transmission.fmt.speed(rate_val), ')' ].join(''));
|
2008-07-10 23:57:46 +00:00
|
|
|
$('#limited_download_rate').deselectMenuSiblings().selectMenuItem();
|
2010-09-03 00:03:21 +00:00
|
|
|
$('div.preference input#download_rate')[0].value = rate_str;
|
|
|
|
args[RPC._DownSpeedLimit] = rate_val;
|
|
|
|
args[RPC._DownSpeedLimited] = true;
|
2008-07-10 23:57:46 +00:00
|
|
|
}
|
2010-09-03 00:03:21 +00:00
|
|
|
$('div.preference input#limit_download')[0].checked = args[RPC._DownSpeedLimited];
|
2011-08-24 02:04:35 +00:00
|
|
|
tr.remote.savePrefs(args);
|
2008-07-10 23:57:46 +00:00
|
|
|
break;
|
2010-06-21 13:14:33 +00:00
|
|
|
|
2008-07-10 23:57:46 +00:00
|
|
|
// Limit the upload rate
|
|
|
|
case 'footer_upload_rate_menu':
|
|
|
|
var args = { };
|
2009-05-23 02:28:04 +00:00
|
|
|
if ($element.is('#unlimited_upload_rate')) {
|
|
|
|
$element.deselectMenuSiblings().selectMenuItem();
|
2010-09-03 00:03:21 +00:00
|
|
|
args[RPC._UpSpeedLimited] = false;
|
2008-07-10 23:57:46 +00:00
|
|
|
} else {
|
2011-08-24 02:04:35 +00:00
|
|
|
var rate_str = $element[0].innerHTML;
|
|
|
|
var rate_val = parseInt(rate_str, 10);
|
|
|
|
setInnerHTML($('#limited_upload_rate')[0], [ 'Limit (', Transmission.fmt.speed(rate_val), ')' ].join(''));
|
2008-07-10 23:57:46 +00:00
|
|
|
$('#limited_upload_rate').deselectMenuSiblings().selectMenuItem();
|
2010-09-03 00:03:21 +00:00
|
|
|
$('div.preference input#upload_rate')[0].value = rate_str;
|
|
|
|
args[RPC._UpSpeedLimit] = rate_val;
|
|
|
|
args[RPC._UpSpeedLimited] = true;
|
2008-07-10 23:57:46 +00:00
|
|
|
}
|
2010-09-03 00:03:21 +00:00
|
|
|
$('div.preference input#limit_upload')[0].checked = args[RPC._UpSpeedLimited];
|
2011-08-24 02:04:35 +00:00
|
|
|
tr.remote.savePrefs(args);
|
2008-07-10 23:57:46 +00:00
|
|
|
break;
|
2010-06-21 13:14:33 +00:00
|
|
|
|
2009-08-12 14:40:32 +00:00
|
|
|
// Sort the torrent list
|
2008-07-10 23:57:46 +00:00
|
|
|
case 'footer_sort_menu':
|
|
|
|
|
|
|
|
// The 'reverse sort' option state can be toggled independently of the other options
|
2009-05-23 02:28:04 +00:00
|
|
|
if ($element.is('#reverse_sort_order')) {
|
2011-08-24 02:04:35 +00:00
|
|
|
if (!$element.is('#reverse_sort_order.active')) break;
|
2008-07-10 23:57:46 +00:00
|
|
|
var dir;
|
2009-05-23 02:28:04 +00:00
|
|
|
if ($element.menuItemIsSelected()) {
|
|
|
|
$element.deselectMenuItem();
|
2008-07-10 23:57:46 +00:00
|
|
|
dir = Prefs._SortAscending;
|
|
|
|
} else {
|
2009-05-23 02:28:04 +00:00
|
|
|
$element.selectMenuItem();
|
2008-07-10 23:57:46 +00:00
|
|
|
dir = Prefs._SortDescending;
|
|
|
|
}
|
2011-08-24 02:04:35 +00:00
|
|
|
tr.setSortDirection(dir);
|
2008-07-10 23:57:46 +00:00
|
|
|
|
|
|
|
// Otherwise, deselect all other options (except reverse-sort) and select this one
|
|
|
|
} else {
|
2011-08-24 02:04:35 +00:00
|
|
|
$element.parent().find('span.selected').each(function() {
|
2009-05-23 02:28:04 +00:00
|
|
|
if (! $element.parent().is('#reverse_sort_order')) {
|
|
|
|
$element.parent().deselectMenuItem();
|
2008-07-10 23:57:46 +00:00
|
|
|
}
|
|
|
|
});
|
2009-05-23 02:28:04 +00:00
|
|
|
$element.selectMenuItem();
|
|
|
|
var method = $element[0].id.replace(/sort_by_/, '');
|
2011-08-24 02:04:35 +00:00
|
|
|
tr.setSortMethod(method);
|
2008-07-10 23:57:46 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2009-05-23 02:56:55 +00:00
|
|
|
$('#settings_menu').trigger('closemenu');
|
|
|
|
return false; // to prevent the event from bubbling up
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
|
2011-08-27 21:35:19 +00:00
|
|
|
onTorrentChanged: function(tor)
|
2011-08-26 01:46:07 +00:00
|
|
|
{
|
2011-08-27 21:35:19 +00:00
|
|
|
// update our dirty fields
|
2011-08-31 14:24:35 +00:00
|
|
|
this.dirtyTorrents[ tor.getId() ] = true;
|
2011-08-27 21:35:19 +00:00
|
|
|
|
2011-08-28 15:16:54 +00:00
|
|
|
// enqueue ui refreshes
|
2011-08-26 01:46:07 +00:00
|
|
|
this.refilterSoon();
|
2011-08-28 15:16:54 +00:00
|
|
|
this.updateButtonsSoon();
|
2011-08-26 01:46:07 +00:00
|
|
|
},
|
2008-07-10 23:57:46 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
updateFromTorrentGet: function(updates, removed_ids)
|
|
|
|
{
|
2011-08-31 14:24:35 +00:00
|
|
|
var i, o, t, id, needed, needinfo = [];
|
2010-06-21 13:14:33 +00:00
|
|
|
|
2011-08-31 03:31:10 +00:00
|
|
|
for (i=0; o=updates[i]; ++i)
|
|
|
|
{
|
|
|
|
id = o.id;
|
2011-08-26 01:46:07 +00:00
|
|
|
if ((t = this._torrents[id]))
|
2011-08-31 03:31:10 +00:00
|
|
|
{
|
|
|
|
needed = t.needsMetaData();
|
2011-08-26 01:46:07 +00:00
|
|
|
t.refresh(o);
|
2011-08-31 14:24:35 +00:00
|
|
|
if (needed && !t.needsMetaData())
|
2011-08-31 03:31:10 +00:00
|
|
|
needinfo.push(id);
|
|
|
|
}
|
2011-08-26 01:46:07 +00:00
|
|
|
else {
|
2011-08-26 22:49:57 +00:00
|
|
|
var tr = this;
|
|
|
|
t = tr._torrents[id] = new Torrent(o);
|
2011-08-27 21:35:19 +00:00
|
|
|
this.dirtyTorrents[id] = true;
|
|
|
|
$(t).bind('dataChanged',function(ev,tor) {tr.onTorrentChanged(tor);});
|
2011-08-26 23:34:43 +00:00
|
|
|
if(!('name' in t.fields) || !('status' in t.fields)) // missing some fields...
|
|
|
|
needinfo.push(id);
|
2011-08-26 01:46:07 +00:00
|
|
|
}
|
|
|
|
}
|
2010-06-21 13:14:33 +00:00
|
|
|
|
2011-08-26 23:34:43 +00:00
|
|
|
if (needinfo.length) {
|
2011-08-26 22:49:57 +00:00
|
|
|
// whee, new torrents! get their initial information.
|
2011-09-02 19:29:41 +00:00
|
|
|
this.updateTorrents(needinfo, ['id'].concat(Torrent.Fields.Metadata, Torrent.Fields.Stats));
|
2011-08-26 01:46:07 +00:00
|
|
|
this.refilterSoon();
|
2008-07-10 23:57:46 +00:00
|
|
|
}
|
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
if (removed_ids) {
|
|
|
|
this.deleteTorrents(removed_ids);
|
|
|
|
this.refilterSoon();
|
|
|
|
}
|
|
|
|
},
|
2008-08-29 17:57:53 +00:00
|
|
|
|
2011-09-02 19:29:41 +00:00
|
|
|
updateTorrents: function(ids, fields)
|
|
|
|
{
|
|
|
|
this.remote.updateTorrents(ids, fields, this.updateFromTorrentGet, this);
|
|
|
|
},
|
|
|
|
|
2011-08-26 19:42:07 +00:00
|
|
|
refreshTorrents: function()
|
|
|
|
{
|
|
|
|
// send a request right now
|
2011-09-02 19:29:41 +00:00
|
|
|
this.updateTorrents('recently-active', ['id'].concat(Torrent.Fields.Stats));
|
2011-08-26 19:42:07 +00:00
|
|
|
|
|
|
|
// schedule the next request
|
|
|
|
clearTimeout(this.refreshTorrentsTimeout);
|
2011-08-30 21:55:44 +00:00
|
|
|
this.refreshTorrentsTimeout = setTimeout($.proxy(this.refreshTorrents,this), this[Prefs._RefreshRate]*1000);
|
2011-08-26 01:46:07 +00:00
|
|
|
},
|
2011-08-26 22:49:57 +00:00
|
|
|
|
|
|
|
initializeTorrents: function()
|
|
|
|
{
|
2011-09-02 19:29:41 +00:00
|
|
|
this.updateTorrents(null, ['id'].concat(Torrent.Fields.Metadata, Torrent.Fields.Stats));
|
2011-08-26 01:46:07 +00:00
|
|
|
},
|
2009-06-26 03:03:17 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
onRowClicked: function(ev, row)
|
|
|
|
{
|
2011-08-31 04:39:24 +00:00
|
|
|
// handle the per-row "torrent_resume" button
|
|
|
|
if (ev.target.className === 'torrent_resume') {
|
|
|
|
this.startTorrent(row.getTorrent());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// handle the per-row "torrent_pause" button
|
|
|
|
if (ev.target.className === 'torrent_pause') {
|
|
|
|
this.stopTorrent(row.getTorrent());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
// Prevents click carrying to parent element
|
|
|
|
// which deselects all on click
|
|
|
|
ev.stopPropagation();
|
|
|
|
// but still hide the context menu if it is showing
|
|
|
|
$('#jqContextMenu').hide();
|
2008-07-10 23:57:46 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
// 'Apple' button emulation on PC :
|
|
|
|
// Need settable meta-key and ctrl-key variables for mac emulation
|
|
|
|
var meta_key = ev.metaKey;
|
|
|
|
if (ev.ctrlKey && navigator.appVersion.toLowerCase().indexOf("mac") == -1)
|
|
|
|
meta_key = true;
|
2011-08-20 21:17:12 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
// Shift-Click - selects a range from the last-clicked row to this one
|
2011-08-28 17:24:56 +00:00
|
|
|
if (isMobileDevice) {
|
2011-08-26 01:46:07 +00:00
|
|
|
if (row.isSelected())
|
|
|
|
this.setInspectorVisible(true);
|
|
|
|
this.setSelectedRow(row);
|
2010-10-12 17:38:03 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
} else if (ev.shiftKey) {
|
|
|
|
this.selectRange(row);
|
|
|
|
// Need to deselect any selected text
|
|
|
|
window.focus();
|
2008-07-10 23:57:46 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
// Apple-Click, not selected
|
|
|
|
} else if (!row.isSelected() && meta_key) {
|
|
|
|
this.selectRow(row);
|
2011-08-24 02:04:35 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
// Regular Click, not selected
|
|
|
|
} else if (!row.isSelected()) {
|
|
|
|
this.setSelectedRow(row);
|
2010-06-17 04:40:06 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
// Apple-Click, selected
|
|
|
|
} else if (row.isSelected() && meta_key) {
|
|
|
|
this.deselectRow(row);
|
2009-05-23 20:39:55 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
// Regular Click, selected
|
|
|
|
} else if (row.isSelected()) {
|
|
|
|
this.setSelectedRow(row);
|
2011-08-16 18:49:26 +00:00
|
|
|
}
|
2011-08-26 01:46:07 +00:00
|
|
|
|
|
|
|
this._last_torrent_clicked = row.getTorrentId();
|
2009-05-23 20:39:55 +00:00
|
|
|
},
|
2011-08-26 01:46:07 +00:00
|
|
|
|
2011-08-26 19:42:07 +00:00
|
|
|
deleteTorrents: function(ids)
|
2011-08-25 23:06:41 +00:00
|
|
|
{
|
2011-08-26 19:42:07 +00:00
|
|
|
if (ids && ids.length)
|
2011-08-26 01:46:07 +00:00
|
|
|
{
|
2011-08-30 04:27:09 +00:00
|
|
|
for (var i=0, id; id=ids[i]; ++i) {
|
|
|
|
this.dirtyTorrents[id] = true;
|
2011-08-26 01:46:07 +00:00
|
|
|
delete this._torrents[id];
|
2011-08-30 04:27:09 +00:00
|
|
|
}
|
2011-08-26 01:46:07 +00:00
|
|
|
this.refilter();
|
2011-08-16 18:49:26 +00:00
|
|
|
}
|
2011-08-26 01:46:07 +00:00
|
|
|
},
|
2011-08-16 18:49:26 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
updateStatusbar: function()
|
|
|
|
{
|
2011-08-31 14:24:35 +00:00
|
|
|
var i, row,
|
|
|
|
u=0, d=0,
|
|
|
|
fmt = Transmission.fmt,
|
|
|
|
torrents = this.getAllTorrents();
|
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
this.refreshFilterButton();
|
2011-08-16 18:49:26 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
// up/down speed
|
2011-08-31 14:24:35 +00:00
|
|
|
for (i=0; row=torrents[i]; ++i) {
|
2011-08-26 01:46:07 +00:00
|
|
|
u += row.getUploadSpeed();
|
|
|
|
d += row.getDownloadSpeed();
|
2011-08-16 18:49:26 +00:00
|
|
|
}
|
2011-08-26 20:02:40 +00:00
|
|
|
|
|
|
|
setInnerHTML($('#statusbar #speed-up-label')[0], u ? '↑ ' + fmt.speedBps(u) : '');
|
|
|
|
setInnerHTML($('#statusbar #speed-dn-label')[0], d ? '↓ ' + fmt.speedBps(d) : '');
|
2011-08-16 18:49:26 +00:00
|
|
|
},
|
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
/*
|
|
|
|
* Select a torrent file to upload
|
|
|
|
* FIXME
|
|
|
|
*/
|
|
|
|
uploadTorrentFile: function(confirmed)
|
2011-08-25 23:06:41 +00:00
|
|
|
{
|
2011-08-26 01:46:07 +00:00
|
|
|
// Display the upload dialog
|
|
|
|
if (! confirmed) {
|
2011-08-28 13:57:25 +00:00
|
|
|
$('input#torrent_upload_file').attr('value', '');
|
|
|
|
$('input#torrent_upload_url').attr('value', '');
|
|
|
|
$('input#torrent_auto_start').attr('checked', $('#prefs_form #auto_start')[0].checked);
|
|
|
|
$('#upload_container').show();
|
|
|
|
$('#torrent_upload_url').focus();
|
2011-08-26 01:46:07 +00:00
|
|
|
|
|
|
|
// Submit the upload form
|
|
|
|
} else {
|
|
|
|
var args = { };
|
2011-08-30 21:55:44 +00:00
|
|
|
var remote = this.remote;
|
2011-08-26 01:46:07 +00:00
|
|
|
var paused = !$('#torrent_auto_start').is(':checked');
|
|
|
|
if ('' != $('#torrent_upload_url').val()) {
|
2011-08-30 21:55:44 +00:00
|
|
|
remote.addTorrentByUrl($('#torrent_upload_url').val(), { paused: paused });
|
2011-08-26 01:46:07 +00:00
|
|
|
} else {
|
|
|
|
args.url = '../upload?paused=' + paused;
|
|
|
|
args.type = 'POST';
|
2011-08-30 21:55:44 +00:00
|
|
|
args.data = { 'X-Transmission-Session-Id' : remote._token };
|
2011-08-26 01:46:07 +00:00
|
|
|
args.dataType = 'xml';
|
|
|
|
args.iframe = true;
|
|
|
|
$('#torrent_upload_form').ajaxSubmit(args);
|
2011-08-25 23:06:41 +00:00
|
|
|
}
|
2010-06-17 04:40:06 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
removeSelectedTorrents: function() {
|
|
|
|
var torrents = this.getSelectedTorrents();
|
|
|
|
if (torrents.length)
|
|
|
|
this.promptToRemoveTorrents(torrents);
|
|
|
|
},
|
2011-08-25 23:06:41 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
removeSelectedTorrentsAndData: function() {
|
2011-08-24 02:04:35 +00:00
|
|
|
var torrents = this.getSelectedTorrents();
|
2011-08-26 01:46:07 +00:00
|
|
|
if (torrents.length)
|
|
|
|
this.promptToRemoveTorrentsAndData(torrents);
|
|
|
|
},
|
2011-08-25 23:06:41 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
promptToRemoveTorrents:function(torrents)
|
|
|
|
{
|
|
|
|
if (torrents.length == 1)
|
2011-08-25 23:06:41 +00:00
|
|
|
{
|
2011-08-26 01:46:07 +00:00
|
|
|
var torrent = torrents[0];
|
|
|
|
var header = 'Remove ' + torrent.getName() + '?';
|
|
|
|
var message = 'Once removed, continuing the transfer will require the torrent file. Are you sure you want to remove it?';
|
|
|
|
dialog.confirm(header, message, 'Remove', 'transmission.removeTorrents', torrents);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var header = 'Remove ' + torrents.length + ' transfers?';
|
|
|
|
var message = 'Once removed, continuing the transfers will require the torrent files. Are you sure you want to remove them?';
|
|
|
|
dialog.confirm(header, message, 'Remove', 'transmission.removeTorrents', torrents);
|
|
|
|
}
|
|
|
|
},
|
2011-08-25 23:06:41 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
promptToRemoveTorrentsAndData:function(torrents)
|
|
|
|
{
|
|
|
|
if (torrents.length == 1)
|
|
|
|
{
|
|
|
|
var torrent = torrents[0],
|
|
|
|
header = 'Remove ' + torrent.getName() + ' and delete data?',
|
|
|
|
message = 'All data downloaded for this torrent will be deleted. Are you sure you want to remove it?';
|
|
|
|
dialog.confirm(header, message, 'Remove', 'transmission.removeTorrentsAndData', torrents);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var header = 'Remove ' + torrents.length + ' transfers and delete data?',
|
|
|
|
message = 'All data downloaded for these torrents will be deleted. Are you sure you want to remove them?';
|
|
|
|
dialog.confirm(header, message, 'Remove', 'transmission.removeTorrentsAndData', torrents);
|
|
|
|
}
|
|
|
|
},
|
2011-08-25 23:06:41 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
removeTorrents: function(torrents) {
|
2011-08-26 19:42:07 +00:00
|
|
|
var ids = $.map(torrents, function(t) { return t.getId(); });
|
2011-08-28 06:05:46 +00:00
|
|
|
this.remote.removeTorrents(ids, this.refreshTorrents, this);
|
2011-08-26 01:46:07 +00:00
|
|
|
},
|
2011-08-25 23:06:41 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
removeTorrentsAndData: function(torrents) {
|
|
|
|
this.remote.removeTorrentsAndData(torrents);
|
|
|
|
},
|
2011-08-25 23:06:41 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
verifySelectedTorrents: function() {
|
|
|
|
this.verifyTorrents(this.getSelectedTorrents());
|
|
|
|
},
|
2011-08-25 23:06:41 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
reannounceSelectedTorrents: function() {
|
|
|
|
this.reannounceTorrents(this.getSelectedTorrents());
|
|
|
|
},
|
2011-08-25 23:06:41 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
startSelectedTorrents: function(force) {
|
|
|
|
this.startTorrents(this.getSelectedTorrents(), force);
|
|
|
|
},
|
|
|
|
startAllTorrents: function() {
|
|
|
|
this.startTorrents(this.getAllTorrents(), false);
|
|
|
|
},
|
|
|
|
startTorrent: function(torrent) {
|
|
|
|
this.startTorrents([ torrent ], false);
|
|
|
|
},
|
|
|
|
startTorrents: function(torrents, force) {
|
2011-08-28 06:05:46 +00:00
|
|
|
this.remote.startTorrents($.map(torrents, function(t) {return t.getId();}),
|
|
|
|
force, this.refreshTorrents, this);
|
2011-08-26 01:46:07 +00:00
|
|
|
},
|
|
|
|
verifyTorrent: function(torrent) {
|
|
|
|
this.verifyTorrents([ torrent ]);
|
|
|
|
},
|
|
|
|
verifyTorrents: function(torrents) {
|
2011-08-28 06:05:46 +00:00
|
|
|
this.remote.verifyTorrents($.map(torrents, function(t) {return t.getId();}),
|
|
|
|
this.refreshTorrents, this);
|
2011-08-26 01:46:07 +00:00
|
|
|
},
|
2011-08-25 23:06:41 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
reannounceTorrent: function(torrent) {
|
|
|
|
this.reannounceTorrents([ torrent ]);
|
|
|
|
},
|
|
|
|
reannounceTorrents: function(torrents) {
|
2011-08-28 06:05:46 +00:00
|
|
|
this.remote.reannounceTorrents($.map(torrents, function(t) {return t.getId();}),
|
|
|
|
this.refreshTorrents, this);
|
2010-01-31 02:42:48 +00:00
|
|
|
},
|
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
stopSelectedTorrents: function() {
|
|
|
|
this.stopTorrents(this.getSelectedTorrents());
|
2010-02-01 01:08:17 +00:00
|
|
|
},
|
2011-08-26 01:46:07 +00:00
|
|
|
stopAllTorrents: function() {
|
|
|
|
this.stopTorrents(this.getAllTorrents());
|
2010-02-01 01:08:17 +00:00
|
|
|
},
|
2011-08-26 01:46:07 +00:00
|
|
|
stopTorrent: function(torrent) {
|
|
|
|
this.stopTorrents([ torrent ]);
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
2011-08-26 01:46:07 +00:00
|
|
|
stopTorrents: function(torrents) {
|
2011-08-28 06:05:46 +00:00
|
|
|
this.remote.stopTorrents($.map(torrents.slice(0), function(t) {return t.getId();}),
|
|
|
|
this.refreshTorrents, this);
|
2010-02-06 16:43:48 +00:00
|
|
|
},
|
2011-08-26 01:46:07 +00:00
|
|
|
changeFileCommand: function(command, rows) {
|
|
|
|
this.remote.changeFileCommand(command, rows);
|
2010-02-06 16:43:48 +00:00
|
|
|
},
|
|
|
|
|
2011-08-31 14:24:35 +00:00
|
|
|
hideMobileAddressbar: function(delaySecs) {
|
2011-08-30 21:55:44 +00:00
|
|
|
if (isMobileDevice && !scroll_timeout) {
|
2011-08-31 14:24:35 +00:00
|
|
|
var delayMsec = delaySecs*1000 || 150;
|
|
|
|
scroll_timeout = setTimeout($.proxy(this.doToolbarHide,this), delayMsec);
|
2011-08-16 18:49:26 +00:00
|
|
|
}
|
2011-08-26 01:46:07 +00:00
|
|
|
},
|
|
|
|
doToolbarHide: function() {
|
|
|
|
window.scrollTo(0,1);
|
|
|
|
scroll_timeout=null;
|
2009-05-22 22:45:09 +00:00
|
|
|
},
|
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
// Queue
|
|
|
|
moveTop: function() {
|
2011-08-28 06:05:46 +00:00
|
|
|
this.remote.moveTorrentsToTop(this.getSelectedTorrentIds(),
|
|
|
|
this.refreshTorrents, this);
|
2011-08-25 23:06:41 +00:00
|
|
|
},
|
2011-08-26 01:46:07 +00:00
|
|
|
moveUp: function() {
|
2011-08-28 06:05:46 +00:00
|
|
|
this.remote.moveTorrentsUp(this.getSelectedTorrentIds(),
|
|
|
|
this.refreshTorrents, this);
|
2011-08-25 23:06:41 +00:00
|
|
|
},
|
2011-08-26 01:46:07 +00:00
|
|
|
moveDown: function() {
|
2011-08-28 06:05:46 +00:00
|
|
|
this.remote.moveTorrentsDown(this.getSelectedTorrentIds(),
|
|
|
|
this.refreshTorrents, this);
|
2011-08-25 23:06:41 +00:00
|
|
|
},
|
2011-08-26 01:46:07 +00:00
|
|
|
moveBottom: function() {
|
2011-08-28 06:05:46 +00:00
|
|
|
this.remote.moveTorrentsToBottom(this.getSelectedTorrentIds(),
|
|
|
|
this.refreshTorrents, this);
|
2009-05-22 22:45:09 +00:00
|
|
|
},
|
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
2011-08-25 09:21:05 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
setEnabled: function(key, flag)
|
2011-08-24 02:04:35 +00:00
|
|
|
{
|
2011-08-26 01:46:07 +00:00
|
|
|
$(key).toggleClass('disabled', !flag);
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
2010-06-21 13:14:33 +00:00
|
|
|
|
2011-08-28 15:16:54 +00:00
|
|
|
updateButtonsSoon: function()
|
|
|
|
{
|
|
|
|
if (!this.buttonRefreshTimer)
|
2011-08-30 21:55:44 +00:00
|
|
|
this.buttonRefreshTimer = setTimeout($.proxy(this.updateButtonStates,this), 100);
|
2011-08-28 15:16:54 +00:00
|
|
|
},
|
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
updateButtonStates: function()
|
2008-07-10 23:57:46 +00:00
|
|
|
{
|
2011-08-28 15:16:54 +00:00
|
|
|
clearTimeout(this.buttonRefreshTimer);
|
|
|
|
delete this.buttonRefreshTimer;
|
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
var showing_dialog = new RegExp("(prefs_showing|dialog_showing|open_showing)").test(document.body.className);
|
|
|
|
this._toolbar_buttons.toggleClass('disabled', showing_dialog);
|
2010-06-21 13:14:33 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
if (!showing_dialog)
|
|
|
|
{
|
2011-08-28 06:20:32 +00:00
|
|
|
var haveSelection = false,
|
|
|
|
haveActive = false,
|
|
|
|
haveActiveSelection = false,
|
|
|
|
havePaused = false,
|
|
|
|
havePausedSelection = false;
|
2011-08-24 02:04:35 +00:00
|
|
|
|
|
|
|
for (var i=0, row; row=this._rows[i]; ++i) {
|
|
|
|
var isStopped = row.getTorrent().isStopped();
|
|
|
|
var isSelected = row.isSelected();
|
|
|
|
if (!isStopped) haveActive = true;
|
|
|
|
if (isStopped) havePaused = true;
|
|
|
|
if (isSelected) haveSelection = true;
|
|
|
|
if (isSelected && !isStopped) haveActiveSelection = true;
|
|
|
|
if (isSelected && isStopped) havePausedSelection = true;
|
2011-08-16 18:49:26 +00:00
|
|
|
}
|
2011-08-24 02:04:35 +00:00
|
|
|
|
|
|
|
this.setEnabled(this._toolbar_pause_button, haveActiveSelection);
|
|
|
|
this.setEnabled(this._context_pause_button, haveActiveSelection);
|
|
|
|
this.setEnabled(this._toolbar_start_button, havePausedSelection);
|
|
|
|
this.setEnabled(this._context_start_button, havePausedSelection);
|
|
|
|
this.setEnabled(this._context_move_top_button, haveSelection);
|
|
|
|
this.setEnabled(this._context_move_up_button, haveSelection);
|
|
|
|
this.setEnabled(this._context_move_down_button, haveSelection);
|
|
|
|
this.setEnabled(this._context_move_bottom_button, haveSelection);
|
|
|
|
this.setEnabled(this._context_start_now_button, havePausedSelection);
|
|
|
|
this.setEnabled(this._toolbar_remove_button, haveSelection);
|
|
|
|
this.setEnabled(this._toolbar_pause_all_button, haveActive);
|
|
|
|
this.setEnabled(this._toolbar_start_all_button, havePaused);
|
2011-08-16 18:49:26 +00:00
|
|
|
}
|
2011-08-24 02:04:35 +00:00
|
|
|
},
|
2011-08-16 18:49:26 +00:00
|
|
|
|
2011-08-26 01:46:07 +00:00
|
|
|
/****
|
|
|
|
*****
|
|
|
|
***** INSPECTOR
|
|
|
|
*****
|
|
|
|
****/
|
|
|
|
|
2011-09-02 19:29:41 +00:00
|
|
|
inspectorIsVisible: function()
|
2011-08-26 01:46:07 +00:00
|
|
|
{
|
2011-09-02 19:29:41 +00:00
|
|
|
return $('#torrent_inspector').is(':visible');
|
2011-08-30 21:40:18 +00:00
|
|
|
},
|
2011-08-26 01:46:07 +00:00
|
|
|
toggleInspector: function()
|
|
|
|
{
|
2011-08-30 04:54:37 +00:00
|
|
|
this.setInspectorVisible(!this.inspectorIsVisible());
|
2011-08-26 01:46:07 +00:00
|
|
|
},
|
|
|
|
setInspectorVisible: function(visible)
|
|
|
|
{
|
|
|
|
// update the ui widgetry
|
|
|
|
$('#torrent_inspector').toggle(visible);
|
2011-08-28 17:24:56 +00:00
|
|
|
if (isMobileDevice) {
|
2011-08-26 01:46:07 +00:00
|
|
|
$('body').toggleClass('inspector_showing',visible);
|
|
|
|
$('#inspector_close').toggle(visible);
|
2011-08-28 17:24:56 +00:00
|
|
|
this.hideMobileAddressbar();
|
2011-08-26 01:46:07 +00:00
|
|
|
} else {
|
|
|
|
var w = visible ? $('#torrent_inspector').width() + 1 + 'px' : '0px';
|
|
|
|
$('#torrent_container')[0].style.right = w;
|
|
|
|
}
|
|
|
|
setInnerHTML($('ul li#context_toggle_inspector')[0], (visible?'Hide':'Show')+' Inspector');
|
2011-08-30 21:40:18 +00:00
|
|
|
|
2011-09-02 19:29:41 +00:00
|
|
|
if (visible)
|
|
|
|
this.inspector.setTorrents(this.getSelectedTorrents());
|
2011-08-26 01:46:07 +00:00
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
/****
|
|
|
|
*****
|
|
|
|
***** FILTER
|
|
|
|
*****
|
|
|
|
****/
|
|
|
|
|
|
|
|
filterSetup: function()
|
|
|
|
{
|
|
|
|
var popup = $('#filter-popup');
|
|
|
|
popup.dialog({
|
|
|
|
autoOpen: false,
|
2011-08-28 17:24:56 +00:00
|
|
|
position: isMobileDevice ? [0,0] : [40,80],
|
2011-08-24 02:04:35 +00:00
|
|
|
show: 'blind',
|
|
|
|
hide: 'blind',
|
|
|
|
title: 'Show',
|
|
|
|
width: 315
|
|
|
|
});
|
|
|
|
var tr = this;
|
|
|
|
$('#filter-button').click(function() {
|
|
|
|
if (popup.is(":visible"))
|
|
|
|
popup.dialog('close');
|
|
|
|
else {
|
|
|
|
tr.refreshFilterPopup();
|
|
|
|
popup.dialog('open');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.refreshFilterButton();
|
|
|
|
},
|
|
|
|
|
|
|
|
refreshFilterButton: function()
|
|
|
|
{
|
2011-09-01 17:24:49 +00:00
|
|
|
var o, tmp, text, torrent_count,
|
2011-08-28 06:20:32 +00:00
|
|
|
state = this[Prefs._FilterMode],
|
|
|
|
state_all = state == Prefs._FilterAll,
|
|
|
|
state_string = this.getStateString(state),
|
|
|
|
tracker = this.filterTracker,
|
|
|
|
tracker_all = !tracker,
|
|
|
|
tracker_string = tracker ? this.getReadableDomain(tracker) : '',
|
|
|
|
visible_count = this._rows.length;
|
|
|
|
|
2011-09-01 17:24:49 +00:00
|
|
|
// count the total number of torrents
|
|
|
|
// torrent_count = Object.keys(this._torrents).length; // IE8 doesn't support Object.keys(
|
|
|
|
torrent_count = 0;
|
|
|
|
o = this._torrents;
|
|
|
|
for (tmp in o)
|
|
|
|
if (o.hasOwnProperty(tmp))
|
|
|
|
++torrent_count;
|
|
|
|
|
2011-08-28 13:57:25 +00:00
|
|
|
text = 'Show <span class="filter-selection">';
|
2011-08-24 02:04:35 +00:00
|
|
|
if (state_all && tracker_all)
|
2011-08-28 13:57:25 +00:00
|
|
|
text += 'All';
|
2011-08-24 02:04:35 +00:00
|
|
|
else if (state_all)
|
2011-08-28 13:57:25 +00:00
|
|
|
text += tracker_string;
|
2011-08-24 02:04:35 +00:00
|
|
|
else if (tracker_all)
|
2011-08-28 13:57:25 +00:00
|
|
|
text += state_string;
|
2011-08-24 02:04:35 +00:00
|
|
|
else
|
2011-08-28 13:57:25 +00:00
|
|
|
text += state_string + '</span> at <span class="filter-selection">' + tracker_string;
|
|
|
|
text += '</span> — ';
|
2011-08-24 02:04:35 +00:00
|
|
|
|
|
|
|
if (torrent_count === visible_count)
|
2011-08-28 13:57:25 +00:00
|
|
|
text += torrent_count + ' Transfers';
|
2011-08-24 02:04:35 +00:00
|
|
|
else
|
2011-08-28 13:57:25 +00:00
|
|
|
text += visible_count + ' of ' + torrent_count;
|
|
|
|
$('#filter-button').html(text);
|
2011-08-24 02:04:35 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
refilterSoon: function()
|
|
|
|
{
|
2011-08-31 04:39:24 +00:00
|
|
|
if (!this.refilterTimer) {
|
|
|
|
var tr = this;
|
|
|
|
this.refilterTimer = setTimeout(function(){tr.refilter(false);}, 100);
|
|
|
|
}
|
2011-08-24 02:04:35 +00:00
|
|
|
},
|
2008-07-10 23:57:46 +00:00
|
|
|
|
2011-08-27 21:35:19 +00:00
|
|
|
sortRows: function(rows)
|
|
|
|
{
|
|
|
|
var i, tor, row,
|
|
|
|
id2row = {},
|
|
|
|
torrents = [];
|
|
|
|
|
|
|
|
for (i=0; row=rows[i]; ++i) {
|
|
|
|
tor = row.getTorrent();
|
|
|
|
torrents.push(tor);
|
|
|
|
id2row[ tor.getId() ] = row;
|
|
|
|
}
|
|
|
|
|
|
|
|
Torrent.sortTorrents(torrents, this[Prefs._SortMethod],
|
|
|
|
this[Prefs._SortDirection]);
|
|
|
|
|
|
|
|
for (i=0; tor=torrents[i]; ++i)
|
|
|
|
rows[i] = id2row[ tor.getId() ];
|
|
|
|
},
|
|
|
|
|
|
|
|
refilter: function(rebuildEverything)
|
2011-08-24 02:04:35 +00:00
|
|
|
{
|
2011-08-31 00:09:21 +00:00
|
|
|
var i, e, id, t, row, tmp, rows, clean_rows, dirty_rows, frag,
|
2011-08-28 04:14:58 +00:00
|
|
|
sort_mode = this[Prefs._SortMethod],
|
|
|
|
sort_direction = this[Prefs._SortDirection],
|
|
|
|
filter_mode = this[Prefs._FilterMode],
|
|
|
|
filter_text = this.filterText,
|
|
|
|
filter_tracker = this.filterTracker,
|
|
|
|
renderer = this.torrentRenderer,
|
2011-08-30 21:27:30 +00:00
|
|
|
list = this._torrent_list,
|
|
|
|
old_sel_count = $(list).children('.selected').length;
|
|
|
|
|
2011-08-27 21:35:19 +00:00
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
clearTimeout(this.refilterTimer);
|
|
|
|
delete this.refilterTimer;
|
|
|
|
|
2011-08-28 04:14:58 +00:00
|
|
|
if (rebuildEverything) {
|
|
|
|
$(list).empty();
|
|
|
|
this._rows = [];
|
2011-08-27 21:35:19 +00:00
|
|
|
for (id in this._torrents)
|
2011-08-28 04:14:58 +00:00
|
|
|
this.dirtyTorrents[id] = true;
|
|
|
|
}
|
2011-08-27 21:35:19 +00:00
|
|
|
|
|
|
|
// rows that overlap with dirtyTorrents need to be refiltered.
|
|
|
|
// those that don't are 'clean' and don't need refiltering.
|
2011-08-28 04:14:58 +00:00
|
|
|
clean_rows = [];
|
|
|
|
dirty_rows = [];
|
2011-08-27 21:35:19 +00:00
|
|
|
for (i=0; row=this._rows[i]; ++i) {
|
|
|
|
if(row.getTorrentId() in this.dirtyTorrents)
|
|
|
|
dirty_rows.push(row);
|
|
|
|
else
|
|
|
|
clean_rows.push(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove the dirty rows from the dom
|
2011-08-28 04:14:58 +00:00
|
|
|
e = $.map(dirty_rows.slice(0), function(r) {
|
2011-08-27 21:35:19 +00:00
|
|
|
return r.getElement();
|
|
|
|
});
|
2011-08-31 16:23:38 +00:00
|
|
|
$(e).detach();
|
2011-08-27 21:35:19 +00:00
|
|
|
|
|
|
|
// drop any dirty rows that don't pass the filter test
|
2011-08-28 04:14:58 +00:00
|
|
|
tmp = [];
|
2011-08-27 21:35:19 +00:00
|
|
|
for (i=0; row=dirty_rows[i]; ++i) {
|
2011-08-30 04:27:09 +00:00
|
|
|
id = row.getTorrentId();
|
|
|
|
t = this._torrents[ id ];
|
|
|
|
if (t && t.test(filter_mode, filter_text, filter_tracker))
|
2011-08-27 21:35:19 +00:00
|
|
|
tmp.push(row);
|
2011-08-30 04:27:09 +00:00
|
|
|
delete this.dirtyTorrents[id];
|
2011-08-27 21:35:19 +00:00
|
|
|
}
|
|
|
|
dirty_rows = tmp;
|
|
|
|
|
|
|
|
// make new rows for dirty torrents that pass the filter test
|
|
|
|
// but don't already have a row
|
|
|
|
for (id in this.dirtyTorrents) {
|
|
|
|
t = this._torrents[id];
|
2011-08-30 04:27:09 +00:00
|
|
|
if (t && t.test(filter_mode, filter_text, filter_tracker)) {
|
2011-08-30 21:27:30 +00:00
|
|
|
row = new TorrentRow(renderer, this, t);
|
2011-08-31 16:23:38 +00:00
|
|
|
e = row.getElement();
|
|
|
|
e.row = row;
|
2011-08-27 21:35:19 +00:00
|
|
|
dirty_rows.push(row);
|
2011-08-31 16:23:38 +00:00
|
|
|
var tr = this;
|
|
|
|
$(e).click(function(ev){tr.onRowClicked(ev,ev.currentTarget.row);});
|
|
|
|
$(e).dblclick(function(ev){tr.toggleInspector();});
|
2011-08-27 21:35:19 +00:00
|
|
|
}
|
|
|
|
}
|
2011-08-24 02:04:35 +00:00
|
|
|
|
2011-08-27 21:35:19 +00:00
|
|
|
// sort the dirty rows
|
|
|
|
this.sortRows (dirty_rows);
|
|
|
|
|
|
|
|
// now we have two sorted arrays of rows
|
|
|
|
// and can do a simple two-way sorted merge.
|
2011-08-28 04:14:58 +00:00
|
|
|
rows = [];
|
2011-08-27 21:35:19 +00:00
|
|
|
var ci=0, cmax=clean_rows.length;
|
|
|
|
var di=0, dmax=dirty_rows.length;
|
2011-08-31 00:09:21 +00:00
|
|
|
frag = document.createDocumentFragment();
|
2011-08-27 21:35:19 +00:00
|
|
|
while (ci!=cmax || di!=dmax)
|
2011-08-24 02:04:35 +00:00
|
|
|
{
|
2011-08-27 21:35:19 +00:00
|
|
|
var push_clean;
|
2011-08-26 00:43:35 +00:00
|
|
|
|
2011-08-27 21:35:19 +00:00
|
|
|
if (ci==cmax)
|
|
|
|
push_clean = false;
|
|
|
|
else if (di==dmax)
|
|
|
|
push_clean = true;
|
|
|
|
else {
|
2011-08-28 13:57:25 +00:00
|
|
|
var c = Torrent.compareTorrents(
|
|
|
|
clean_rows[ci].getTorrent(),
|
|
|
|
dirty_rows[di].getTorrent(),
|
|
|
|
sort_mode, sort_direction);
|
2011-08-27 21:35:19 +00:00
|
|
|
push_clean = (c < 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (push_clean)
|
|
|
|
rows.push(clean_rows[ci++]);
|
|
|
|
else {
|
2011-08-28 04:14:58 +00:00
|
|
|
row = dirty_rows[di++];
|
|
|
|
e = row.getElement();
|
2011-08-27 21:35:19 +00:00
|
|
|
if (ci !== cmax)
|
|
|
|
list.insertBefore(e, clean_rows[ci].getElement());
|
|
|
|
else
|
2011-08-31 00:09:21 +00:00
|
|
|
frag.appendChild(e);
|
2011-08-26 00:43:35 +00:00
|
|
|
rows.push(row);
|
2011-08-24 02:04:35 +00:00
|
|
|
}
|
2011-08-27 21:35:19 +00:00
|
|
|
}
|
2011-08-31 00:09:21 +00:00
|
|
|
list.appendChild(frag);
|
2011-08-26 00:43:35 +00:00
|
|
|
|
2011-08-27 21:35:19 +00:00
|
|
|
// update our implementation fields
|
|
|
|
this._rows = rows;
|
|
|
|
this.dirtyTorrents = { };
|
2011-08-26 01:27:16 +00:00
|
|
|
|
2011-08-28 13:57:25 +00:00
|
|
|
// jquery's even/odd starts with 1 not 0, so invert its logic
|
2011-08-28 04:14:58 +00:00
|
|
|
e = $.map(rows.slice(0), function(r){return r.getElement();});
|
|
|
|
$(e).filter(":odd").addClass('even');
|
|
|
|
$(e).filter(":even").removeClass('even');
|
2008-07-10 23:57:46 +00:00
|
|
|
|
|
|
|
// sync gui
|
2011-08-24 02:04:35 +00:00
|
|
|
this.updateStatusbar();
|
|
|
|
this.refreshFilterButton();
|
2011-08-30 21:27:30 +00:00
|
|
|
if (old_sel_count !== $(list).children('.selected').length)
|
2011-08-28 15:16:54 +00:00
|
|
|
this.selectionChanged();
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
2011-08-27 21:35:19 +00:00
|
|
|
setFilterMode: function(mode)
|
2008-07-10 23:57:46 +00:00
|
|
|
{
|
2011-08-24 02:04:35 +00:00
|
|
|
// set the state
|
|
|
|
this.setPref(Prefs._FilterMode, mode);
|
|
|
|
|
|
|
|
// refilter
|
2011-08-27 21:35:19 +00:00
|
|
|
this.refilter(true);
|
2008-07-10 23:57:46 +00:00
|
|
|
},
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
refreshFilterPopup: function()
|
2008-07-10 23:57:46 +00:00
|
|
|
{
|
2011-08-24 02:04:35 +00:00
|
|
|
var tr = this;
|
2009-05-23 21:39:16 +00:00
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
/***
|
|
|
|
**** States
|
|
|
|
***/
|
|
|
|
|
|
|
|
var counts = { };
|
|
|
|
var states = [ Prefs._FilterAll,
|
|
|
|
Prefs._FilterActive,
|
|
|
|
Prefs._FilterDownloading,
|
2011-08-25 06:26:07 +00:00
|
|
|
Prefs._FilterSeeding,
|
2011-08-24 02:04:35 +00:00
|
|
|
Prefs._FilterPaused,
|
|
|
|
Prefs._FilterFinished ];
|
|
|
|
for (var i=0, state; state=states[i]; ++i)
|
|
|
|
counts[state] = 0;
|
|
|
|
var torrents = this.getAllTorrents();
|
|
|
|
for (var i=0, tor; tor=torrents[i]; ++i)
|
|
|
|
for (var j=0, s; s=states[j]; ++j)
|
|
|
|
if (tor.testState(s))
|
|
|
|
counts[s]++;
|
|
|
|
var sel_state = tr[Prefs._FilterMode];
|
|
|
|
var fragment = document.createDocumentFragment();
|
|
|
|
for (var i=0, s; s=states[i]; ++i)
|
2008-07-10 23:57:46 +00:00
|
|
|
{
|
2011-08-24 02:04:35 +00:00
|
|
|
var div = document.createElement('div');
|
|
|
|
div.id = 'show-state-' + s;
|
|
|
|
div.className = 'row' + (s === sel_state ? ' selected':'');
|
|
|
|
div.innerHTML = '<span class="filter-img"></span>'
|
|
|
|
+ '<span class="filter-name">' + tr.getStateString(s) + '</span>'
|
|
|
|
+ '<span class="count">' + counts[s] + '</span>';
|
2011-08-27 21:35:19 +00:00
|
|
|
$(div).click({'state':s}, function(ev) {
|
|
|
|
tr.setFilterMode(ev.data.state);
|
|
|
|
$('#filter-popup').dialog('close');
|
|
|
|
});
|
2011-08-24 02:04:35 +00:00
|
|
|
fragment.appendChild(div);
|
|
|
|
}
|
|
|
|
$('#filter-by-state .row').remove();
|
|
|
|
$('#filter-by-state')[0].appendChild(fragment);
|
|
|
|
|
|
|
|
/***
|
|
|
|
**** Trackers
|
|
|
|
***/
|
|
|
|
|
|
|
|
var trackers = this.getTrackers();
|
2011-09-01 17:24:49 +00:00
|
|
|
//var names = Object.keys(trackers).sort(); (IE8 doesn't have Object.keys)
|
|
|
|
var name, name=[];
|
|
|
|
var names = [];
|
|
|
|
for (name in trackers)
|
|
|
|
names.push (name);
|
|
|
|
names.sort();
|
2011-08-24 02:04:35 +00:00
|
|
|
|
|
|
|
var fragment = document.createDocumentFragment();
|
|
|
|
var div = document.createElement('div');
|
|
|
|
div.id = 'show-tracker-all';
|
|
|
|
div.className = 'row' + (tr.filterTracker ? '' : ' selected');
|
|
|
|
div.innerHTML = '<span class="filter-img"></span>'
|
|
|
|
+ '<span class="filter-name">All</span>'
|
|
|
|
+ '<span class="count">' + torrents.length + '</span>';
|
2011-08-27 21:35:19 +00:00
|
|
|
$(div).click(function() {
|
|
|
|
tr.setFilterTracker(null);
|
|
|
|
$('#filter-popup').dialog('close');
|
|
|
|
});
|
2011-08-24 02:04:35 +00:00
|
|
|
fragment.appendChild(div);
|
|
|
|
for (var i=0, name; name=names[i]; ++i) {
|
|
|
|
var div = document.createElement('div');
|
|
|
|
var o = trackers[name];
|
|
|
|
div.id = 'show-tracker-' + name;
|
|
|
|
div.className = 'row' + (o.domain === tr.filterTracker ? ' selected':'');
|
|
|
|
div.innerHTML = '<img class="filter-img" src="http://'+o.domain+'/favicon.ico"/>'
|
|
|
|
+ '<span class="filter-name">'+ name + '</span>'
|
|
|
|
+ '<span class="count">'+ o.count + '</span>';
|
2011-08-27 21:35:19 +00:00
|
|
|
$(div).click({domain:o.domain}, function(ev) {
|
|
|
|
tr.setFilterTracker(ev.data.domain);
|
|
|
|
$('#filter-popup').dialog('close');
|
|
|
|
});
|
2011-08-24 02:04:35 +00:00
|
|
|
fragment.appendChild(div);
|
|
|
|
}
|
|
|
|
$('#filter-by-tracker .row').remove();
|
|
|
|
$('#filter-by-tracker')[0].appendChild(fragment);
|
|
|
|
},
|
2008-07-10 23:57:46 +00:00
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
getStateString: function(mode)
|
|
|
|
{
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case Prefs._FilterActive: return 'Active';
|
|
|
|
case Prefs._FilterSeeding: return 'Seeding';
|
|
|
|
case Prefs._FilterDownloading: return 'Downloading';
|
|
|
|
case Prefs._FilterPaused: return 'Paused';
|
|
|
|
case Prefs._FilterFinished: return 'Finished';
|
|
|
|
default: return 'All';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
setFilterTracker: function(domain)
|
|
|
|
{
|
|
|
|
this.filterTracker = domain;
|
|
|
|
|
|
|
|
// update which tracker is selected in the popup
|
|
|
|
var key = domain ? this.getReadableDomain(domain) : 'all';
|
|
|
|
var id = '#show-tracker-' + key;
|
|
|
|
$(id).addClass('selected').siblings().removeClass('selected');
|
|
|
|
|
2011-08-27 21:35:19 +00:00
|
|
|
this.refilter(true);
|
2011-08-24 02:04:35 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/* example: "tracker.ubuntu.com" returns "ubuntu.com" */
|
|
|
|
getDomainName: function(host)
|
|
|
|
{
|
|
|
|
var dot = host.indexOf('.');
|
|
|
|
if (dot !== host.lastIndexOf('.'))
|
|
|
|
host = host.slice(dot+1);
|
|
|
|
return host;
|
|
|
|
},
|
|
|
|
|
|
|
|
/* example: "ubuntu.com" returns "Ubuntu" */
|
|
|
|
getReadableDomain: function(name)
|
|
|
|
{
|
|
|
|
if (name.length)
|
|
|
|
name = name.charAt(0).toUpperCase() + name.slice(1);
|
|
|
|
var dot = name.indexOf('.');
|
|
|
|
if (dot !== -1)
|
|
|
|
name = name.slice(0, dot);
|
|
|
|
return name;
|
|
|
|
},
|
|
|
|
|
|
|
|
getTrackers: function()
|
|
|
|
{
|
2011-08-25 23:06:41 +00:00
|
|
|
var ret = {};
|
2011-08-24 02:04:35 +00:00
|
|
|
|
|
|
|
var torrents = this.getAllTorrents();
|
|
|
|
for (var i=0, torrent; torrent=torrents[i]; ++i) {
|
|
|
|
var names = [];
|
2011-08-25 23:06:41 +00:00
|
|
|
var trackers = torrent.getTrackers();
|
|
|
|
for (var j=0, tracker; tracker=trackers[j]; ++j) {
|
|
|
|
var uri = parseUri(tracker.announce);
|
|
|
|
var domain = this.getDomainName(uri.host);
|
|
|
|
var name = this.getReadableDomain(domain);
|
|
|
|
if (!(name in ret))
|
|
|
|
ret[name] = { 'uri': uri, 'domain': domain, 'count': 0 };
|
|
|
|
if (names.indexOf(name) === -1)
|
|
|
|
names.push(name);
|
2008-07-10 23:57:46 +00:00
|
|
|
}
|
2011-08-24 02:04:35 +00:00
|
|
|
for (var j=0, name; name=names[j]; ++j)
|
2011-08-25 23:06:41 +00:00
|
|
|
ret[name].count++;
|
2011-08-24 02:04:35 +00:00
|
|
|
}
|
2008-07-10 23:57:46 +00:00
|
|
|
|
2011-08-25 23:06:41 +00:00
|
|
|
return ret;
|
2011-08-24 02:04:35 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
**** Compact Mode
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
|
|
|
toggleCompactClicked: function()
|
|
|
|
{
|
|
|
|
this.setCompactMode(!this[Prefs._CompactDisplayState]);
|
|
|
|
},
|
|
|
|
setCompactMode: function(is_compact)
|
|
|
|
{
|
2011-08-28 13:57:25 +00:00
|
|
|
var key = Prefs._CompactDisplayState,
|
|
|
|
was_compact = this[key];
|
|
|
|
|
2011-08-24 02:04:35 +00:00
|
|
|
if (was_compact !== is_compact) {
|
|
|
|
this.setPref(key, is_compact);
|
|
|
|
this.onCompactModeChanged();
|
2008-07-10 23:57:46 +00:00
|
|
|
}
|
2011-08-24 02:04:35 +00:00
|
|
|
},
|
|
|
|
initCompactMode: function()
|
|
|
|
{
|
|
|
|
this.onCompactModeChanged();
|
|
|
|
},
|
|
|
|
onCompactModeChanged: function()
|
|
|
|
{
|
|
|
|
var compact = this[Prefs._CompactDisplayState];
|
|
|
|
|
|
|
|
// update the ui: footer button
|
|
|
|
$("#compact-button").toggleClass('enabled',compact);
|
|
|
|
|
|
|
|
// update the ui: torrent list
|
|
|
|
this.torrentRenderer = compact ? new TorrentRendererCompact()
|
|
|
|
: new TorrentRendererFull();
|
2011-08-27 21:35:19 +00:00
|
|
|
this.refilter(true);
|
2008-07-10 23:57:46 +00:00
|
|
|
}
|
|
|
|
};
|