// $Revision: 12164 $ $Date: 2010-12-06 11:02:39 -0200 (Mon, 06 Dec 2010) $
var LumisPortal = new LumisPortal();
document.onkeydown = LumisPortal.onKeyDown;
function LumisPortal()
{
this.onKeyDown = onKeyDown;
this.onRefresh = onRefresh;
this.onSubmitForm = onSubmitForm;
this.onPrint = onPrint;
this.getCookie = getCookie;
this.addMessage = addMessage;
this.onBodyLoad = onBodyLoad;
this.checkForMessages = checkForMessages;
this.gotoPage = gotoPage;
this.htmlEncode = htmlEncode;
this.mainName = "main.jsp";
this.pageParameterChannelIdName = "lumChannelId";
this.pageParameterPageIdName = "lumPageId";
this.isSubmitting = false;
this.renderInterfaceInstance = renderInterfaceInstance;
this.getXmlHttpObject = getXmlHttpObject;
this.lumisEncodeURIComponent = lumisEncodeURIComponent;
if(window.addEventListener)
{
try
{
window.addEventListener("pageshow", onPageShow, false);
}
catch(e)
{
;
}
}
function onPageShow()
{
this.isSubmitting = false;
}
function gotoPage(lumPageId, lumChannelId)
{
var url = this.mainName;
if(lumPageId != null)
url += "?"+this.pageParameterPageIdName+"="+lumPageId;
if(lumChannelId != null)
{
if(lumPageId == null)
url += "?";
else
url += "&";
url += this.pageParameterChannelIdName+"="+lumChannelId;
}
window.location.href = url;
}
function onKeyDown(event)
{
if(this.isSubmitting)
return;
if(!event)
event = window.event
if(event)
{
if(event.keyCode == 123)
{
document.forms["LumisPortalForm"].elements["lumMode"].value = 1;
if(event.ctrlKey)
document.forms["LumisPortalForm"].elements["lumSafeRenderMode"].value = 1;
document.forms["LumisPortalForm"].action = document.forms["LumisPortalForm"].elements["pageOriginalUrl"].value;
document.forms["LumisPortalForm"].submit();
this.isSubmitting = true;
}
}
}
function onRefresh()
{
if(this.isSubmitting)
return;
if (g_LumisIsHtmlCache)
{
this.isSubmitting = true;
document.location.reload();
}
else
{
if("1"==getCookie("lumMode"))
document.forms["LumisPortalForm"].action = document.forms["LumisPortalForm"].elements["pageOriginalUrl"].value;
document.forms["LumisPortalForm"].submit();
this.isSubmitting = true;
}
}
function onPrint(bUseNewWindow)
{
if(this.isSubmitting)
return;
if(bUseNewWindow)
{
var strFormTarget = document.forms['LumisPortalForm'].target;
document.forms['LumisPortalForm'].target = "_blank";
document.forms['LumisPortalForm'].elements['lumPrinting'].value = '1';
document.forms["LumisPortalForm"].submit();
document.forms['LumisPortalForm'].target = strFormTarget;
document.forms['LumisPortalForm'].elements['lumPrinting'].value = '0';
}
else
{
document.forms['LumisPortalForm'].elements['lumPrinting'].value = '1';
document.forms["LumisPortalForm"].submit();
this.isSubmitting = true;
}
}
function onSubmitForm(formName, destId, destType, bProcessAction, includeAnchor, updateElementId)
{
if(this.isSubmitting)
return;
var pForm = document.forms[formName];
if(!formHasFileInputs(pForm))
{
if(destType == null)
destType = "lumII";
var parameters = "
' + htmlEncode(strValue) + '
'; } } return strFormParams; } function getCookie(sName) { // cookies are separated by semicolons var aCookie = document.cookie.split("; "); for (var i=0; i < aCookie.length; i++) { // a name/value pair (a crumb) is separated by an equal sign var aCrumb = aCookie[i].split("="); if (sName == aCrumb[0]) { var strToDecode = aCrumb[1]; // replace '+' by space, because javascript decoding miss it strToDecode = strToDecode.replace(/\+/g, ' '); if (decodeURIComponent) return decodeURIComponent(strToDecode); else return unescape(strToDecode); // fallback for old browsers. May not display unicode correctly. } } // a cookie with the requested name does not exist return null; } function addMessage(message) { var pMsg = document.forms['LumisPortalForm'].elements['LumisClientMessage']; if (pMsg.value != '') pMsg.value += "\n"; pMsg.value += message; } function onBodyLoad() { // clear any parameters set by doing a [back] in browser var portalForm = document.forms["LumisPortalForm"]; portalForm.elements["lumNewParams"].value = ""; portalForm.elements["lumA"].value = ""; checkForMessages(); } function checkForMessages() { var strClientMessage = document.forms["LumisPortalForm"].elements["LumisClientMessage"].value; if (strClientMessage != "") window.setTimeout(showMessages, 1); } function showMessages() { var strClientMessage = document.forms["LumisPortalForm"].elements["LumisClientMessage"].value; if (strClientMessage != "") { alert(strClientMessage); document.forms["LumisPortalForm"].elements["LumisClientMessage"].value = ""; } } function htmlEncode(text) { if ( typeof( text ) != "string" ) text = text.toString() ; text = text.replace(/&/g, "&") ; text = text.replace(/"/g, """) ; text = text.replace(//g, ">") ; text = text.replace(/'/g, "'") ; return text ; } function renderInterfaceInstance(interfaceInstanceElement, interfaceInstanceId, updatingControl) { if(updatingControl != true && interfaceInstanceElement.innerHTML.length > 0) { var loadingDivBg = document.createElement('div'); loadingDivBg.style.position = "absolute"; loadingDivBg.style.width = (interfaceInstanceElement.offsetWidth)+"px"; loadingDivBg.style.height = (interfaceInstanceElement.offsetHeight)+"px"; loadingDivBg.style.overflow = "hidden"; loadingDivBg.style.zIndex = "1001"; loadingDivBg.className = "cLumClientRenderWaitBox"; var loadingDiv = document.createElement('div'); loadingDiv.style.position = "absolute"; loadingDiv.style.width = (interfaceInstanceElement.offsetWidth)+"px"; loadingDiv.style.height = (interfaceInstanceElement.offsetHeight)+"px"; loadingDiv.style.overflow = "hidden"; loadingDiv.style.zIndex = "1002"; loadingDiv.className = "cLumClientRenderWaitMessage"; loadingDiv.innerHTML = g_LumisLoadingHtmlMessage; if(interfaceInstanceElement.childNodes.length > 0) interfaceInstanceElement.insertBefore(loadingDivBg, interfaceInstanceElement.childNodes[0]); else interfaceInstanceElement.appendChild(loadingDivBg); interfaceInstanceElement.insertBefore(loadingDiv, interfaceInstanceElement.childNodes[0]); } else if(updatingControl != true) { interfaceInstanceElement.innerHTML = g_LumisLoadingHtmlMessage; } var xmlHttp = getXmlHttpObject(); function handleRenderResponse() { if ( xmlHttp.readyState == 4 ) { if (navigator.userAgent.indexOf("MSIE") == -1) { var tempDiv = document.createElement('div'); tempDiv.innerHTML = xmlHttp.responseText; var tempDivChildren = tempDiv.childNodes; interfaceInstanceElement.innerHTML = ""; while(tempDivChildren.length > 0) interfaceInstanceElement.appendChild(tempDivChildren[0]); } else { var tempDiv = document.createElement('div'); tempDiv.id = interfaceInstanceElement.id; interfaceInstanceElement.parentNode.insertBefore(tempDiv, interfaceInstanceElement); tempDiv.innerHTML = xmlHttp.responseText; interfaceInstanceElement.parentNode.removeChild(interfaceInstanceElement); } xmlHttp = null; } } // get the interface content and render it var strRequest = "lumPrevParams="+lumisEncodeURIComponent(document.forms["LumisPortalForm"].elements["lumPrevParams"].value); strRequest += "&lumNewParams="+lumisEncodeURIComponent(document.forms["LumisPortalForm"].elements["lumNewParams"].value); xmlHttp.open("POST", document.forms["LumisPortalRenderInterfaceForm"].action+"&lumScript=1&lumRenderII="+interfaceInstanceId, true); xmlHttp.onreadystatechange = handleRenderResponse; xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xmlHttp.send(strRequest); } function getXmlHttpObject() { var httpObj = null; if (window.XMLHttpRequest) httpObj=new XMLHttpRequest(); else httpObj=new ActiveXObject("Microsoft.XMLHTTP"); return httpObj; } function lumisEncodeURIComponent(str) { if (encodeURIComponent) return encodeURIComponent(str); else return escape(str); } }