2011-03-28 14:21:28 +00:00
function show _peers ( TorrentID , Page ) {
2013-04-30 18:18:07 +00:00
if ( Page > 0 ) {
2011-03-28 14:21:28 +00:00
ajax . get ( 'torrents.php?action=peerlist&page=' + Page + '&torrentid=' + TorrentID , function ( response ) {
$ ( '#peers_' + TorrentID ) . show ( ) . raw ( ) . innerHTML = response ;
} ) ;
} else {
if ( $ ( '#peers_' + TorrentID ) . raw ( ) . innerHTML === '' ) {
$ ( '#peers_' + TorrentID ) . show ( ) . raw ( ) . innerHTML = '<h4>Loading...</h4>' ;
ajax . get ( 'torrents.php?action=peerlist&torrentid=' + TorrentID , function ( response ) {
$ ( '#peers_' + TorrentID ) . show ( ) . raw ( ) . innerHTML = response ;
} ) ;
} else {
$ ( '#peers_' + TorrentID ) . toggle ( ) ;
}
}
$ ( '#snatches_' + TorrentID ) . hide ( ) ;
$ ( '#downloads_' + TorrentID ) . hide ( ) ;
$ ( '#files_' + TorrentID ) . hide ( ) ;
$ ( '#reported_' + TorrentID ) . hide ( ) ;
}
function show _snatches ( TorrentID , Page ) {
2013-04-30 18:18:07 +00:00
if ( Page > 0 ) {
2011-03-28 14:21:28 +00:00
ajax . get ( 'torrents.php?action=snatchlist&page=' + Page + '&torrentid=' + TorrentID , function ( response ) {
$ ( '#snatches_' + TorrentID ) . show ( ) . raw ( ) . innerHTML = response ;
} ) ;
} else {
if ( $ ( '#snatches_' + TorrentID ) . raw ( ) . innerHTML === '' ) {
$ ( '#snatches_' + TorrentID ) . show ( ) . raw ( ) . innerHTML = '<h4>Loading...</h4>' ;
ajax . get ( 'torrents.php?action=snatchlist&torrentid=' + TorrentID , function ( response ) {
$ ( '#snatches_' + TorrentID ) . show ( ) . raw ( ) . innerHTML = response ;
} ) ;
} else {
$ ( '#snatches_' + TorrentID ) . toggle ( ) ;
}
}
$ ( '#peers_' + TorrentID ) . hide ( ) ;
$ ( '#downloads_' + TorrentID ) . hide ( ) ;
$ ( '#files_' + TorrentID ) . hide ( ) ;
$ ( '#reported_' + TorrentID ) . hide ( ) ;
}
function show _downloads ( TorrentID , Page ) {
2013-04-30 18:18:07 +00:00
if ( Page > 0 ) {
2011-03-28 14:21:28 +00:00
ajax . get ( 'torrents.php?action=downloadlist&page=' + Page + '&torrentid=' + TorrentID , function ( response ) {
$ ( '#downloads_' + TorrentID ) . show ( ) . raw ( ) . innerHTML = response ;
} ) ;
} else {
if ( $ ( '#downloads_' + TorrentID ) . raw ( ) . innerHTML === '' ) {
$ ( '#downloads_' + TorrentID ) . show ( ) . raw ( ) . innerHTML = '<h4>Loading...</h4>' ;
ajax . get ( 'torrents.php?action=downloadlist&torrentid=' + TorrentID , function ( response ) {
$ ( '#downloads_' + TorrentID ) . raw ( ) . innerHTML = response ;
} ) ;
} else {
$ ( '#downloads_' + TorrentID ) . toggle ( ) ;
}
}
$ ( '#peers_' + TorrentID ) . hide ( ) ;
$ ( '#snatches_' + TorrentID ) . hide ( ) ;
$ ( '#files_' + TorrentID ) . hide ( ) ;
$ ( '#reported_' + TorrentID ) . hide ( ) ;
}
function show _files ( TorrentID ) {
$ ( '#files_' + TorrentID ) . toggle ( ) ;
$ ( '#peers_' + TorrentID ) . hide ( ) ;
$ ( '#snatches_' + TorrentID ) . hide ( ) ;
$ ( '#downloads_' + TorrentID ) . hide ( ) ;
$ ( '#reported_' + TorrentID ) . hide ( ) ;
}
function show _reported ( TorrentID ) {
$ ( '#files_' + TorrentID ) . hide ( ) ;
$ ( '#peers_' + TorrentID ) . hide ( ) ;
$ ( '#snatches_' + TorrentID ) . hide ( ) ;
$ ( '#downloads_' + TorrentID ) . hide ( ) ;
$ ( '#reported_' + TorrentID ) . toggle ( ) ;
}
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 ] ) ;
if ( row . has _class ( 'colhead_dark' ) ) { continue ; }
if ( row . has _class ( 'colhead' ) ) { continue ; }
2011-09-04 08:00:07 +00:00
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 ) ) {
2011-09-04 08:00:07 +00:00
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.' ;
2011-09-04 08:00:07 +00:00
$ ( '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' ) ) {
row . show ( ) ;
showRow = ( $ ( 'a' , row . raw ( ) ) . raw ( ) . innerHTML != '+' ) ;
} else {
if ( showRow ) {
row . show ( ) ;
} else {
row . hide ( ) ;
}
}
} else {
row . hide ( ) ;
}
}
}
}
if ( event . preventDefault ) { event . preventDefault ( ) ; } else { 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 ;
var group _rows = $ ( 'tr.groupid_' + groupid ) ;
for ( var i = 0 ; i < group _rows . results ( ) ; i ++ ) {
var row = $ ( group _rows . raw ( i ) ) ;
2011-09-04 08:00:07 +00:00
if ( row . has _class ( 'edition' ) && ( allEditions || row . raw ( 0 ) == clickedRow ) ) {
2011-03-28 14:21:28 +00:00
$ ( 'a' , row . raw ( ) ) . raw ( ) . innerHTML = ( showing ) ? '−' : '+' ;
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' ) ) {
row . show ( ) ;
} else {
row . hide ( ) ;
}
}
}
if ( event . preventDefault ) { event . preventDefault ( ) ; } else { event . returnValue = false ; }
}
2013-02-23 08:00:22 +00:00
function toggleTorrentSearch ( mode ) {
if ( mode == 0 ) {
var link = $ ( '#ft_toggle' ) . raw ( ) ;
$ ( '#ft_container' ) . toggle ( ) ;
link . innerHTML = link . textContent == 'Hide' ? 'Show' : 'Hide' ;
} if ( mode == 'basic' ) {
$ ( '.fti_advanced' ) . disable ( ) ;
$ ( '.fti_basic' ) . enable ( ) ;
2013-02-25 21:16:55 +00:00
$ ( '.ftr_advanced' ) . hide ( true ) ;
2013-02-23 08:00:22 +00:00
$ ( '.ftr_basic' ) . show ( ) ;
$ ( '#ft_advanced_link' ) . show ( ) ;
$ ( '#ft_advanced_text' ) . hide ( ) ;
$ ( '#ft_basic_link' ) . hide ( ) ;
$ ( '#ft_basic_text' ) . show ( ) ;
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 ( ) ;
$ ( '.ftr_advanced' ) . show ( ) ;
$ ( '.ftr_basic' ) . hide ( ) ;
$ ( '#ft_advanced_link' ) . hide ( ) ;
$ ( '#ft_advanced_text' ) . show ( ) ;
$ ( '#ft_basic_link' ) . show ( ) ;
$ ( '#ft_basic_text' ) . hide ( ) ;
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' ) {
$ ( '#other_bitrate_span' ) . show ( ) ;
} else {
$ ( '#other_bitrate_span' ) . hide ( ) ;
}
}
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[]" ;
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
}
function ToggleEditionRows ( ) {
$ ( '#edition_title' ) . toggle ( ) ;
$ ( '#edition_label' ) . toggle ( ) ;
$ ( '#edition_catalogue' ) . toggle ( ) ;
}
2012-06-05 08:00:11 +00:00
function check _private ( TorrentID ) {
$ ( '#checkprivate-' + TorrentID ) . raw ( ) . innerHTML = "Checking..." ;
ajax . get ( 'ajax.php?action=checkprivate&torrentid=' + TorrentID , function ( response ) {
$ ( '#checkprivate-' + TorrentID ) . raw ( ) . innerHTML = response ;
} ) ;
2012-10-05 08:00:20 +00:00
}