Changeset 393
- Timestamp:
- 06/30/08 09:48:39 (2 months ago)
- Files:
-
- branches/rpc/web/javascript/common.js (modified) (4 diffs)
- branches/rpc/web/javascript/dialog.js (modified) (2 diffs)
- branches/rpc/web/javascript/torrent.js (modified) (3 diffs)
- branches/rpc/web/javascript/transmission.js (modified) (7 diffs)
- branches/rpc/web/javascript/transmission.remote.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/rpc/web/javascript/common.js
r391 r393 16 16 if (iPhone) var scroll_timeout; 17 17 18 /* (is this used?) 18 19 function updateLayout() 19 20 { … … 33 34 } 34 35 }; 36 */ 35 37 36 38 function testSafari3() … … 97 99 }); 98 100 99 /**100 * Array convenience method to clear membership.101 *102 * @param object element103 * @returns void104 */105 Array.prototype.clear = function () {106 this.length = 0;107 };108 109 110 /*111 * Return true if the given object is in the array112 *113 * @param object element114 * @returns boolean115 */116 Array.prototype.inArray = function (obj) {117 return this.indexOf( obj ) != -1;118 };119 120 121 101 /* 122 102 * Return a copy of the array … … 128 108 } 129 109 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 */ 115 function setInnerHTML( e, html ) 116 { 117 if( e.innerHTML != html ) 118 e.innerHTML = html; 119 } 145 120 146 121 /* branches/rpc/web/javascript/dialog.js
r390 r393 87 87 $('.dialog_container').hide(); 88 88 } 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 ); 93 93 this._confirm_button.show(); 94 94 this._callback_function = callback_function; … … 116 116 $('.dialog_container').hide(); 117 117 } 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 ); 120 120 // jquery::hide() doesn't work here in Safari for some odd reason 121 121 this._confirm_button.css('display', 'none'); 122 this._cancel_button[0].innerHTML = cancel_button_label;122 setInnerHTML( this._cancel_button[0], cancel_button_label ); 123 123 // Just in case 124 124 if (!iPhone && Safari3) { branches/rpc/web/javascript/torrent.js
r392 r393 300 300 var root = this._element; 301 301 302 root._name_container[0].innerHTML = this._name;302 setInnerHTML( root._name_container[0], this._name ); 303 303 304 304 // Figure out the percent completed … … 386 386 387 387 // Update the progress details 388 root._progress_details_container[0].innerHTML = progress_details;388 setInnerHTML( root._progress_details_container[0], progress_details ); 389 389 390 390 // Update the peer details and pause/resume button … … 402 402 } 403 403 404 root._peer_details_container[0].innerHTML = peer_details;404 setInnerHTML( root._peer_details_container[0], peer_details ); 405 405 }, 406 406 branches/rpc/web/javascript/transmission.js
r392 r393 667 667 if (!iPhone) 668 668 { 669 $('#limited_download_rate')[0].innerHTML = 'Limit (' + down_limit + ' KB/s)';669 setInnerHTML( $('#limited_download_rate')[0], 'Limit (' + down_limit + ' KB/s)' ); 670 670 var key = down_limited ? '#limited_download_rate' 671 671 : '#unlimited_download_rate'; 672 672 $(key).deselectMenuSiblings().selectMenuItem(); 673 673 674 $('#limited_upload_rate')[0].innerHTML = 'Limit (' + up_limit + ' KB/s)';674 setInnerHTML( $('#limited_upload_rate')[0], 'Limit (' + up_limit + ' KB/s)' ); 675 675 key = up_limited ? '#limited_upload_rate' 676 676 : '#unlimited_upload_rate'; … … 721 721 args[RPC._DownSpeedLimited] = false; 722 722 } else { 723 $('#limited_download_rate')[0].innerHTML = 'Limit (' + rate + ' KB/s)';723 setInnerHTML( $('#limited_download_rate')[0], 'Limit (' + rate + ' KB/s)' ); 724 724 $('#limited_download_rate').deselectMenuSiblings().selectMenuItem(); 725 725 $('div.preference input#download_rate')[0].value = rate; … … 739 739 args[RPC._UpSpeedLimited] = false; 740 740 } else { 741 $('#limited_upload_rate')[0].innerHTML = 'Limit (' + rate + ' KB/s)';741 setInnerHTML( $('#limited_upload_rate')[0], 'Limit (' + rate + ' KB/s)' ); 742 742 $('#limited_upload_rate').deselectMenuSiblings().selectMenuItem(); 743 743 $('div.preference input#upload_rate')[0].value = rate; … … 914 914 } 915 915 916 $('ul li#context_toggle_inspector')[0].innerHTML = 'Hide Inspector';916 setInnerHTML( $('ul li#context_toggle_inspector')[0], 'Hide Inspector' ); 917 917 918 918 this.setPref( Prefs._ShowInspector, true ); … … 934 934 $('#torrent_filter_bar')[0].style.right = '0px'; 935 935 $('#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' ); 937 937 } 938 938 … … 1024 1024 //+ Math.formatBytes(data.free_space_bytes) 1025 1025 //+ ' (' + data.free_space_percent + '% )'; 1026 // $('div#disk_space_container')[0].innerHTML = disk_space_msg;1026 //setInnerHTML( $('div#disk_space_container')[0], disk_space_msg ); 1027 1027 1028 1028 this.refilter( ); … … 1062 1062 else 1063 1063 s = visibleCount + ' of ' + torrentCount + ' Transfers'; 1064 $('#torrent_global_transfer')[0].innerHTML = s;1064 setInnerHTML( $('#torrent_global_transfer')[0], s ); 1065 1065 1066 1066 // update the speeds 1067 1067 s = Math.formatBytes( upSpeed ) + '/s'; 1068 1068 if( iPhone ) s = 'UL: ' + s; 1069 $('#torrent_global_upload')[0].innerHTML = s;1069 setInnerHTML( $('#torrent_global_upload')[0], s ); 1070 1070 1071 1071 // download speeds 1072 1072 s = Math.formatBytes( downSpeed ) + '/s'; 1073 1073 if( iPhone ) s = 'DL: ' + s; 1074 $('#torrent_global_download')[0].innerHTML = s;1074 setInnerHTML( $('#torrent_global_download')[0], s ); 1075 1075 }, 1076 1076 branches/rpc/web/javascript/transmission.remote.js
r391 r393 55 55 }); 56 56 }, 57 57 58 58 /* 59 59 * Display an error if an ajax request fails, and stop sending requests 60 60 */ 61 61 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'; 66 65 67 66 dialog.confirm('Connection Failed', … … 72 71 'Dismiss'); 73 72 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+'}');81 73 }, 82 74 … … 112 104 for( var i=0, len=torrents.length; i<len; ++i ) 113 105 o.arguments.ids.push( torrents[i].id() ); 114 $.post( RPC._Root, $.toJSON(o), function( ) {106 $.post( RPC._Root, $.toJSON(o), function( ) { 115 107 remote.loadTorrents(); 116 108 }, "json" ); … … 160 152 */ 161 153 addTorrentByURL: function() { 162 $('#torrent_upload_form')[0].action = 'remote/index.php?action=addTorrentByURL¶m=[]' + 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¶m=[]'; 167 155 $('#torrent_upload_form').ajaxSubmit({dataType: 'script', type: 'POST'}); 168 156 },
