v0.9.0 & compiled

This commit is contained in:
Diego Rodríguez 2016-01-01 22:53:14 -05:00
parent e07685a273
commit 7b4402b2d7
4 changed files with 75 additions and 17 deletions

View file

@ -46,11 +46,11 @@
rtcConfig: rtcConfig
});
dbg = function(string, torrent, color) {
dbg = function(string, item, color) {
color = color != null ? color : '#333333';
if (window.localStorage.getItem('debug') != null) {
if ((torrent != null) && torrent.name) {
console.debug('%cβTorrent:torrent:' + torrent.name + ' (' + torrent.infoHash + ') %c' + string, 'color: #33C3F0', 'color: ' + color);
if ((item != null) && item.name) {
console.debug('%cβTorrent:' + (item.infoHash != null ? 'torrent ' : 'torrent ' + item._torrent.name + ':file ') + item.name + (item.infoHash != null ? ' (' + item.infoHash + ')' : '') + ' %c' + string, 'color: #33C3F0', 'color: ' + color);
return;
} else {
console.debug('%cβTorrent:client %c' + string, 'color: #33C3F0', 'color: ' + color);
@ -131,7 +131,7 @@
];
$scope.gridOptions = {
columnDefs: $scope.columns,
data: $scope.client.validTorrents,
data: $scope.client.torrents,
enableColumnResizing: true,
enableColumnMenus: false,
enableRowSelection: true,
@ -155,11 +155,19 @@
}
});
};
$scope.seedFile = function(file) {
if (file != null) {
dbg('Seeding file ' + file.name);
$scope.seedFiles = function(files) {
var name;
if (files != null) {
if (files.length === 1) {
dbg('Seeding file ' + files[0].name);
} else {
dbg('Seeding ' + files.length + ' files');
name = prompt('Please name your torrent', 'My Awesome Torrent') || 'My Awesome Torrent';
opts.name = name;
}
$scope.client.processing = true;
$scope.client.seed(file, opts, $scope.onSeed);
$scope.client.seed(files, opts, $scope.onSeed);
delete opts.name;
}
};
$scope.openTorrentFile = function(file) {
@ -183,11 +191,21 @@
}
};
$scope.destroyedTorrent = function(err) {
$scope.client.processing = false;
if (err) {
throw err;
}
dbg('Destroyed torrent');
dbg('Destroyed torrent', $scope.selectedTorrent);
$scope.selectedTorrent = null;
$scope.client.processing = false;
};
$scope.changePriority = function(file) {
if (file.priority === '-1') {
dbg('Deselected', file);
return file.deselect();
} else {
dbg('Selected ', file);
return file.select();
}
};
$scope.onTorrent = function(torrent, isSeed) {
torrent.safeTorrentFileURL = torrent.torrentFileURL;
@ -206,7 +224,9 @@
}
if (isSeed) {
dbg('Started seeding', torrent);
$scope.client.validTorrents.push(torrent);
if ($scope.client.validTorrents.indexOf(torrent) === -1) {
$scope.client.validTorrents.push(torrent);
}
if (!($scope.selectedTorrent != null)) {
$scope.selectedTorrent = torrent;
}

View file

@ -8,7 +8,7 @@
<meta name="keywords" content="βTorrent, btorrent, client, webtorrent, browser, torrent, stream, bittorrent">
<meta name="author" content="Diego Rodríguez Baquero - DiegoRBaquero">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://cdn.jsdelivr.net/g/webtorrent@0.63,momentjs@2.10,angularjs@1.4,angular.ui-grid@3.0,angular.ng-notify@0.7,angular.file-upload@10.1"></script>
<script src="https://cdn.jsdelivr.net/g/webtorrent@0.67.1,momentjs@2.10,angularjs@1.4,angular.ui-grid@3.0,angular.ng-notify@0.7,angular.file-upload@10.1"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/g/normalize@3.0,skeleton@2.0,angular.ng-notify@0.7(ng-notify.min.css)">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/fontawesome/4.5/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/angular.ui-grid/3.0.7/ui-grid.min.css">
@ -16,7 +16,7 @@
</head>
<body ng-controller="bTorrentCtrl" ng-cloak="">
<header>
<h1>βTorrent<span class="version"> v0.8.1</span></h1>
<h1>βTorrent<span class="version"> v0.9.0</span></h1>
</header>
<div class="container">
<div class="row">
@ -30,13 +30,17 @@
<button type="file" ngf-select="openTorrentFile($file)" class="button-primary"><i class="fa fa-folder-open"></i> Open torrent file</button>
</div>
<div class="three columns u-pull-right">
<button type="file" ngf-select="seedFile($file)" class="u-pull-right button-primary"><i class="fa fa-upload"></i> Seed a file</button>
<button ngf-select="seedFiles($files)" multiple="" class="u-pull-right button-primary"><i class="fa fa-upload"></i> Seed files</button>
</div>
</div>
<div ui-grid="gridOptions" ui-grid-resize-columns ui-grid-selection class="row grid"></div>
<div ng-if="selectedTorrent" class="row">
<div style="overflow: auto" class="six columns">
<h5>{{selectedTorrent.name}}</h5>
<h5>{{selectedTorrent.name}}
<button ng-if="!selectedTorrent.swarm.paused" ng-click="selectedTorrent.pause()"><i class="fa fa-pause"></i> Pause</button>
<button ng-if="selectedTorrent.swarm.paused" ng-click="selectedTorrent.resume()"><i class="fa fa-play"></i> Resume</button>
<button ng-click="client.remove(selectedTorrent.infoHash, destroyedTorrent)" class="button-danger"><i class="fa fa-times"></i> Remove</button>
</h5>
<h6>Share</h6>
<ul>
<li><a ng-href="#{{selectedTorrent.infoHash}}" target="_blank">βTorrent</a></li>
@ -52,13 +56,21 @@
<tr>
<th>Name</th>
<th>Size</th>
<th>Priority</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="file in selectedTorrent.files" class="files">
<td ng-hide="file.done">{{file.name}}</td>
<td ng-show="file.done"><a ng-href="{{file.url}}" download="{{file.name}}" target="_self" ng-show="file.done">{{file.name}}</a></td>
<td> {{file.length | pbytes}}</td>
<td>{{file.length | pbytes}}</td>
<td>
<select name="{{file.name}}Priority" ng-model="file.priority" ng-init="file.priority = &quot;0&quot;" ng-change="changePriority(file)" class="no-margin">
<option value="1">High Priority</option>
<option value="0" selected="">Low Priority</option>
<option value="-1">Don't download</option>
</select>
</td>
</tr>
</tbody>
</table>

View file

@ -33,6 +33,9 @@ footer {
.download-button {
margin-left: 10px; }
.no-margin {
margin: 0px; }
.spinner {
position: absolute;
top: 30%;
@ -51,3 +54,26 @@ footer {
margin-top: -100px;
font-size: 200px;
transform: translateY(-50%); }
.button.button-danger,
button.button-danger,
input[type="submit"].button-danger,
input[type="reset"].button-danger,
input[type="button"].button-danger {
color: #FFF;
background-color: #D9534F;
border-color: #D9534F; }
.button.button-danger:hover,
button.button-danger:hover,
input[type="submit"].button-danger:hover,
input[type="reset"].button-danger:hover,
input[type="button"].button-danger:hover,
.button.button-danger:focus,
button.button-danger:focus,
input[type="submit"].button-danger:focus,
input[type="reset"].button-danger:focus,
input[type="button"].button-danger:focus {
color: #FFF;
background-color: #C43E3A;
border-color: #C43E3A; }

View file

@ -8,7 +8,7 @@ html(ng-app='bTorrent', lang='en')
meta(name='keywords', content='βTorrent, btorrent, client, webtorrent, browser, torrent, stream, bittorrent')
meta(name='author', content='Diego Rodríguez Baquero - DiegoRBaquero')
meta(name='viewport', content='width=device-width, initial-scale=1')
script(src='https://cdn.jsdelivr.net/g/webtorrent@0.66,momentjs@2.10,angularjs@1.4,angular.ui-grid@3.0,angular.ng-notify@0.7,angular.file-upload@10.1')
script(src='https://cdn.jsdelivr.net/g/webtorrent@0.67.1,momentjs@2.10,angularjs@1.4,angular.ui-grid@3.0,angular.ng-notify@0.7,angular.file-upload@10.1')
link(rel='stylesheet', href='https://cdn.jsdelivr.net/g/normalize@3.0,skeleton@2.0,angular.ng-notify@0.7(ng-notify.min.css)')
link(rel='stylesheet', href='https://cdn.jsdelivr.net/fontawesome/4.5/css/font-awesome.min.css')
link(rel='stylesheet', href='https://cdn.jsdelivr.net/angular.ui-grid/3.0.7/ui-grid.min.css')