46
46
$('#filter_paused_link').parent().bind('click', function(e){ tr.showPausedClicked(e); });
47
47
$('#prefs_save_button').bind('click', function(e) { tr.savePrefsClicked(e); return false;});
48
48
$('#prefs_cancel_button').bind('click', function(e){ tr.cancelPrefsClicked(e); return false; });
49
$('#stats_close_button').bind('click', function(e){ tr.closeStatsClicked(e); return false; });
49
50
$('.inspector_tab').bind('click', function(e){ tr.inspectorTabClicked(e, this); });
50
51
$('.file_wanted_control').live('click', function(e){ tr.fileWantedClicked(e, this); });
51
52
$('.file_priority_control').live('click', function(e){ tr.filePriorityClicked(e, this); });
835
* Turn the periodic ajax stats refresh on & off
837
togglePeriodicStatsRefresh: function(state) {
839
if (state && this._periodic_stats_refresh == null) {
841
if( !this[Prefs._SessionRefreshRate] )
842
this[Prefs._SessionRefreshRate] = 5;
843
remote = this.remote;
844
this._periodic_stats_refresh = setInterval(
845
function(){ tr.loadDaemonStats(); }, this[Prefs._SessionRefreshRate] * 1000
848
clearInterval(this._periodic_stats_refresh);
849
this._periodic_stats_refresh = null;
820
853
toggleTurtleClicked: function() {
821
854
// Toggle the value
822
855
this[Prefs._TurtleState] = !this[Prefs._TurtleState];
829
862
updateTurtleButton: function() {
863
var w = $('#turtle_button');
830
865
if ( this[Prefs._TurtleState] ) {
831
$('#turtle_button').addClass('turtleEnabled');
832
$('#turtle_button').removeClass('turtleDisabled');
866
w.addClass('turtleEnabled');
867
w.removeClass('turtleDisabled');
868
t = "Click to disable Temporary Speed Limits";
834
$('#turtle_button').removeClass('turtleEnabled');
835
$('#turtle_button').addClass('turtleDisabled');
870
w.removeClass('turtleEnabled');
871
w.addClass('turtleDisabled');
872
t = "Click to enable Temporary Speed Limits";
874
t += " (" + this._prefs[RPC._TurtleUpSpeedLimit] + " kB/s up, "
875
+ this._prefs[RPC._TurtleDownSpeedLimit] + " kB/s down)";
876
w.attr( 'title', t );
839
879
/*--------------------------------------------
915
955
this.updateTurtleButton();
958
showStatsDialog: function( ) {
959
this.loadDaemonStats();
960
$('body').addClass('stats_showing');
961
$('#stats_container').show();
962
this.hideiPhoneAddressbar();
964
setTimeout("$('div#stats_container div.dialog_window').css('top', '0px');",10);
965
this.updateButtonStates( );
966
this.togglePeriodicStatsRefresh(true);
969
hideStatsDialog: function( ){
970
$('body.stats_showing').removeClass('stats_showing');
972
this.hideiPhoneAddressbar();
973
$('#stats_container').hide();
974
} else if (Safari3) {
975
$('div#stats_container div.dialog_window').css('top', '-425px');
976
setTimeout("$('#stats_container').hide();",500);
978
$('#stats_container').hide();
980
this.updateButtonStates( );
981
this.togglePeriodicStatsRefresh(false);
985
* Process got some new session stats from the server
987
updateStats: function( stats )
989
// can't think of a reason to remember this
990
//this._stats = stats;
992
var session = stats["current-stats"];
993
var total = stats["cumulative-stats"];
995
setInnerHTML( $('#stats_session_uploaded')[0], Math.formatBytes(session["uploadedBytes"]) );
996
setInnerHTML( $('#stats_session_downloaded')[0], Math.formatBytes(session["downloadedBytes"]) );
997
setInnerHTML( $('#stats_session_ratio')[0], Math.ratio(session["uploadedBytes"],session["downloadedBytes"]));
998
setInnerHTML( $('#stats_session_duration')[0], Math.formatSeconds(session["secondsActive"]) );
999
setInnerHTML( $('#stats_total_count')[0], total["sessionCount"] + " times" );
1000
setInnerHTML( $('#stats_total_uploaded')[0], Math.formatBytes(total["uploadedBytes"]) );
1001
setInnerHTML( $('#stats_total_downloaded')[0], Math.formatBytes(total["downloadedBytes"]) );
1002
setInnerHTML( $('#stats_total_ratio')[0], Math.ratio(total["uploadedBytes"],total["downloadedBytes"]));
1003
setInnerHTML( $('#stats_total_duration')[0], Math.formatSeconds(total["secondsActive"]) );
918
1006
setSearch: function( search ) {
919
1007
this._current_search = search ? search.trim() : null;
920
1008
this.refilter( );
947
1035
$('div#prefs_container h2.dialog_heading').show();
948
1036
tr.showPrefsDialog( );
1038
else if ($element[0].id == 'statistics') {
1039
$('div#stats_container div#stats_error').hide();
1040
$('div#stats_container h2.dialog_heading').show();
1041
tr.showStatsDialog( );
952
1045
// Limit the download rate