<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"/>
+ <input type="text" name="refresh_rate" id="refresh_rate" class="numberinput"/>
<label class="suffix">seconds</label>
</div>
</div>
<div class="formdiv checkbox">
<input type="checkbox" name="limit_download" id="limit_download"/>
<label for="limit_download" class="item">Download Rate:</label>
- <input type="text" name="download_rate" id="download_rate"/>
+ <input type="text" name="download_rate" id="download_rate" class="numberinput"/>
<label class="suffix">kB/s</label>
</div>
<div class="formdiv checkbox">
<input type="checkbox" name="limit_upload" id="limit_upload"/>
<label for="limit_upload" class="item">Upload Rate:</label>
- <input type="text" name="upload_rate" id="upload_rate"/>
+ <input type="text" name="upload_rate" id="upload_rate" class="numberinput"/>
<label class="suffix">kB/s</label>
</div>
</div>
<label>Override normal speed limits manually or at scheduled times</label>
<div class="formdiv">
<label for="turtle_download_rate" class="item">Download Rate:</label>
- <input type="text" name="turtle_download_rate" id="turtle_download_rate"/>
+ <input type="text" name="turtle_download_rate" id="turtle_download_rate" class="numberinput"/>
<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"/>
+ <input type="text" name="turtle_upload_rate" id="turtle_upload_rate" class="numberinput"/>
<label class="suffix">kB/s</label>
</div>
<div class="formdiv checkbox">
<label class="category">Connections:</label>
<div class="formdiv">
<label for="conn_global" class="item">Global maximum connections:</label>
- <input type="text" name="conn_global" id="conn_global"/>
+ <input type="text" name="conn_global" id="conn_global" class="numberinput"/>
<label class="suffix">peers</label>
</div>
<div class="formdiv">
<label for="conn_torrent" class="item">Maximum connections for new transfers:</label>
- <input type="text" name="conn_torrent" id="conn_torrent"/>
+ <input type="text" name="conn_torrent" id="conn_torrent" class="numberinput"/>
<label class="suffix">peers</label>
</div>
<div class="formdiv checkbox">
<label class="category">Peer listening port:</label>
<div class="formdiv">
<label for="port" class="item">Incoming TCP Port:</label>
- <input type="text" id="port" name="port"/>
+ <input type="text" id="port" name="port" class="numberinput"/>
<label class="suffix" id="port_test"></label>
</div>
<div class="formdiv checkbox">
o[key] = Prefs.getValue( key, Prefs._Defaults[key] );
return o;
};
+
+
+// forceNumeric() plug-in implementation
+jQuery.fn.forceNumeric = function () {
+ return this.each(function () {
+ $(this).keydown(function (e) {
+ var key = e.which || e.keyCode;
+ return !e.shiftKey && !e.altKey && !e.ctrlKey &&
+ // numbers
+ key >= 48 && key <= 57 ||
+ // Numeric keypad
+ key >= 96 && key <= 105 ||
+ // comma, period and minus, . on keypad
+ key == 190 || key == 188 || key == 109 || key == 110 ||
+ // Backspace and Tab and Enter
+ key == 8 || key == 9 || key == 13 ||
+ // Home and End
+ key == 35 || key == 36 ||
+ // left and right arrows
+ key == 37 || key == 39 ||
+ // Del and Ins
+ key == 46 || key == 45;
+ });
+ });
+}
// Set up user events
var tr = this;
+ $(".numberinput").forceNumeric();
$('#pause_all_link').bind('click', function(e){ tr.stopAllClicked(e); });
$('#resume_all_link').bind('click', function(e){ tr.startAllClicked(e); });
$('#pause_selected_link').bind('click', function(e){ tr.stopSelectedClicked(e); } );
this._inspector._info_tab.upload_speed = $(ti+'upload_speed')[0];
this._inspector._info_tab.upload_to = $(ti+'upload_to')[0];
- // Setup the preference box
- this.setupPrefConstraints();
-
// Setup the prefs gui
this.initializeSettings( );
jQuery("<img>").attr("src", row);
},
- /*
- * Set up the preference validation
- */
- setupPrefConstraints: function() {
- // only allow integers for speed limit & port options
- $('div.preference input[@type=text]:not(#download_location,#block_url)').blur( function() {
- this.value = this.value.replace(/[^0-9]/gi, '');
- if (this.value == '') {
- if ($(this).is('#refresh_rate')) {
- this.value = 5;
- } else {
- this.value = 0;
- }
- }
- });
- },
-
setCompactMode: function( is_compact )
{
this.torrentRenderer = is_compact ? new TorrentRendererCompact( )
$element.deselectMenuSiblings().selectMenuItem();
args[RPC._DownSpeedLimited] = false;
} else {
- var rate_str = ($element[0].innerHTML).replace(/[^0-9]/ig, '');
+ var rate_str = $element[0].innerHTML
var rate_val = parseInt( rate_str );
setInnerHTML( $('#limited_download_rate')[0], [ 'Limit (', Transmission.fmt.speed(rate_val), ')' ].join('') );
$('#limited_download_rate').deselectMenuSiblings().selectMenuItem();
$element.deselectMenuSiblings().selectMenuItem();
args[RPC._UpSpeedLimited] = false;
} else {
- var rate_str = ($element[0].innerHTML).replace(/[^0-9]/ig, '');
+ var rate_str = $element[0].innerHTML
var rate_val = parseInt( rate_str );
setInnerHTML( $('#limited_upload_rate')[0], [ 'Limit (', Transmission.fmt.speed(rate_val), ')' ].join('') );
$('#limited_upload_rate').deselectMenuSiblings().selectMenuItem();