//ddv-changelog.js

var AudienceUser   = $.getUrlVar('audience');
var RevLevel           = $.getUrlVar('rev');
var IsDDV                = window.location.href.indexOf("exp_DDV_changelog.html") != -1;
var IsDDVRN 	       = window.location.href.indexOf("exp_DDV_changelog.html") != -1;
var PageName         = getBaseName(window.location.href) + ".html";  // NEW CODE 2019-08-21
<<<<<<< HEAD
// console.log("Pagename = " + PageName);
=======
console.log("Pagename = " + PageName);
>>>>>>> ba3cce447028aa36eb6b98130fad93dabc7a5554

// correct pagename if necessary
if (PageName != "index.html"){
    PageName = "index.html";
<<<<<<< HEAD
    // console.log("Pagename now = " + PageName);
=======
    console.log("Pagename now = " + PageName);
>>>>>>> ba3cce447028aa36eb6b98130fad93dabc7a5554
}


if ( AudienceUser == 'DDV' ) {
    // $('[data-audience=installed]').css('display', 'inline');
    // $('[data-audience=hosted]').remove(); 
    // console.log("is DDV document");


    if ( PageName == "index.html" || ((AudienceUser == 'DDV') && (PageName == "webhelp.html"))){
        // console.log("is the Index page");
        $('.ChangelogLink').remove();     // Remove header links
        $('#searchForm').remove();     // Remove search feature
        $('.wh_logo').removeAttr('href');     // Remove link in logo
        $('.wkfs_title>a').removeAttr('href');    // Remove link in title and change the color to black
        $('.wkfs_title>a>.title').css('color','black');
        // $('.wh_publication_title wkfs_title>a').remove();     // Remove link in title
        // Remove wh_main_page_toc_entry items that link to topics other than the DDV changelog
        $('[data-id=' + 'exp_AboutAuthoringTools' + ']').parent().remove();
        $('[data-id=' + 'concept_pvz_3qc_kcb' + ']').parent().remove();
        $('[data-id=' + 'concept_yv1_bgg_phb' + ']').parent().remove();
        $('[data-id=' + 'exp_ReleaseNotes' + ']').parent().remove();
    }

    if ( IsDDVRN){
        // console.log("is DDV Changelog");
        $('.ChangelogLink').remove();
        $('.wh_logo').removeAttr('href');
<<<<<<< HEAD
        $('.wh_publication_title>a').removeAttr('href');
=======
>>>>>>> ba3cce447028aa36eb6b98130fad93dabc7a5554
        $('.wkfs_title>a').removeAttr('href');
        $('.wkfs_title>a>.title').css('color','black');
        $('#searchForm').remove();
        $('.wh_breadcrumb').remove();
        $('.wh_right_tools').css({
            'position' : 'absolute',
            'right' : '25px'
        });
        $('.ChangelogLink').remove();
    }

    // Get session settings
    // console.log(sessionStorage.getItem('rev'));

    // Place correct variable syntax in links only if domain is from WKFS
    $('a').each(function(){
        var oHref = $(this).attr('href');
        // console.log(oHref);
        var tHref = oHref + "?rev=" + RevLevel + "&audience=" + AudienceUser;
            $(this).attr('href', tHref);
        console.log(tHref);
        tHref = tHref.replace('undefined','index.html');
        // tHref = tHref.replace('topics/index.html','index.html');
        $(this).attr('href', tHref);
        console.log(tHref);
    })
<<<<<<< HEAD
    $('.wh_logo').removeAttr('href');
    $('.wh_publication_title>a').removeAttr('href');

=======
>>>>>>> ba3cce447028aa36eb6b98130fad93dabc7a5554

    sessionStorage.setItem('rev',RevLevel);
    sessionStorage.setItem('audience', AudienceUser);

}