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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
|
function show_peers (TorrentID, Page) {
if (Page > 0) {
ajax.get('torrents.php?action=peerlist&page=' + Page + '&torrentid=' + TorrentID, function(response) {
$('#peers_' + TorrentID).gshow().raw().innerHTML = response;
});
} else {
if ($('#peers_' + TorrentID).raw().innerHTML === '') {
$('#peers_' + TorrentID).gshow().raw().innerHTML = '<h4>Loading...</h4>';
ajax.get('torrents.php?action=peerlist&torrentid=' + TorrentID, function(response) {
$('#peers_' + TorrentID).gshow().raw().innerHTML = response;
});
} else {
$('#peers_' + TorrentID).gtoggle();
}
}
$('#snatches_' + TorrentID).ghide();
$('#downloads_' + TorrentID).ghide();
$('#files_' + TorrentID).ghide();
$('#reported_' + TorrentID).ghide();
}
function show_snatches (TorrentID, Page) {
if (Page > 0) {
ajax.get('torrents.php?action=snatchlist&page=' + Page + '&torrentid=' + TorrentID, function(response) {
$('#snatches_' + TorrentID).gshow().raw().innerHTML = response;
});
} else {
if ($('#snatches_' + TorrentID).raw().innerHTML === '') {
$('#snatches_' + TorrentID).gshow().raw().innerHTML = '<h4>Loading...</h4>';
ajax.get('torrents.php?action=snatchlist&torrentid=' + TorrentID, function(response) {
$('#snatches_' + TorrentID).gshow().raw().innerHTML = response;
});
} else {
$('#snatches_' + TorrentID).gtoggle();
}
}
$('#peers_' + TorrentID).ghide();
$('#downloads_' + TorrentID).ghide();
$('#files_' + TorrentID).ghide();
$('#reported_' + TorrentID).ghide();
}
function show_downloads (TorrentID, Page) {
if (Page > 0) {
ajax.get('torrents.php?action=downloadlist&page=' + Page + '&torrentid=' + TorrentID, function(response) {
$('#downloads_' + TorrentID).gshow().raw().innerHTML = response;
});
} else {
if ($('#downloads_' + TorrentID).raw().innerHTML === '') {
$('#downloads_' + TorrentID).gshow().raw().innerHTML = '<h4>Loading...</h4>';
ajax.get('torrents.php?action=downloadlist&torrentid=' + TorrentID, function(response) {
$('#downloads_' + TorrentID).raw().innerHTML = response;
});
} else {
$('#downloads_' + TorrentID).gtoggle();
}
}
$('#peers_' + TorrentID).ghide();
$('#snatches_' + TorrentID).ghide();
$('#files_' + TorrentID).ghide();
$('#reported_' + TorrentID).ghide();
}
function show_files(TorrentID) {
$('#files_' + TorrentID).gtoggle();
$('#peers_' + TorrentID).ghide();
$('#snatches_' + TorrentID).ghide();
$('#downloads_' + TorrentID).ghide();
$('#reported_' + TorrentID).ghide();
}
function show_reported(TorrentID) {
$('#files_' + TorrentID).ghide();
$('#peers_' + TorrentID).ghide();
$('#snatches_' + TorrentID).ghide();
$('#downloads_' + TorrentID).ghide();
$('#reported_' + TorrentID).gtoggle();
}
function add_tag(tag) {
if ($('#tags').raw().value == "") {
$('#tags').raw().value = tag;
} else {
$('#tags').raw().value = $('#tags').raw().value + ", " + tag;
}
}
function toggle_group(groupid, link, event) {
var showRow = true;
var clickedRow = link;
while (clickedRow.nodeName != 'TR') {
clickedRow = clickedRow.parentNode;
}
var group_rows = clickedRow.parentNode.children;
var showing = $(clickedRow).nextElementSibling().has_class('hidden');
var allGroups = (event.ctrlKey || event.metaKey); // detect ctrl or cmd
// for dealing with Mac OS X
// http://stackoverflow.com/a/3922353
var allGroupsMac = (
event.keyCode == 91 // WebKit (left apple)
|| event.keyCode == 93 // WebKit (right apple)
|| event.keyCode == 224 // Firefox
|| event.keyCode == 17 // Opera
) ? true : null;
for (var i = 0; i < group_rows.length; i++) {
var row = $(group_rows[i]);
if (row.has_class('colhead_dark')) {
continue;
}
if (row.has_class('colhead')) {
continue;
}
if (row.has_class('torrent')) {
continue; // Prevents non-grouped torrents from disappearing when collapsing all groups
}
var relevantRow = row.has_class('group') ? $(group_rows[i + 1]) : row;
if (allGroups || allGroupsMac || relevantRow.has_class('groupid_' + groupid)) {
row = $(group_rows[i]); // idk why we need this :S
if (row.has_class('group')) {
var section;
if (location.pathname.search('/artist.php$') !== -1) {
section = 'in this release type.';
} else {
section = 'on this page.';
}
var tooltip = showing
? 'Collapse this group. Hold [Command] <em>(Mac)</em> or [Ctrl] <em>(PC)</em> while clicking to collapse all groups '+section
: 'Expand this group. Hold [Command] <em>(Mac)</em> or [Ctrl] <em>(PC)</em> while clicking to expand all groups '+section;
$('a.show_torrents_link', row).updateTooltip(tooltip);
$('a.show_torrents_link', row).raw().parentNode.className = (showing) ? 'hide_torrents' : 'show_torrents';
} else {
if (showing) {
// show the row depending on whether the edition it's in is collapsed or not
if (row.has_class('edition')) {
row.gshow();
showRow = ($('a', row.raw()).raw().innerHTML != '+');
} else {
if (showRow) {
row.gshow();
} else {
row.ghide();
}
}
} else {
row.ghide();
}
}
}
}
if (event.preventDefault) {
event.preventDefault();
} else {
// for IE < 9 support
event.returnValue = false;
}
}
function toggle_edition(groupid, editionid, lnk, event) {
var clickedRow = lnk;
while (clickedRow.nodeName != 'TR') {
clickedRow = clickedRow.parentNode;
}
//var showing = has_class(nextElementSibling(clickedRow), 'hidden');
var showing = $(clickedRow).nextElementSibling().has_class('hidden');
var allEditions = (event.ctrlKey || event.metaKey); // detect ctrl and cmd
// for dealing with Mac OS X
// http://stackoverflow.com/a/3922353
var allEditionsMac = (
event.keyCode == 91 // WebKit (left apple)
|| event.keyCode == 93 // WebKit (right apple)
|| event.keyCode == 224 // Firefox
|| event.keyCode == 17 // Opera
) ? true : null;
var group_rows = $('tr.groupid_' + groupid);
for (var i = 0; i < group_rows.results(); i++) {
var row = $(group_rows.raw(i));
if (row.has_class('edition') && (allEditions || row.raw(0) == clickedRow)) {
var tooltip = showing
? 'Collapse this edition. Hold [Command] <em>(Mac)</em> or [Ctrl] <em>(PC)</em> while clicking to collapse all editions in this torrent group.'
: 'Expand this edition. Hold [Command] <em>(Mac)</em> or [Ctrl] <em>(PC)</em> while clicking to expand all editions in this torrent group.';
$('a', row).raw().innerHTML = (showing) ? '−' : '+';
$('a', row).updateTooltip(tooltip);
continue;
}
if (allEditions || allEditionsMac || row.has_class('edition_' + editionid)) {
if (showing && !row.has_class('torrentdetails')) {
row.gshow();
} else {
row.ghide();
}
}
}
if (event.preventDefault) {
event.preventDefault();
} else {
// for IE < 9 support
event.returnValue = false;
}
}
function toggleTorrentSearch(mode) {
if (mode == 0) {
var link = $('#ft_toggle').raw();
$('#ft_container').gtoggle();
link.innerHTML = link.textContent == 'Hide' ? 'Show' : 'Hide';
}
if (mode == 'basic') {
$('.fti_advanced').disable();
$('.fti_basic').enable();
$('.ftr_advanced').ghide(true);
$('.ftr_basic').gshow();
$('#ft_advanced_link').gshow();
$('#ft_advanced_text').ghide();
$('#ft_basic_link').ghide();
$('#ft_basic_text').gshow();
$('#ft_type').raw().value = 'basic';
} else if (mode == 'advanced') {
$('.fti_advanced').enable();
$('.fti_basic').disable();
$('.ftr_advanced').gshow();
$('.ftr_basic').ghide();
$('#ft_advanced_link').ghide();
$('#ft_advanced_text').gshow();
$('#ft_basic_link').gshow();
$('#ft_basic_text').ghide();
$('#ft_type').raw().value = 'advanced';
}
return false;
}
var ArtistFieldCount = 1;
function AddArtistField() {
if (ArtistFieldCount >= 100) {
return;
}
var x = $('#AddArtists').raw();
x.appendChild(document.createElement("br"));
var ArtistField = document.createElement("input");
ArtistField.type = "text";
ArtistField.name = "aliasname[]";
ArtistField.size = "17";
x.appendChild(ArtistField);
x.appendChild(document.createTextNode(' '));
var Importance = document.createElement("select");
Importance.name = "importance[]";
Importance.innerHTML = '<option value="1">Main</option><option value="2">Guest</option><option value="4">Composer</option><option value="5">Conductor</option><option value="6">DJ / Compiler</option><option value="3">Remixer</option><option value="7">Producer</option>';
x.appendChild(Importance);
if ($("#artist").data("gazelle-autocomplete")) {
$(ArtistField).live('focus', function() {
$(ArtistField).autocomplete({
serviceUrl : 'artist.php?action=autocomplete'
});
});
}
ArtistFieldCount++;
}
var coverFieldCount = 0;
var hasCoverAddButton = false;
function addCoverField() {
if (coverFieldCount >= 100) {
return;
}
var x = $('#add_cover').raw();
x.appendChild(document.createElement("br"));
var field = document.createElement("input");
field.type = "text";
field.name = "image[]";
field.placeholder = "URL";
x.appendChild(field);
x.appendChild(document.createTextNode(' '));
var summary = document.createElement("input");
summary.type = "text";
summary.name = "summary[]";
summary.placeholder = "Summary";
x.appendChild(summary);
coverFieldCount++;
if (!hasCoverAddButton) {
x = $('#add_covers_form').raw();
field = document.createElement("input");
field.type = "submit";
field.value = "Add";
x.appendChild(field);
hasCoverAddButton = true;
}
}
function ToggleEditionRows() {
$('#edition_title').gtoggle();
$('#edition_label').gtoggle();
$('#edition_catalogue').gtoggle();
}
|