/* * Copyright © Dave Perrett and Malcolm Jarvis * This code is licensed under the GPL version 2. * For details, see http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * * Class Torrent */ function Torrent(controller,data) { this.initialize(controller,data); } // Constants Torrent._StatusWaitingToCheck = 1; Torrent._StatusChecking = 2; Torrent._StatusDownloading = 4; Torrent._StatusSeeding = 8; Torrent._StatusPaused = 16; Torrent._InfiniteTimeRemaining = 215784000; // 999 Hours - may as well be infinite Torrent.prototype = { /* * Constructor */ initialize: function(controller, data) { // Create a new
  • element var element = $('
  • '); element.addClass('torrent'); element[0].id = 'torrent_' + data.id; element._torrent = this; this._element = element; this._controller = controller; controller._rows.push( element ); // Create the 'name'
    var e = $('
    '); e.addClass('torrent_name'); element.append( e ); element._name_container = e; // Create the 'progress details'
    e = $('
    '); e.addClass('torrent_progress_details'); element.append(e); element._progress_details_container = e; // Create the 'in progress' bar e = $('
    '); e.addClass('torrent_progress_bar incomplete'); e.css('width', '0%'); element.append( e ); element._progress_complete_container = e; // Create the 'incomplete' bar (initially hidden) e = $('
    '); e.addClass('torrent_progress_bar incomplete'); e.hide(); element.append( e ); element._progress_incomplete_container = e; // Add the pause/resume button - don't specify the // image or alt text until the 'refresh()' function // (depends on torrent state) var image = $('
  • 's in straight html, but adding through the DOM gets a bit odd. if ($.browser.safari) this._element.css('margin-top', '7px'); // insert the element $('#torrent_list').append(this._element); this.initializeTorrentFilesInspectorGroup(data.files.length); for (var i = 0; i < data.files.length; i++) { var file = data.files[i]; file.index = i; file.torrent = this; file.priority = data.priorities[i]; file.wanted = data.wanted[i]; var torrentFile = new TorrentFile(file); this._files.push(torrentFile); this._fileList.append( torrentFile.element().addClass(i % 2 ? 'even' : 'odd').addClass('inspector_torrent_file_list_entry') ); } // Update all the labels etc this.refresh(data); }, initializeTorrentFilesInspectorGroup: function(length) { this._files = []; this._fileList = $('