\n';
} else if (isCategoryMusic) {
genreFilter += '
Genre
\n';
} else if (isCategorySoftware) {
// genreFilter += '
Software Filters Coming Soon
\n'; // Not enough to warrant this for now
} else if (isCategoryNonPorn) {
genreFilter += '
Non Porn Filters Coming Soon
\n';
}
} else {
// genreFilter += '
All Filters Coming Soon
\n'; // Not enough to warrant this for now
}
genreFilter += '
\n';
// Creates the Advanced Filter HTML box
let AdvancedFiltersHTML = `
Category Icons
Torrent Images
Porn
${ genreFilter }
Update Page with FiltersReset Filters
`;
// Attaches Advanced Filters HTML box to RARBG
$('#searchTorrent').parent().append(AdvancedFiltersHTML);
// TODO: Likely going to need to move the ToggleFilter and ToggleAdvancedFilters method calls into this gated logic
if (nonStandardUrlParams) {
toggleFilter('#shadvbutton', 'data-shadvbutton', showAdvancedOptions, true);
toggleAdvancedFilters(true, true);
} else {
showAdvancedOptions = ((window.localStorage.getItem('shadvbutton') == 'true') ? true : false);
toggleFilter('#shadvbutton', 'data-shadvbutton', showAdvancedOptions, true);
toggleAdvancedFilters(showAdvancedOptions);
}
// Logic for HTML box icons
showIcon = ((window.localStorage.getItem('jQIcon') == 'false') ? false : true);
toggleFilter('#jQIcon', 'data-icon', showIcon);
showTorrentThumbnail = ((window.localStorage.getItem('jQTorrentThumbnail') == 'false') ? false : true);
toggleFilter('#jQTorrentThumbnail', 'data-torrent-thumbs', showTorrentThumbnail);
showPorn = ((window.localStorage.getItem('jQShowPorn') == 'false') ? false : true);
toggleFilter('#jQShowPorn', 'data-porn', showPorn);
showKORSUB = ((window.localStorage.getItem('jQKORSUB') == 'false') ? false : true);
toggleFilter('#jQKORSUB', 'data-korsub', showKORSUB);
show720p = ((window.localStorage.getItem('jQ720p') == 'false') ? false : true);
toggleFilter('#jQ720p', 'data-720p', show720p);
$('#shadvbutton').on('click', function() {
showAdvancedOptions = ($(this).attr('data-shadvbutton') == 'false') ? true : false;
toggleFilter('#shadvbutton', 'data-shadvbutton', showAdvancedOptions, true);
toggleAdvancedFilters(showAdvancedOptions, true);
});
$('#jQIcon').on('click', function() {
showIcon = ($(this).attr('data-icon') == 'false') ? true : false;
toggleFilter('#jQIcon', 'data-icon', showIcon);
});
$('#jQTorrentThumbnail').on('click', function() {
showTorrentThumbnail = ($(this).attr('data-torrent-thumbs') == 'false') ? true : false;
toggleFilter('#jQTorrentThumbnail', 'data-torrent-thumbs', showTorrentThumbnail);
});
$('#jQShowPorn').on('click', function() {
showPorn = ($(this).attr('data-porn') == 'false') ? true : false;
toggleFilter('#jQShowPorn', 'data-porn', showPorn);
});
$('#jQKORSUB').on('click', function() {
showKORSUB = ($(this).attr('data-korsub') == 'false') ? true : false;
toggleFilter('#jQKORSUB', 'data-korsub', showKORSUB);
});
$('#jQ720p').on('click', function() {
show720p = ($(this).attr('data-720p') == 'false') ? true : false;
toggleFilter('#jQ720p', 'data-720p', show720p);
});
// Movies and TV Shows only
if (isCategoryMovies || isCategoryTVShows) {
if (window.localStorage.getItem('minimum-rating') > 0) {
let mr = window.localStorage.getItem('minimum-rating');
$('#jQIMDB').find('input').attr('value', mr);
minRating = mr;
} else {
$('#jQIMDB').find('input').attr('value', 0);
}
if (window.localStorage.getItem('media-genre') !== null) {
let gen = window.localStorage.getItem('media-genre');
$('#jQgenre').find('input').attr('value', gen);
searchGenre = gen.toLowerCase();
}
}
// Games only
if (isCategoryGames) {
if(window.localStorage.getItem('game-group') !== undefined) {
let gg = window.localStorage.getItem('game-group');
$('#jQGamingGroup').find('input').attr('value', gg);
gameGroup = gg;
} else {
$('#jQGamingGroup').find('input').removeAttr('value');
}
}
// Music only
if (isCategoryMusic) {
if(window.localStorage.getItem('music-genre') !== undefined) {
let mg = window.localStorage.getItem('music-genre');
$('#jQMusicGenre').find('input').attr('value', mg);
musicGenre = mg;
} else {
$('#jQMusicGenre').find('input').removeAttr('value');
}
}
// Input click event
/*
document.querySelectorAll('#jQIMDB input, #jQGamingGroup input, #jQMusicGenre input, #jQgenre input').forEach( selector => {
selector.addEventListener('blur', e => { console.log(e.key) });
});
*/
$('#jQIMDB input, #jQGamingGroup input, #jQMusicGenre input, #jQgenre input').on('keydown', function() {
if (event.which == 13 || event.keyCode == 13) $('.jQUpdateFilters').click();
});
// Events for the 'Update Filters' button
$('.jQUpdateFilters').on('click', function () {
if (isCategoryMovies || isCategoryTVShows) {
let minRating = $('#jQIMDB').parent().find('input').val();
window.localStorage.setItem('minimum-rating', minRating);
let genre = $('#jQgenre').find('input').val();
window.localStorage.setItem('media-genre', genre);
}
if (isCategoryGames) {
let gameGroup = $('#jQGamingGroup').parent().find('input').val();
window.localStorage.setItem('game-group', gameGroup);
}
if (isCategoryMusic) {
let musicGenre = $('#jQMusicGenre').parent().find('input').val();
window.localStorage.setItem('music-genre', musicGenre);
}
location.reload();
});
// Events for the 'Reset Filters' button
$('.jQResetFilters').on('click', function() {
window.localStorage.removeItem('jQIcon');
window.localStorage.removeItem('jQTorrentThumbnail');
window.localStorage.removeItem('jQKORSUB');
window.localStorage.removeItem('jQ720p');
window.localStorage.removeItem('jQShowPorn');
window.localStorage.removeItem('media-genre');
window.localStorage.removeItem('minimum-rating');
window.localStorage.removeItem('game-group');
window.localStorage.removeItem('music-genre');
location.reload();
});
// Removes Movie filters after clicking the 'View all' link
$('.tdlinkfull2').on('click', function() {
if ($(this).text() === 'View all') {
window.localStorage.removeItem('jQKORSUB');
window.localStorage.removeItem('jQ720p');
window.localStorage.removeItem('minimum-rating');
window.localStorage.removeItem('game-group');
window.localStorage.removeItem('music-genre');
window.localStorage.removeItem('media-genre');
}
});
// CATEGORY SPECIFIC =================================================================================================
// Hides torrents with seeders equal to or lower than a number [TODO: make this a form input filter]
// use inArray method from work (Configurator height normalizer)
/*
if (parseInt(title.indexOf('720p')) > 0)
{
$(this).parents('.lista2').remove();
}
*/
// Logic to hide porn
if (!showPorn) {
$.each($('.tdlinkfull2'), function() {
const TARGET_TEXT = $(this).text().toLowerCase();
if (TARGET_TEXT == 'xxx') $(this).parent().parent().remove();
});
$.each($('.divadvscat a'), function() {
const TARGET_TEXT = $(this).text().toLowerCase();
if(TARGET_TEXT == 'xxx (18+)') $(this).parent().remove();
});
}
// Loops through all torrents looking at each span tag
$.each($('.lista span'), function(index, value) {
const GENRE = $(this).text().toLowerCase();
if (GENRE !== undefined)
// Creates the logic for category specific filters
if (getParameterByName('category') !== null || nonStandardUrlParams)
if (isCategoryMovies || isCategoryTVShows)
if (GENRE.search(searchGenre) == -1)
$(this).parents('.lista2').remove();
});
// Loops through all torrents looking at each anchor tag
$.each($('.lista a'), function(index, value) {
let title = $(this).attr('title');
let icon = $(this).find('img').attr('src');
if (title !== undefined) {
// Logic to hide KORSUB torrents
if (parseInt(title.indexOf('RARBG')) > 0 || parseInt(title.indexOf('VXT')) > 0 || parseInt(title.indexOf('XVID')) > 0 || parseInt(title.indexOf('ION10')) > 0 || parseInt(title.indexOf('BDRip')) > 0 || parseInt(title.indexOf('BDRiP')) > 0 || parseInt(title.indexOf('REMUX')) > 0 || parseInt(title.indexOf('ION265')) > 0)
$(this).parents('.lista2').remove();
// Logic to hide 720p torrents
if (parseInt(title.indexOf('720p')) > 0)
$(this).parents('.lista2').remove();
// Creates the logic for category specific filters
if (getParameterByName('category') !== null || nonStandardUrlParams) {
if (isCategoryMovies || isCategoryTVShows) {
// IMDB Ratings
$.each($('.lista:nth-child(2)'), function(index, value) {
if ($(this).children('span').length) {
const RATINGS = $(this).children('span').text();
const IMDB = RATINGS.indexOf('IMDB: ') + 6;
const SCOPE_MIN_RATING = $('#jQIMDB').parent().find('input').val();
if (SCOPE_MIN_RATING > 0) {
if (RATINGS !== '' && IMDB !== -1) {
minRating = parseFloat(minRating);
const RATE_VALUE = parseFloat(RATINGS.substring(IMDB,RATINGS.length-3));
if (!isNaN(RATE_VALUE)) {
if (RATE_VALUE <= minRating) $(this).parents('.lista2').remove();
} else {
$(this).parents('.lista2').remove();
}
}
}
}
});
}
// Game Torrent Group
else if (isCategoryGames) {
$.each($('.lista2t a'), function(index, value) {
if ($(this).attr('title') !== undefined) {
const TORRENT_TITLE = $(this).attr('title');
const SEARCH_VALUE = TORRENT_TITLE.toLowerCase().indexOf(gameGroup);
if (SEARCH_VALUE === -1 && gameGroup !== null)
$(this).parents('.lista2').remove();
}
});
}
else if (isCategoryMusic) {
$.each($('.lista2t .lista span:last-child'), function(index, value) {
const GENRE_TITLE = $(this).text();
if (GENRE_TITLE !== undefined) {
const SEARCH_VALUE = GENRE_TITLE.toLowerCase().indexOf(musicGenre);
if (SEARCH_VALUE === -1 && musicGenre !== null)
$(this).parents('.lista2').remove();
}
});
}
// Coming soon
// else if (categorySoftwareArray) { }
// else if (categoryNonPornArray) { }
}
}
// Logic to hide porn
if (!showPorn) {
if (title !== undefined) {
title = title.indexOf('XXX');
if (title >= 0) $(this).parents('.lista2').remove();
}
if (icon !== undefined) {
icon = icon.indexOf('cat_new4.gif');
if (icon >= 0) $(this).parents('.lista2').remove();
}
}
});
// NON-CATEGORY SPECIFIC =================================================================================================
// Logic to hide icons
if (!showIcon) {
$('.lista2t tr td:nth-of-type(1)').attr('style','display:none;');
} else {
// TODO: Make child of showIcon (=true)
// Logic to show torrent thumbnails
if (showTorrentThumbnail) {
const LOCAL_STORAGE_SETTING = 'RARBG-Advanced-Filters-Large-Thumbnails';
window.isLargeThumb = ( window.localStorage.getItem(LOCAL_STORAGE_SETTING) == 'true' ) ? true : false;
if (window.isLargeThumb)
$('.lista2t').find('tr:first-child td:first-child').html('Thumbnail ()');
else
$('.lista2t').find('tr:first-child td:first-child').html('Thumbnail ()');
$.each($('.lista2t .lista2'), function() {
const ANCHOR = $(this);
$.each(ANCHOR.find('.lista'), function() {
const IMAGE = $(this).find('a');
const TARGET = ANCHOR.find(':nth-child(1) a');
if (IMAGE.attr('onmouseover') !== undefined) {
const HREF = IMAGE.attr('href');
const SOURCE_THUMB = IMAGE.attr('onmouseover');
let val1 = SOURCE_THUMB.match(/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/g).map(String)[0];
val1 = SOURCE_THUMB.lastIndexOf(val1);
const VAL2 = SOURCE_THUMB.indexOf("\' border=0>')")-1;
let imageID = SOURCE_THUMB.substring(val1,VAL2);
if (window.isLargeThumb) {
if (imageID.includes('static/over')) {
let pvid = imageID.substring(22,23);
imageID = imageID.replace('static/over','posters2/' + pvid);
}
if (imageID.includes('over_opt'))
imageID = imageID.replace('over_opt','poster_opt');
if (imageID.includes('_small'))
imageID = imageID.replace('_small','_banner_optimized');
}
let thumbnailImage = "";
if (window.isLargeThumb)
if (imageID.includes('posters2/') || imageID.includes('poster_opt') || imageID.includes('_banner_optimized'))
$('.thumbnail').addClass('resize');
IMAGE.removeAttr('onmouseover').removeAttr('onmouseout');
TARGET.find('img').replaceWith(thumbnailImage);
TARGET.attr('href', HREF);
ANCHOR.find('td:nth-child(1)').attr( 'align', 'center' );
}
});
});
$(document).on('click', '.jQlargeThumbs', function() {
if (window.isLargeThumb)
window.localStorage.setItem(LOCAL_STORAGE_SETTING, 'false');
else
window.localStorage.setItem(LOCAL_STORAGE_SETTING, 'true');
window.location.href = window.location.href;
});
}
}
// Is Grid active?
const SHOW_GRID = ((window.localStorage.getItem('advanced-search-grid-view') == 'true') ? true : false);
// Creates the Grid button toggle
const GRID_ICON = SHOW_GRID ? '' : '';
const TOOL_TIP = SHOW_GRID ? 'Show list view' : 'Show grid view';
$('#searchTorrent table tbody tr').prepend('
' + GRID_ICON + '
');
// Grid button toggle logic
$(document).on('click', '.jQGridButton', function() {
if (SHOW_GRID)
window.localStorage.setItem('advanced-search-grid-view', 'false');
else
window.localStorage.setItem('advanced-search-grid-view', 'true');
location.reload();
});
if (SHOW_GRID) {
let isTorrentMagnetLinksScriptActive = false;
// Determines if the torrent and magnet links script is installed
$.each($('.lista2t tbody tr:first-child td'), function(index) {
const CONTENT = $(this).html();
switch (CONTENT) {
case 'DL ML':
isTorrentMagnetLinksScriptActive = true;
break;
}
});
// Creates the grid
let gridTemplate = `#TorrentGrid .grid-lista2 { grid-template-areas: "thumb thumb"
"file file"
"added added"
"size size"
"seeders leechers"
"comments uploader"; }`;
if (isTorrentMagnetLinksScriptActive) {
gridTemplate = `#TorrentGrid .grid-lista2 { grid-template-areas: "thumb thumb"
"file file"
"mldl mldl"
"added added"
"size size"
"seeders leechers"
"comments uploader"; }`;
}
// Creates the CSS for the grid
$('').insertBefore('.lista2t').prepend(``);
$.each($('.lista2t .lista2'), function(index) {
let parentIndex = index + 1;
$('#TorrentGrid').append('');
$.each($(this).find('td'), function(index) {
let childIndex = index + 1;
let target = $(this).closest('table').prev().find('div.grid-lista2:nth-of-type('+parentIndex+')');
target.append('');
let currentElement = target.find('.lista:nth-of-type('+childIndex+')').eq(0);
let fileName;
currentElement.html($(this).html());
if (isTorrentMagnetLinksScriptActive) {
switch (childIndex) {
case 1: // thumbnail TD
currentElement.addClass('thumb');
break;
case 2: // file TD
currentElement.addClass('file');
currentElement.find('a:first-child').addClass('alt-layout');
currentElement = currentElement.find('a:first-child');
fileName = currentElement.text().replace(/\./g,' ');
currentElement.text(fileName);
break;
case 3: // DL ML TD - belongs to the torrent and magnet links script
currentElement.addClass('mldl alt-darker');
currentElement.prepend('DL ML: ');
break;
case 4: // Added TD
currentElement.addClass('added alt-deco');
currentElement.prepend('Added: ');
break;
case 5: // Size TD
currentElement.addClass('size alt-size');
currentElement.prepend('Size: ');
break;
case 6: // Seed TD
currentElement.addClass('seeders badge');
currentElement.prepend('Seeds: ');
currentElement.find('font').removeAttr('color');
break;
case 7: // Leecher TD
currentElement.addClass('leechers badge');
currentElement.prepend('Leechers: ');
currentElement.find('font').removeAttr('color');
break;
case 8: // Comments TD
currentElement.addClass('comments');
currentElement.prepend('# Comments: ');
break;
case 9: // Uploader TD
currentElement.addClass('uploader');
currentElement.prepend('# Uploader: ');
break;
}
} else {
switch (childIndex) {
case 1: // thumbnail TD
currentElement.addClass('thumb');
break;
case 2: // file TD
currentElement.addClass('file');
currentElement.find('a:first-child').addClass('alt-layout');
currentElement = currentElement.find('a:first-child');
fileName = currentElement.text().replace(/\./g,' ');
currentElement.text(fileName);
break;
case 3: // Added TD
currentElement.addClass('added alt-deco');
currentElement.prepend('Added: ');
break;
case 4: // Size TD
currentElement.addClass('size alt-size');
currentElement.prepend('Size: ');
break;
case 5: // Seed TD
currentElement.addClass('seeders badge');
currentElement.prepend('Seeds: ');
currentElement.find('font').removeAttr('color');
break;
case 6: // Leecher TD
currentElement.addClass('leechers badge');
currentElement.prepend('Leechers: ');
currentElement.find('font').removeAttr('color');
break;
case 7: // Comments TD
currentElement.addClass('comments');
currentElement.prepend('# Comments: ');
break;
case 8: // Uploader TD
currentElement.addClass('uploader');
currentElement.prepend('# Uploader: ');
break;
}
}
});
});
// Sorting Buttons
$('').insertBefore('#TorrentGrid');
$.each($('.lista2t tbody tr:first-child td'), function(index) {
const CONTENT = $(this).html();
if (CONTENT.match('tdlinkfull3')) {
const HREF = $(this).find('.tdlinkfull3').attr('href');
const BUTTON_ID = HREF.substring(HREF.lastIndexOf('order=')+6,HREF.indexOf('&by='));
let buttonName = BUTTON_ID.charAt(0).toUpperCase() + BUTTON_ID.substr(1).toLowerCase();
if (buttonName === 'Data') buttonName = 'Added';
$('#TorrentGridControls').append('Sort ' + buttonName + '');
}
});
// Sorting title logic
const URL = window.location.href;
let sorting_by = URL.substring(URL.lastIndexOf('&by=')+4,URL.indexOf('&page='));
if (URL.indexOf('&page=') === -1) sorting_by = URL.substring(URL.lastIndexOf('&by=')+4);
const BUTTON_ID = URL.substring(URL.lastIndexOf('order=')+6,URL.indexOf('&by='));
if (BUTTON_ID === 'https') {
$('#TorrentGridControls').prepend('
Not Sorted
');
} else {
let buttonName = BUTTON_ID.charAt(0).toUpperCase() + BUTTON_ID.substr(1).toLowerCase();
if (buttonName === 'Data') buttonName = 'Added';
$('#TorrentGridControls').prepend('
' + sorting_by + ' Sorted by ' + buttonName + '
');
}
// Event trigger for sorting buttons
$(document).on('click', '.jQGridSort', function (){
location.href = $(this).attr('href');
});
// Removes the list from the DOM
$('.lista2t').remove();
}
});