// This code hides any tiles on the index.html page that appear blank.

function removeTile() {
    $(".wh_tile").find("a:hidden").closest('.wh_tile').remove();
    $(".wh_tile").find("span:empty").closest('.wh_tile').remove();


    $('*').each(function() {
        var curRev = ($(this).data('rev'));
        if (curRev != undefined){

            // console.log("curRev = " + curRev);
                // If the element is a topicref and has a data-rev > revExists, then remove it
                if($(this).is("a")){
                    // console.log("curRev = " + curRev);
                    // console.log("revExists = " + revExists);
                    var revExistsNoDots = revExists.split(".").join("");
                    var curRevNoDots = curRev.split(".").join("");
                    // console.log("revExistsNoDots = " + revExistsNoDots);
                    // console.log("curRevNoDots = " + curRevNoDots);
                    if(parseInt(curRevNoDots) > parseInt(revExistsNoDots)){
                        // console.log(curRevNoDots + " > " + revExistsNoDots);
                        // console.log((this).textContent);
                        var a = $(this).closest('div').prop('className');
                        // console.log(a);
                        if($(this).closest('span').hasClass('topicref')){
                            $(this).closest('span').parent().parent().parent('.wh_main_page_toc_accordion_header').remove();
                        }
                        if($(this).closest('div').hasClass('wh_main_page_toc_entry')){
                            // console.log(a);
                            $(this).closest('.wh_main_page_toc_entry').remove();
                        }
                    }
                }
                if($(this).is("section")){
                    var revExistsNoDots = revExists.split(".").join("");
                    var curRevNoDots = curRev.split(".").join("");
                    // console.log("revExistsNoDots = " + revExistsNoDots);
                    // console.log("curRevNoDots = " + curRevNoDots);
                    if(parseInt(curRevNoDots) > parseInt(revExistsNoDots)){
                        // console.log(curRevNoDots + " > " + revExistsNoDots);
                        // console.log((this).textContent);
                        var a = $(this).closest('div').prop('className');
                        // console.log(a);
                        if($(this).closest('span').hasClass('topicref')){
                            $(this).closest('span').parent().parent().parent('.wh_main_page_toc_accordion_header').remove();
                        }
                        if($(this).closest('div').hasClass('wh_main_page_toc_entry')){
                            // console.log(a);
                            $(this).closest('div').parent().remove();
                        }
                    }
                }

        }
        
    });
}




setTimeout(removeTile, 50);