Gazelle/static/functions/browse.js

271 lines
8.5 KiB
JavaScript
Raw Normal View History

2011-03-28 14:21:28 +00:00
function show_peers (TorrentID, Page) {
2013-04-30 18:18:07 +00:00
if (Page > 0) {
2013-05-04 08:00:48 +00:00
ajax.get('torrents.php?action=peerlist&page='+Page+'&torrentid=' + TorrentID,function(response) {
2013-06-17 08:01:02 +00:00
$('#peers_' + TorrentID).gshow().raw().innerHTML=response;
2011-03-28 14:21:28 +00:00
});
} else {
if ($('#peers_' + TorrentID).raw().innerHTML === '') {
2013-06-17 08:01:02 +00:00
$('#peers_' + TorrentID).gshow().raw().innerHTML = '<h4>Loading...</h4>';
2013-05-04 08:00:48 +00:00
ajax.get('torrents.php?action=peerlist&torrentid=' + TorrentID,function(response) {
2013-06-17 08:01:02 +00:00
$('#peers_' + TorrentID).gshow().raw().innerHTML=response;
2011-03-28 14:21:28 +00:00
});
} else {
2013-06-17 08:01:02 +00:00
$('#peers_' + TorrentID).gtoggle();
2011-03-28 14:21:28 +00:00
}
}
2013-06-17 08:01:02 +00:00
$('#snatches_' + TorrentID).ghide();
$('#downloads_' + TorrentID).ghide();
$('#files_' + TorrentID).ghide();
$('#reported_' + TorrentID).ghide();
2011-03-28 14:21:28 +00:00
}
2013-05-04 08:00:48 +00:00
function show_snatches (TorrentID, Page) {
2013-04-30 18:18:07 +00:00
if (Page > 0) {
2013-05-04 08:00:48 +00:00
ajax.get('torrents.php?action=snatchlist&page='+Page+'&torrentid=' + TorrentID,function(response) {
2013-06-17 08:01:02 +00:00
$('#snatches_' + TorrentID).gshow().raw().innerHTML=response;
2011-03-28 14:21:28 +00:00
});
} else {
if ($('#snatches_' + TorrentID).raw().innerHTML === '') {
2013-06-17 08:01:02 +00:00
$('#snatches_' + TorrentID).gshow().raw().innerHTML = '<h4>Loading...</h4>';
2013-05-04 08:00:48 +00:00
ajax.get('torrents.php?action=snatchlist&torrentid=' + TorrentID,function(response) {
2013-06-17 08:01:02 +00:00
$('#snatches_' + TorrentID).gshow().raw().innerHTML=response;
2011-03-28 14:21:28 +00:00
});
} else {
2013-06-17 08:01:02 +00:00
$('#snatches_' + TorrentID).gtoggle();
2011-03-28 14:21:28 +00:00
}
}
2013-06-17 08:01:02 +00:00
$('#peers_' + TorrentID).ghide();
$('#downloads_' + TorrentID).ghide();
$('#files_' + TorrentID).ghide();
$('#reported_' + TorrentID).ghide();
2011-03-28 14:21:28 +00:00
}
2013-05-04 08:00:48 +00:00
function show_downloads (TorrentID, Page) {
2013-04-30 18:18:07 +00:00
if (Page > 0) {
2013-05-04 08:00:48 +00:00
ajax.get('torrents.php?action=downloadlist&page='+Page+'&torrentid=' + TorrentID,function(response) {
2013-06-17 08:01:02 +00:00
$('#downloads_' + TorrentID).gshow().raw().innerHTML=response;
2011-03-28 14:21:28 +00:00
});
} else {
if ($('#downloads_' + TorrentID).raw().innerHTML === '') {
2013-06-17 08:01:02 +00:00
$('#downloads_' + TorrentID).gshow().raw().innerHTML = '<h4>Loading...</h4>';
2013-05-04 08:00:48 +00:00
ajax.get('torrents.php?action=downloadlist&torrentid=' + TorrentID,function(response) {
2011-03-28 14:21:28 +00:00
$('#downloads_' + TorrentID).raw().innerHTML=response;
});
} else {
2013-06-17 08:01:02 +00:00
$('#downloads_' + TorrentID).gtoggle();
2011-03-28 14:21:28 +00:00
}
}
2013-06-17 08:01:02 +00:00
$('#peers_' + TorrentID).ghide();
$('#snatches_' + TorrentID).ghide();
$('#files_' + TorrentID).ghide();
$('#reported_' + TorrentID).ghide();
2011-03-28 14:21:28 +00:00
}
2013-05-04 08:00:48 +00:00
function show_files(TorrentID) {
2013-06-17 08:01:02 +00:00
$('#files_' + TorrentID).gtoggle();
$('#peers_' + TorrentID).ghide();
$('#snatches_' + TorrentID).ghide();
$('#downloads_' + TorrentID).ghide();
$('#reported_' + TorrentID).ghide();
2011-03-28 14:21:28 +00:00
}
2013-05-04 08:00:48 +00:00
function show_reported(TorrentID) {
2013-06-17 08:01:02 +00:00
$('#files_' + TorrentID).ghide();
$('#peers_' + TorrentID).ghide();
$('#snatches_' + TorrentID).ghide();
$('#downloads_' + TorrentID).ghide();
$('#reported_' + TorrentID).gtoggle();
2011-03-28 14:21:28 +00:00
}
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 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;
for (var i = 0; i < group_rows.length; i++) {
var row = $(group_rows[i]);
2013-05-04 08:00:48 +00:00
if (row.has_class('colhead_dark')) {
continue;
}
if (row.has_class('colhead')) {
continue;
}
var relevantRow = row.has_class('group') ? $(group_rows[i+1]) : row;
2011-03-28 14:21:28 +00:00
if (allGroups || relevantRow.has_class('groupid_' + groupid)) {
row = $(group_rows[i]); // idk why we need this :S
2011-03-28 14:21:28 +00:00
if (row.has_class('group')) {
2012-10-06 08:00:19 +00:00
$('a.show_torrents_link', row.raw()).raw().title = (showing) ? 'Collapse this group. Hold "Ctrl" while clicking to collapse all groups/editions in this section.' : 'Expand this group. Hold "Ctrl" while clicking to expand all groups/editions in this section.';
$('a.show_torrents_link', row.raw()).raw().parentNode.className = (showing) ? 'hide_torrents' : 'show_torrents';
2011-03-28 14:21:28 +00:00
} else {
if (showing) {
// show the row depending on whether the edition it's in is collapsed or not
if (row.has_class('edition')) {
2013-06-17 08:01:02 +00:00
row.gshow();
2011-03-28 14:21:28 +00:00
showRow = ($('a', row.raw()).raw().innerHTML != '+');
} else {
if (showRow) {
2013-06-17 08:01:02 +00:00
row.gshow();
2011-03-28 14:21:28 +00:00
} else {
2013-06-17 08:01:02 +00:00
row.ghide();
2011-03-28 14:21:28 +00:00
}
}
} else {
2013-06-17 08:01:02 +00:00
row.ghide();
2011-03-28 14:21:28 +00:00
}
}
}
}
2013-05-04 08:00:48 +00:00
if (event.preventDefault) {
event.preventDefault();
} else {
event.returnValue = false;
}
2011-03-28 14:21:28 +00:00
}
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;
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)) {
2011-03-28 14:21:28 +00:00
$('a', row.raw()).raw().innerHTML = (showing) ? '&minus;' : '+';
2012-10-06 08:00:19 +00:00
$('a', row.raw()).raw().title = (showing) ? 'Collapse this edition. Hold "Ctrl" to collapse all editions in this torrent group.' : 'Expand this edition. Hold "Ctrl" to expand all editions in this torrent group.';
2011-03-28 14:21:28 +00:00
continue;
}
if (allEditions || row.has_class('edition_' + editionid)) {
if (showing && !row.has_class('torrentdetails')) {
2013-06-17 08:01:02 +00:00
row.gshow();
2011-03-28 14:21:28 +00:00
} else {
2013-06-17 08:01:02 +00:00
row.ghide();
2011-03-28 14:21:28 +00:00
}
}
}
2013-05-04 08:00:48 +00:00
if (event.preventDefault) {
event.preventDefault();
} else {
event.returnValue = false;
}
2011-03-28 14:21:28 +00:00
}
2013-02-23 08:00:22 +00:00
function toggleTorrentSearch(mode) {
if (mode == 0) {
var link = $('#ft_toggle').raw();
2013-06-17 08:01:02 +00:00
$('#ft_container').gtoggle();
2013-02-23 08:00:22 +00:00
link.innerHTML = link.textContent == 'Hide' ? 'Show' : 'Hide';
} if (mode == 'basic') {
$('.fti_advanced').disable();
$('.fti_basic').enable();
2013-06-17 08:01:02 +00:00
$('.ftr_advanced').ghide(true);
$('.ftr_basic').gshow();
$('#ft_advanced_link').gshow();
$('#ft_advanced_text').ghide();
$('#ft_basic_link').ghide();
$('#ft_basic_text').gshow();
2013-02-25 21:16:55 +00:00
$('#ft_type').raw().value = 'basic';
2013-02-23 08:00:22 +00:00
} else if (mode == 'advanced') {
$('.fti_advanced').enable();
$('.fti_basic').disable();
2013-06-17 08:01:02 +00:00
$('.ftr_advanced').gshow();
$('.ftr_basic').ghide();
$('#ft_advanced_link').ghide();
$('#ft_advanced_text').gshow();
$('#ft_basic_link').gshow();
$('#ft_basic_text').ghide();
2013-02-25 21:16:55 +00:00
$('#ft_type').raw().value = 'advanced';
2013-02-23 08:00:22 +00:00
}
return false;
}
2011-03-28 14:21:28 +00:00
// For /sections/torrents/browse.php (not browse2.php)
function Bitrate() {
$('#other_bitrate').raw().value = '';
if ($('#bitrate').raw().options[$('#bitrate').raw().selectedIndex].value == 'Other') {
2013-06-17 08:01:02 +00:00
$('#other_bitrate_span').gshow();
2011-03-28 14:21:28 +00:00
} else {
2013-06-17 08:01:02 +00:00
$('#other_bitrate_span').ghide();
2011-03-28 14:21:28 +00:00
}
}
var ArtistFieldCount = 1;
function AddArtistField() {
2013-05-04 08:00:48 +00:00
if (ArtistFieldCount >= 100) {
return;
}
2011-03-28 14:21:28 +00:00
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[]";
2012-02-19 08:00:19 +00:00
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>';
2011-03-28 14:21:28 +00:00
x.appendChild(Importance);
2013-02-22 08:00:24 +00:00
ArtistFieldCount++;
2011-03-28 14:21:28 +00:00
}
2013-05-27 08:00:58 +00:00
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;
}
}
2011-03-28 14:21:28 +00:00
function ToggleEditionRows() {
2013-06-17 08:01:02 +00:00
$('#edition_title').gtoggle();
$('#edition_label').gtoggle();
$('#edition_catalogue').gtoggle();
2011-03-28 14:21:28 +00:00
}
2012-06-05 08:00:11 +00:00
function check_private(TorrentID) {
$('#checkprivate-'+TorrentID).raw().innerHTML = "Checking...";
2013-05-04 08:00:48 +00:00
ajax.get('ajax.php?action=checkprivate&torrentid=' + TorrentID,function(response) {
2012-06-05 08:00:11 +00:00
$('#checkprivate-'+TorrentID).raw().innerHTML = response;
});
2012-10-05 08:00:20 +00:00
}