Changeset 393

Show
Ignore:
Timestamp:
06/30/08 09:48:39 (2 months ago)
Author:
charles
Message:

`setInnerHTML' speedup for FF

Files:

Legend:

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

    r391 r393  
    1616if (iPhone) var scroll_timeout; 
    1717 
     18/* (is this used?) 
    1819function updateLayout() 
    1920{ 
     
    3334        } 
    3435}; 
     36*/ 
    3537 
    3638function testSafari3() 
     
    9799}); 
    98100 
    99 /** 
    100  *   Array convenience method to clear membership. 
    101  * 
    102  *   @param object element 
    103  *   @returns void 
    104  */ 
    105 Array.prototype.clear = function () { 
    106     this.length = 0; 
    107 }; 
    108  
    109  
    110 /* 
    111  *   Return true if the given object is in the array 
    112  * 
    113  *   @param object element 
    114  *   @returns boolean 
    115  */ 
    116 Array.prototype.inArray = function (obj) { 
    117         return this.indexOf( obj ) != -1; 
    118 }; 
    119  
    120  
    121101/* 
    122102 *   Return a copy of the array 
     
    128108} 
    129109 
    130  
    131 /* 
    132  *   Return a JSON representation of the array.  
    133  *   Force single integers to be returned in an array 
    134  * 
    135  *   @returns string 
    136  */ 
    137 Array.prototype.json = function () { 
    138         var result = $.toJSON(this); 
    139         if (parseInt(result) == result) { 
    140                 result = '[' + result + ']' 
    141         } 
    142         return result; 
    143 
    144  
     110/** 
     111 * "innerHTML = html" is pretty slow in FF.  Happily a lot of our innerHTML 
     112 * changes are triggered by periodic refreshes on torrents whose state hasn't 
     113 * changed sine the last update, so even this simple test helps a lot. 
     114 */ 
     115function setInnerHTML( e, html ) 
     116
     117        if( e.innerHTML != html ) 
     118                e.innerHTML = html; 
     119
    145120 
    146121/* 
  • branches/rpc/web/javascript/dialog.js

    r390 r393  
    8787                        $('.dialog_container').hide(); 
    8888                } 
    89                 this._heading[0].innerHTML = dialog_heading
    90                 this._message[0].innerHTML = dialog_message
    91                 this._cancel_button[0].innerHTML = (cancel_button_label == null) ? 'Cancel' : cancel_button_label
    92                 this._confirm_button[0].innerHTML = confirm_button_label
     89                setInnerHTML( this._heading[0], dialog_heading )
     90                setInnerHTML( this._message[0], dialog_message )
     91                setInnerHTML( this._cancel_button[0], (cancel_button_label == null) ? 'Cancel' : cancel_button_label )
     92                setInnerHTML( this._confirm_button[0], confirm_button_label )
    9393                this._confirm_button.show(); 
    9494                this._callback_function = callback_function; 
     
    116116                        $('.dialog_container').hide(); 
    117117                } 
    118                 this._heading[0].innerHTML = dialog_heading
    119                 this._message[0].innerHTML = dialog_message
     118                setInnerHTML( this._heading[0], dialog_heading )
     119                setInnerHTML( this._message[0], dialog_message )
    120120                // jquery::hide() doesn't work here in Safari for some odd reason 
    121121                this._confirm_button.css('display', 'none'); 
    122                 this._cancel_button[0].innerHTML = cancel_button_label
     122                setInnerHTML( this._cancel_button[0], cancel_button_label )
    123123                // Just in case 
    124124                if (!iPhone && Safari3) { 
  • branches/rpc/web/javascript/torrent.js

    r392 r393  
    300300                var root = this._element; 
    301301                 
    302                 root._name_container[0].innerHTML = this._name
     302                setInnerHTML( root._name_container[0], this._name )
    303303                 
    304304                // Figure out the percent completed 
     
    386386                 
    387387                // Update the progress details 
    388                 root._progress_details_container[0].innerHTML = progress_details
     388                setInnerHTML( root._progress_details_container[0], progress_details )
    389389                 
    390390                // Update the peer details and pause/resume button 
     
    402402                } 
    403403                 
    404                 root._peer_details_container[0].innerHTML = peer_details
     404                setInnerHTML( root._peer_details_container[0], peer_details )
    405405        }, 
    406406 
  • branches/rpc/web/javascript/transmission.js

    r392 r393  
    667667                if (!iPhone) 
    668668                { 
    669                         $('#limited_download_rate')[0].innerHTML = 'Limit (' + down_limit + ' KB/s)'
     669                        setInnerHTML( $('#limited_download_rate')[0], 'Limit (' + down_limit + ' KB/s)' )
    670670                        var key = down_limited ? '#limited_download_rate' 
    671671                                               : '#unlimited_download_rate'; 
    672672                        $(key).deselectMenuSiblings().selectMenuItem(); 
    673673                 
    674                         $('#limited_upload_rate')[0].innerHTML = 'Limit (' + up_limit + ' KB/s)'
     674                        setInnerHTML( $('#limited_upload_rate')[0], 'Limit (' + up_limit + ' KB/s)' )
    675675                        key = up_limited ? '#limited_upload_rate' 
    676676                                         : '#unlimited_upload_rate'; 
     
    721721                                        args[RPC._DownSpeedLimited] = false; 
    722722                                } else { 
    723                                         $('#limited_download_rate')[0].innerHTML = 'Limit (' + rate + ' KB/s)'
     723                                        setInnerHTML( $('#limited_download_rate')[0], 'Limit (' + rate + ' KB/s)' )
    724724                                        $('#limited_download_rate').deselectMenuSiblings().selectMenuItem(); 
    725725                                        $('div.preference input#download_rate')[0].value = rate; 
     
    739739                                        args[RPC._UpSpeedLimited] = false; 
    740740                                } else { 
    741                                         $('#limited_upload_rate')[0].innerHTML = 'Limit (' + rate + ' KB/s)'
     741                                        setInnerHTML( $('#limited_upload_rate')[0], 'Limit (' + rate + ' KB/s)' )
    742742                                        $('#limited_upload_rate').deselectMenuSiblings().selectMenuItem(); 
    743743                                        $('div.preference input#upload_rate')[0].value = rate; 
     
    914914                } 
    915915 
    916                 $('ul li#context_toggle_inspector')[0].innerHTML = 'Hide Inspector'
     916                setInnerHTML( $('ul li#context_toggle_inspector')[0], 'Hide Inspector' )
    917917 
    918918                this.setPref( Prefs._ShowInspector, true ); 
     
    934934                        $('#torrent_filter_bar')[0].style.right = '0px'; 
    935935                        $('#torrent_container')[0].style.right = '0px'; 
    936                         $('ul li#context_toggle_inspector')[0].innerHTML = 'Show Inspector'
     936                        setInnerHTML( $('ul li#context_toggle_inspector')[0], 'Show Inspector' )
    937937                } 
    938938                 
     
    10241024                //+ Math.formatBytes(data.free_space_bytes) 
    10251025                //+ ' (' + data.free_space_percent + '% )'; 
    1026                 //$('div#disk_space_container')[0].innerHTML = disk_space_msg
     1026                //setInnerHTML( $('div#disk_space_container')[0], disk_space_msg )
    10271027                 
    10281028                this.refilter( ); 
     
    10621062                else 
    10631063                        s = visibleCount + ' of ' + torrentCount + ' Transfers'; 
    1064                 $('#torrent_global_transfer')[0].innerHTML = s
     1064                setInnerHTML( $('#torrent_global_transfer')[0], s )
    10651065                 
    10661066                // update the speeds 
    10671067                s = Math.formatBytes( upSpeed ) + '/s'; 
    10681068                if( iPhone ) s = 'UL: ' + s; 
    1069                 $('#torrent_global_upload')[0].innerHTML = s
     1069                setInnerHTML( $('#torrent_global_upload')[0], s )
    10701070                 
    10711071                // download speeds 
    10721072                s = Math.formatBytes( downSpeed ) + '/s'; 
    10731073                if( iPhone ) s = 'DL: ' + s; 
    1074                 $('#torrent_global_download')[0].innerHTML = s
     1074                setInnerHTML( $('#torrent_global_download')[0], s )
    10751075        }, 
    10761076     
  • branches/rpc/web/javascript/transmission.remote.js

    r391 r393  
    5555                }); 
    5656        }, 
    57          
     57 
    5858        /* 
    5959         * Display an error if an ajax request fails, and stop sending requests 
    6060         */ 
    6161        ajaxError: function(request, error_string, exception) { 
    62                 transmission.remote._error = request.responseText ? request.responseText.trim().replace(/(<([^>]+)>)/ig,"") : ""; 
    63                 if (transmission.remote._error == '') { 
    64                         transmission.remote._error = 'Server not responding'; 
    65                 } 
     62                this._error = request.responseText ? request.responseText.trim().replace(/(<([^>]+)>)/ig,"") : ""; 
     63                if( this._error.length == 0 ) 
     64                        this._error = 'Server not responding'; 
    6665                 
    6766                dialog.confirm('Connection Failed',  
     
    7271                        'Dismiss'); 
    7372                transmission.togglePeriodicRefresh(false); 
    74         }, 
    75          
    76         /* 
    77          * Request the initial settings for the web client (up/down speed etc) 
    78          */ 
    79         setPreference: function(key, value) { 
    80                 this.request('setPreferences', '{"'+key+'":'+value+'}');         
    8173        }, 
    8274 
     
    112104                        for( var i=0, len=torrents.length; i<len; ++i ) 
    113105                                o.arguments.ids.push( torrents[i].id() ); 
    114         $.post( RPC._Root, $.toJSON(o), function( ) { 
     106               $.post( RPC._Root, $.toJSON(o), function( ) { 
    115107                        remote.loadTorrents(); 
    116108                }, "json" ); 
     
    160152         */ 
    161153        addTorrentByURL: function() { 
    162                 $('#torrent_upload_form')[0].action = 'remote/index.php?action=addTorrentByURL&param=[]' +  
    163                                 '&filter=' + this._controller.currentFilter() + 
    164                                 '&sort_method=' + this._controller.currentSortMethod() + 
    165                                 '&sort_direction=' + this._controller.currentSortDirection() + 
    166                                 '&search=' + this._controller.currentSearch(); 
     154                $('#torrent_upload_form')[0].action = 'remote/index.php?action=addTorrentByURL&param=[]'; 
    167155                $('#torrent_upload_form').ajaxSubmit({dataType: 'script', type: 'POST'}); 
    168156        },