function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i"+""; if (document.getElementById("subscrimia-customer-portal-container")) { console.log("Iframe already loaded...") return; } var tmpObj = document.createElement("div"); tmpObj.id = "subscrimia-customer-portal-container"; tmpObj.innerHTML= iframe_content; document.getElementById("subscrimia-portal-script").parentNode.appendChild( tmpObj ); console.log("Iframe loaded into parent of script..."); var sheet = document.createElement('style') sheet.innerHTML = " \ @media (min-width:320px) { /* smartphones, iPhone, portrait 480x320 phones */ }\ @media (min-width:481px) { /* portrait e-readers (Nook/Kindle), smaller tablets @ 600 or @ 640 wide. */ }\ @media (min-width:641px) { #subscrimia-customer-portal-container {min-width:500px} /* portrait tablets, portrait iPad, landscape e-readers, landscape 800x480 or 854x480 phones */ }\ @media (min-width:961px) { #subscrimia-customer-portal-container {min-width:800px} /* tablet, landscape iPad, lo-res laptops ands desktops */ }\ @media (min-width:1025px) { #subscrimia-customer-portal-container {min-width:800px} /* big landscape tablets, laptops, and desktops */ }\ @media (min-width:1281px) { #subscrimia-customer-portal-container {min-width:800px} /* hi-res laptops and desktops */ }\ "; document.body.appendChild(sheet); console.log("Iframe styles loaded on body..."); iFrameResize({"checkOrigin": false, "inPageLinks": true}); console.log("Finished loading"); } else { console.log("Error loading iframe.") } } } var portal_page_param = ""; if (window.location && window.location.hash){ portal_page_param = window.location.hash.substr(1); } xmlhttp_subscrimia_load_iframe.open("GET", "https://subscrimia.com/resource/portaldecode/?hash="+customer_endoded_data+"&page="+portal_page_param, true); xmlhttp_subscrimia_load_iframe.send(); } function loginAndRedirect() { console.log("Login non authenticated user using JWT method ..."); if (!getQueryVariable("h")) { window.location.href = "/login.php?from=subscriptions" console.log("Non auth parameters..."); return; } var xmlhttp_subscrimia = new XMLHttpRequest(); xmlhttp_subscrimia.onreadystatechange = function() { if (xmlhttp_subscrimia.readyState == 4) { if (xmlhttp_subscrimia.status == 200) { console.log("User authenticated succesfully, redirecting to JWT Auth Method..."); window.location.href = "/login/token/"+xmlhttp_subscrimia.responseText; } else { console.log("Not loaded encoded login response"); } } } var portal_page_param = ""; if (window.location && window.location.hash){ portal_page_param = window.location.hash.substr(1); } xmlhttp_subscrimia.open("GET", "https://subscrimia.com/resource/portalloginencode/?h="+getQueryVariable("h")+"&page="+portal_page_param, true); xmlhttp_subscrimia.send(); } function logoutCurrentCustomer(successCallback) { var xmlhttp_subscrimia = new XMLHttpRequest(); xmlhttp_subscrimia.onreadystatechange = function() { if (xmlhttp_subscrimia.readyState == 4) { successCallback(); } } xmlhttp_subscrimia.open("GET", "/login.php?action=logout", true); xmlhttp_subscrimia.send(); } checkLogin(loadIframe, loginAndRedirect);