Permalink
Browse files

Merge branch 'rewrite' of https://github.com/chvckd/deluge-in-chrome

…into rewrite
  • Loading branch information...
2 parents ca7697f + 8c731b4 commit 056a7073f71efaa70700333d8ec13379be2f7203 @RichGuk committed Feb 7, 2012
Showing with 170 additions and 166 deletions.
  1. +1 −1 background.html
  2. +0 −19 js/jquery-1.3.2.min.js
  3. +0 −16 js/libs/jquery-1.5.1.min.js
  4. +4 −0 js/libs/jquery-1.7.1.min.js
  5. +100 −0 js/options.js
  6. +1 −1 manifest.json
  7. +64 −129 options.html
View
@@ -4,7 +4,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Background</title>
- <script src="js/libs/jquery-1.5.1.min.js" type="text/javascript" charset="utf-8"></script>
+ <script src="js/libs/jquery-1.7.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/deluge.js" type="text/javascript" charset="utf-8"></script>
<script src="js/background.js" type="text/javascript" charset="utf-8"></script>
</head>
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
View
@@ -0,0 +1,100 @@
+$(function() {
+ var $address = $('#address');
+ var $password = $('#password');
+ var $delugeDownloadIcon = $('#enable_download_torrent');
+ var $debugMode = $('#enable_debug_mode');
+
+ function restoreOptions() {
+ $address.val(localStorage.delugeAddress);
+ $password.val(localStorage.delugePassword);
+
+ if (localStorage.delugeDownloadIcon == 'true') {
+ $delugeDownloadIcon.attr('checked', 'checked');
+ } else {
+ $delugeDownloadIcon.removeAttr('checked');
+ }
+
+ if (localStorage.debugMode == 'true') {
+ $debugMode.attr('checked', 'checked');
+ } else {
+ $debugMode.removeAttr('checked');
+ }
+ }
+
+ function saveOptions() {
+ var message = new Array();
+ var addressVal = $address.val();
+ var passwordVal = $password.val();
+ var $downloadLinkChecked = $delugeDownloadIcon.is(':checked');
+ var $debugModeChecked = $debugMode.is(':checked');
+
+ if (addressVal) {
+ if (localStorage.delugeAddress != addressVal) {
+ message.push('Address updated.');
+ }
+ localStorage.delugeAddress = addressVal.replace(/\/$/, '');
+ }
+
+ if (passwordVal) {
+ if (localStorage.delugePassword != passwordVal) {
+ message.push('Password updated.');
+ }
+ localStorage.delugePassword = passwordVal;
+ }
+
+ var downloadIcon = localStorage.delugeDownloadIcon;
+ if ($downloadLinkChecked
+ && String($downloadLinkChecked) != downloadIcon) {
+ message.push('Download torrent icon enabled!');
+ } else if (String($downloadLinkChecked) != downloadIcon) {
+ message.push('Download torrent icon disabled!');
+ }
+ localStorage.delugeDownloadIcon = $downloadLinkChecked;
+
+ var debugMode = localStorage.debugMode;
+ if ($debugModeChecked
+ && String($debugModeChecked) != debugMode) {
+ message.push('Debug mode enabled!');
+ } else if (String($debugModeChecked) != debugMode) {
+ message.push('Debug mode disabled!');
+ }
+ localStorage.debugMode = $debugModeChecked;
+
+ var background = chrome.extension.getBackgroundPage();
+ background.Background.check_status();
+
+ if ($debugModeChecked) {
+ console.log('deluge: options saved!');
+ }
+
+ if(message.length > 0) {
+ var messageText = '';
+ $.each(message, function(index, obj) {
+ messageText += obj + '<br>';
+ });
+ $('#status-message').html(messageText).fadeIn();
+ setTimeout('$("#status-message").fadeOut();', 5000);
+ }
+ }
+
+
+ (function() {
+ $('.buttons .save').live('click', function() {
+ saveOptions();
+ window.close();
+ return false;
+ });
+
+ $('.buttons .apply').live('click', function() {
+ saveOptions();
+ return false;
+ });
+
+ $('.buttons .cancel').live('click', function() {
+ window.close();
+ return false;
+ });
+
+ restoreOptions();
+ })();
+});
View
@@ -18,7 +18,7 @@
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
- "js": ["js/jquery-1.3.2.min.js", "js/add_torrent.js"]
+ "js": ["js/libs/jquery-1.7.1.min.js", "js/add_torrent.js"]
}
],
"permissions": [
View
@@ -3,147 +3,82 @@
<head>
<meta charset="utf-8" />
<title>Deluge in Chrome : Configuration</title>
+
+ <script src="js/libs/jquery-1.7.1.min.js" type="text/javascript" charset="utf-8"></script>
+ <script src="js/options.js" type="text/javascript" charset="utf-8"></script>
+
<link rel="stylesheet" href="css/master.css" type="text/css" />
<link rel="stylesheet" href="css/chrome.css" type="text/css" />
<style type="text/css" media="screen">
+ body { width: 100%; }
.buttons { margin: 10px 0 0 0; }
.buttons .left { float: left; }
.buttons .right { float: right; }
+ #content { width: 790px; margin-left: auto; margin-right: auto;
+ border: 1px solid #CCC; padding: 5px; }
+ #options form { width: 500px; margin-left: auto; margin-right: auto;}
</style>
</head>
<body>
- <div id="header">
- <div id="logo">
- <a href="#" title="Go to Deluge WebUI!">
- <span class="title">Deluge</span>
- <span class="subtitle">Deluge torrent information in Chrome</span>
- </a>
- </div>
- <div class="clr"></div>
- </div>
-
- <div id="options">
- <div class="chrome-header">
- <h2>Configuration</h2>
- </div>
- <div class="chrome-sub-header">
- <p>This extension requires an accessible version of Deluge web interface to be running. Please refer to the <a href="http://deluge-torrent.org/" target="_blank">Deluge documentation</a> on how to get this working.</p>
- <p>In order to connect to the web interface with need to know some details about the web interface. The address used to access the interface (http://address:port) and finally the password used to login.</p>
+ <div id="content">
+ <div id="header">
+ <div id="logo">
+ <a href="#" title="Go to Deluge WebUI!">
+ <span class="title">Deluge</span>
+ <span class="subtitle">Deluge torrent information in Chrome</span>
+ </a>
+ </div>
+ <div class="clr"></div>
</div>
-
- <div id="status-message"></div>
-
- <form class="nice-form" style="width: 500px">
- <fieldset>
- <legend>Options</legend>
- <p>
- <label>Address:</label>
- <input type="text" name="address" id="address" style="width: 300px" placeholder="http://" />
- </p>
-
- <p>
- <label>Password:</label>
- <input type="password" name="password" id="password" />
- </p>
-
- <p>
- <input type="checkbox" name="enable_download_torrent" id="enable_download_torrent" value="1" />
- <label class="normal" for="enable_download_torrent"> Enable download torrent icon? <span>(experimental)</span></label>
- </p>
- </fieldset>
-
- <div class="buttons">
- <div class="left">
- <button type="submit" class="cancel">Cancel</button>
- </div>
- <div class="right">
- <button type="submit" class="save">Save</button>
- <button type="submit" class="apply">Apply</button>
- </div>
- <div class="clr"></div>
+
+ <div id="options">
+ <div class="chrome-header">
+ <h2>Configuration</h2>
+ </div>
+ <div class="chrome-sub-header">
+ <p>This extension requires an accessible version of Deluge web interface to be running. Please refer to the <a href="http://deluge-torrent.org/" target="_blank">Deluge documentation</a> on how to get this working.</p>
+ <p>In order to connect to the web interface with need to know some details about the web interface. The address used to access the interface (http://address:port) and finally the password used to login.</p>
</div>
- </form>
+
+ <div id="status-message"></div>
+
+ <form class="nice-form" style="width: 500px">
+ <fieldset>
+ <legend>Options</legend>
+ <p>
+ <label>Address:</label>
+ <input type="text" name="address" id="address" style="width: 300px" placeholder="http://" />
+ </p>
+
+ <p>
+ <label>Password:</label>
+ <input type="password" name="password" id="password" />
+ </p>
+
+ <p>
+ <input type="checkbox" name="enable_download_torrent" id="enable_download_torrent" value="1" />
+ <label class="normal" for="enable_download_torrent"> Enable download torrent icon? <span>(experimental)</span></label>
+ </p>
+
+ <p>
+ <input type="checkbox" name="enable_debug_mode" id="enable_debug_mode" value="0" />
+ <label class="normal" for="enable_debug_mode"> Enable debug mode? </label>
+ </p>
+ </fieldset>
+
+ <div class="buttons">
+ <div class="left">
+ <button type="submit" class="cancel">Cancel</button>
+ </div>
+ <div class="right">
+ <button type="submit" class="save">Save</button>
+ <button type="submit" class="apply">Apply</button>
+ </div>
+ <div class="clr"></div>
+ </div>
+ </form>
+ </div>
</div>
-
- <script src="js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
- <script type="text/javascript" charset="utf-8">
- function restore_options() {
- var address = '';
-
- address = localStorage.deluge_address;
- $('#address').val(address);
- $('#password').val(localStorage.deluge_password);
- if(localStorage.deluge_download_icon == 'true') {
- $('#enable_download_torrent').attr('checked', 'checked');
- } else {
- $('#enable_download_torrent').removeAttr('checked');
- }
- }
-
- function save_options() {
- var message = new Array();
- var address = $('#address').val();
- var password = $('#password').val();
- var download_link = $('#enable_download_torrent').is(':checked');
-
- if(address) {
- if(localStorage.deluge_address != address) {
- message.push('Address updated.');
- }
- localStorage.deluge_address = address.replace(/\/$/, '');
- }
- if(password) {
- if(localStorage.deluge_password != password) {
- message.push('Password updated.');
- }
- localStorage.deluge_password = password;
- }
- if(download_link
- && String(download_link) != localStorage.deluge_download_icon) {
- message.push('Download torrent icon enabled!');
- } else if(String(download_link) != localStorage.deluge_download_icon) {
- message.push('Download torrent icon disabled!');
- }
- localStorage.deluge_download_icon = download_link;
-
- var background = chrome.extension.getBackgroundPage();
- background.deluge_status_check({
- success: background.enable_icon,
- error: background.disable_icon
- });
-
- console.log('deluge: options saved!');
- if(message.length > 0) {
- var message_text = '';
- $.each(message, function(index, obj) {
- message_text += obj + '<br>';
- });
- $('#status-message').html(message_text).fadeIn();
- setTimeout('$("#status-message").fadeOut();', 5000);
- }
- }
-
-
- $(document).ready(function() {
- $('.buttons .save').live('click', function() {
- save_options();
- window.close();
- return false;
- });
-
- $('.buttons .apply').live('click', function() {
- save_options();
- return false;
- });
-
- $('.buttons .cancel').live('click', function() {
- window.close();
- return false;
- });
-
- restore_options();
- });
- </script>
</body>
</html>

0 comments on commit 056a707

Please sign in to comment.