';
// 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);
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);
});
$("#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 (categoryMoviesArray || categoryTVShowsArray)
{
if (window.localStorage.getItem("minimum-rating") > 0)
{
var 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)
{
var gen = window.localStorage.getItem("media-genre");
$("#jQgenre").find("input").attr("value", gen);
searchGenre = gen.toLowerCase();
}
}
// Games only
if (categoryGamesArray)
{
if(window.localStorage.getItem("game-group") !== undefined)
{
var gg = window.localStorage.getItem("game-group");
$("#jQGamingGroup").find("input").attr("value", gg);
gameGroup = gg;
}
else
{
$("#jQGamingGroup").find("input").removeAttr("value");
}
}
// Music only
if (categoryMusicArray)
{
if(window.localStorage.getItem("music-genre") !== undefined)
{
var mg = window.localStorage.getItem("music-genre");
$("#jQMusicGenre").find("input").attr("value", mg);
musicGenre = mg;
}
else
{
$("#jQMusicGenre").find("input").removeAttr("value");
}
}
// Input click event
$("#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 (categoryMoviesArray || categoryTVShowsArray)
{
var minRating = $("#jQIMDB").parent().find("input").val();
window.localStorage.setItem("minimum-rating", minRating);
var genre = $("#jQgenre").find("input").val();
window.localStorage.setItem("media-genre", genre);
}
if (categoryGamesArray)
{
var gameGroup = $("#jQGamingGroup").parent().find("input").val();
window.localStorage.setItem("game-group", gameGroup);
}
if (categoryMusicArray)
{
var 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("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
$.each($(".tdlinkfull2"), function() {
var targetText = $(this).text().toLowerCase();
if (targetText == "xxx")
{
$(this).parent().parent().remove();
}
});
$.each($(".divadvscat a"), function() {
var targetText = $(this).text().toLowerCase();
if(targetText == "xxx (18+)")
{
$(this).parent().remove();
}
});
// Loops through all torrents looking at each span tag
$.each($(".lista span"), function(index, value) {
var genre = $(this).text().toLowerCase();
if (genre !== undefined)
{
// Creates the logic for category specific filters
if (GetParameterByName("category") !== null || nonStandardUrlParams)
{
if (categoryMoviesArray || categoryTVShowsArray)
{
// Genres
if (genre.search(searchGenre) == -1)
{
$(this).parents(".lista2").remove();
}
}
}
}
});
// Loops through all torrents looking at each anchor tag
$.each($(".lista a"), function(index, value) {
var title = $(this).attr("title");
var icon = $(this).find("img").attr("src");
if (title !== undefined)
{
// Logic to hide KORSUB torrents
if (!showKORSUB)
{
if (parseInt(title.indexOf("KORSUB")) > 0)
{
$(this).parents(".lista2").remove();
}
}
// Logic to hide 720p torrents
if (!show720p)
{
if (parseInt(title.indexOf("720p")) > 0)
{
$(this).parents(".lista2").remove();
}
}
// Creates the logic for category specific filters
if (GetParameterByName("category") !== null || nonStandardUrlParams)
{
if (categoryMoviesArray || categoryTVShowsArray)
{
// IMDB Ratings
$.each($(".lista:nth-child(2)"), function(index, value) {
if ($(this).children("span").length) {
var ratings = $(this).children("span").text();
var imdb = ratings.indexOf("IMDB: ") + 6;
var scopemr = $("#jQIMDB").parent().find("input").val();
if (scopemr > 0)
{
if (ratings !== undefined && imdb !== -1)
{
minRating = parseFloat(minRating);
var rateValue = parseFloat(ratings.substring(imdb,ratings.length-3));
if (!isNaN(rateValue))
{
if (showMoviesTVFilters) { $(this).children("span").attr("style", "display: block;"); }
if (rateValue <= minRating)
{
$(this).parents(".lista2").remove();
}
}
else
{
$(this).parents(".lista2").remove();
}
}
}
}
});
}
// Game Torrent Group
else if (categoryGamesArray)
{
$.each($(".lista2t a"), function(index, value) {
if ($(this).attr("title") !== undefined)
{
var torrentTitle = $(this).attr("title");
var searchValue = torrentTitle.toLowerCase().indexOf(gameGroup);
var compareValue = torrentTitle.substring(searchValue,torrentTitle.length);
if (searchValue === -1 && gameGroup !== null)
{
$(this).parents(".lista2").remove();
}
}
});
}
else if (categoryMusicArray)
{
$.each($(".lista2t .lista span:last-child"), function(index, value) {
var genreTitle = $(this).text();
if (genreTitle !== undefined)
{
var searchValue = genreTitle.toLowerCase().indexOf(musicGenre);
var compareValue = genreTitle.substring(searchValue,genreTitle.length);
if (searchValue === -1 && musicGenre !== null)
{
$(this).parents(".lista2").remove();
}
}
});
}
// Coming soon
else if (categorySoftwareArray) { }
else if (categoryNonPornArray) { }
}
}
// Logic to hide porn
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)
{
var LSsetting = "RARBG-Advanced-Filters-Large-Thumbnails";
window.isLargeThumb = ( window.localStorage.getItem(LSsetting) == "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() {
var anchor = $(this);
$.each(anchor.find(".lista"), function() {
var image = $(this).find("a");
var target = anchor.find(":nth-child(1) a");
if (image.attr("onmouseover") !== undefined)
{
var href = image.attr("href");
var sourceThumb = image.attr("onmouseover");
var val1 = sourceThumb.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 = sourceThumb.lastIndexOf(val1);
var val2 = sourceThumb.indexOf("\' border=0>')")-1;
var imageID = sourceThumb.substring(val1,val2);
if (window.isLargeThumb)
{
if (imageID.includes("static/over"))
{
var 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");
}
}
var 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(LSsetting, "false");
} else {
window.localStorage.setItem(LSsetting, "true");
}
window.location.href = window.location.href;
});
}
}
// May need to update to DOM structure changes
$("body > div:last-of-type").prev().prev().prev().remove();
$("body > div:last-of-type").prev().remove();
// Is Grid active?
var showGrid = ((window.localStorage.getItem("advanced-search-grid-view") == "true") ? true : false);
// Creates the Grid button toggle
var gridIcon = showGrid ? "" : "";
var tooltip = showGrid ? "Show list view" : "Show grid view";
$("#searchTorrent table tbody tr").prepend("
" + gridIcon + "
");
// Grid button toggle logic
$(document).on("click", ".jQGridButton", function() {
if (showGrid) {
window.localStorage.setItem("advanced-search-grid-view", "false");
} else {
window.localStorage.setItem("advanced-search-grid-view", "true");
}
location.reload();
});
if (showGrid) {
var isTorrentMagnetLinksScriptActive = false;
// Determines if the torrent and magnet links script is installed
$.each($(".lista2t tbody tr:first-child td"), function(index) {
var content = $(this).html();
switch (content) {
case "DL ML":
isTorrentMagnetLinksScriptActive = true;
break;
}
});
// Creates the CSS for the grid
$("
").insertBefore(".lista2t").prepend('');
if (isTorrentMagnetLinksScriptActive)
{
$("#TorrentGrid").prepend('');
}
else
{
$("#TorrentGrid").prepend('');
}
// Creates the grid
$.each($(".lista2t .lista2"), function(index) {
var parentIndex = index + 1;
$("#TorrentGrid").append("
");
$.each($(this).find("td"), function(index) {
var childIndex = index + 1;
var target = $(this).closest("table").prev().find("div.grid-lista2:nth-of-type("+parentIndex+")");
target.append("
");
var currentElement = target.find(".lista:nth-of-type("+childIndex+")").eq(0);
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");
var fileName = currentElement.text().replace(/\./g," ");
currentElement.text(fileName);
break;
case 3: // DL ML TD - belongs to 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) {
var content = $(this).html();
if (content.match("tdlinkfull3")) {
var href = $(this).find(".tdlinkfull3").attr("href");
var btnID = href.substring(href.lastIndexOf("order=")+6,href.indexOf("&by="));
var buttonName = btnID.charAt(0).toUpperCase() + btnID.substr(1).toLowerCase();
if (buttonName === "Data") {
buttonName = "Added";
}
$("#TorrentGridControls").append("Sort " + buttonName + "");
}
});
// Sorting title logic
var url = window.location.href;
var sortingBy = url.substring(url.lastIndexOf("&by=")+4);
var btnID = url.substring(url.lastIndexOf("order=")+6,url.indexOf("&by="));
if (btnID === "https") {
$("#TorrentGridControls").prepend("
Not Sorted
");
} else {
var buttonName = btnID.charAt(0).toUpperCase() + btnID.substr(1).toLowerCase();
if (buttonName === "Data") {
buttonName = "Added";
}
$("#TorrentGridControls").prepend("
" + sortingBy + " 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();
}
});