console.log('JWT blank. Not taking any login action.');
//************************************************
//********** GLOBAL PD/ONE VARIABLES *************
//************************************************
var pdCategoryId = "722";
//************************************************
//************ JS/CSS FILE ROUTINES *************
//************************************************
function pdLoadJsCssFile(filename, filetype){
if (filetype=="js") {
var fileref=document.createElement('script');
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("async",true);
fileref.setAttribute("src", filename);
}
else if (filetype=="css") {
var fileref=document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", filename);
}
if (typeof fileref!="undefined")
document.getElementsByTagName("head")[0].appendChild(fileref);
}
//************************************************
//****** PD/ONE FEATURE SPECIFIC CSS/JS *********
//************************************************
pdLoadJsCssFile("https://cdn.practicaldatacore.com/my-superiornutstore/mod_bigcommerce/pdCompiledScript.js?cb=1939578", "js");
pdLoadJsCssFile("https://cdn.practicaldatacore.com/my-superiornutstore/mod_pdOneStyleEditor/pdPublicStyle.css?cb=484894", "css");
//*** CATEGORY ID:722****
//*** PRODUCT ID:****
//*** PRODUCT ID LIST CSV:****
//**** INCLUDE CATEGORY PAGE JAVASCRIPT ****
var pdStarsRefreshFlag = true;
function pdDisplayCategoryStars() {
if(pdStarsRefreshFlag == true) {
document.querySelectorAll("div[productId='1467'], div[data-itemid='1467'], .pdRatingStarsWrapper[data-itemid='1467']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='1471'], div[data-itemid='1471'], .pdRatingStarsWrapper[data-itemid='1471']").forEach(function(element) {
element.innerHTML = "
(1 reviews)";
});
document.querySelectorAll("div[productId='1509'], div[data-itemid='1509'], .pdRatingStarsWrapper[data-itemid='1509']").forEach(function(element) {
element.innerHTML = "
(4 reviews)";
});
document.querySelectorAll("div[productId='1560'], div[data-itemid='1560'], .pdRatingStarsWrapper[data-itemid='1560']").forEach(function(element) {
element.innerHTML = "
(8 reviews)";
});
document.querySelectorAll("div[productId='1561'], div[data-itemid='1561'], .pdRatingStarsWrapper[data-itemid='1561']").forEach(function(element) {
element.innerHTML = "
(6 reviews)";
});
document.querySelectorAll("div[productId='1562'], div[data-itemid='1562'], .pdRatingStarsWrapper[data-itemid='1562']").forEach(function(element) {
element.innerHTML = "
(9 reviews)";
});
document.querySelectorAll("div[productId='1576'], div[data-itemid='1576'], .pdRatingStarsWrapper[data-itemid='1576']").forEach(function(element) {
element.innerHTML = "
(11 reviews)";
});
document.querySelectorAll("div[productId='1578'], div[data-itemid='1578'], .pdRatingStarsWrapper[data-itemid='1578']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='1579'], div[data-itemid='1579'], .pdRatingStarsWrapper[data-itemid='1579']").forEach(function(element) {
element.innerHTML = "
(34 reviews)";
});
document.querySelectorAll("div[productId='1610'], div[data-itemid='1610'], .pdRatingStarsWrapper[data-itemid='1610']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='1663'], div[data-itemid='1663'], .pdRatingStarsWrapper[data-itemid='1663']").forEach(function(element) {
element.innerHTML = "
(8 reviews)";
});
document.querySelectorAll("div[productId='1699'], div[data-itemid='1699'], .pdRatingStarsWrapper[data-itemid='1699']").forEach(function(element) {
element.innerHTML = "
(4 reviews)";
});
document.querySelectorAll("div[productId='1744'], div[data-itemid='1744'], .pdRatingStarsWrapper[data-itemid='1744']").forEach(function(element) {
element.innerHTML = "
(3 reviews)";
});
document.querySelectorAll("div[productId='1745'], div[data-itemid='1745'], .pdRatingStarsWrapper[data-itemid='1745']").forEach(function(element) {
element.innerHTML = "
(13 reviews)";
});
document.querySelectorAll("div[productId='1746'], div[data-itemid='1746'], .pdRatingStarsWrapper[data-itemid='1746']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='1792'], div[data-itemid='1792'], .pdRatingStarsWrapper[data-itemid='1792']").forEach(function(element) {
element.innerHTML = "
(2 reviews)";
});
document.querySelectorAll("div[productId='1860'], div[data-itemid='1860'], .pdRatingStarsWrapper[data-itemid='1860']").forEach(function(element) {
element.innerHTML = "
(5 reviews)";
});
document.querySelectorAll("div[productId='1949'], div[data-itemid='1949'], .pdRatingStarsWrapper[data-itemid='1949']").forEach(function(element) {
element.innerHTML = "
(12 reviews)";
});
document.querySelectorAll("div[productId='1954'], div[data-itemid='1954'], .pdRatingStarsWrapper[data-itemid='1954']").forEach(function(element) {
element.innerHTML = "
(10 reviews)";
});
document.querySelectorAll("div[productId='1955'], div[data-itemid='1955'], .pdRatingStarsWrapper[data-itemid='1955']").forEach(function(element) {
element.innerHTML = "
(6 reviews)";
});
document.querySelectorAll("div[productId='1956'], div[data-itemid='1956'], .pdRatingStarsWrapper[data-itemid='1956']").forEach(function(element) {
element.innerHTML = "
(47 reviews)";
});
document.querySelectorAll("div[productId='2066'], div[data-itemid='2066'], .pdRatingStarsWrapper[data-itemid='2066']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2067'], div[data-itemid='2067'], .pdRatingStarsWrapper[data-itemid='2067']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2068'], div[data-itemid='2068'], .pdRatingStarsWrapper[data-itemid='2068']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2069'], div[data-itemid='2069'], .pdRatingStarsWrapper[data-itemid='2069']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2070'], div[data-itemid='2070'], .pdRatingStarsWrapper[data-itemid='2070']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2071'], div[data-itemid='2071'], .pdRatingStarsWrapper[data-itemid='2071']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2072'], div[data-itemid='2072'], .pdRatingStarsWrapper[data-itemid='2072']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2073'], div[data-itemid='2073'], .pdRatingStarsWrapper[data-itemid='2073']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2074'], div[data-itemid='2074'], .pdRatingStarsWrapper[data-itemid='2074']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2075'], div[data-itemid='2075'], .pdRatingStarsWrapper[data-itemid='2075']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2076'], div[data-itemid='2076'], .pdRatingStarsWrapper[data-itemid='2076']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2077'], div[data-itemid='2077'], .pdRatingStarsWrapper[data-itemid='2077']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2078'], div[data-itemid='2078'], .pdRatingStarsWrapper[data-itemid='2078']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2079'], div[data-itemid='2079'], .pdRatingStarsWrapper[data-itemid='2079']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2080'], div[data-itemid='2080'], .pdRatingStarsWrapper[data-itemid='2080']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2081'], div[data-itemid='2081'], .pdRatingStarsWrapper[data-itemid='2081']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2082'], div[data-itemid='2082'], .pdRatingStarsWrapper[data-itemid='2082']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2083'], div[data-itemid='2083'], .pdRatingStarsWrapper[data-itemid='2083']").forEach(function(element) {
element.innerHTML = "
(4 reviews)";
});
document.querySelectorAll("div[productId='2087'], div[data-itemid='2087'], .pdRatingStarsWrapper[data-itemid='2087']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2088'], div[data-itemid='2088'], .pdRatingStarsWrapper[data-itemid='2088']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2089'], div[data-itemid='2089'], .pdRatingStarsWrapper[data-itemid='2089']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2090'], div[data-itemid='2090'], .pdRatingStarsWrapper[data-itemid='2090']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2091'], div[data-itemid='2091'], .pdRatingStarsWrapper[data-itemid='2091']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2092'], div[data-itemid='2092'], .pdRatingStarsWrapper[data-itemid='2092']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2093'], div[data-itemid='2093'], .pdRatingStarsWrapper[data-itemid='2093']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2094'], div[data-itemid='2094'], .pdRatingStarsWrapper[data-itemid='2094']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2095'], div[data-itemid='2095'], .pdRatingStarsWrapper[data-itemid='2095']").forEach(function(element) {
element.innerHTML = "";
});
document.querySelectorAll("div[productId='2096'], div[data-itemid='2096'], .pdRatingStarsWrapper[data-itemid='2096']").forEach(function(element) {
element.innerHTML = "
(5 reviews)";
});
pdStarsRefreshFlag = false;
}
}
pdDisplayCategoryStars();
function pdRefreshCategoryStarsDelayed() {
pdStarsRefreshFlag = true;
setTimeout(pdDisplayCategoryStars, 500);
}
try {
document.getElementById('product-listing-container').addEventListener('DOMSubtreeModified', function() {
pdRefreshCategoryStarsDelayed();
});
} catch(e){};
//*** BEGIN public_mod_myRewards_getRenderedPromotionMessagingJsInsertionCode ***
document.querySelectorAll("div.pdRewardsPromoMessage[productId=\"\"], div.pdRewardsPromoMessage[data-itemid=\"\"]").forEach(function(div) { div.innerHTML = "";});
//*** END public_mod_myRewards_getRenderedPromotionMessagingJsInsertionCode ***
//*** BEGIN public_mod_myRewards_getRenderedPromotionPopupJsInsertionCode ***
document.body.insertAdjacentHTML("beforeend", "");
//*** END public_mod_myRewards_getRenderedPromotionPopupJsInsertionCode ***
//*** public_mod_structuredData_renderJsonByItemId found
//*** public_mod_structuredData enabled
var script = document.createElement('script');
script.setAttribute('type', 'application/ld+json');
script.innerHTML = "{\"@context\":\"http:\\/\\/schema.org\",\"@type\":\"Organization\",\"name\":\"Superior Nut Store\",\"url\":\"https:\\/\\/www.superiornutstore.com\\/\",\"address\":{\"@type\":\"PostalAddress\"},\"founders\":[{\"@type\":\"Person\"}],\"contactPoint\":{\"@type\":\"ContactPoint\"}}"
document.getElementsByTagName('head')[0].appendChild(script); ;
function pdInjectAccountLinkModifications() {
//***** INJECT REWARDS LINK ****
jQuery(".navBar-section li:nth-child(2)").after('Rewards');
//***** INJECT OLDER ORDER HISTORY LINK ****
jQuery(".navBar-section li:nth-child(1)").after('Older Orders');
}
pdInjectAccountLinkModifications();var pdPublicUrl = 'https://my.superiornutstore.com/';
jQuery(document).ready(function(){
const urlParams = new URLSearchParams(location.search);
var prevLinkElem = jQuery('.navBar-section .is-active').data("pdLinkElem");
var prevLinkTarget = jQuery('.navBar-section .is-active').data("pdLinkElemTarget");
if (prevLinkElem && prevLinkTarget) {
jQuery(prevLinkTarget).html(prevLinkElem);
jQuery('.navBar-section .is-active').data("pdLinkElem", false);
jQuery('.navBar-section .is-active').data("pdLinkElemTarget", false);
}
if (urlParams.has('pd_module_content')){
var module = urlParams.get('pd_module_content');
var subNav = urlParams.get('pd_module_subNav');
var moduleTitle = jQuery('#pdContent_'+module+' a').html();
var currentUrl = window.location.href;
var currentUrlNoQuery = currentUrl.substring(0, currentUrl.indexOf('?'));
console.log(currentUrlNoQuery);
var currentTab = jQuery('.navBar-section .is-active').html();
if (jQuery('.navBar-section .is-active').hasClass('pdLinkEvent') == false){
if(jQuery('.navBar-section .is-active .navBar-action').length){
}
else {
jQuery('.navBar-section .is-active').html(''+currentTab+'');
}
}
jQuery('.navBar-section .is-active').data("pdLinkElemTarget", '#pdContent_'+module);
jQuery('.navBar-section .is-active').data("pdLinkElem", jQuery('#pdContent_'+module).html());
jQuery('#pdContent_'+module).html(jQuery('#pdContent_'+module+' a').text());
jQuery('.navBar-section .is-active').removeClass('is-active');
jQuery('#pdContent_'+module).addClass('is-active');
jQuery('.page-heading').html(moduleTitle);
if (subNav !== '' && subNav !== null){
url = pdPublicUrl+'/'+module+'/'+subNav+'.php?module='+module;
}
else {
url = pdPublicUrl+'/'+module+'/index.php?module='+module;
}
pdOneAjaxLinkHandler(url);
}
});
jQuery(document).on('submit', '.pdModal form', function(e){
e.preventDefault();
e.stopImmediatePropagation()
pdOneAjaxFormHandler(this);
});
jQuery(document).on('submit', '#pdModuleContent form', function(e){
e.preventDefault();
e.stopImmediatePropagation()
pdOneAjaxFormHandler(this);
});
jQuery(document).on('click', '.pdLinkEvent', function(e){
var currentUrl = window.location.href;
var currentTab = jQuery('.navBar-section .is-active .navBar-action').html();
console.log(jQuery(this).html());
if (jQuery('.navBar-section .is-active').hasClass('pdLinkEvent') == false){
jQuery('.navBar-section .is-active').html(''+currentTab+'');
}
jQuery('.navBar-section .is-active').removeClass('is-active');
jQuery(this).parent().addClass('is-active');
var url = jQuery(this).attr('href');
e.preventDefault();
e.stopImmediatePropagation()
pdOneAjaxLinkHandler(url);
});
jQuery(document).on('click', '#pdModuleContent a', function(e) {
var url = jQuery(this).attr('href');
jQuery(this).attr("href", "#");
e.preventDefault();
pdOneAjaxLinkHandler(url);
});
function pdOneAjaxLinkHandler(url){
console.log("pdOneAjaxLinkHandler:" + url);
var currModule = jQuery('#pdModuleContent').attr('data-currmodule');
var externalLink = false;
//assume http or https is external link
var testUrl = url;
var testUrlNoQuery = url.substring(0, testUrl.indexOf('?'));
if (testUrlNoQuery !== ''){
if ((url.includes('https://') || url.includes('http://')) && !testUrlNoQuery.includes('mod_')){
externalLink = true;
}
}
if (!externalLink && currModule !== '' && currModule !== undefined) {
testUrl = testUrl.replace('https://', '');
testUrl = testUrl.replace('http://', '');
replaceStart = testUrl.indexOf('/');
if (replaceStart == -1){
replaceStart = 0;
}
testurl = testUrl.substring(replaceStart);
//If no 'mod_' present assume reference path to current module and create absolute path
if (!url.includes('mod_')){
url = pdPublicUrl+'/'+currModule+'/'+testurl+'?module='+currModule;
}
//Else assume link to other module and create absolute path
else {
url = pdPublicUrl+'/'+testurl+'?module='+currModule;
}
}
//Perform ajax if not linking to external site
if (!externalLink){
if (url.includes('?')){
url += '&mode=inject';
}
else {
url += '?mode=inject';
}
jQuery.ajax({
'async': true,
'global': false,
'xhrFields': {
withCredentials: true
},
'type': "POST",
'crossDomain': true,
'url': url,
'success': function(result) {
console.log('success');
jQuery('.account-content').html(result);
},
error: function(errMsg) {
console.log('error');
console.log(errMsg['statusText']);
}
});
}
else {
// window.location.href = url;
}
}
function pdOneAjaxFormHandler(form, module){
currModule = jQuery('#pdModuleData').attr('data-currmodule');
if (currModule == undefined){
currModule = jQuery('#pdModuleContent').attr('data-currmodule');
}
formData = jQuery(form).serializeArray();
console.log(formData);
var method = jQuery(form).attr('method');
var url = jQuery(form).attr('action');
replaceStart = url.indexOf('/');
if (replaceStart == -1){
replaceStart = 0;
}
url = url.substring(replaceStart);
url = pdPublicUrl+'/'+currModule+'/'+url+'?module='+currModule;
if (url.includes('?')){
url += '&mode=inject';
}
else {
url += '?mode=inject';
}
if (url.includes('?')){
url += '&module='+currModule;
}
else {
url += '?module='+currModule;
}
jQuery.ajax({
'async': false,
'global': false,
'xhrFields': {
withCredentials: true
},
'type': method,
'crossDomain': true,
'url': url,
data: formData,
'success': function(result) {
console.log('success');
console.log(result);
jQuery(form).closest('#pdModuleContent').replaceWith(result);
},
error: function(errMsg) {
console.log('error');
console.log(errMsg);
}
});
}var script = document.createElement('style');
script.setAttribute('type', 'text/css');
script.innerHTML = ``;
document.getElementsByTagName('head')[0].appendChild(script);
if(jQuery('#pd_pdOneBanner').length) {
//*** BANNER ALREADY EXISTS, DO NOT RE-INSERT
} else {
jQuery("body").prepend('');
}
jQuery("#pd_pdOneBanner").html("");
//*** COMPLETEION CALLBACK
try{pdContentRenderCompleted()}catch(e){};
//*** done.