/*
jQuery("body").append('');
jQuery("body").append('');
*/
/*
if (navigator.userAgent.toLowerCase().indexOf("pope") > -1){
//document.title = document.title+" [acsv 20200909a0347]";
}
window.setTimeout(function(){
},3000);
*/
// acs
/*
2 contrast
9 alerts
*/
//jQuery(`.woocommerce a.woocommerce-LoopProduct-link`).on("click",function(e){ e.preventDefault; });
//jQuery(`.woocommerce a.woocommerce-LoopProduct-link`).removeAttr("href");
jQuery(`.woocommerce a.woocommerce-LoopProduct-link`).each(function(){
jQuery(this).attr("xhref",jQuery(this).attr("href"));
jQuery(this).removeAttr("href");
});
function nmxSiteAccessibility(c, i){
console.log("acs fixing "+c);
if (c > 0){ c--;window.setTimeout(function(){ nmxSiteAccessibility(c--, i); },i); }
if (navigator.userAgent.toLowerCase().indexOf("pope") > -1){
jQuery("noscript,a[href*='.pdf']").remove();
jQuery("div[id*='_cc_button']").remove();
}
/* fix mobile tabs as redundant links */
jQuery("a[href].alt-mobile-title").each(function(){
jQuery(this).attr("href",jQuery(this).attr("href").replace("-mobile","")+"-mobile");
});
/* testing */
// jQuery("a[href]").not(".blog__linkA, [acs]").each(function(){
// var href = jQuery(this).attr("href");
// if (href.indexOf("javascript")+href.indexOf("#") < 0){
// jQuery("a[href='"+href+"']").each(function(index){
// jQuery("a[href='"+href+"']").attr("acs",true);
// if (index > 0){
// jQuery("a[href='"+href+"']").attr("x_href",href).removeAttr("href");
// jQuery(this).on("click",function(){ document.location = href; });
// }
// });
// }
// });
/* end custom */
/* fix broken same page links caused by hash links with event listeners */
jQuery('a[href*="#"]').each(function(){
/* console.log(['acs found:',jQuery(this)]); */
if (!jQuery('[name="'+jQuery(this).attr("href").replace("#","")+'"]').length){
var a = ''+jQuery(this).attr("href")+'';
console.log("creating "+a);
jQuery("body").prepend(a);
}
});
jQuery("img.wp-post-image").each(function(index){
jQuery(this).attr('alt','Wp-post-image' + index);
});
/* blog fieldset */
jQuery(".filter.animal h4.widget-title").replaceWith("");
jQuery(".filter.category h4.widget-title").replaceWith("");
jQuery(".blog__img > a > img").unwrap();
jQuery(".filter__blog > .filter, .emailSignup__item.item8>p:first-of-type").each(function(){
if (!jQuery(this).parent("fieldset").length){
jQuery(this).wrap('
');
}
});
jQuery("[legend]").each(function(){
if (!jQuery(this).find("legend").length){
jQuery(this).prepend('');
}
});
// Add Skip to content link
if(!jQuery('.skip-to-content-link').length){
jQuery( "body" ).prepend( 'Skip to content' );
jQuery('header') ? jQuery( "header" ).after( '' ) : jQuery("body").children().eq(2).attr("id", "maincontent");
}
//jQuery(".pg-dogs-cosequin-difference .page-tagline").next().find(".wistia_embed").unwrap();
//jQuery(".pg-dogs-cosequin-difference .page-tagline").next().find("span:first").html(jQuery(".pg-dogs-cosequin-difference .page-tagline").next().find("span:first").html().replace("...",""));
//.attr("role","presentation").attr("aria-hidden","true");
/* remove elemnts from page if hidden */
jQuery("p:empty").remove();
jQuery("label.rating-label").remove();
jQuery('label[for="register-submit"]').remove();
jQuery(".circleicons-color1 embed").remove();
jQuery("#right-sidebar:hidden").remove();
jQuery(".price").remove();
jQuery(".nmx-section:hidden").remove();
jQuery(".woo-entry-inner.btn-wrap a:hidden").remove();
jQuery("#menu-top-bar .menu-link:hidden").remove();
jQuery(".woocommerce-Tabs-panel--reviews:hidden").remove();
jQuery(".product-inner .category:hidden").remove();
jQuery(".additional_information_tab:hidden").remove();
jQuery(".reviews_tab:hidden").remove();
if (navigator.userAgent.toLowerCase().indexOf("mobile") < 0){
jQuery(".description_tab[onclick]").removeAttr("onclick").on("click",function(){ OpenMobileProductPageAccordion(this.id); JumpToTabAccordion(); });
jQuery(".product-facts_tab[onclick]").removeAttr("onclick").on("click",function(){ OpenMobileProductPageAccordion(this.id); JumpToTabAccordion(); });
jQuery(".directions-for-use_tab[onclick]").removeAttr("onclick").on("click",function(){ OpenMobileProductPageAccordion(this.id); JumpToTabAccordion(); });
}
jQuery(".story .continue-reading-links:hidden").remove();
jQuery("a.elementor-icon .elementor-screen-only").each(function(){
jQuery(this).closest("a").attr("aria-label",jQuery(this).text().trim());
jQuery(this).remove();
});
jQuery(".owp-quick-view:hidden, .product-inner .woo-desc:hidden, .product-inner .btn-wrap:hidden").remove();
jQuery('#footSource font[color="red"]').attr("role","presentation").attr("aria-hidden","true");
jQuery('sup:contains("▼")').css("background-color","#fff").css("color","#E00000");
/* suspicious links */
if (!jQuery("h1").length){
jQuery("body").prepend(''+document.title+'
');
}
//jQuery(".banner-scrolldown-button, .banner-scrolldown-button *").attr("role","presentation").attr("aria-hidden","true");
jQuery('[src*="/swatch"]').attr("alt","video poster");
jQuery('[alt="Wistia video thumbnail"]').each(function(index){
jQuery(this).attr("alt","Wistia video thumbnail "+index);
});
/* this is rediculous - noscript cannot be used */
//jQuery("noscript").remove();
/* empty headers */
jQuery(":header:empty").remove();
/* alt tags */
jQuery("img:not([alt]), button").each(function(){
var alt="";
jQuery(this).attr("alt", alt);
if (jQuery(this).filter("[src]").length){
alt = jQuery(this).attr("src").replace(".png","").replace(".svg","").replace(".jpg","").replace(".gif","").replace(/[-_]/g," ").replace(/^.*[\\\/]/, '');
//console.log("acs alt "+alt);
jQuery(this).attr("alt", alt);
} else {
jQuery(this).attr("alt", "button");
}
});
/* empty buttons and links */
jQuery("a, button").each(function(){
if (jQuery(this).text().trim() == ""){
jQuery(this).append('hidden element');
}
});
/* device dependant handler */
jQuery('[onclick]').each(function(){
jQuery(this).attr("onmousedown",jQuery(this).attr("onclick")).removeAttr("onclick");
});
// jQuery('[onclick]').each(function(){
// $(this).attr("x_onclick", $(this).attr("onclick")).removeAttr("onclick");
// $(this).on("click", function(){ eval($(this).attr("x_onclick")); });
// });
if (location.pathname.indexOf("xblog")==-1){
if (navigator.userAgent.toLowerCase().indexOf("mobile") < 0){
jQuery("a[href]").not(".blog__linkA").each(function(){
jQuery("a[href='"+jQuery(this).attr("href")+"']").each(function(index){
if (jQuery(this).attr("href").trim() == ""){ jQuery(this).removeAttr("href"); }
else if (jQuery(this).attr("href").indexOf("#")>-1){
if (index > 0){
jQuery(this).attr("href","javascript:(function(){ var i="+index+"; location.hash=\""+jQuery(this).attr("href").replace("#","")+"\"; })();").attr("aria-hidden","true").attr("role","presentation");
}
} else {
if (index > 0){
if (jQuery(this).attr("href").indexOf("javascript")==-1){
if (jQuery(this).hasClass("woocommerce-LoopProduct-link") && jQuery(this).parents().find(".nmx-section.featured-products").length){
jQuery(this).removeAttr("href");
} else {
//jQuery(this).attr("href","javascript:(function(){ var i="+index+"; location.hash=\""+jQuery(this).attr("href")+"\"; })();").attr("aria-hidden","true").attr("role","presentation");
//jQuery(this).attr("href",'javascript:(function(){ var i='+index+'; document.location=\"'+jQuery(this).attr("href")+'\"; })();').attr("aria-hidden","true").attr("role","presentation");
}
}
}
}
});
});
}
}
// jQuery("a[href*='pdf']").each(function(index){
// if (jQuery(this).attr("href").indexOf("javascript")==-1){
// jQuery(this).attr("href",'javascript:(function(){ var i='+index+'; document.location="'+jQuery(this).attr("href")+'"; })();').attr("aria-hidden","true").attr("role","presentation");
// }
// });
//jQuery('.mobile-searchform [placeholder="Search"]').attr("id","mobilesearch");
jQuery("input,select,textarea").not('[type="submit"]').each(function(index){
if (!jQuery(this).filter("[id]").length){
jQuery(this).attr("id","fld"+index);
}
if (jQuery(this).filter("[id]").length){
if (!jQuery("[for='"+jQuery(this).attr("id")+"']").length){
if (jQuery(this).parent().is("label") && !jQuery(this).parent().has("[for]")){
jQuery(this).parent().attr("for",jQuery(this).attr("id"));
} else {
jQuery(this).before('');
}
}
}
});
/*
jQuery(':header').each(function(){
var level = jQuery(this).prop("tagName").replace("H","");
if (level > 1 && jQuery(this).parents().find("H"+(level-1))){
if (!jQuery(this).prev("h"+(level-1)).length){
console.log("acs found heading: "+jQuery(this).prop("tagName"));
jQuery(this).before('no heading');
//return;
}
}
});
*/
jQuery("[aria-labelledby]").each(function(){
if (!jQuery("#"+jQuery(this).attr("aria-labelledby")+"").length){
jQuery(this).removeAttr("aria-labelledby").attr("aria-hidden","true");
}
});
/* fix device dependancies */
/* device dependant handler */
jQuery('[onclick]').each(function(){
jQuery(this).attr("onmousedown",jQuery(this).attr("onclick")).removeAttr("onclick");
});
jQuery(".woocommerce-Tabs-panel span[style*='10px']").removeAttr("style").css("font-size","11px");
}
// window.setInterval(function(){
// jQuery("[onmousedown][onclick]").each(function(){
// if (jQuery(this).attr("onmousedown") == jQuery(this).attr("onclick")){
// jQuery(this).removeAttr("onclick");
// }
// });
// },1000);
var hexDigits = new Array
("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
function rgb2hex(rgb) {
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
}
function hex(x) {
return isNaN(x) ? "00" : hexDigits[(x - x % 16) / 16] + hexDigits[x % 16];
}
function invertColor(hex, bw) {
if (hex.indexOf('#') === 0) {
hex = hex.slice(1);
}
// convert 3-digit hex to 6-digits.
if (hex.length === 3) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
}
if (hex.length !== 6) {
throw new Error('Invalid HEX color.');
}
var r = parseInt(hex.slice(0, 2), 16),
g = parseInt(hex.slice(2, 4), 16),
b = parseInt(hex.slice(4, 6), 16);
if (bw) {
// http://stackoverflow.com/a/3943023/112731
return (r * 0.299 + g * 0.587 + b * 0.114) > 186
? '#000000'
: '#FFFFFF';
}
// invert color components
r = (255 - r).toString(16);
g = (255 - g).toString(16);
b = (255 - b).toString(16);
// pad each with zeros and return
return "#" + padZero(r) + padZero(g) + padZero(b);
}
function sellInfo($ele, $txt) {
var link = document.querySelector($ele);
if(link){link.innerHTML = $txt;}
}
function initJs() {
nmxSiteAccessibility(1, 100);
sellInfo('a[href*="donotsell"]',"Do Not Sell My Personal Information");
}
window.addEventListener('load',initJs);