mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 12:28:52 +00:00
#5944: Unify indentation style and strip trailing whitespaces across JS code, no functional changes (patch by xzcvczx + a lot more)
This commit is contained in:
@@ -28,7 +28,7 @@ $.fn.tabbedDialog = function (dialog_opts) {
|
|||||||
this.find('.ui-tab-dialog-close').css({'position':'absolute','right':'0', 'top':'16px'});
|
this.find('.ui-tab-dialog-close').css({'position':'absolute','right':'0', 'top':'16px'});
|
||||||
this.find('.ui-tab-dialog-close > a').css({'float':'none','padding':'0'});
|
this.find('.ui-tab-dialog-close > a').css({'float':'none','padding':'0'});
|
||||||
var tabul = this.find('ul:first');
|
var tabul = this.find('ul:first');
|
||||||
this.parent().addClass('ui-tabs').prepend(tabul).draggable('option','handle',tabul);
|
this.parent().addClass('ui-tabs').prepend(tabul).draggable('option','handle',tabul);
|
||||||
this.siblings('.ui-dialog-titlebar').remove();
|
this.siblings('.ui-dialog-titlebar').remove();
|
||||||
tabul.addClass('ui-dialog-titlebar');
|
tabul.addClass('ui-dialog-titlebar');
|
||||||
}
|
}
|
||||||
@@ -246,7 +246,7 @@ jQuery.fn.forceNumeric = function () {
|
|||||||
$(this).keydown(function (e) {
|
$(this).keydown(function (e) {
|
||||||
var key = e.which || e.keyCode;
|
var key = e.which || e.keyCode;
|
||||||
return !e.shiftKey && !e.altKey && !e.ctrlKey &&
|
return !e.shiftKey && !e.altKey && !e.ctrlKey &&
|
||||||
// numbers
|
// numbers
|
||||||
key >= 48 && key <= 57 ||
|
key >= 48 && key <= 57 ||
|
||||||
// Numeric keypad
|
// Numeric keypad
|
||||||
key >= 96 && key <= 105 ||
|
key >= 96 && key <= 105 ||
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Dialog.prototype = {
|
|||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Private Interface Variables
|
* Private Interface Variables
|
||||||
*/
|
*/
|
||||||
@@ -25,7 +25,7 @@ Dialog.prototype = {
|
|||||||
this._cancel_button = $('#dialog_cancel_button');
|
this._cancel_button = $('#dialog_cancel_button');
|
||||||
this._confirm_button = $('#dialog_confirm_button');
|
this._confirm_button = $('#dialog_confirm_button');
|
||||||
this._callback = null;
|
this._callback = null;
|
||||||
|
|
||||||
// Observe the buttons
|
// Observe the buttons
|
||||||
this._cancel_button.bind('click', {dialog: this}, this.onCancelClicked);
|
this._cancel_button.bind('click', {dialog: this}, this.onCancelClicked);
|
||||||
this._confirm_button.bind('click', {dialog: this}, this.onConfirmClicked);
|
this._confirm_button.bind('click', {dialog: this}, this.onConfirmClicked);
|
||||||
@@ -108,6 +108,6 @@ Dialog.prototype = {
|
|||||||
transmission.hideMobileAddressbar();
|
transmission.hideMobileAddressbar();
|
||||||
this._container.show();
|
this._container.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,11 +45,11 @@ function FileRow(torrent, depth, name, indices, even)
|
|||||||
{
|
{
|
||||||
var pct = 100 * (fields.size ? (fields.have / fields.size) : 1.0),
|
var pct = 100 * (fields.size ? (fields.have / fields.size) : 1.0),
|
||||||
c = [ Transmission.fmt.size(fields.have),
|
c = [ Transmission.fmt.size(fields.have),
|
||||||
' of ',
|
' of ',
|
||||||
Transmission.fmt.size(fields.size),
|
Transmission.fmt.size(fields.size),
|
||||||
' (',
|
' (',
|
||||||
Transmission.fmt.percentString(pct),
|
Transmission.fmt.percentString(pct),
|
||||||
'%)' ].join('');
|
'%)' ].join('');
|
||||||
setTextContent(elements.progress, c);
|
setTextContent(elements.progress, c);
|
||||||
},
|
},
|
||||||
refreshImpl = function() {
|
refreshImpl = function() {
|
||||||
|
|||||||
@@ -279,9 +279,9 @@ Transmission.fmt = (function()
|
|||||||
return [ n.toStringWithCommas(), this.ngettext(msgid,msgid_plural,n) ].join(' ');
|
return [ n.toStringWithCommas(), this.ngettext(msgid,msgid_plural,n) ].join(' ');
|
||||||
},
|
},
|
||||||
|
|
||||||
peerStatus: function( flagStr )
|
peerStatus: function( flagStr )
|
||||||
{
|
{
|
||||||
var formattedFlags = [];
|
var formattedFlags = [];
|
||||||
for (var i=0, flag; flag=flagStr[i]; ++i)
|
for (var i=0, flag; flag=flagStr[i]; ++i)
|
||||||
{
|
{
|
||||||
var explanation = null;
|
var explanation = null;
|
||||||
@@ -301,13 +301,13 @@ Transmission.fmt = (function()
|
|||||||
case "T": explanation = "Peer is connected via uTP"; break;
|
case "T": explanation = "Peer is connected via uTP"; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!explanation) {
|
if (!explanation) {
|
||||||
formattedFlags.push(flag);
|
formattedFlags.push(flag);
|
||||||
} else {
|
} else {
|
||||||
formattedFlags.push("<span title=\"" + flag + ': ' + explanation + "\">" + flag + "</span>");
|
formattedFlags.push("<span title=\"" + flag + ': ' + explanation + "\">" + flag + "</span>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return formattedFlags.join('');
|
return formattedFlags.join('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,42 +1,42 @@
|
|||||||
var Notifications = {};
|
var Notifications = {};
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
if (!window.webkitNotifications) {
|
if (!window.webkitNotifications) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var notificationsEnabled = (window.webkitNotifications.checkPermission() === 0),
|
var notificationsEnabled = (window.webkitNotifications.checkPermission() === 0),
|
||||||
toggle = $('#toggle_notifications');
|
toggle = $('#toggle_notifications');
|
||||||
|
|
||||||
toggle.show();
|
toggle.show();
|
||||||
updateMenuTitle();
|
updateMenuTitle();
|
||||||
$(transmission).bind('downloadComplete seedingComplete', function (event, torrent) {
|
$(transmission).bind('downloadComplete seedingComplete', function (event, torrent) {
|
||||||
if (notificationsEnabled) {
|
if (notificationsEnabled) {
|
||||||
var title = (event.type == 'downloadComplete' ? 'Download' : 'Seeding') + ' complete',
|
var title = (event.type == 'downloadComplete' ? 'Download' : 'Seeding') + ' complete',
|
||||||
content = torrent.getName(),
|
content = torrent.getName(),
|
||||||
notification;
|
notification;
|
||||||
|
|
||||||
notification = window.webkitNotifications.createNotification('style/transmission/images/logo.png', title, content);
|
notification = window.webkitNotifications.createNotification('style/transmission/images/logo.png', title, content);
|
||||||
notification.show();
|
notification.show();
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
notification.cancel();
|
notification.cancel();
|
||||||
}, 5000);
|
}, 5000);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
function updateMenuTitle() {
|
function updateMenuTitle() {
|
||||||
toggle.html((notificationsEnabled ? 'Disable' : 'Enable') + ' Notifications');
|
toggle.html((notificationsEnabled ? 'Disable' : 'Enable') + ' Notifications');
|
||||||
}
|
}
|
||||||
|
|
||||||
Notifications.toggle = function () {
|
Notifications.toggle = function () {
|
||||||
if (window.webkitNotifications.checkPermission() !== 0) {
|
if (window.webkitNotifications.checkPermission() !== 0) {
|
||||||
window.webkitNotifications.requestPermission(function () {
|
window.webkitNotifications.requestPermission(function () {
|
||||||
notificationsEnabled = (window.webkitNotifications.checkPermission() === 0);
|
notificationsEnabled = (window.webkitNotifications.checkPermission() === 0);
|
||||||
updateMenuTitle();
|
updateMenuTitle();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
notificationsEnabled = !notificationsEnabled;
|
notificationsEnabled = !notificationsEnabled;
|
||||||
updateMenuTitle();
|
updateMenuTitle();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,312 +7,312 @@
|
|||||||
|
|
||||||
function PrefsDialog(remote) {
|
function PrefsDialog(remote) {
|
||||||
|
|
||||||
var data = {
|
var data = {
|
||||||
dialog: null,
|
dialog: null,
|
||||||
remote: null,
|
remote: null,
|
||||||
elements: { },
|
elements: { },
|
||||||
|
|
||||||
// all the RPC session keys that we have gui controls for
|
// all the RPC session keys that we have gui controls for
|
||||||
keys: [
|
keys: [
|
||||||
'alt-speed-down',
|
'alt-speed-down',
|
||||||
'alt-speed-time-begin',
|
'alt-speed-time-begin',
|
||||||
'alt-speed-time-day',
|
'alt-speed-time-day',
|
||||||
'alt-speed-time-enabled',
|
'alt-speed-time-enabled',
|
||||||
'alt-speed-time-end',
|
'alt-speed-time-end',
|
||||||
'alt-speed-up',
|
'alt-speed-up',
|
||||||
'blocklist-enabled',
|
'blocklist-enabled',
|
||||||
'blocklist-size',
|
'blocklist-size',
|
||||||
'blocklist-url',
|
'blocklist-url',
|
||||||
'dht-enabled',
|
'dht-enabled',
|
||||||
'download-dir',
|
'download-dir',
|
||||||
'encryption',
|
'encryption',
|
||||||
'idle-seeding-limit',
|
'idle-seeding-limit',
|
||||||
'idle-seeding-limit-enabled',
|
'idle-seeding-limit-enabled',
|
||||||
'lpd-enabled',
|
'lpd-enabled',
|
||||||
'peer-limit-global',
|
'peer-limit-global',
|
||||||
'peer-limit-per-torrent',
|
'peer-limit-per-torrent',
|
||||||
'peer-port',
|
'peer-port',
|
||||||
'peer-port-random-on-start',
|
'peer-port-random-on-start',
|
||||||
'pex-enabled',
|
'pex-enabled',
|
||||||
'port-forwarding-enabled',
|
'port-forwarding-enabled',
|
||||||
'rename-partial-files',
|
'rename-partial-files',
|
||||||
'seedRatioLimit',
|
'seedRatioLimit',
|
||||||
'seedRatioLimited',
|
'seedRatioLimited',
|
||||||
'speed-limit-down',
|
'speed-limit-down',
|
||||||
'speed-limit-down-enabled',
|
'speed-limit-down-enabled',
|
||||||
'speed-limit-up',
|
'speed-limit-up',
|
||||||
'speed-limit-up-enabled',
|
'speed-limit-up-enabled',
|
||||||
'start-added-torrents',
|
'start-added-torrents',
|
||||||
'utp-enabled'
|
'utp-enabled'
|
||||||
],
|
],
|
||||||
|
|
||||||
// map of keys that are enabled only if a 'parent' key is enabled
|
// map of keys that are enabled only if a 'parent' key is enabled
|
||||||
groups: {
|
groups: {
|
||||||
'alt-speed-time-enabled': ['alt-speed-time-begin',
|
'alt-speed-time-enabled': ['alt-speed-time-begin',
|
||||||
'alt-speed-time-day',
|
'alt-speed-time-day',
|
||||||
'alt-speed-time-end' ],
|
'alt-speed-time-end' ],
|
||||||
'blocklist-enabled': ['blocklist-url',
|
'blocklist-enabled': ['blocklist-url',
|
||||||
'blocklist-update-button' ],
|
'blocklist-update-button' ],
|
||||||
'idle-seeding-limit-enabled': [ 'idle-seeding-limit' ],
|
'idle-seeding-limit-enabled': [ 'idle-seeding-limit' ],
|
||||||
'seedRatioLimited': [ 'seedRatioLimit' ],
|
'seedRatioLimited': [ 'seedRatioLimit' ],
|
||||||
'speed-limit-down-enabled': [ 'speed-limit-down' ],
|
'speed-limit-down-enabled': [ 'speed-limit-down' ],
|
||||||
'speed-limit-up-enabled': [ 'speed-limit-up' ]
|
'speed-limit-up-enabled': [ 'speed-limit-up' ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
initTimeDropDown = function(e)
|
initTimeDropDown = function(e)
|
||||||
{
|
{
|
||||||
var i, hour, mins, value, content;
|
var i, hour, mins, value, content;
|
||||||
|
|
||||||
for (i=0; i<24*4; ++i) {
|
for (i=0; i<24*4; ++i) {
|
||||||
hour = parseInt(i/4, 10);
|
hour = parseInt(i/4, 10);
|
||||||
mins = ((i%4) * 15);
|
mins = ((i%4) * 15);
|
||||||
value = i * 15;
|
value = i * 15;
|
||||||
content = hour + ':' + (mins || '00');
|
content = hour + ':' + (mins || '00');
|
||||||
e.options[i] = new Option(content, value);
|
e.options[i] = new Option(content, value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onPortChecked = function(response)
|
onPortChecked = function(response)
|
||||||
{
|
{
|
||||||
var is_open = response['arguments']['port-is-open'],
|
var is_open = response['arguments']['port-is-open'],
|
||||||
text = 'Port is <b>' + (is_open ? 'Open' : 'Closed') + '</b>',
|
text = 'Port is <b>' + (is_open ? 'Open' : 'Closed') + '</b>',
|
||||||
e = data.elements.root.find('#port-label');
|
e = data.elements.root.find('#port-label');
|
||||||
setInnerHTML(e[0],text);
|
setInnerHTML(e[0],text);
|
||||||
},
|
},
|
||||||
|
|
||||||
setGroupEnabled = function(parent_key, enabled)
|
setGroupEnabled = function(parent_key, enabled)
|
||||||
{
|
{
|
||||||
var i, key, keys, root;
|
var i, key, keys, root;
|
||||||
|
|
||||||
if (parent_key in data.groups)
|
if (parent_key in data.groups)
|
||||||
{
|
{
|
||||||
root = data.elements.root,
|
root = data.elements.root,
|
||||||
keys = data.groups[parent_key];
|
keys = data.groups[parent_key];
|
||||||
|
|
||||||
for (i=0; key=keys[i]; ++i)
|
for (i=0; key=keys[i]; ++i)
|
||||||
root.find('#'+key).attr('disabled',!enabled);
|
root.find('#'+key).attr('disabled',!enabled);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onBlocklistUpdateClicked = function ()
|
onBlocklistUpdateClicked = function ()
|
||||||
{
|
{
|
||||||
data.remote.updateBlocklist();
|
data.remote.updateBlocklist();
|
||||||
setBlocklistButtonEnabled(false);
|
setBlocklistButtonEnabled(false);
|
||||||
},
|
},
|
||||||
setBlocklistButtonEnabled = function(b)
|
setBlocklistButtonEnabled = function(b)
|
||||||
{
|
{
|
||||||
var e = data.elements.blocklist_button;
|
var e = data.elements.blocklist_button;
|
||||||
e.attr('disabled',!b);
|
e.attr('disabled',!b);
|
||||||
e.val(b ? 'Update' : 'Updating...');
|
e.val(b ? 'Update' : 'Updating...');
|
||||||
},
|
},
|
||||||
|
|
||||||
getValue = function(e)
|
getValue = function(e)
|
||||||
{
|
{
|
||||||
var str;
|
var str;
|
||||||
|
|
||||||
switch (e[0].type)
|
switch (e[0].type)
|
||||||
{
|
{
|
||||||
case 'checkbox':
|
case 'checkbox':
|
||||||
case 'radio':
|
case 'radio':
|
||||||
return e.prop('checked');
|
return e.prop('checked');
|
||||||
|
|
||||||
case 'text':
|
case 'text':
|
||||||
case 'url':
|
case 'url':
|
||||||
case 'email':
|
case 'email':
|
||||||
case 'number':
|
case 'number':
|
||||||
case 'search':
|
case 'search':
|
||||||
case 'select-one':
|
case 'select-one':
|
||||||
str = e.val();
|
str = e.val();
|
||||||
if( parseInt(str,10).toString() === str)
|
if( parseInt(str,10).toString() === str)
|
||||||
return parseInt(str,10);
|
return parseInt(str,10);
|
||||||
if( parseFloat(str).toString() === str)
|
if( parseFloat(str).toString() === str)
|
||||||
return parseFloat(str);
|
return parseFloat(str);
|
||||||
return str;
|
return str;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/* this callback is for controls whose changes can be applied
|
/* this callback is for controls whose changes can be applied
|
||||||
immediately, like checkboxs, radioboxes, and selects */
|
immediately, like checkboxs, radioboxes, and selects */
|
||||||
onControlChanged = function(ev)
|
onControlChanged = function(ev)
|
||||||
{
|
{
|
||||||
var o = {};
|
var o = {};
|
||||||
o[ev.target.id] = getValue($(ev.target));
|
o[ev.target.id] = getValue($(ev.target));
|
||||||
data.remote.savePrefs(o);
|
data.remote.savePrefs(o);
|
||||||
},
|
},
|
||||||
|
|
||||||
/* these two callbacks are for controls whose changes can't be applied
|
|
||||||
immediately -- like a text entry field -- because it takes many
|
|
||||||
change events for the user to get to the desired result */
|
|
||||||
onControlFocused = function(ev)
|
|
||||||
{
|
|
||||||
data.oldValue = getValue($(ev.target));
|
|
||||||
},
|
|
||||||
onControlBlurred = function(ev)
|
|
||||||
{
|
|
||||||
var newValue = getValue($(ev.target));
|
|
||||||
if (newValue !== data.oldValue)
|
|
||||||
{
|
|
||||||
var o = {};
|
|
||||||
o[ev.target.id] = newValue;
|
|
||||||
data.remote.savePrefs(o);
|
|
||||||
delete data.oldValue;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
getDefaultMobileOptions = function()
|
/* these two callbacks are for controls whose changes can't be applied
|
||||||
{
|
immediately -- like a text entry field -- because it takes many
|
||||||
return {
|
change events for the user to get to the desired result */
|
||||||
width: $(window).width(),
|
onControlFocused = function(ev)
|
||||||
height: $(window).height(),
|
{
|
||||||
position: [ 'left', 'top' ]
|
data.oldValue = getValue($(ev.target));
|
||||||
};
|
},
|
||||||
},
|
onControlBlurred = function(ev)
|
||||||
|
{
|
||||||
|
var newValue = getValue($(ev.target));
|
||||||
|
if (newValue !== data.oldValue)
|
||||||
|
{
|
||||||
|
var o = {};
|
||||||
|
o[ev.target.id] = newValue;
|
||||||
|
data.remote.savePrefs(o);
|
||||||
|
delete data.oldValue;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
initialize = function (remote)
|
getDefaultMobileOptions = function()
|
||||||
{
|
{
|
||||||
var i, key, e, o;
|
return {
|
||||||
|
width: $(window).width(),
|
||||||
|
height: $(window).height(),
|
||||||
|
position: [ 'left', 'top' ]
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
data.remote = remote;
|
initialize = function (remote)
|
||||||
|
{
|
||||||
|
var i, key, e, o;
|
||||||
|
|
||||||
e = $('#prefs-dialog');
|
data.remote = remote;
|
||||||
data.elements.root = e;
|
|
||||||
|
|
||||||
initTimeDropDown(e.find('#alt-speed-time-begin')[0]);
|
e = $('#prefs-dialog');
|
||||||
initTimeDropDown(e.find('#alt-speed-time-end')[0]);
|
data.elements.root = e;
|
||||||
|
|
||||||
o = isMobileDevice
|
initTimeDropDown(e.find('#alt-speed-time-begin')[0]);
|
||||||
? getDefaultMobileOptions()
|
initTimeDropDown(e.find('#alt-speed-time-end')[0]);
|
||||||
: { width: 350, height: 400 };
|
|
||||||
o.autoOpen = false;
|
|
||||||
o.show = o.hide = 'fade';
|
|
||||||
o.close = onDialogClosed;
|
|
||||||
e.tabbedDialog(o);
|
|
||||||
|
|
||||||
e = e.find('#blocklist-update-button');
|
o = isMobileDevice
|
||||||
data.elements.blocklist_button = e;
|
? getDefaultMobileOptions()
|
||||||
e.click(onBlocklistUpdateClicked);
|
: { width: 350, height: 400 };
|
||||||
|
o.autoOpen = false;
|
||||||
|
o.show = o.hide = 'fade';
|
||||||
|
o.close = onDialogClosed;
|
||||||
|
e.tabbedDialog(o);
|
||||||
|
|
||||||
// listen for user input
|
e = e.find('#blocklist-update-button');
|
||||||
for (i=0; key=data.keys[i]; ++i)
|
data.elements.blocklist_button = e;
|
||||||
{
|
e.click(onBlocklistUpdateClicked);
|
||||||
e = data.elements.root.find('#'+key);
|
|
||||||
switch (e[0].type)
|
|
||||||
{
|
|
||||||
case 'checkbox':
|
|
||||||
case 'radio':
|
|
||||||
case 'select-one':
|
|
||||||
e.change(onControlChanged);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'text':
|
// listen for user input
|
||||||
case 'url':
|
for (i=0; key=data.keys[i]; ++i)
|
||||||
case 'email':
|
{
|
||||||
case 'number':
|
e = data.elements.root.find('#'+key);
|
||||||
case 'search':
|
switch (e[0].type)
|
||||||
e.focus(onControlFocused);
|
{
|
||||||
e.blur(onControlBlurred);
|
case 'checkbox':
|
||||||
|
case 'radio':
|
||||||
|
case 'select-one':
|
||||||
|
e.change(onControlChanged);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
case 'text':
|
||||||
break;
|
case 'url':
|
||||||
}
|
case 'email':
|
||||||
}
|
case 'number':
|
||||||
},
|
case 'search':
|
||||||
|
e.focus(onControlFocused);
|
||||||
|
e.blur(onControlBlurred);
|
||||||
|
|
||||||
getValues = function()
|
default:
|
||||||
{
|
break;
|
||||||
var i, key, val, o={},
|
}
|
||||||
keys = data.keys,
|
}
|
||||||
root = data.elements.root;
|
},
|
||||||
|
|
||||||
for (i=0; key=keys[i]; ++i) {
|
getValues = function()
|
||||||
val = getValue(root.find('#'+key));
|
{
|
||||||
if (val !== null)
|
var i, key, val, o={},
|
||||||
o[key] = val;
|
keys = data.keys,
|
||||||
}
|
root = data.elements.root;
|
||||||
|
|
||||||
return o;
|
for (i=0; key=keys[i]; ++i) {
|
||||||
},
|
val = getValue(root.find('#'+key));
|
||||||
|
if (val !== null)
|
||||||
|
o[key] = val;
|
||||||
|
}
|
||||||
|
|
||||||
onDialogClosed = function()
|
return o;
|
||||||
{
|
},
|
||||||
transmission.hideMobileAddressbar();
|
|
||||||
|
|
||||||
$(data.dialog).trigger('closed', getValues());
|
onDialogClosed = function()
|
||||||
};
|
{
|
||||||
|
transmission.hideMobileAddressbar();
|
||||||
|
|
||||||
/****
|
$(data.dialog).trigger('closed', getValues());
|
||||||
***** PUBLIC FUNCTIONS
|
};
|
||||||
****/
|
|
||||||
|
|
||||||
// update the dialog's controls
|
/****
|
||||||
this.set = function (o)
|
***** PUBLIC FUNCTIONS
|
||||||
{
|
****/
|
||||||
var e, i, key, val, option,
|
|
||||||
keys = data.keys,
|
|
||||||
root = data.elements.root;
|
|
||||||
|
|
||||||
setBlocklistButtonEnabled(true);
|
// update the dialog's controls
|
||||||
|
this.set = function (o)
|
||||||
|
{
|
||||||
|
var e, i, key, val, option,
|
||||||
|
keys = data.keys,
|
||||||
|
root = data.elements.root;
|
||||||
|
|
||||||
for (i=0; key=keys[i]; ++i)
|
setBlocklistButtonEnabled(true);
|
||||||
{
|
|
||||||
val = o[key];
|
|
||||||
e = root.find('#'+key);
|
|
||||||
|
|
||||||
if (key === 'blocklist-size')
|
for (i=0; key=keys[i]; ++i)
|
||||||
{
|
{
|
||||||
// special case -- regular text area
|
val = o[key];
|
||||||
e.text('' + val.toStringWithCommas());
|
e = root.find('#'+key);
|
||||||
}
|
|
||||||
else switch (e[0].type)
|
|
||||||
{
|
|
||||||
case 'checkbox':
|
|
||||||
case 'radio':
|
|
||||||
e.prop('checked', val);
|
|
||||||
setGroupEnabled(key, val);
|
|
||||||
break;
|
|
||||||
case 'text':
|
|
||||||
case 'url':
|
|
||||||
case 'email':
|
|
||||||
case 'number':
|
|
||||||
case 'search':
|
|
||||||
// don't change the text if the user's editing it.
|
|
||||||
// it's very annoying when that happens!
|
|
||||||
if (e[0] !== document.activeElement)
|
|
||||||
e.val(val);
|
|
||||||
break;
|
|
||||||
case 'select-one':
|
|
||||||
e.val(val);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.show = function ()
|
if (key === 'blocklist-size')
|
||||||
{
|
{
|
||||||
transmission.hideMobileAddressbar();
|
// special case -- regular text area
|
||||||
|
e.text('' + val.toStringWithCommas());
|
||||||
|
}
|
||||||
|
else switch (e[0].type)
|
||||||
|
{
|
||||||
|
case 'checkbox':
|
||||||
|
case 'radio':
|
||||||
|
e.prop('checked', val);
|
||||||
|
setGroupEnabled(key, val);
|
||||||
|
break;
|
||||||
|
case 'text':
|
||||||
|
case 'url':
|
||||||
|
case 'email':
|
||||||
|
case 'number':
|
||||||
|
case 'search':
|
||||||
|
// don't change the text if the user's editing it.
|
||||||
|
// it's very annoying when that happens!
|
||||||
|
if (e[0] !== document.activeElement)
|
||||||
|
e.val(val);
|
||||||
|
break;
|
||||||
|
case 'select-one':
|
||||||
|
e.val(val);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
setBlocklistButtonEnabled(true);
|
this.show = function ()
|
||||||
data.remote.checkPort(onPortChecked,this);
|
{
|
||||||
data.elements.root.dialog('open');
|
transmission.hideMobileAddressbar();
|
||||||
};
|
|
||||||
|
|
||||||
this.close = function ()
|
setBlocklistButtonEnabled(true);
|
||||||
{
|
data.remote.checkPort(onPortChecked,this);
|
||||||
transmission.hideMobileAddressbar();
|
data.elements.root.dialog('open');
|
||||||
data.elements.root.dialog('close');
|
};
|
||||||
},
|
|
||||||
|
|
||||||
this.shouldAddedTorrentsStart = function()
|
this.close = function ()
|
||||||
{
|
{
|
||||||
return data.elements.root.find('#start-added-torrents')[0].checked;
|
transmission.hideMobileAddressbar();
|
||||||
};
|
data.elements.root.dialog('close');
|
||||||
|
},
|
||||||
|
|
||||||
data.dialog = this;
|
this.shouldAddedTorrentsStart = function()
|
||||||
initialize (remote);
|
{
|
||||||
|
return data.elements.root.find('#start-added-torrents')[0].checked;
|
||||||
|
};
|
||||||
|
|
||||||
|
data.dialog = this;
|
||||||
|
initialize (remote);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ TransmissionRemote.prototype =
|
|||||||
}
|
}
|
||||||
|
|
||||||
remote._error = request.responseText
|
remote._error = request.responseText
|
||||||
? request.responseText.trim().replace(/(<([^>]+)>)/ig,"")
|
? request.responseText.trim().replace(/(<([^>]+)>)/ig,"")
|
||||||
: "";
|
: "";
|
||||||
if (!remote._error.length)
|
if (!remote._error.length)
|
||||||
remote._error = 'Server not responding';
|
remote._error = 'Server not responding';
|
||||||
|
|
||||||
@@ -101,17 +101,20 @@ TransmissionRemote.prototype =
|
|||||||
var o = { method: 'session-get' };
|
var o = { method: 'session-get' };
|
||||||
this.sendRequest(o, callback, context, async);
|
this.sendRequest(o, callback, context, async);
|
||||||
},
|
},
|
||||||
|
|
||||||
checkPort: function(callback, context, async) {
|
checkPort: function(callback, context, async) {
|
||||||
var o = { method: 'port-test' };
|
var o = { method: 'port-test' };
|
||||||
this.sendRequest(o, callback, context, async);
|
this.sendRequest(o, callback, context, async);
|
||||||
},
|
},
|
||||||
|
|
||||||
renameTorrent: function(torrentIds, oldpath, newname, callback, context) {
|
renameTorrent: function(torrentIds, oldpath, newname, callback, context) {
|
||||||
var o = { method: 'torrent-rename-path',
|
var o = {
|
||||||
arguments: { 'ids': torrentIds,
|
method: 'torrent-rename-path',
|
||||||
'path': oldpath,
|
arguments: {
|
||||||
'name': newname }
|
'ids': torrentIds,
|
||||||
|
'path': oldpath,
|
||||||
|
'name': newname
|
||||||
|
}
|
||||||
};
|
};
|
||||||
this.sendRequest(o, callback, context);
|
this.sendRequest(o, callback, context);
|
||||||
},
|
},
|
||||||
@@ -124,7 +127,7 @@ TransmissionRemote.prototype =
|
|||||||
updateTorrents: function(torrentIds, fields, callback, context) {
|
updateTorrents: function(torrentIds, fields, callback, context) {
|
||||||
var o = {
|
var o = {
|
||||||
method: 'torrent-get',
|
method: 'torrent-get',
|
||||||
'arguments': {
|
arguments: {
|
||||||
'fields': fields
|
'fields': fields
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -184,7 +187,7 @@ TransmissionRemote.prototype =
|
|||||||
|
|
||||||
moveTorrents: function(torrent_ids, new_location, callback, context) {
|
moveTorrents: function(torrent_ids, new_location, callback, context) {
|
||||||
var remote = this;
|
var remote = this;
|
||||||
this.sendTorrentSetRequests( 'torrent-set-location', torrent_ids,
|
this.sendTorrentSetRequests( 'torrent-set-location', torrent_ids,
|
||||||
{"move": true, "location": new_location}, callback, context);
|
{"move": true, "location": new_location}, callback, context);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -239,10 +239,10 @@ TorrentRendererFull.prototype =
|
|||||||
' (', t.getPercentDoneStr(), '%)' ];
|
' (', t.getPercentDoneStr(), '%)' ];
|
||||||
// append UL stats: ', uploaded 8.59 GiB (Ratio: 12.3)'
|
// append UL stats: ', uploaded 8.59 GiB (Ratio: 12.3)'
|
||||||
c.push(', uploaded ',
|
c.push(', uploaded ',
|
||||||
Transmission.fmt.size(t.getUploadedEver()),
|
Transmission.fmt.size(t.getUploadedEver()),
|
||||||
' (Ratio ',
|
' (Ratio ',
|
||||||
Transmission.fmt.ratioString(t.getUploadRatio()),
|
Transmission.fmt.ratioString(t.getUploadRatio()),
|
||||||
')');
|
')');
|
||||||
} else { // not done yet
|
} else { // not done yet
|
||||||
c = [ Transmission.fmt.size(sizeWhenDone - t.getLeftUntilDone()),
|
c = [ Transmission.fmt.size(sizeWhenDone - t.getLeftUntilDone()),
|
||||||
' of ', Transmission.fmt.size(sizeWhenDone),
|
' of ', Transmission.fmt.size(sizeWhenDone),
|
||||||
@@ -257,7 +257,7 @@ TorrentRendererFull.prototype =
|
|||||||
c.push('remaining time unknown');
|
c.push('remaining time unknown');
|
||||||
else
|
else
|
||||||
c.push(Transmission.fmt.timeInterval(t.getETA()),
|
c.push(Transmission.fmt.timeInterval(t.getETA()),
|
||||||
' remaining');
|
' remaining');
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.join('');
|
return c.join('');
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ Torrent.prototype =
|
|||||||
setField: function(o, name, value)
|
setField: function(o, name, value)
|
||||||
{
|
{
|
||||||
var i, observer;
|
var i, observer;
|
||||||
|
|
||||||
if (o[name] === value)
|
if (o[name] === value)
|
||||||
return false;
|
return false;
|
||||||
if (o == this.fields && this.fieldObservers[name] && this.fieldObservers[name].length) {
|
if (o == this.fields && this.fieldObservers[name] && this.fieldObservers[name].length) {
|
||||||
@@ -420,14 +420,13 @@ Torrent.compareByProgress = function(ta, tb)
|
|||||||
|
|
||||||
return (a - b) || Torrent.compareByRatio(ta, tb);
|
return (a - b) || Torrent.compareByRatio(ta, tb);
|
||||||
};
|
};
|
||||||
|
|
||||||
Torrent.compareBySize = function(ta, tb)
|
Torrent.compareBySize = function(ta, tb)
|
||||||
{
|
{
|
||||||
var a = ta.getTotalSize(),
|
var a = ta.getTotalSize(),
|
||||||
b = tb.getTotalSize();
|
b = tb.getTotalSize();
|
||||||
|
|
||||||
return (a - b) || Torrent.compareByName(ta, tb);
|
return (a - b) || Torrent.compareByName(ta, tb);
|
||||||
}
|
};
|
||||||
|
|
||||||
Torrent.compareTorrents = function(a, b, sortMethod, sortDirection)
|
Torrent.compareTorrents = function(a, b, sortMethod, sortDirection)
|
||||||
{
|
{
|
||||||
@@ -447,9 +446,9 @@ Torrent.compareTorrents = function(a, b, sortMethod, sortDirection)
|
|||||||
case Prefs._SortByProgress:
|
case Prefs._SortByProgress:
|
||||||
i = Torrent.compareByProgress(a,b);
|
i = Torrent.compareByProgress(a,b);
|
||||||
break;
|
break;
|
||||||
case Prefs._SortBySize:
|
case Prefs._SortBySize:
|
||||||
i = Torrent.compareBySize(a,b);
|
i = Torrent.compareBySize(a,b);
|
||||||
break;
|
break;
|
||||||
case Prefs._SortByState:
|
case Prefs._SortByState:
|
||||||
i = Torrent.compareByState(a,b);
|
i = Torrent.compareByState(a,b);
|
||||||
break;
|
break;
|
||||||
@@ -488,9 +487,9 @@ Torrent.sortTorrents = function(torrents, sortMethod, sortDirection)
|
|||||||
case Prefs._SortByProgress:
|
case Prefs._SortByProgress:
|
||||||
torrents.sort(this.compareByProgress);
|
torrents.sort(this.compareByProgress);
|
||||||
break;
|
break;
|
||||||
case Prefs._SortBySize:
|
case Prefs._SortBySize:
|
||||||
torrents.sort(this.compareBySize);
|
torrents.sort(this.compareBySize);
|
||||||
break;
|
break;
|
||||||
case Prefs._SortByState:
|
case Prefs._SortByState:
|
||||||
torrents.sort(this.compareByState);
|
torrents.sort(this.compareByState);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ Transmission.prototype =
|
|||||||
|
|
||||||
if (this.isMenuEnabled)
|
if (this.isMenuEnabled)
|
||||||
this.createSettingsMenu();
|
this.createSettingsMenu();
|
||||||
|
|
||||||
e = {};
|
e = {};
|
||||||
e.torrent_list = $('#torrent_list')[0];
|
e.torrent_list = $('#torrent_list')[0];
|
||||||
e.toolbar_buttons = $('#toolbar ul li');
|
e.toolbar_buttons = $('#toolbar ul li');
|
||||||
@@ -606,7 +606,7 @@ Transmission.prototype =
|
|||||||
clearInterval(this.sessionInterval);
|
clearInterval(this.sessionInterval);
|
||||||
delete this.sessionInterval;
|
delete this.sessionInterval;
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
var callback = $.proxy(this.loadDaemonPrefs,this),
|
var callback = $.proxy(this.loadDaemonPrefs,this),
|
||||||
msec = 8000;
|
msec = 8000;
|
||||||
this.sessionInterval = setInterval(callback, msec);
|
this.sessionInterval = setInterval(callback, msec);
|
||||||
}
|
}
|
||||||
@@ -704,7 +704,7 @@ Transmission.prototype =
|
|||||||
|
|
||||||
case 'tipjar':
|
case 'tipjar':
|
||||||
window.open('http://www.transmissionbt.com/donate.php');
|
window.open('http://www.transmissionbt.com/donate.php');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'unlimited_download_rate':
|
case 'unlimited_download_rate':
|
||||||
o = {};
|
o = {};
|
||||||
@@ -944,7 +944,7 @@ Transmission.prototype =
|
|||||||
|
|
||||||
jQuery.each (fileInput[0].files, function(i,file) {
|
jQuery.each (fileInput[0].files, function(i,file) {
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
reader.onload = function(e) {
|
reader.onload = function(e) {
|
||||||
var contents = e.target.result;
|
var contents = e.target.result;
|
||||||
var key = "base64,"
|
var key = "base64,"
|
||||||
var index = contents.indexOf (key);
|
var index = contents.indexOf (key);
|
||||||
@@ -969,7 +969,7 @@ Transmission.prototype =
|
|||||||
|
|
||||||
var url = $('#torrent_upload_url').val();
|
var url = $('#torrent_upload_url').val();
|
||||||
if (url != '') {
|
if (url != '') {
|
||||||
if (url.match(/^[0-9a-f]{40}$/i))
|
if (url.match(/^[0-9a-f]{40}$/i))
|
||||||
url = 'magnet:?xt=urn:btih:'+url;
|
url = 'magnet:?xt=urn:btih:'+url;
|
||||||
var o = {
|
var o = {
|
||||||
'method': 'torrent-add',
|
'method': 'torrent-add',
|
||||||
@@ -1001,9 +1001,9 @@ Transmission.prototype =
|
|||||||
} else {
|
} else {
|
||||||
var ids = this.getTorrentIds(torrents);
|
var ids = this.getTorrentIds(torrents);
|
||||||
this.remote.moveTorrents(
|
this.remote.moveTorrents(
|
||||||
ids,
|
ids,
|
||||||
$("input#torrent_path").val(),
|
$("input#torrent_path").val(),
|
||||||
this.refreshTorrents,
|
this.refreshTorrents,
|
||||||
this);
|
this);
|
||||||
$('#move_container').hide();
|
$('#move_container').hide();
|
||||||
}
|
}
|
||||||
@@ -1199,8 +1199,8 @@ Transmission.prototype =
|
|||||||
updateGuiFromSession: function(o)
|
updateGuiFromSession: function(o)
|
||||||
{
|
{
|
||||||
var limit, limited, e, b, text,
|
var limit, limited, e, b, text,
|
||||||
fmt = Transmission.fmt,
|
fmt = Transmission.fmt,
|
||||||
menu = $('#footer_super_menu');
|
menu = $('#footer_super_menu');
|
||||||
|
|
||||||
this.serverVersion = o.version;
|
this.serverVersion = o.version;
|
||||||
|
|
||||||
@@ -1227,10 +1227,10 @@ Transmission.prototype =
|
|||||||
limited = o[RPC._DownSpeedLimited];
|
limited = o[RPC._DownSpeedLimited];
|
||||||
|
|
||||||
e = menu.find('#limited_download_rate');
|
e = menu.find('#limited_download_rate');
|
||||||
e.html('Limit (' + fmt.speed(limit) + ')');
|
e.html('Limit (' + fmt.speed(limit) + ')');
|
||||||
|
|
||||||
if (!limited)
|
if (!limited)
|
||||||
e = menu.find('#unlimited_download_rate');
|
e = menu.find('#unlimited_download_rate');
|
||||||
e.selectMenuItem();
|
e.selectMenuItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1241,10 +1241,10 @@ Transmission.prototype =
|
|||||||
limited = o[RPC._UpSpeedLimited];
|
limited = o[RPC._UpSpeedLimited];
|
||||||
|
|
||||||
e = menu.find('#limited_upload_rate');
|
e = menu.find('#limited_upload_rate');
|
||||||
e.html('Limit (' + fmt.speed(limit) + ')');
|
e.html('Limit (' + fmt.speed(limit) + ')');
|
||||||
|
|
||||||
if (!limited)
|
if (!limited)
|
||||||
e = menu.find('#unlimited_upload_rate');
|
e = menu.find('#unlimited_upload_rate');
|
||||||
e.selectMenuItem();
|
e.selectMenuItem();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1535,8 +1535,8 @@ Transmission.prototype =
|
|||||||
e = []
|
e = []
|
||||||
for (i=0; row=rows[i]; ++i)
|
for (i=0; row=rows[i]; ++i)
|
||||||
e.push(row.getElement());
|
e.push(row.getElement());
|
||||||
$(e).filter(":odd").addClass('even');
|
$(e).filter(":odd").addClass('even');
|
||||||
$(e).filter(":even").removeClass('even');
|
$(e).filter(":even").removeClass('even');
|
||||||
|
|
||||||
// sync gui
|
// sync gui
|
||||||
this.updateStatusbar();
|
this.updateStatusbar();
|
||||||
@@ -1680,7 +1680,7 @@ Transmission.prototype =
|
|||||||
delete this.statsInterval;
|
delete this.statsInterval;
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
var callback = $.proxy(this.loadDaemonStats,this),
|
var callback = $.proxy(this.loadDaemonStats,this),
|
||||||
msec = 5000;
|
msec = 5000;
|
||||||
this.statsInterval = setInterval(callback, msec);
|
this.statsInterval = setInterval(callback, msec);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user