/
torrents.js
56 lines (45 loc) · 1.46 KB
/
torrents.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
kettu.TorrentsView = function(torrent, context) {
var view = torrent;
view.pauseAndActivateButton = function() {
var torrent = kettu.Torrent(view);
var options = torrent.isActive() ? ['torrent-stop', 'Pause'] : ['torrent-start', 'Resume'];
this.cachePartial('templates/torrents/pause_and_activate_button.mustache', 'pause_and_activate_button', context);
return context.mustache(context.cache('pause_and_activate_button'), {
'id': torrent.id,
'method': options[0],
'button': options[1],
'css_class': torrent.statusWord(),
'isMobile': !!kettu.app.mobile
});
};
view.firstTracker = function() {
if(view.trackerStats && view.trackerStats[0]) {
return view.trackerStats[0].host;
} else {
return '';
}
};
view.errorClass = function() {
return view.hasError() ? ' error' : '';
};
view.isMobile = function() {
return !!kettu.app.mobile;
};
view.paused = function() {
return view.statusWord() === 'paused' || view.statusWord() === 'finished';
};
view.mobileError = function() {
return (view.isMobile() && view.hasError()) ? 'mobile-error' : '';
};
view.showPriorityArrow = function() {
return torrent.bandwidthPriority !== 0;
};
view.priorityArrow = function() {
return torrent.bandwidthPriority === 1 ? 'up' : 'down';
};
view.cachePartial = context.cachePartial;
if(kettu.app.mobile) {
view.name = context.shorten(view.name, 32);
}
return view;
};