Changeset 10114
- Timestamp:
- Feb 6, 2010, 4:43:48 PM (12 years ago)
- Location:
- trunk/web/javascript
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/javascript/torrent.js
r10061 r10114 34 34 35 35 36 Torrent._StaticFields = [ 'addedDate', 'comment', 'creator', 'dateCreated', 37 'hashString', 'id', 'isPrivate', 'name', 'totalSize', 'pieceCount', 'pieceSize' ] 36 Torrent._StaticFields = [ 'hashString', 'id' ] 37 38 Torrent._MetaDataFields = [ 'addedDate', 'comment', 'creator', 'dateCreated', 39 'isPrivate', 'name', 'totalSize', 'pieceCount', 'pieceSize' ] 40 38 41 Torrent._DynamicFields = [ 'downloadedEver', 'error', 'errorString', 'eta', 39 42 'haveUnchecked', 'haveValid', 'leftUntilDone', 'metadataPercentComplete', 'peersConnected', … … 44 47 Torrent.prototype = 45 48 { 49 initMetaData: function( data ) { 50 this._date = data.addedDate; 51 this._comment = data.comment; 52 this._creator = data.creator; 53 this._creator_date = data.dateCreated; 54 this._is_private = data.isPrivate; 55 this._name = data.name; 56 this._name_lc = this._name.toLowerCase( ); 57 this._size = data.totalSize; 58 this._pieceCount = data.pieceCount; 59 this._pieceSize = data.pieceSize; 60 61 if( data.files ) { 62 for( var i=0, row; row=data.files[i]; ++i ) { 63 this._file_model[i] = { 64 'index': i, 65 'torrent': this, 66 'length': row.length, 67 'name': row.name 68 }; 69 } 70 } 71 }, 72 46 73 /* 47 74 * Constructor … … 49 76 initialize: function( transferListParent, fileListParent, controller, data) { 50 77 this._id = data.id; 51 this._is_private = data.isPrivate;52 78 this._hashString = data.hashString; 53 this._date = data.addedDate;54 this._size = data.totalSize;55 this._pieceCount = data.pieceCount;56 this._pieceSize = data.pieceSize;57 this._comment = data.comment;58 this._creator = data.creator;59 this._creator_date = data.dateCreated;60 79 this._sizeWhenDone = data.sizeWhenDone; 61 this._name = data.name;62 this._name_lc = this._name.toLowerCase( );63 80 this._trackerStats = this.buildTrackerStats(data.trackerStats); 64 81 this._file_model = [ ]; 65 82 this._file_view = [ ]; 83 this.initMetaData( data ); 66 84 67 85 // Create a new <li> element … … 129 147 130 148 this.initializeTorrentFilesInspectorGroup( fileListParent ); 131 132 if( data.files ) {133 for( var i=0, row; row=data.files[i]; ++i ) {134 this._file_model[i] = {135 'index': i,136 'torrent': this,137 'length': row.length,138 'name': row.name139 };140 }141 }142 149 143 150 // Update all the labels etc … … 342 349 * 343 350 *--------------------------------------------*/ 351 352 refreshMetaData: function(data) { 353 this.initMetaData( data ); 354 this.ensureFileListExists(); 355 this.refreshFileView(); 356 this.refreshHTML( ); 357 }, 344 358 345 359 refresh: function(data) { … … 351 365 * Refresh display 352 366 */ 353 refreshData: function(data) { 367 refreshData: function(data) 368 { 369 if( this.needsMetaData() && ( data.metadataPercentComplete >= 1 ) ) 370 transmission.refreshMetaData( [ this._id ] ); 371 354 372 this._completed = data.haveUnchecked + data.haveValid; 355 373 this._verified = data.haveValid; -
trunk/web/javascript/transmission.js
r10061 r10114 1359 1359 }, 1360 1360 1361 refreshMetaData: function(ids) { 1362 var tr = this; 1363 this.remote.getMetaDataFor(ids, function(active, removed){ tr.updateMetaData(active); }); 1364 }, 1365 1366 updateMetaData: function( torrents ) 1367 { 1368 var tr = this; 1369 var refresh_files_for = [ ]; 1370 jQuery.each( torrents, function( ) { 1371 var t = tr._torrents[ this.id ]; 1372 if( t ) { 1373 t.refreshMetaData( this ); 1374 if( t.isSelected( ) ) 1375 refresh_files_for.push( t.id( ) ); 1376 } 1377 } ); 1378 if( refresh_files_for.length > 0 ) 1379 tr.remote.loadTorrentFiles( refresh_files_for ); 1380 }, 1381 1361 1382 refreshTorrents: function(ids) { 1362 1383 var tr = this; -
trunk/web/javascript/transmission.remote.js
r9982 r10114 113 113 method: 'torrent-get', 114 114 arguments: { 115 fields: Torrent._StaticFields.concat(Torrent._DynamicFields, [ 'files', 'fileStats' ]) 115 fields: Torrent._StaticFields.concat( Torrent._MetaDataFields, 116 Torrent._DynamicFields, 117 [ 'files', 'fileStats' ] ) 118 } 119 }; 120 121 if(torrent_ids) 122 o.arguments.ids = torrent_ids; 123 124 this.sendRequest( o, function(data){ callback(data.arguments.torrents)} ); 125 }, 126 127 getMetaDataFor: function(torrent_ids, callback) { 128 var o = { 129 method: 'torrent-get', 130 arguments: { 131 fields: Torrent._StaticFields.concat( Torrent._MetaDataFields, 132 [ 'files', 'fileStats' ] ) 116 133 } 117 134 };
Note: See TracChangeset
for help on using the changeset viewer.