Changeset 12819
- Timestamp:
- Aug 31, 2011, 2:24:35 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/javascript/transmission.js
r12817 r12819 45 45 $('#remove_link').click(function(e) { tr.removeClicked(e); }); 46 46 $('#prefs_save_button').click(function(e) { tr.savePrefsClicked(e); return false;}); 47 $('#prefs_cancel_button').click(function( e) { tr.hidePrefsDialog(); return false; });48 $('#block_update_button').click(function( e) { tr.remote.updateBlocklist(); return false; });49 $('#stats_close_button').click(function( e) { tr.hideStatsDialog(); return false; });47 $('#prefs_cancel_button').click(function() { tr.hidePrefsDialog(); return false; }); 48 $('#block_update_button').click(function() { tr.remote.updateBlocklist(); return false; }); 49 $('#stats_close_button').click(function() { tr.hideStatsDialog(); return false; }); 50 50 $('.inspector_tab').click(function(e) { tr.inspectorTabClicked(e, this); }); 51 51 $('#files_select_all').live('click', function(e) { tr.filesSelectAllClicked(e, this); }); … … 53 53 $('#open_link').click(function(e) { tr.openTorrentClicked(e); }); 54 54 $('#upload_confirm_button').click(function(e) { tr.confirmUploadClicked(e); return false;}); 55 $('#upload_cancel_button').click(function( e) { tr.hideUploadDialog(); return false; });55 $('#upload_cancel_button').click(function() { tr.hideUploadDialog(); return false; }); 56 56 $('#turtle-button').click(function() { tr.toggleTurtleClicked(); }); 57 57 $('#compact-button').click(function() { tr.toggleCompactClicked(); }); … … 68 68 69 69 $(document).delegate('#torrent_list > li', 'click', function(ev) {tr.onRowClicked(ev,ev.currentTarget.row);}); 70 $(document).delegate('#torrent_list > li', 'dblclick', function( e) {tr.toggleInspector();});70 $(document).delegate('#torrent_list > li', 'dblclick', function() {tr.toggleInspector();}); 71 71 72 72 $('#torrent_upload_form').submit(function() { $('#upload_confirm_button').click(); return false; }); … … 360 360 361 361 seedRatioLimit: function() { 362 if (this._prefs && this._prefs['seedRatioLimited']) 363 return this._prefs['seedRatioLimit']; 362 var p = this._prefs; 363 if (p && p.seedRatioLimited) 364 return p.seedRatioLimit; 364 365 return -1; 365 366 }, … … 382 383 383 384 getSelectedTorrents: function() { 384 return $.map(this.getSelectedRows(),function(r) {return r.getTorrent();}); 385 return $.map(this.getSelectedRows(),function(r) { 386 return r.getTorrent(); 387 }); 385 388 }, 386 389 387 390 getSelectedTorrentIds: function() { 388 return $.map(this.getSelectedRows(),function(r) {return r.getTorrentId();}); 391 return $.map(this.getSelectedRows(),function(r) { 392 return r.getTorrentId(); 393 }); 389 394 }, 390 395 … … 455 460 { 456 461 if (!this.selectionChangedTimer) 457 this.selectionChangedTimer = setTimeout($.proxy(this.selectionChanged,this),200); 462 this.selectionChangedTimer = 463 setTimeout($.proxy(this.selectionChanged,this),200); 458 464 }, 459 465 … … 470 476 { 471 477 var handled = false, 472 478 rows = this._rows, 473 479 up = ev.keyCode === 38; // up key pressed 474 480 dn = ev.keyCode === 40, // down key pressed … … 493 499 if (anchor >= 0) 494 500 { 495 // user is extending the selection with the shift + arrow keys... 501 // user is extending the selection 502 // with the shift + arrow keys... 496 503 if ( ((anchor <= last) && (last < i)) 497 504 || ((anchor >= last) && (last > i))) … … 530 537 }, 531 538 532 isButtonEnabled: function(e) { 533 var p = e.target ? e.target.parentNode : e.srcElement.parentNode; 534 return p.className!='disabled' && p.parentNode.className!='disabled'; 539 isButtonEnabled: function(ev) { 540 var p = (ev.target || ev.srcElement).parentNode; 541 return p.className!=='disabled' 542 && p.parentNode.className!=='disabled'; 535 543 }, 536 544 … … 704 712 /* Turn the periodic ajax session refresh on & off */ 705 713 togglePeriodicSessionRefresh: function(enabled) { 706 clearInterval(this. _periodic_session_refresh);707 delete this. _periodic_session_refresh;714 clearInterval(this.sessionInterval); 715 delete this.sessionInterval; 708 716 if (enabled) { 709 717 var msec = this.getIntervalMsec(Prefs._SessionRefreshRate, 5); 710 this. _periodic_session_refresh= setInterval($.proxy(this.loadDaemonPrefs,this), msec);718 this.sessionInterval = setInterval($.proxy(this.loadDaemonPrefs,this), msec); 711 719 } 712 720 }, … … 714 722 /* Turn the periodic ajax stats refresh on & off */ 715 723 togglePeriodicStatsRefresh: function(enabled) { 716 clearInterval(this. _periodic_stats_refresh);717 delete this. _periodic_stats_refresh;724 clearInterval(this.statsInterval); 725 delete this.statsInterval; 718 726 if (enabled) { 719 727 var msec = this.getIntervalMsec(Prefs._SessionRefreshRate, 5); 720 this. _periodic_stats_refresh= setInterval($.proxy(this.loadDaemonStats,this), msec);728 this.statsInterval = setInterval($.proxy(this.loadDaemonStats,this), msec); 721 729 } 722 730 }, … … 998 1006 onTorrentChanged: function(tor) 999 1007 { 1000 var id = tor.getId();1001 1002 1008 // update our dirty fields 1003 this.dirtyTorrents[ id] = true;1009 this.dirtyTorrents[ tor.getId() ] = true; 1004 1010 1005 1011 // enqueue ui refreshes … … 1010 1016 updateFromTorrentGet: function(updates, removed_ids) 1011 1017 { 1012 var i, o, t, id, needed, needs, 1013 needinfo = []; 1018 var i, o, t, id, needed, needinfo = []; 1014 1019 1015 1020 for (i=0; o=updates[i]; ++i) … … 1020 1025 needed = t.needsMetaData(); 1021 1026 t.refresh(o); 1022 needs = t.needsMetaData(); 1023 if (needed && !needs) 1027 if (needed && !t.needsMetaData()) 1024 1028 needinfo.push(id); 1025 1029 } … … 1062 1066 initializeTorrents: function() 1063 1067 { 1064 // to bootstrap, we only need to ask for the servers's torrents' ids.1065 // updateFromTorrentGet() automatically asks for the rest of the info when it gets a new id.1066 var fields = ['id'].concat(Torrent.Fields.Metadata, Torrent.Fields.Stats);1067 this.remote.updateTorrents(null, fields,this.updateFromTorrentGet, this);1068 var fields = ['id'].concat(Torrent.Fields.Metadata, 1069 Torrent.Fields.Stats); 1070 this.remote.updateTorrents(null, fields, 1071 this.updateFromTorrentGet, this); 1068 1072 }, 1069 1073 … … 1080 1084 }, 1081 1085 1086 // Load the torrent fields which are only used by the inspector 1082 1087 refreshInspectorTorrents: function(full) 1083 1088 { 1084 // some torrent fields are only used by the inspector, so we defer loading them 1085 // until the user is viewing the torrent in the inspector. 1086 if (this.inspectorIsVisible()) { 1087 var ids = this.getSelectedTorrentIds(); 1088 if (ids && ids.length) { 1089 var fields = ['id'].concat(Torrent.Fields.StatsExtra); 1090 if (this.needsExtraInfo(ids)) 1091 fields = fields.concat(Torrent.Fields.InfoExtra); 1092 this.remote.updateTorrents(ids, fields, this.updateFromTorrentGet, this); 1093 } 1089 var fields, ids=null; 1090 1091 if (this.inspectorIsVisible()) 1092 ids = this.getSelectedTorrentIds(); 1093 1094 if (ids && ids.length) { 1095 fields = ['id'].concat(Torrent.Fields.StatsExtra); 1096 if (this.needsExtraInfo(ids)) 1097 $.merge(fields, Torrent.Fields.InfoExtra); 1098 this.remote.updateTorrents( 1099 ids, fields, this.updateFromTorrentGet, this); 1094 1100 } 1095 1101 }, … … 1166 1172 updateStatusbar: function() 1167 1173 { 1174 var i, row, 1175 u=0, d=0, 1176 fmt = Transmission.fmt, 1177 torrents = this.getAllTorrents(); 1178 1168 1179 this.refreshFilterButton(); 1169 1180 1170 1181 // up/down speed 1171 var u=0, d=0; 1172 var torrents = this.getAllTorrents(); 1173 for (var i=0, row; row=torrents[i]; ++i) { 1182 for (i=0; row=torrents[i]; ++i) { 1174 1183 u += row.getUploadSpeed(); 1175 1184 d += row.getDownloadSpeed(); 1176 1185 } 1177 1186 1178 var fmt = Transmission.fmt;1179 1187 setInnerHTML($('#statusbar #speed-up-label')[0], u ? '↑ ' + fmt.speedBps(u) : ''); 1180 1188 setInnerHTML($('#statusbar #speed-dn-label')[0], d ? '↓ ' + fmt.speedBps(d) : ''); … … 1322 1330 }, 1323 1331 1324 hideMobileAddressbar: function( timeInSeconds) {1332 hideMobileAddressbar: function(delaySecs) { 1325 1333 if (isMobileDevice && !scroll_timeout) { 1326 var delay Length = timeInSeconds ? timeInSeconds*1000 :150;1327 scroll_timeout = setTimeout($.proxy(this.doToolbarHide,this), delay Length);1334 var delayMsec = delaySecs*1000 || 150; 1335 scroll_timeout = setTimeout($.proxy(this.doToolbarHide,this), delayMsec); 1328 1336 } 1329 1337 },
Note: See TracChangeset
for help on using the changeset viewer.