css("//www.nutramax.biz/mods/form.hcpractitioner/custom.shopify.css"); js("//www.nutramax.biz/mods/form.hcpractitioner/custom.shopify.js"); this.init = function() { console.log("/mods/form.hcpractitioner/index.php"); window.onload = function() { jQueryLoader(50); } function jQueryLoader(timeout){ var jquery_script = 'https://www.nutramax.biz/js/jquery.js'; if (timeout <= 0){ return; console.log('timed out waiting for jquery'); } if (window.jQuery) { console.log("found jQuery"); js("//www.nutramax.biz/mods/form.hcpractitioner/nmx.js"); } else { if (document.getElementsByTagName('head')[0].innerHTML.indexOf(jquery_script)<=0){ js(jquery_script); console.log('calling jQuery'); } window.setTimeout(function(){ console.log('waiting for jQuery'); jQueryLoader(timeout--); },200); } } if (window.jQuery) { console.log("found jQuery"); js("//www.nutramax.biz/mods/form.hcpractitioner/nmx.js"); } function js(filename){ if (document.getElementsByTagName('head')[0].innerHTML.indexOf(filename)<=0){ enableJS(".",filename); } } function css(filename){ if (document.getElementsByTagName('head')[0].innerHTML.indexOf(filename)<=0){ enableCSS(".",filename); } } function enableNMX(match,filename){ if ((filename.toLowerCase()+"|").indexOf(".js|")>-1){ enableJS(match,filename); } else if ((filename.toLowerCase()+"|").indexOf(".css|")>-1){ enableCSS(match,filename); } else { enableCSS(match,filename); enableJS(match,filename); } } function enableJS(match,filename){ filename = (filename.toLowerCase()+"|").replace(".js|","").replace(".css|","").replace(".|","").replace("|",""); filename = filename+".js"; if (matchURL(match)){ var script = document.createElement("script"); script.src = ''+filename; document.head.appendChild(script); console.log(filename); } } function enableCSS(match,filename){ filename = (filename.toLowerCase()+"|").replace(".js|","").replace(".css|","").replace(".|","").replace("|",""); filename = filename+".css"; if (matchURL(match)){ var link = document.createElement('link') link.setAttribute('rel', 'stylesheet') link.setAttribute('type', 'text/css') link.setAttribute('href', ''+filename) document.getElementsByTagName('head')[0].appendChild(link); console.log(filename); } } function matchURL(match){ if(match == "*" || match == ""){ return true; } if (document.location.href.toLowerCase().indexOf(match.toLowerCase().trim())>-1){ return true; } return false; } }; this.init();