(trunk web) Add turtle mode. Patch from Grug. Fixes #2157

This commit is contained in:
Kevin Glowacz
2009-11-10 05:42:57 +00:00
parent 8d16fdc31b
commit fe8743be5c
6 changed files with 246 additions and 58 deletions

View File

@@ -206,52 +206,101 @@
<h2 class="dialog_heading">Preferences</h2> <h2 class="dialog_heading">Preferences</h2>
<div id="pref_error"></div> <div id="pref_error"></div>
<form action="" id="prefs_form"> <form action="" id="prefs_form">
<div class="preference download_location"> <div id="prefs_tabs">
<label class="category">Add transfers:</label> <ul>
<div class="formdiv"> <li onclick="changeTab(this, 'prefs_tab_general');" class="prefs_tab_enabled">General</li>
<label for="download_location" class="item">Download to:</label> <li onclick="changeTab(this, 'prefs_tab_speed');" class="prefs_tab_disabled">Speed</li>
<input type="text" name="download_location" id="download_location"/> </ul>
<div id="prefs_tab_general" class="prefs_tab">
<div class="preference download_location">
<label class="category">Add transfers:</label>
<div class="formdiv">
<label for="download_location" class="item">Download to:</label>
<input type="text" name="download_location" id="download_location"/>
</div>
<div class="formdiv checkbox auto_start">
<input type="checkbox" name="auto_start" id="auto_start"/>
<label for="auto_start" class="item">Start transfers when added</label>
</div>
</div>
<div class="preference port">
<label class="category">Network:</label>
<div class="formdiv">
<label for="port" class="item">Incoming TCP Port:</label>
<input type="text" id="port" name="port"/>
</div>
</div>
<div class="preference encryption">
<label class="category">Encryption:</label>
<div class="formdiv checkbox">
<input type="checkbox" name="encryption" id="encryption"/>
<label for="encryption" class="item">Ignore unencrypted peers</label>
</div>
</div>
<div class="preference web_gui">
<label class="category">Web Client:</label>
<div class="formdiv">
<label for="refresh_rate" class="item">Refresh Rate:</label>
<input type="text" name="refresh_rate" id="refresh_rate"/>
<label class="suffix">seconds</label>
</div>
</div>
<div style="clear: both; visibility: hidden;"/></div>
</div> </div>
<div class="formdiv checkbox auto_start"> <div id="prefs_tab_speed" class="prefs_tab" style="display: none;">
<input type="checkbox" name="auto_start" id="auto_start"/> <div class="preference limit_total">
<label for="auto_start" class="item">Start transfers when added</label> <label class="category">Speed Limits:</label>
</div> <div class="formdiv checkbox">
</div> <input type="checkbox" name="limit_download" id="limit_download"/>
<div class="preference port"> <label for="limit_download" class="item">Download Rate:</label>
<label class="category">Network:</label> <input type="text" name="download_rate" id="download_rate"/>
<div class="formdiv"> <label class="suffix">KB/s</label>
<label for="port" class="item">Incoming TCP Port:</label> </div>
<input type="text" id="port" name="port"/> <div class="formdiv checkbox">
</div> <input type="checkbox" name="limit_upload" id="limit_upload"/>
</div> <label for="limit_upload" class="item">Upload Rate:</label>
<div class="preference encryption"> <input type="text" name="upload_rate" id="upload_rate"/>
<label class="category">Encryption:</label> <label class="suffix">KB/s</label>
<div class="formdiv checkbox"> </div>
<input type="checkbox" name="encryption" id="encryption"/> </div>
<label for="encryption" class="item">Ignore unencrypted peers</label> <div class="preference limit_turtle">
</div> <label class="category">Temporary Speed Limits: (Turtle)</label>
</div> <label>Override normal speed limits manually or at scheduled times</label>
<div class="preference limit_total"> <div class="formdiv">
<label class="category">Limit total bandwidth:</label> <label for="turtle_download_rate" class="item">Download Rate:</label>
<div class="formdiv checkbox"> <input type="text" name="turtle_download_rate" id="turtle_download_rate"/>
<input type="checkbox" name="limit_download" id="limit_download"/> <label class="suffix">KB/s</label>
<label for="limit_download" class="item">Download Rate:</label> </div>
<input type="text" name="download_rate" id="download_rate"/> <div class="formdiv">
<label class="suffix">KB/s</label> <label for="turtle_upload_rate" class="item">Upload Rate:</label>
</div> <input type="text" name="turtle_upload_rate" id="turtle_upload_rate"/>
<div class="formdiv checkbox"> <label class="suffix">KB/s</label>
<input type="checkbox" name="limit_upload" id="limit_upload"/> </div>
<label for="limit_upload" class="item">Upload Rate:</label> <div class="formdiv checkbox">
<input type="text" name="upload_rate" id="upload_rate"/> <input type="checkbox" name="turtle_schedule" id="turtle_schedule"/>
<label class="suffix">KB/s</label> <label for="turtle_schedule" class="item">Scheduled times:</label>
</div> <select name="turtle_start_time" id="turtle_start_time" size="1">
</div> </select>
<div class="preference web_gui"> <select name="turtle_end_time" id="turtle_end_time" size="1">
<label class="category">Web Client:</label> </select>
<div class="formdiv"> </div>
<label for="refresh_rate" class="item">Refresh Rate:</label> <div class="formdiv">
<input type="text" name="refresh_rate" id="refresh_rate"/> <label for="turtle_days" class="item">On days:</label>
<label class="suffix">seconds</label> <select name="turtle_days" id="turtle_days" size="1">
<option value="127">Everyday</option>
<option value="62">Weekdays</option>
<option value="65">Weekends</option>
<option value="1">Sunday</option>
<option value="2">Monday</option>
<option value="4">Tuesday</option>
<option value="8">Wednesday</option>
<option value="16">Thursday</option>
<option value="32">Friday</option>
<option value="64">Saturday</option>
</select>
</div>
</div>
<div style="clear: both; visibility: hidden;"/></div>
</div> </div>
</div> </div>
<a href="#save" id="prefs_save_button">Save</a> <a href="#save" id="prefs_save_button">Save</a>
@@ -341,6 +390,8 @@
</ul> </ul>
</li> </li>
</ul> </ul>
<div id="turtle_button">&nbsp;</div>
<div style="clear: both; visibility: hidden;"></div>
</div> </div>
<div class="contextMenu" id="torrent_context_menu"> <div class="contextMenu" id="torrent_context_menu">

