var XD = function(){ var interval_id, last_hash, cache_bust = 1, attached_callback, window = this; return { receiveMessage : function(callback, source_origin) { if (window['postMessage']) { if (callback) { attached_callback = function(e) { if ((typeof source_origin === 'string' && e.origin !== source_origin) || (Object.prototype.toString.call(source_origin) === "[object Function]" && source_origin(e.origin) === !1)) { return !1; } callback(e); }; } if (window['addEventListener']) { window[callback ? 'addEventListener' : 'removeEventListener']('message', attached_callback, !1); } else { window[callback ? 'attachEvent' : 'detachEvent']('onmessage', attached_callback); } } else { interval_id && clearInterval(interval_id); interval_id = null; if (callback) { interval_id = setInterval(function(){ var hash = document.location.hash, re = /^#?\d+&/; if (hash !== last_hash && re.test(hash)) { last_hash = hash; callback({data: hash.replace(re, '')}); } }, 100); } } } }; }(); var additiveHt = 0; var frameName = 'embeddedIframe'; var clientURL = 'https://apl.pedemontana.com'; var clientPath = '/jax-web/jawBridge/paga_sollecito.jsf'; frameSrc = clientURL + clientPath + '#' + encodeURIComponent(document.location.href); document.getElementById(frameName).src = frameSrc; XD.receiveMessage( function(message) { if( frameSrc.indexOf(clientURL) !== 0 ) { window.alert("Frame source URL invalid."); return; } var curHt = parseInt(message.data, 10); if(curHt) { document.getElementById(frameName).style.height = (curHt + additiveHt) + "px"; } }, clientURL ); /** * Script da installare sulla pagina di liferay con l'ifram che punta a jax */ var actionToFrameUrl = { "rr": "https://apl.pedemontana.com/jax-web/jawBridge/riepilogo_registrazione.jsf", "mp": "https://apl.pedemontana.com/jax-web/jawBridge/secure_folder/modifica_profilo_carta_credito.jsf", "err": "http://apl.pedemontana.com/jax-web/jawBridge/error_payment.jsf", "vp": "http://apl.pedemontana.com/jax-web/jawBridge/verify_payment.jsf" } function getUrlVars() { var vars = {}; window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m, key, value) { vars[key] = value; }); return vars; } function redirectEmbeddedFrame() { var urlParams = getUrlVars(); var frameUrl = actionToFrameUrl[urlParams.action]; if (frameUrl !== undefined) { var firstParam = true; delete urlParams.action; for (var urlParam in urlParams) { if (urlParams.hasOwnProperty(urlParam)) { frameUrl += (firstParam ? '?' : '&') + urlParam + '=' + urlParams[urlParam]; firstParam = false; } } var frame = document.getElementById('embeddedIframe') frame.src = frameUrl; } window.history.replaceState({}, document.title, '/paga-il-pedaggio'); } redirectEmbeddedFrame(); // ]]>