Changeset 402

Show
Ignore:
Timestamp:
07/02/08 09:05:00 (2 months ago)
Author:
charles
Message:

get the ajax error dialog working again. fix some of the this-vs-global-transmission ambiguity in transmission.js.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/rpc/web/javascript/transmission.js

    r401 r402  
    184184        }, 
    185185 
     186        contextStopSelected: function( ) { 
     187                transmission.stopSelectedTorrents( ); 
     188        }, 
     189        contextStartSelected: function( ) { 
     190                transmission.startSelectedTorrents( ); 
     191        }, 
     192        contextRemoveSelected: function( ) { 
     193                transmission.removeSelectedTorrents( ); 
     194        }, 
     195        contextToggleInspector: function( ) { 
     196                transmission.toggleInspector( ); 
     197        }, 
    186198        contextSelectAll: function( ) { 
    187199                transmission.selectAll( true ); 
    188200        }, 
    189  
    190201        contextDeselectAll: function( ) { 
    191202                transmission.deselectAll( true ); 
     
    198209                 
    199210                var bindings = { 
    200                         context_pause_selected:    this.stopSelectedTorrents
    201                         context_resume_selected:   this.startSelectedTorrents
    202                         context_remove:            this.removeSelectedTorrents
    203                         context_toggle_inspector:  this.toggleInspector, 
     211                        context_pause_selected:    this.contextStopSelected
     212                        context_resume_selected:   this.contextStartSelected
     213                        context_remove:            this.contextRemoveSelected
     214                        context_toggle_inspector:  this.contextToggleInspector, 
    204215                        context_select_all:        this.contextSelectAll, 
    205216                        context_deselect_all:      this.contextDeselectAll 
     
    897908         */ 
    898909        toggleInspector: function() { 
    899                 if( transmission[Prefs._ShowInspector] ) 
    900                         transmission.hideInspector( ); 
     910                if( this[Prefs._ShowInspector] ) 
     911                        this.hideInspector( ); 
    901912                else 
    902                         transmission.showInspector( ); 
     913                        this.showInspector( ); 
    903914        }, 
    904915     
     
    944955         */ 
    945956        toggleFilter: function() { 
    946                 if( transmission[Prefs._ShowFilter] ) 
    947                         transmission.hideFilter(); 
     957                if( this[Prefs._ShowFilter] ) 
     958                        this.hideFilter(); 
    948959                else 
    949                         transmission.showFilter(); 
     960                        this.showFilter(); 
    950961        }, 
    951962 
     
    11081119    
    11091120        removeSelectedTorrents: function() { 
    1110                 var torrents = transmission.getSelectedTorrents( ); 
     1121                var torrents = this.getSelectedTorrents( ); 
    11111122                if( torrents.length ) 
    1112                         transmission.promptToRemoveTorrents( torrents ); 
     1123                        this.promptToRemoveTorrents( torrents ); 
    11131124        }, 
    11141125 
     
    11371148 
    11381149        startSelectedTorrents: function( ) { 
    1139                 var tr = transmission; 
    1140                 tr.startTorrents( tr.getSelectedTorrents( ) ); 
     1150                this.startTorrents( this.getSelectedTorrents( ) ); 
    11411151        }, 
    11421152        startAllTorrents: function( ) { 
    1143                 var tr = transmission; 
    1144                 tr.startTorrents( tr.getAllTorrents( ) ); 
     1153                this.startTorrents( this.getAllTorrents( ) ); 
    11451154        }, 
    11461155        startTorrent: function( torrent ) { 
     
    11521161     
    11531162        stopSelectedTorrents: function( ) { 
    1154                 var tr = transmission; 
    1155                 tr.stopTorrents( tr.getSelectedTorrents( ) ); 
     1163                this.stopTorrents( this.getSelectedTorrents( ) ); 
    11561164        }, 
    11571165        stopAllTorrents: function( ) { 
    1158                 var tr = transmission; 
    1159                 tr.stopTorrents( tr.getAllTorrents( ) ); 
     1166                this.stopTorrents( this.getAllTorrents( ) ); 
    11601167        }, 
    11611168        stopTorrent: function( torrent ) { 
  • branches/rpc/web/javascript/transmission.remote.js

    r401 r402  
    5757        }, 
    5858 
     59        sendRequest: function( url, data, success, contentType ) 
     60        { 
     61                var o = { }; 
     62                o.cache = false; 
     63                o.contentType = contentType; 
     64                o.data = data; 
     65                o.dataType = 'json'; 
     66                o.error = this.ajaxError; 
     67                o.success = success; 
     68                o.type = 'POST'; 
     69                o.url = url; 
     70                $.ajax( o ); 
     71        }, 
     72 
    5973        loadDaemonPrefs: function() { 
    6074                var tr = this._controller; 
    6175                var o = { }; 
    6276                o.method = 'session-get'; 
    63                 $.post( RPC._Root, $.toJSON(o), function(data) { 
     77                this.sendRequest( RPC._Root, $.toJSON(o), function(data) { 
    6478                        var o = data.arguments.session; 
    6579                        Prefs.getClutchPrefs( o ); 
     
    7488                o.arguments = { }; 
    7589                o.arguments.fields = 1+2+4+16+32+64+128+1024+2048+4096; 
    76                 $.post( RPC._Root, $.toJSON(o), function(data) { 
     90                this.sendRequest( RPC._Root, $.toJSON(o), function(data) { 
    7791                        tr.updateTorrents( data.arguments.torrents ); 
    7892                }, "json" ); 
     
    88102                        for( var i=0, len=torrents.length; i<len; ++i ) 
    89103                                o.arguments.ids.push( torrents[i].id() ); 
    90                 $.post( RPC._Root, $.toJSON(o), function( ) { 
     104                this.sendRequest( RPC._Root, $.toJSON(o), function( ) { 
    91105                        remote.loadTorrents(); 
    92106                }, "json" ); 
     
    107121                o.method = 'session-set'; 
    108122                o.arguments = args; 
    109                 $.post( RPC._Root, $.toJSON(o), function(){ 
     123                this.sendRequest( RPC._Root, $.toJSON(o), function(){ 
    110124                        remote.loadDaemonPrefs(); 
    111125                }, "json" );