Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Commit

Permalink
Cleaning up some trailing whitespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich Grundy committed Feb 13, 2012
1 parent f5f8821 commit 2ddd5e6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 39 deletions.
22 changes: 11 additions & 11 deletions js/background.js
Expand Up @@ -97,7 +97,7 @@ var Background = (function($) {
if (Global.getDebugMode()) {
console.log('Deluge: Checking status');
}

var that = this;

function checkStatus() {
Expand Down Expand Up @@ -207,7 +207,7 @@ var Background = (function($) {
// Send deactivation to anything listening.
chrome.extension.sendRequest({ msg: 'extension_deactivated' });
};

/**
* Add a torrent to Deluge using a URL. This method is meant to be called
* as part of Chrome extensions messaging system.
Expand Down Expand Up @@ -249,7 +249,7 @@ var Background = (function($) {
sendResponse({msg: 'error', result: null, error: 'unable to add torrent to deluge'});
});
}

// Need to get config values to add with the torrent first.
Deluge.api('core.get_config_values', [['add_paused', 'compact_allocation', 'download_location',
'max_connections_per_torrent', 'max_download_speed_per_torrent',
Expand Down Expand Up @@ -298,7 +298,7 @@ var Background = (function($) {
sendResponse({msg: 'error', result: null, error: 'failed to download torrent from URL.'});
});
}

function handleContextMenuClick(OnClickData) {
var torrentUrl = OnClickData.linkUrl;
if(torrentUrl.search(/\/(download|get)\//) > 0 || torrentUrl.search(/\.torrent$/) > 0) {
Expand All @@ -318,12 +318,12 @@ var Background = (function($) {
console.log('Deluge: Link not a torrent!');
}
}

return false;
}

var contextMenu = null;

pub.addContextMenu = function() {
if (contextMenu === null) {
contextMenu = chrome.contextMenus.create({
Expand All @@ -333,14 +333,14 @@ var Background = (function($) {
});
}
}

pub.removeContextMenu = function() {
if (contextMenu !== null) {
chrome.contextMenus.remove(contextMenu);
contextMenu = null;
}
}

//for some reason the context menu is always added regardless of the if
if (localStorage.contextMenu) {
pub.addContextMenu();
Expand Down Expand Up @@ -371,7 +371,7 @@ chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
} else if(request.msg == 'enable_download_icon') {
sendResponse(localStorage.delugeDownloadIcon);
}

// We need to send a reponse, even if it's empty.
sendResponse({msg: 'error', result: null, error: 'nothing called!'});
});
});
54 changes: 26 additions & 28 deletions js/status.js
Expand Up @@ -90,7 +90,7 @@ jQuery(document).ready(function($) {

// Set the initial height for the overlay.
var $overlay = $('#overlay').css({ height: $(document).height() });

// I can't get the popup to play nicely when there is a scroll bar and then
// when there isn't - so going to adjust the width if a scroll bar is
// visible (this needs to be done on timeout to give popup time to show).
Expand Down Expand Up @@ -156,7 +156,7 @@ jQuery(document).ready(function($) {
checkStatus();
});
}

/**
* Pause the table refresh.
*/
Expand All @@ -165,7 +165,7 @@ jQuery(document).ready(function($) {
clearInterval(refreshTimer);
}
}

/**
* Resume the table refresh.
*/
Expand Down Expand Up @@ -235,22 +235,21 @@ jQuery(document).ready(function($) {
}
$(document).trigger('table_updated');
}

(function() {

function getRowData(element) {
var $parent = $(element).parents('tr');
var torrentId = $parent.data('id');
var torrent = Torrents.getById(torrentId);

return {'torrentId': torrentId, 'torrent': torrent};
}

$('.main_actions .toggle_managed').live('click', function() {
var rowData = getRowData(this);

var autoManaged = !rowData.torrent.autoManaged;

Deluge.api('core.set_torrent_auto_managed', [rowData.torrentId, autoManaged])
.success(function() {
if (Global.getDebugMode()) {
Expand All @@ -264,12 +263,11 @@ jQuery(document).ready(function($) {
}
});
});

$('.main_actions .state').live('click', function() {
var rowData = getRowData(this);

var method = rowData.torrent.state == 'Paused' ? 'core.resume_torrent' : 'core.pause_torrent';

Deluge.api(method, [[rowData.torrentId]])
.success(function() {
if (Global.getDebugMode()) {
Expand All @@ -283,10 +281,10 @@ jQuery(document).ready(function($) {
}
});
});

$('.main_actions .move_up').live('click', function() {
var rowData = getRowData(this);

Deluge.api('core.queue_up', [[rowData.torrentId]])
.success(function() {
if (Global.getDebugMode()) {
Expand All @@ -300,10 +298,10 @@ jQuery(document).ready(function($) {
}
});
});

$('.main_actions .move_down').live('click', function() {
var rowData = getRowData(this);

Deluge.api('core.queue_down', [[rowData.torrentId]])
.success(function() {
if (Global.getDebugMode()) {
Expand All @@ -317,10 +315,10 @@ jQuery(document).ready(function($) {
}
});
});

$('.main_actions .delete').live('click', function() {
pauseTableRefresh();

var parentTd = $(this).parents('td');
var newElm = $('<div>');
newElm.addClass('delete-options');
Expand All @@ -332,10 +330,10 @@ jQuery(document).ready(function($) {
tmp.append('<a href="#delete-torrent" title="Just delete torrent file" rel="torrent"><img src="images/file.png" alt="T" /></a>');
});
});

$('.delete-options a').live('click', function() {
var rowData = getRowData(this);

var action = $(this).attr('rel') || 'cancel';
// If canceling remove overlay and resume refresh now and return.
if(action == 'cancel') {
Expand All @@ -346,15 +344,15 @@ jQuery(document).ready(function($) {
});
return false;
}

function removeButtons() {
// Remove buttons, resume refresh.
$('.delete-options').fadeOut('fast', function() {
resumeTableRefresh();
updateTable();
});
}

var delData = (action == 'data') ? true : false;
Deluge.api('core.remove_torrent', [rowData.torrentId, delData])
.success(function() {
Expand All @@ -372,21 +370,21 @@ jQuery(document).ready(function($) {
return false;
});
})();

(function() {
var $inputBox = $('#manual_add_input');
var $addButton = $('#manual_add_button');

$inputBox.keydown(function(event){
if (event.keyCode == '13') {
event.preventDefault();
$addButton.click();
}
});

$addButton.live('click', function() {
var url = $inputBox.val();

// Now check that the link contains either .torrent or download, get, etc...
if(url.search(/\/(download|get)\//) > 0 || url.search(/\.torrent$/) > 0) {
chrome.extension.sendRequest({ msg: 'add_torrent_from_url', url: url},
Expand Down Expand Up @@ -437,8 +435,8 @@ jQuery(document).ready(function($) {

// This function is called when the background page sends an activated
// message, this happens roughly every minute so we only want to call
// updateTable, or hide any current overlays once, we can let the local
// timers in within this script handle table updating.
// updateTable, or hide any current overlays once. We can let the local
// timers within this script handle table updating.
function activated() {
if (!extensionActivated) {
if (Global.getDebugMode()) {
Expand Down

0 comments on commit 2ddd5e6

Please sign in to comment.