v0.9.2 - Fixed data binding, compiled

This commit is contained in:
Diego Rodríguez 2016-01-02 01:06:46 -05:00
parent 9f9ba0b386
commit 9c09ad40e1
4 changed files with 18 additions and 33 deletions

View file

@ -1,6 +1,6 @@
// Generated by CoffeeScript 1.10.0
(function() {
var app, client, dbg, er, opts, rtcConfig, trackers;
var app, client, dbg, debug, er, opts, rtcConfig, trackers;
trackers = [['wss://tracker.btorrent.xyz'], ['wss://tracker.webtorrent.io']];
@ -16,18 +16,6 @@
}, {
"url": "stun:stun.l.google.com:19302",
"urls": "stun:stun.l.google.com:19302"
}, {
"url": "stun:stun1.l.google.com:19302",
"urls": "stun:stun1.l.google.com:19302"
}, {
"url": "stun:stun2.l.google.com:19302",
"urls": "stun:stun2.l.google.com:19302"
}, {
"url": "stun:stun3.l.google.com:19302",
"urls": "stun:stun3.l.google.com:19302"
}, {
"url": "stun:stun4.l.google.com:19302",
"urls": "stun:stun4.l.google.com:19302"
}, {
"url": "turn:global.turn.twilio.com:3478?transport=udp",
"urls": "turn:global.turn.twilio.com:3478?transport=udp",
@ -42,13 +30,11 @@
]
};
client = new WebTorrent({
rtcConfig: rtcConfig
});
debug = window.localStorage.getItem('debug') != null;
dbg = function(string, item, color) {
color = color != null ? color : '#333333';
if (window.localStorage.getItem('debug') != null) {
if (debug) {
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;
@ -63,6 +49,10 @@
return dbg(err, torrent, '#FF0000');
};
client = new WebTorrent({
rtcConfig: rtcConfig
});
app = angular.module('bTorrent', ['ui.grid', 'ui.grid.resizeColumns', 'ui.grid.selection', 'ngFileUpload', 'ngNotify'], [
'$compileProvider', '$locationProvider', function($compileProvider, $locationProvider) {
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|magnet|blob|javascript):/);
@ -78,7 +68,6 @@
var updateAll;
$scope.client = client;
$scope.seedIt = true;
$scope.client.validTorrents = [];
$scope.columns = [
{
field: 'name',
@ -108,7 +97,7 @@
field: 'timeRemaining',
displayName: 'ETA',
cellFilter: 'humanTime',
width: '150'
width: '140'
}, {
field: 'uploaded',
displayName: 'Uploaded',
@ -211,7 +200,6 @@
torrent.safeTorrentFileURL = torrent.torrentFileURL;
torrent.fileName = torrent.name + '.torrent';
if (!isSeed) {
$scope.client.validTorrents.push(torrent);
if (!($scope.selectedTorrent != null)) {
$scope.selectedTorrent = torrent;
}
@ -224,9 +212,6 @@
}
if (isSeed) {
dbg('Started seeding', torrent);
if ($scope.client.validTorrents.indexOf(torrent) === -1) {
$scope.client.validTorrents.push(torrent);
}
if (!($scope.selectedTorrent != null)) {
$scope.selectedTorrent = torrent;
}
@ -234,11 +219,11 @@
}
file.url = url;
if (!isSeed) {
dbg('Finished downloading file ' + file.name, torrent);
dbg('Done ', file);
}
});
if (!isSeed) {
dbg('Received file ' + file.name + ' metadata', torrent);
dbg('Received metadata', file);
}
});
torrent.on('download', function(chunkSize) {
@ -268,8 +253,10 @@
setTimeout(function() {
dbg('Adding ' + $location.hash());
return $scope.client.add($location.hash(), $scope.onTorrent);
}, 500);
}, 0);
return;
}
return dbg('Ready');
}
]);
@ -287,13 +274,11 @@
if (isNaN(num)) {
return '';
}
exponent = void 0;
unit = void 0;
units = ['B', 'kB', 'MB', 'GB', 'TB'];
if (num < 1) {
return (speed ? '' : '0 B');
}
exponent = Math.min(Math.floor(Math.log(num) / Math.log(1000)), 8);
exponent = Math.min(Math.floor(Math.log(num) / 6.907755278982137), 8);
num = (num / Math.pow(1000, exponent)).toFixed(1) * 1;
unit = units[exponent];
return num + ' ' + unit + (speed ? '/s' : '');
@ -306,7 +291,7 @@
if (millis < 1000) {
return '';
}
remaining = moment.duration(millis / 1000, 'seconds').humanize();
remaining = moment.duration(millis).humanize();
return remaining[0].toUpperCase() + remaining.substr(1);
};
});

View file

@ -16,7 +16,7 @@
</head>
<body ng-controller="bTorrentCtrl" ng-cloak="">
<header>
<h1>βTorrent<span class="version"> v0.9.0</span></h1>
<h1>βTorrent<span class="version"> v0.9.2</span></h1>
</header>
<div class="container">
<div class="row">

View file

@ -83,7 +83,7 @@ app.controller 'bTorrentCtrl', ['$scope','$http','$log','$location', 'ngNotify',
$scope.$apply()
return
#setInterval updateAll, 500
setInterval updateAll, 500
$scope.gridOptions.onRegisterApi = ( gridApi ) ->
$scope.gridApi = gridApi

View file

@ -17,7 +17,7 @@ html(ng-app='bTorrent', lang='en')
header
h1
| βTorrent
span.version v0.9.1
span.version v0.9.2
.container
.row
.four.columns