mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 04:18:39 +00:00
(trunk web) Add turtle mode. Patch from Grug. Fixes #2157
This commit is contained in:
@@ -206,6 +206,12 @@
|
||||
<h2 class="dialog_heading">Preferences</h2>
|
||||
<div id="pref_error"></div>
|
||||
<form action="" id="prefs_form">
|
||||
<div id="prefs_tabs">
|
||||
<ul>
|
||||
<li onclick="changeTab(this, 'prefs_tab_general');" class="prefs_tab_enabled">General</li>
|
||||
<li onclick="changeTab(this, 'prefs_tab_speed');" class="prefs_tab_disabled">Speed</li>
|
||||
</ul>
|
||||
<div id="prefs_tab_general" class="prefs_tab">
|
||||
<div class="preference download_location">
|
||||
<label class="category">Add transfers:</label>
|
||||
<div class="formdiv">
|
||||
@@ -231,8 +237,19 @@
|
||||
<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 id="prefs_tab_speed" class="prefs_tab" style="display: none;">
|
||||
<div class="preference limit_total">
|
||||
<label class="category">Limit total bandwidth:</label>
|
||||
<label class="category">Speed Limits:</label>
|
||||
<div class="formdiv checkbox">
|
||||
<input type="checkbox" name="limit_download" id="limit_download"/>
|
||||
<label for="limit_download" class="item">Download Rate:</label>
|
||||
@@ -246,12 +263,44 @@
|
||||
<label class="suffix">KB/s</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="preference web_gui">
|
||||
<label class="category">Web Client:</label>
|
||||
<div class="preference limit_turtle">
|
||||
<label class="category">Temporary Speed Limits: (Turtle)</label>
|
||||
<label>Override normal speed limits manually or at scheduled times</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>
|
||||
<label for="turtle_download_rate" class="item">Download Rate:</label>
|
||||
<input type="text" name="turtle_download_rate" id="turtle_download_rate"/>
|
||||
<label class="suffix">KB/s</label>
|
||||
</div>
|
||||
<div class="formdiv">
|
||||
<label for="turtle_upload_rate" class="item">Upload Rate:</label>
|
||||
<input type="text" name="turtle_upload_rate" id="turtle_upload_rate"/>
|
||||
<label class="suffix">KB/s</label>
|
||||
</div>
|
||||
<div class="formdiv checkbox">
|
||||
<input type="checkbox" name="turtle_schedule" id="turtle_schedule"/>
|
||||
<label for="turtle_schedule" class="item">Scheduled times:</label>
|
||||
<select name="turtle_start_time" id="turtle_start_time" size="1">
|
||||
</select>
|
||||
<select name="turtle_end_time" id="turtle_end_time" size="1">
|
||||
</select>
|
||||
</div>
|
||||
<div class="formdiv">
|
||||
<label for="turtle_days" class="item">On days:</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>
|
||||
<a href="#save" id="prefs_save_button">Save</a>
|
||||
@@ -341,6 +390,8 @@
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<div id="turtle_button"> </div>
|
||||
<div style="clear: both; visibility: hidden;"></div>
|
||||
</div>
|
||||
|
||||
<div class="contextMenu" id="torrent_context_menu">
|
||||
|
||||
@@ -252,6 +252,29 @@ String.prototype.compareTo = function( that ) {
|
||||
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
|
||||
@@ -287,6 +310,7 @@ Prefs._SortByProgress = 'percent_completed';
|
||||
Prefs._SortByState = 'state';
|
||||
Prefs._SortByTracker = 'tracker';
|
||||
|
||||
Prefs._TurtleState = 'turtle-state';
|
||||
|
||||
Prefs._Defaults =
|
||||
{
|
||||
@@ -296,7 +320,8 @@ Prefs._Defaults =
|
||||
'show_filter': true,
|
||||
'show_inspector': false,
|
||||
'sort_direction': 'ascending',
|
||||
'sort_method': 'name'
|
||||
'sort_method': 'name',
|
||||
'turtle-state' : false
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -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);}}
|
||||
$(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);}
|
||||
$(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>"));}
|
||||
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);
|
||||
|
||||
@@ -52,6 +52,7 @@ Transmission.prototype =
|
||||
$('#open_link').bind('click', function(e){ tr.openTorrentClicked(e); });
|
||||
$('#upload_confirm_button').bind('click', function(e){ tr.confirmUploadClicked(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) {
|
||||
$('#inspector_close').bind('click', function(e){ tr.hideInspector(); });
|
||||
$('#preferences_link').bind('click', function(e){ tr.releaseClutchPreferencesButton(e); });
|
||||
@@ -65,6 +66,7 @@ Transmission.prototype =
|
||||
this.createContextMenu();
|
||||
this.createSettingsMenu();
|
||||
}
|
||||
this.initTurtleDropDowns();
|
||||
|
||||
this._torrent_list = $('#torrent_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
|
||||
@@ -613,6 +628,13 @@ Transmission.prototype =
|
||||
o[RPC._Encryption] = $('#prefs_form #encryption')[0].checked
|
||||
? RPC._EncryptionRequired
|
||||
: 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.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
|
||||
@@ -782,6 +823,12 @@ Transmission.prototype =
|
||||
$('input#upload_rate')[0].value = up_limit;
|
||||
$('input#refresh_rate')[0].value = prefs[Prefs._RefreshRate];
|
||||
$('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)
|
||||
{
|
||||
@@ -795,6 +842,9 @@ Transmission.prototype =
|
||||
: '#unlimited_upload_rate';
|
||||
$(key).deselectMenuSiblings().selectMenuItem();
|
||||
}
|
||||
|
||||
this[Prefs._TurtleState] = prefs[RPC._TurtleState];
|
||||
this.updateTurtleButton();
|
||||
},
|
||||
|
||||
setSearch: function( search ) {
|
||||
|
||||
@@ -20,6 +20,13 @@ RPC._DownloadDir = 'download-dir';
|
||||
RPC._PeerPort = 'peer-port';
|
||||
RPC._UpSpeedLimited = 'speed-limit-up-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 )
|
||||
{
|
||||
|
||||
@@ -739,6 +739,22 @@ div.torrent_footer div#disk_space_container {
|
||||
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
|
||||
@@ -865,12 +881,12 @@ iframe#torrent_upload_frame {
|
||||
|
||||
div#prefs_container label {
|
||||
display: block;
|
||||
margin: 0 0 0 2px;
|
||||
}
|
||||
|
||||
div#prefs_container label.category {
|
||||
clear: both;
|
||||
font-size: 1.2em;
|
||||
margin: 0 0 0 2px;
|
||||
}
|
||||
|
||||
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 {
|
||||
width: 91px;
|
||||
width: 102px;
|
||||
}
|
||||
|
||||
div#prefs_container div.limit_turtle label.item {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
div#prefs_container div.preference input[type=checkbox] {
|
||||
@@ -935,6 +955,41 @@ div#prefs_container h2.dialog_heading {
|
||||
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 {
|
||||
display: none;
|
||||
width: 395px;
|
||||
|
||||
Reference in New Issue
Block a user