View File

@@ -252,6 +252,29 @@ String.prototype.compareTo = function( that ) {
return 0; return 0;
} }
/**
* @brief Switch between different dialog tabs
*/
function changeTab(tab, id) {
for ( var x = 0, node; tab.parentNode.childNodes[x]; x++ ) {
node = tab.parentNode.childNodes[x];
if (node == tab) {
node.className = "prefs_tab_enabled";
} else {
node.className = "prefs_tab_disabled";
}
}
for ( x = 0; tab.parentNode.parentNode.childNodes[x]; x++ ) {
node = tab.parentNode.parentNode.childNodes[x];
if (node.tagName == "DIV") {
if (node.id == id) {
node.style.display = "block";
} else {
node.style.display = "none";
}
}
}
}
/*** /***
**** Preferences **** Preferences
@@ -287,6 +310,7 @@ Prefs._SortByProgress = 'percent_completed';
Prefs._SortByState = 'state'; Prefs._SortByState = 'state';
Prefs._SortByTracker = 'tracker'; Prefs._SortByTracker = 'tracker';
Prefs._TurtleState = 'turtle-state';
Prefs._Defaults = Prefs._Defaults =
{ {
@@ -296,7 +320,8 @@ Prefs._Defaults =
'show_filter': true, 'show_filter': true,
'show_inspector': false, 'show_inspector': false,
'sort_direction': 'ascending', 'sort_direction': 'ascending',
'sort_method': 'name' 'sort_method': 'name',
'turtle-state' : false
}; };
/* /*

View File

@@ -25,6 +25,6 @@ if(!$(this).is('.trans_menu')){$(this).addClass('trans_menu');}
$('ul',this).shadowBox();$(this).bind('closemenu',function(){clean();});var liElems=$(this).children('li');for(var j=0;j<liElems.length;j++){if(getOneChild(getOneChild(getOneChild(liElems[j],'DIV'),'UL'),'LI')){$(liElems[j]).click(mainClick);}} $('ul',this).shadowBox();$(this).bind('closemenu',function(){clean();});var liElems=$(this).children('li');for(var j=0;j<liElems.length;j++){if(getOneChild(getOneChild(getOneChild(liElems[j],'DIV'),'UL'),'LI')){$(liElems[j]).click(mainClick);}}
$(liElems).hover(mainHoverIn,mainHoverOut).addClass('main').find('>div').addClass('inner');if(transMenuSettings.arrow_char){var arrow_markup=$("<span class='arrow'>"+transMenuSettings.arrow_char+'</span>');if($.browser.mozilla&&+$.browser.version.replace(/\./g,'').slice(0,3)<191){arrow_markup.css('margin-top','-13px');} $(liElems).hover(mainHoverIn,mainHoverOut).addClass('main').find('>div').addClass('inner');if(transMenuSettings.arrow_char){var arrow_markup=$("<span class='arrow'>"+transMenuSettings.arrow_char+'</span>');if($.browser.mozilla&&+$.browser.version.replace(/\./g,'').slice(0,3)<191){arrow_markup.css('margin-top','-13px');}
$('div.inner div.outerbox',this).before(arrow_markup);} $('div.inner div.outerbox',this).before(arrow_markup);}
$(this).wrap('<div class="main_container"></div>').after('<div style="clear: both; visibility: hidden;"></div>');});};$.fn.transMenu.setDefaults=function(o){$.extend(defaults,o);};$.fn.shadowBox=function(){return this.each(function(){var outer=$('<div class="outerbox"></div>').get(0);if($(this).css('position')=='absolute'){$(outer).css({position:'relative',width:this.offsetWidth,height:this.offsetHeight});}else{$(outer).css('position','absolute');} });};$.fn.transMenu.setDefaults=function(o){$.extend(defaults,o);};$.fn.shadowBox=function(){return this.each(function(){var outer=$('<div class="outerbox"></div>').get(0);if($(this).css('position')=='absolute'){$(outer).css({position:'relative',width:this.offsetWidth,height:this.offsetHeight});}else{$(outer).css('position','absolute');}
$(this).addClass('innerBox').wrap(outer).before('<div class="shadowbox1"></div><div class="shadowbox2"></div><div class="shadowbox3"></div>');});};$.fn.selectMenuItem=function(){if(this.find('span.selected').length==0){this.prepend($("<span class='selected'>"+transMenuSettings.selected_char+"</span>"));} $(this).addClass('innerBox').wrap(outer).before('<div class="shadowbox1"></div><div class="shadowbox2"></div><div class="shadowbox3"></div>');});};$.fn.selectMenuItem=function(){if(this.find('span.selected').length==0){this.prepend($("<span class='selected'>"+transMenuSettings.selected_char+"</span>"));}
return this;};$.fn.deselectMenuItem=function(){return this.find('span.selected').remove();};$.fn.menuItemIsSelected=function(){return(this.find('span.selected').length>0);};$.fn.deselectMenuSiblings=function(){this.parent().find('span.selected').remove();this.selectMenuItem();return this;};})(jQuery); return this;};$.fn.deselectMenuItem=function(){return this.find('span.selected').remove();};$.fn.menuItemIsSelected=function(){return(this.find('span.selected').length>0);};$.fn.deselectMenuSiblings=function(){this.parent().find('span.selected').remove();this.selectMenuItem();return this;};})(jQuery);

View File

@@ -52,6 +52,7 @@ Transmission.prototype =
$('#open_link').bind('click', function(e){ tr.openTorrentClicked(e); }); $('#open_link').bind('click', function(e){ tr.openTorrentClicked(e); });
$('#upload_confirm_button').bind('click', function(e){ tr.confirmUploadClicked(e); return false;}); $('#upload_confirm_button').bind('click', function(e){ tr.confirmUploadClicked(e); return false;});
$('#upload_cancel_button').bind('click', function(e){ tr.cancelUploadClicked(e); return false; }); $('#upload_cancel_button').bind('click', function(e){ tr.cancelUploadClicked(e); return false; });
$('#turtle_button').bind('click', function(e){ tr.toggleTurtleClicked(e); return false; });
if (iPhone) { if (iPhone) {
$('#inspector_close').bind('click', function(e){ tr.hideInspector(); }); $('#inspector_close').bind('click', function(e){ tr.hideInspector(); });
$('#preferences_link').bind('click', function(e){ tr.releaseClutchPreferencesButton(e); }); $('#preferences_link').bind('click', function(e){ tr.releaseClutchPreferencesButton(e); });
@@ -65,6 +66,7 @@ Transmission.prototype =
this.createContextMenu(); this.createContextMenu();
this.createSettingsMenu(); this.createSettingsMenu();
} }
this.initTurtleDropDowns();
this._torrent_list = $('#torrent_list')[0]; this._torrent_list = $('#torrent_list')[0];
this._inspector_file_list = $('#inspector_file_list')[0]; this._inspector_file_list = $('#inspector_file_list')[0];
@@ -309,6 +311,19 @@ Transmission.prototype =
}, },
initTurtleDropDowns: function() {
var i, out, hour, mins;
// Build the list of times
out = "";
for (i = 0; i < 24 * 4; i++) {
hour = parseInt(i / 4);
mins = ((i % 4) * 15);
out += "<option value='" + (i * 15) + "'>" + hour + ":" + (mins == 0 ? "00" : mins) + "</option>";
}
setInnerHTML( $('#turtle_start_time')[0], out );
setInnerHTML( $('#turtle_end_time')[0], out );
},
/*-------------------------------------------- /*--------------------------------------------
* *
* U T I L I T I E S * U T I L I T I E S
@@ -604,15 +619,22 @@ Transmission.prototype =
// pass the new prefs upstream to the RPC server // pass the new prefs upstream to the RPC server
var o = { }; var o = { };
o[RPC._PeerPort] = parseInt( $('#prefs_form #port')[0].value ); o[RPC._PeerPort] = parseInt( $('#prefs_form #port')[0].value );
o[RPC._UpSpeedLimit] = parseInt( $('#prefs_form #upload_rate')[0].value ); o[RPC._UpSpeedLimit] = parseInt( $('#prefs_form #upload_rate')[0].value );
o[RPC._DownSpeedLimit] = parseInt( $('#prefs_form #download_rate')[0].value ); o[RPC._DownSpeedLimit] = parseInt( $('#prefs_form #download_rate')[0].value );
o[RPC._DownloadDir] = $('#prefs_form #download_location')[0].value; o[RPC._DownloadDir] = $('#prefs_form #download_location')[0].value;
o[RPC._UpSpeedLimited] = $('#prefs_form #limit_upload')[0].checked; o[RPC._UpSpeedLimited] = $('#prefs_form #limit_upload')[0].checked;
o[RPC._DownSpeedLimited] = $('#prefs_form #limit_download')[0].checked; o[RPC._DownSpeedLimited] = $('#prefs_form #limit_download')[0].checked;
o[RPC._Encryption] = $('#prefs_form #encryption')[0].checked o[RPC._Encryption] = $('#prefs_form #encryption')[0].checked
? RPC._EncryptionRequired ? RPC._EncryptionRequired
: RPC._EncryptionPreferred; : RPC._EncryptionPreferred;
o[RPC._TurtleDownSpeedLimit] = parseInt( $('#prefs_form #turtle_download_rate')[0].value );
o[RPC._TurtleUpSpeedLimit] = parseInt( $('#prefs_form #turtle_upload_rate')[0].value );
o[RPC._TurtleTimeEnabled] = $('#prefs_form #turtle_schedule')[0].checked;
o[RPC._TurtleTimeBegin] = parseInt( $('#prefs_form #turtle_start_time').val() );
o[RPC._TurtleTimeEnd] = parseInt( $('#prefs_form #turtle_end_time').val() );
o[RPC._TurtleTimeDay] = parseInt( $('#prefs_form #turtle_days').val() );
tr.remote.savePrefs( o ); tr.remote.savePrefs( o );
tr.hidePrefsDialog( ); tr.hidePrefsDialog( );
@@ -730,6 +752,25 @@ Transmission.prototype =
} }
}, },
toggleTurtleClicked: function() {
// Toggle the value
this[Prefs._TurtleState] = !this[Prefs._TurtleState];
// Store the result
var args = { };
args[RPC._TurtleState] = this[Prefs._TurtleState];
this.remote.savePrefs( args );
},
updateTurtleButton: function() {
if ( this[Prefs._TurtleState] ) {
$('#turtle_button').addClass('turtleEnabled');
$('#turtle_button').removeClass('turtleDisabled');
} else {
$('#turtle_button').removeClass('turtleEnabled');
$('#turtle_button').addClass('turtleDisabled');
}
},
/*-------------------------------------------- /*--------------------------------------------
* *
* I N T E R F A C E F U N C T I O N S * I N T E R F A C E F U N C T I O N S
@@ -782,6 +823,12 @@ Transmission.prototype =
$('input#upload_rate')[0].value = up_limit; $('input#upload_rate')[0].value = up_limit;
$('input#refresh_rate')[0].value = prefs[Prefs._RefreshRate]; $('input#refresh_rate')[0].value = prefs[Prefs._RefreshRate];
$('div.encryption input')[0].checked = prefs[RPC._Encryption] == RPC._EncryptionRequired; $('div.encryption input')[0].checked = prefs[RPC._Encryption] == RPC._EncryptionRequired;
$('input#turtle_download_rate')[0].value = prefs[RPC._TurtleDownSpeedLimit];
$('input#turtle_upload_rate')[0].value = prefs[RPC._TurtleUpSpeedLimit];
$('input#turtle_schedule')[0].checked = prefs[RPC._TurtleTimeEnabled];
$('select#turtle_start_time').val( prefs[RPC._TurtleTimeBegin] );
$('select#turtle_end_time').val( prefs[RPC._TurtleTimeEnd] );
$('select#turtle_days').val( prefs[RPC._TurtleTimeDay] );
if (!iPhone) if (!iPhone)
{ {
@@ -795,6 +842,9 @@ Transmission.prototype =
: '#unlimited_upload_rate'; : '#unlimited_upload_rate';
$(key).deselectMenuSiblings().selectMenuItem(); $(key).deselectMenuSiblings().selectMenuItem();
} }
this[Prefs._TurtleState] = prefs[RPC._TurtleState];
this.updateTurtleButton();
}, },
setSearch: function( search ) { setSearch: function( search ) {

View File

@@ -20,6 +20,13 @@ RPC._DownloadDir = 'download-dir';
RPC._PeerPort = 'peer-port'; RPC._PeerPort = 'peer-port';
RPC._UpSpeedLimited = 'speed-limit-up-enabled'; RPC._UpSpeedLimited = 'speed-limit-up-enabled';
RPC._DownSpeedLimited = 'speed-limit-down-enabled'; RPC._DownSpeedLimited = 'speed-limit-down-enabled';
RPC._TurtleState = 'alt-speed-enabled';
RPC._TurtleUpSpeedLimit = 'alt-speed-up';
RPC._TurtleDownSpeedLimit = 'alt-speed-down';
RPC._TurtleTimeEnabled = 'alt-speed-time-enabled';
RPC._TurtleTimeBegin = 'alt-speed-time-begin';
RPC._TurtleTimeEnd = 'alt-speed-time-end';
RPC._TurtleTimeDay = 'alt-speed-time-day';
function TransmissionRemote( controller ) function TransmissionRemote( controller )
{ {

View File

@@ -739,6 +739,22 @@ div.torrent_footer div#disk_space_container {
padding: 0px; padding: 0px;
} }
div.torrent_footer div#turtle_button {
height: 22px;
width: 32px !important;
margin: 0 0 0 38px;
padding: 0;
-moz-user-select: none;
-webkit-user-select: none;
}
.turtleEnabled {
background: transparent url('../images/graphics/chrome.png') -32px -119px no-repeat;
}
.turtleDisabled {
background: transparent url('../images/graphics/chrome.png') left -97px no-repeat;
}
/*-------------------------------------- /*--------------------------------------
* *
* D I A L O G S * D I A L O G S
@@ -865,12 +881,12 @@ iframe#torrent_upload_frame {
div#prefs_container label { div#prefs_container label {
display: block; display: block;
margin: 0 0 0 2px;
} }
div#prefs_container label.category { div#prefs_container label.category {
clear: both; clear: both;
font-size: 1.2em; font-size: 1.2em;
margin: 0 0 0 2px;
} }
div#prefs_container label.item { div#prefs_container label.item {
@@ -889,7 +905,11 @@ div#prefs_container div.formdiv.checkbox label.item {
} }
div#prefs_container div.limit_total label.item { div#prefs_container div.limit_total label.item {
width: 91px; width: 102px;
}
div#prefs_container div.limit_turtle label.item {
width: 120px;
} }
div#prefs_container div.preference input[type=checkbox] { div#prefs_container div.preference input[type=checkbox] {
@@ -935,6 +955,41 @@ div#prefs_container h2.dialog_heading {
display: none; display: none;
} }
div#prefs_container div#prefs_tabs {
clear: both;
}
div#prefs_container div#prefs_tabs ul {
margin: 0;
padding: 0;
}
div#prefs_container div#prefs_tabs ul li {
display: block;
float: left;
font-size: 1.2em;
color: #323232;
text-align: center;
padding: 2px 20px;
border-left: 1px solid #787878;
border-right: 1px solid #787878;
border-top: 1px solid #787878;
}
.prefs_tab_disabled {
background: #C0C8D6 url('../images/graphics/filter_bar.png') bottom repeat-x;
}
.prefs_tab_enabled {
background: none;
}
div.dialog_container div#prefs_tabs ul li.prefs_tab_disabled:hover,
div.dialog_container div#prefs_tabs ul li.prefs_tab_disabled:active {
background: none;
}
div#prefs_container div#prefs_tabs div.prefs_tab {
border: 1px solid #787878;
clear: both;
padding: 2px 0;
}
div#prefs_container div#pref_error { div#prefs_container div#pref_error {
display: none; display: none;
width: 395px; width: 395px;