95 lines
3.8 KiB
JavaScript
95 lines
3.8 KiB
JavaScript
LogContext = function(){};
|
|
|
|
LogContext.prototype.id = "";
|
|
|
|
LogContext.prototype.init = function(){
|
|
$('#link_container tr').html(
|
|
'<td>' +
|
|
'initializing' +
|
|
'</td>' +
|
|
'<td>' + '</td>' +
|
|
'<td>' +
|
|
'</td>');
|
|
};
|
|
|
|
LogContext.prototype.log_file_add = function(torrent){
|
|
var progress = (100 * torrent.downloaded / torrent.parsedTorrent.length).toFixed(1)
|
|
$('#link_container tr').html(
|
|
'<tr id="' + torrent.infoHash + '">' +
|
|
'<td>' +
|
|
progress + '%' +
|
|
'</td>' +
|
|
'<td>' +
|
|
'speed: ' + torrent.swarm.downloadSpeed() + '/s' +
|
|
'</td>' +
|
|
'<td>' +
|
|
'<a href="http://www.slingit.org/#!start;hash.' + torrent.infoHash + '"' +
|
|
' target="_blank">' +
|
|
'direct link: ' +
|
|
'</a>' +
|
|
'</td>' +
|
|
'<td>' +
|
|
'<input type="text" value="http://www.slingit.org/#!start;hash.' + torrent.infoHash + '" onClick="this.setSelectionRange(0, this.value.length)"/>' +
|
|
' ' +
|
|
'</td>' +
|
|
'<td>' +
|
|
'<a class="twitter-share-button" href="https://twitter.com/share" data-via="slingtweet" data-url="http://www.slingit.org/#!start;hash.' + torrent.infoHash + '">Tweet</a>' +
|
|
'</td>' +
|
|
'</tr>');
|
|
$.getScript("http://platform.twitter.com/widgets.js");
|
|
};
|
|
|
|
LogContext.prototype.log_file_upd = function(torrent){
|
|
if($('#'+torrent.infoHash).length){
|
|
var progress = (100 * torrent.downloaded / torrent.parsedTorrent.length).toFixed(1)
|
|
$('#'+torrent.infoHash).html(
|
|
'<td>' +
|
|
progress + '%' +
|
|
'</td>' +
|
|
'<td>' +
|
|
'speed: ' + torrent.swarm.downloadSpeed() + '/s / ' + torrent.swarm.uploadSpeed() + '/s' +
|
|
'</td>' +
|
|
'<td>' +
|
|
'<a href="http://www.slingit.org/#!start;hash.' + torrent.infoHash + '"' +
|
|
' target="_blank">' +
|
|
'direct link: ' +
|
|
'</a>' +
|
|
'</td>' +
|
|
'<td>' +
|
|
'<input type="text" value="http://www.slingit.org/#!start;hash.' + torrent.infoHash + '" onClick="this.setSelectionRange(0, this.value.length)"/>' +
|
|
' ' +
|
|
'</td>' +
|
|
'<td>' +
|
|
'<a class="twitter-share-button" href="https://twitter.com/share" data-via="slingtweet" data-url="http://www.slingit.org/#!start;hash.' + torrent.infoHash + '">Tweet</a>' +
|
|
'</td>')
|
|
} else {
|
|
this.log_file_add(torrent);
|
|
}
|
|
};
|
|
|
|
LogContext.prototype.log_file_done = function(torrent,url,file){
|
|
this.log_file_upd(torrent);
|
|
$('#link_container tr').html(
|
|
'<td>' +
|
|
'100%' +
|
|
'</td>' +
|
|
'<td>' +
|
|
'<a href="' + url + '"' +
|
|
' download="' + file.name + '">' +
|
|
'Download ' + file.name +
|
|
'</a>' +
|
|
'</td>' +
|
|
'<td>' +
|
|
'<a href="http://www.slingit.org/#!start;hash.' + torrent.infoHash + '"' +
|
|
' target="_blank">' +
|
|
'direct link: ' +
|
|
'</a>' +
|
|
'</td>' +
|
|
'<td>' +
|
|
'<input type="text" value="http://www.slingit.org/#!start;hash.' + torrent.infoHash + '" onClick="this.setSelectionRange(0, this.value.length)"/>' +
|
|
' ' +
|
|
'</td>' +
|
|
'<td>' +
|
|
'<a class="twitter-share-button" href="https://twitter.com/share" data-via="slingtweet" data-url="http://www.slingit.org/#!start;hash.' + torrent.infoHash + '">Tweet</a>' +
|
|
'</td>');
|
|
}; |