Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: README.md features/step_definitions/torrent_info_steps.rb features/support/testapp.rb features/torrent_info.feature index.html js/controllers/settings.js js/controllers/torrents.js js/helpers/filter_torrents_helpers.js js/helpers/link_helpers.js js/helpers/setting_helpers.js js/helpers/store_helpers.js js/models/torrent.js js/rpc.js js/transmission.js js/views/torrent.js spec/sort_torrents_helpers_spec.js spec/torrent_view_spec.js templates/torrents/show_info.mustache
- Loading branch information
Showing
6 changed files
with
365 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
var LinkHelpers = { | ||
activateLinks: function() { | ||
this.activateAddTorrentLink(); | ||
this.activateSettingsLink(); | ||
this.activateStatisticsLink(); | ||
this.activateTurtleModeLink(); | ||
this.activateCompactViewLink(); | ||
this.activateFilterAndSortLink(); | ||
}, | ||
|
||
activateAddTorrentLink: function() { | ||
var context = this; | ||
$('#add_a_torrent').click(function() { | ||
if(context.infoIsOpen()) { | ||
context.closeInfo(); | ||
} else { | ||
window.location.hash = '/torrents/new'; | ||
} | ||
return false; | ||
}); | ||
}, | ||
|
||
activateFilterAndSortLink: function() { | ||
var context = this; | ||
$('#activate_filters').click(function() { | ||
$('#filters').show(); | ||
$('#sorts').hide(); | ||
}); | ||
$('#activate_sorts').click(function() { | ||
$('#filters').hide(); | ||
$('#sorts').show(); | ||
}); | ||
}, | ||
|
||
activateTurtleModeLink: function() { | ||
var context = this, redirect_path = ''; | ||
$('#turtle_mode').click(function() { | ||
var form = $('#turtle_mode_form'); | ||
form.submit(); | ||
if($(this).hasClass('active')) { | ||
$(this).removeClass('active'); | ||
$(this).text('Enable Turtle Mode'); | ||
form.find('input:first').attr('value', 'true'); | ||
} else { | ||
$(this).addClass('active'); | ||
$(this).text('Disable Turtle Mode'); | ||
form.find('input:first').attr('value', 'false'); | ||
} | ||
/*if activateComapactViewLink.hasClass('active') { | ||
redirect_path = '#/torrents?view=compact'; | ||
}*/ | ||
redirect_path = '#/torrents?view=compact'; | ||
context.redirect(redirect_path) | ||
return false; | ||
}); | ||
}, | ||
|
||
activateCompactViewLink: function() { | ||
var context = this, redirect_path = ''; | ||
$('#compact_view').click(function() { | ||
if($(this).hasClass('active')) { | ||
$(this).removeClass('active'); | ||
$(this).text('Enable Compact View'); | ||
redirect_path = '#/torrents?view=normal'; | ||
} else { | ||
$(this).addClass('active'); | ||
$(this).text('Disable Compact View'); | ||
redirect_path = '#/torrents?view=compact'; | ||
} | ||
context.redirect(redirect_path); | ||
return false; | ||
}); | ||
}, | ||
|
||
activateSettingsLink: function() { | ||
var context = this; | ||
$('#settings').click(function() { | ||
if(context.infoIsOpen()) { | ||
context.closeInfo(); | ||
} else { | ||
context.redirect('#/settings'); | ||
} | ||
return false; | ||
}); | ||
}, | ||
|
||
activateStatisticsLink: function() { | ||
var context = this; | ||
$('#statistics').click(function() { | ||
if(context.infoIsOpen()) { | ||
context.closeInfo(); | ||
} else { | ||
context.redirect('#/statistics'); | ||
} | ||
return false; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
Torrent = function(attributes) { | ||
var torrent = {}; | ||
|
||
torrent['fields'] = [ | ||
'id', 'name', 'status', 'totalSize', 'sizeWhenDone', 'haveValid', 'leftUntilDone', | ||
'eta', 'uploadedEver', 'uploadRatio', 'rateDownload', 'rateUpload', 'metadataPercentComplete', | ||
'addedDate' | ||
]; | ||
torrent['info_fields'] = [ | ||
'downloadDir', 'creator', 'hashString', 'comment', 'isPrivate', 'downloadedEver', | ||
'haveString', 'errorString', 'peersGettingFromUs', 'peersSendingToUs', 'files', | ||
'pieceCount', 'pieceSize', 'trackerStats', 'peers' | ||
]; | ||
$.each(torrent.fields, function() { | ||
torrent[this] = attributes[this]; | ||
}); | ||
$.each(torrent.info_fields, function() { | ||
torrent[this] = attributes[this]; | ||
}); | ||
|
||
$.each(['totalSize', 'downloadedEver', 'uploadedEver', 'pieceSize'], function() { | ||
var attr = this; | ||
torrent[attr + 'String'] = function() { | ||
return Math.formatBytes(torrent[attr]); | ||
} | ||
}); | ||
|
||
torrent.secure = function() { | ||
return (torrent.isPrivate) ? 'Private Torrent' : 'Public Torrent'; | ||
}; | ||
torrent.isActive = function() { | ||
return (torrent.status & (torrent.stati['downloading'] | torrent.stati['seeding'])) > 0; | ||
}; | ||
torrent.isDoneDownloading = function() { | ||
return torrent.status === torrent.stati['seeding'] || torrent.leftUntilDone === 0; | ||
}; | ||
torrent.needsMetaData = function() { | ||
return torrent.metadataPercentComplete < 1 | ||
}; | ||
torrent.percentDone = function() { | ||
return Math.formatPercent(torrent.sizeWhenDone, torrent.leftUntilDone); | ||
}; | ||
torrent.progressDetails = function() { | ||
var progressDetails; | ||
if(torrent.needsMetaData()) { | ||
progressDetails = torrent.metaDataProgress(); | ||
} else if(!torrent.isDoneDownloading()) { | ||
progressDetails = torrent.downloadingProgress(); | ||
if(torrent.isActive()) { | ||
progressDetails += ' - ' + torrent.etaString(); | ||
} | ||
} else { | ||
progressDetails = torrent.uploadingProgress(); | ||
} | ||
|
||
return progressDetails; | ||
}; | ||
torrent.downloadingProgress = function() { | ||
var formattedSizeDownloaded = Math.formatBytes(torrent.sizeWhenDone - torrent.leftUntilDone); | ||
var formattedSizeWhenDone = Math.formatBytes(torrent.sizeWhenDone); | ||
|
||
return (formattedSizeDownloaded + " of " + formattedSizeWhenDone + " (" + torrent.percentDone() + "%)"); | ||
}; | ||
torrent.uploadingProgress = function() { | ||
var formattedSizeWhenDone = Math.formatBytes(torrent.sizeWhenDone); | ||
var formattedUploadedEver = Math.formatBytes(torrent.uploadedEver); | ||
|
||
var uploadingProgress = formattedSizeWhenDone + ", uploaded " + formattedUploadedEver; | ||
return uploadingProgress + " (Ratio: " + torrent.uploadRatio + ")"; | ||
}; | ||
torrent.metaDataProgress = function() { | ||
var percentRetrieved = (Math.floor(torrent.metadataPercentComplete * 10000) / 100).toFixed(1); | ||
return "Magnetized transfer - retrieving metadata (" + percentRetrieved + "%)"; | ||
}; | ||
torrent.progressBar = function() { | ||
var status, progressBar; | ||
|
||
if(torrent.isActive() && torrent.needsMetaData()) { | ||
status = 'meta'; | ||
progressBar = $("<div></div>").progressbar({value: 100}).html(); | ||
} else if(torrent.isActive() && !torrent.isDoneDownloading()) { | ||
status = 'downloading'; | ||
progressBar = $("<div></div>").progressbar({value: torrent.percentDone()}).html(); | ||
} else if(torrent.isActive() && torrent.isDoneDownloading()) { | ||
status = 'uploading'; | ||
progressBar = $("<div></div>").progressbar({value: torrent.percentDone()}).html(); | ||
} else { | ||
status = 'paused'; | ||
progressBar = $("<div></div>").progressbar({value: torrent.percentDone()}).html(); | ||
} | ||
|
||
return progressBar.replace(/ui-widget-header/, 'ui-widget-header-' + status); | ||
}; | ||
torrent.etaString = function() { | ||
if(torrent.eta < 0) { | ||
return "remaining time unknown"; | ||
} else { | ||
return Math.formatSeconds(torrent.eta) + ' ' + 'remaining'; | ||
} | ||
}; | ||
torrent.statusStringLocalized = function(status) { | ||
var localized_stati = {}; | ||
|
||
localized_stati[torrent.stati['waiting_to_check']] = 'Waiting to verify'; | ||
localized_stati[torrent.stati['checking']] = 'Verifying local data'; | ||
localized_stati[torrent.stati['downloading']] = 'Downloading'; | ||
localized_stati[torrent.stati['seeding']] = 'Seeding'; | ||
localized_stati[torrent.stati['paused']] = 'Paused'; | ||
localized_stati[torrent.stati['active']] = 'Activity'; | ||
|
||
return localized_stati[this['status']] ? localized_stati[this['status']] : 'error'; | ||
}; | ||
torrent.statusString = function() { | ||
var currentStatus = torrent.statusStringLocalized(torrent.status); | ||
if(torrent.isActive()) { | ||
currentStatus += ' - ' + torrent.downAndUploadRateString(torrent.rateDownload, torrent.rateUpload); | ||
} | ||
return currentStatus; | ||
}; | ||
torrent.statusWord = function() { | ||
for(var i in torrent.stati) { | ||
if(torrent.stati[i] == torrent.status) { | ||
return i; | ||
} | ||
} | ||
}; | ||
torrent.downAndUploadRateString = function(downloadRate, uploadRate) { | ||
return 'DL: ' + (downloadRate / 1000).toFixed(1) + ' KB/s, UL: ' + (uploadRate / 1000).toFixed(1) + ' KB/s'; | ||
}; | ||
torrent.activity = function() { | ||
return torrent.rateDownload + torrent.rateUpload; | ||
}; | ||
torrent['stati'] = { | ||
'waiting_to_check': 1, | ||
'checking': 2, | ||
'downloading': 4, | ||
'seeding': 8, | ||
'paused': 16 | ||
// 'active': 32 | ||
}; | ||
|
||
return torrent; | ||
}; |
Oops, something went wrong.