/******************************************************************************************************************************** * Licensed Materials - Property of IBM * * * * IBM Cognos Products: AGS * * * * (C) Copyright IBM Corp. 2005, 2010 * * * * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. * *********************************************************************************************************************************/ //define the object that will check the keydown for hot keys var keyDownChecker = new Object(); keyDownChecker.check = checkForHotKeyActions; keyDownChecker.update = function() { return true; } var browserCheck = new BrowserCheck(); //define the hotkeys that are allowed to be processed var allowedHotkeys = new Array(); //K,C,V,X,A allowedHotkeys[K_sKeyCode_K]=true; allowedHotkeys[K_sKeyCode_C]=true; allowedHotkeys[K_sKeyCode_V]=true; allowedHotkeys[K_sKeyCode_X]=true; allowedHotkeys[K_sKeyCode_A]=true; var saveChangesToDialogFrame=false; // // the variable "cfgValues" must have been defined in one the files including this script file. // It is done this way to ensure we have only one valid definition of "cfgValues" // var CURRENT_TIP = "infoItemTip"; var CURRENT_TIP_SYNTAX = "infoItemSyntax"; var CURRENT_ERROR_DIV_ID_KEY = "CURRENT_ERROR_DIV_ID_KEY"; var DIALOG_FRAME_ID = "dialogIFrame"; // var for event studio errors var pageErrors = new Array(); // progressbar handle var g_divProgressBar; if ( window == window.top ) { try { // Sometimes causes "Access is denied" exception window.moveTo( 0,0 ); window.resizeTo( screen.availWidth, screen.availHeight ); } catch ( e ) { }; }; var dialogFormValues = new Array(); var asyncFormValues = new Array(); var cfgValues = new Array(); var __preview_win = null; // These are the languages that are supported by Cognos Connection documentation var sSupportedLangs = " en fr ja de "; var sDefaultLang = "en"; // // --- Configuration management functions --- // function cfgSet(n, v) { cfgValues[n] = v; } function cfgGet(n) { return cfgValues[n]; } function cfgRemove(n) { delete cfgValues[n]; } function cfgIsArray(a) { return isArray(cfgValues[a]); } function cfgPush(a, v) { if (!cfgIsArray(a)) cfgValues[a] = cfgMakeArray(a); addToArray(cfgValues[a], v); } function cfgAddParm(n, v) { if (!isArray(cfgValues[n])) cfgValues[n] = makeArray(cfgValues[n]); addToArray(cfgValues[n], v); } function cfgSetDefaultAt(i) { cfgSetAt("ColFormat", i, new Array("none")); cfgSetAt("IsHidden",i, false); cfgSetAt("OriginalLabels",i,""); cfgSetAt("calcOp",i,""); cfgSetAt("SummaryAgg",i,"none"); cfgSetAt("DetailAgg",i,"none"); cfgSetAt("RegularAgg",i,"none"); cfgSetAt("sortOnRef",i,"none"); cfgSetAt("promptCascadeOnRef",i,"none"); cfgSetAt("PromptType",i,"0"); cfgSetAt("ColFilterIdx",i,""); cfgSetAt("ColLabels",i,""); cfgSetAt("IsFakeMeasure",i,false); cfgSetAt("IsMeasure",i,false); cfgSetAt("IsCollapsed",i,false); cfgSetAt("ColRole",i,"Ungrouped"); cfgSetAt("HasSummaries",i,false); cfgSetAt("displayType",i,""); } function cfgSetColAt(i, v1, v2, v3, v4, v5, v6, v7) { cfgSetAt("QueryIDs",i,v1); cfgSetAt("ColType",i,v2); cfgSetAt("ColUsage",i,v3); cfgSetAt("ColSort",i,v4); cfgSetAt("ColSortBy",i,v5); cfgSetAt("ColIDs",i,v6); cfgSetAt("ColOldType",i,v7); } function cfgSetAt(a, i, v) { if (!cfgIsArray(a)) cfgValues[a] = cfgMakeArray(a); insertInArrayAt(cfgValues[a], i, v); } function cfgGetAt(a, i) { if (!cfgIsArray(a)) return null; return cfgValues[a][i]; } function cfgPop(a, v) { if (!cfgIsArray(a)) return; var bRemoved=false; var size=cfgValues[a].length; for (var i=0;iConfig values ["+(new Date())+"]

"); w.document.writeln(""); //SEC_INFO: cfgValues[i] can contain the values set in the session parameters for (i in cfgValues) w.document.writeln(""); w.document.writeln("
namevalue(s)
"+i+""+htmlEncode(printValue(cfgValues[i]))+"
"); } function showDialogValues() { var w = window.open("../qs/blank.html", "_trace_window_"); w.document.writeln("

Dialog values ["+(new Date())+"]

"); w.document.writeln(""); for (i in dialogFormValues) w.document.writeln(""); w.document.writeln("
namevalue(s)
"+i+""+htmlEncode(printValue(dialogFormValues[i]))+"
"); } /* * Display all the form controls in the message frame */ function showFormValues() { var msgFrame = getMessageIFrame(); var msgDoc = getFrameDocument(msgFrame); var forms = msgDoc.forms; var w = window.open("../ags/blank.html", "_trace_window_"); w.document.write("Agent Studio Message Frame Form Values"); w.document.write("

Agent Studio Form Values ["+(new Date())+"]

"); w.document.write(""); //loop through the forms in the message frame for (var i=0;i"); w.document.write(""); //loop through the controls in the form for (var j=0;jNONE" w.document.write(""); if (control.id != "") { // SEC_INFO: control property values are contants w.document.write(""); } else { w.document.write(blankCell); } if (control.name != undefined) { // SEC_INFO: control property values are contants w.document.write(""); } else { w.document.write(blankCell); } if (control.value != "") { // SEC_INFO: control property values are contants w.document.write(""); } else { w.document.write(blankCell); } w.document.write(""); } } } w.document.write("
Morphlet:"+form.m.value +". Found "+form.length+" input controls in "+form.name+"
idnamevalue
"+htmlEncode(control.id)+""+htmlEncode(control.name)+""+htmlEncode(control.value)+"
"); return; } function printValue(n) { if (n == null) return "null"; if (typeof n == "object" && n.length>0) { var t = ""; for (var i in n) t+=""+i+". "+n[i]+"
"; return t } return n; } function traceObject(obj) { var w = window.open("../qs/blank.html", "_trace_window_"); w.document.writeln("

Output of an object. ["+(new Date())+"]

"); w.document.writeln(""); for (i in obj) w.document.writeln(htmlEncode("")); w.document.writeln("
namevalue(s)
"+i+""+obj[i]+"
"); } function getConnectionParametersSet(configKey){ //get the connection parameters var connectionParamParser = getConnectionParameterValuesParser(configKey); //collect all name elements from the connection params var pv_elements = getElementsByLocalName(connectionParamParser, "item", true); var connection_name_set = new Object(); for(var i = 0; i< pv_elements.length; i++){ var name_string = getElementsByLocalName(pv_elements[i], "name", true); var value_string = pv_elements[i].getValue(); connection_name_set[name_elements[i].getValue()] = value_string; } } //normalise parameter values using a parser //and strip out all but connection prompts function saveParameterValues(parameters, configKey){ //get the connection parameters var connectionParamParser = getConnectionParameterValuesParser(configKey); //get the other parameters var otherParmItemParserArray = otherParmItemParserArray = new Array(); //collect all name elements from the connection params var name_elements = getElementsByLocalName(connectionParamParser, "name", true); var connection_name_set = new Object(); for(var i = 0; i< name_elements.length; i++){ connection_name_set[name_elements[i].getValue()] = true; } for (var i = 0; i < parameters.length; i++) { if(!(parameters[i] instanceof XMLElement)){ parameters[i] = new XMLParser(parameters[i]); } var param_name_element = findChildByLocalName(parameters[i], "name", false); var param_name = param_name_element ? param_name_element.getValue() : null; if(!param_name){ continue; } if(param_name.indexOf("credential:") == 0){ if(!connection_name_set[param_name]){ //save it connectionParamParser.appendChild(parameters[i]); } }else{ otherParmItemParserArray.push(parameters[i]); } } // set the connection parameter values so that we aren't prompted again cfgSet(configKey + "connectionParameterValues", connectionParamParser.toString()); //also hang on to the other prompt values cfgSet(configKey + "otherParameterValues", otherParmItemParserArray); } function initConnectionParameterValues(configKey){ var pvWrapper = ""; cfgSet(configKey + "connectionParameterValues", pvWrapper); return pvWrapper; } function getConnectionParameterValuesParser(configKey){ //get the connection parameters var connectionParams = cfgGet(configKey + "connectionParameterValues"); if (!connectionParams) { connectionParams = initConnectionParameterValues(configKey); } return new XMLParser(connectionParams) } function getConnectionParameterValues(configKey){ return getConnectionParameterValuesParser(configKey).toString(); } //returns the pvs inthe form of a parameterValues prop function getAllParameterValuesParser(configKey){ //get the connection parameters var paramParser = getConnectionParameterValuesParser(configKey); var otherParams = cfgGet(configKey + "otherParameterValues"); if(otherParams){ for(var i = 0; i < otherParams.length; i++){ paramParser.appendChild(otherParams[i]); } } //these are a one hit wonder cfgRemove(configKey + "otherParameterValues"); return paramParser; } //returns the pvs inthe form of a parameterValues prop function getAllParameterValues(configKey){ return getAllParameterValuesParser(configKey).toString(); } //returns the pvs in the form of a parameters prop function getAllParameters(configKey){ var parameterValues = getAllParameterValuesParser(configKey); parameterValues.nodeName = "value"; var paramWrapper = ""; var paramParser = new XMLParser(paramWrapper); paramParser.appendChild(parameterValues); return paramParser.toString(); } //returns the pvs in the form of a parameters prop function getConnectionParameters(configKey){ var parameterValues = getConnectionParameterValuesParser(configKey); parameterValues.nodeName = "value"; var paramWrapper = ""; var paramParser = new XMLParser(paramWrapper); paramParser.appendChild(parameterValues); return paramParser.toString(); } getElementsByLocalName = function (node, s, deep) { var a = new Array(); for (var i = 0; i < node.childNodes.length; i++) { if (node.childNodes[i].getName().indexOf(s) != -1) { a[a.length] = node.childNodes[i]; } } if (deep != false) { for (i = 0; i < node.childNodes.length; i++) { var aChild = getElementsByLocalName(node.childNodes[i], s, deep); for (var j = 0; j < aChild.length; j++) { a[a.length] = aChild[j]; } } } return a; } findChildByLocalName = function (node, n, deepWalk) { if (node.getName() == n) { return(node); } for (var i = 0; i < node.childNodes.length; i++) { if (node.childNodes[i].getName().indexOf(n) != -1) { return node.childNodes[i]; } } if (deepWalk != false) { for (i = 0; i < node.childNodes.length; i++) { var foundChild = node.childNodes[i].findChildByName(n, deepWalk); if (foundChild) { return foundChild; } } } return null; }; // ----------------------------------------------------------------------------- // // Form-related functions // We used those functions to update the form that update the dialogs. // // ----------------------------------------------------------------------------- function dlgGetParm(n) { if (dlgContains(n)) return dialogFormValues[n]; else return null; } function dlgSetParm(n, v) { dialogFormValues[n] = v; } function dlgRemoveParm(n) { if (dlgContains(n)) delete dialogFormValues[n]; } function dlgReset() { dialogFormValues = new Array(); dlgSetParm("b_action", "xts.run"); var productLocale = cfgGet("productLocale"); if (productLocale != null && productLocale != "") dlgSetParm("productLocale", productLocale); var contentLocale = cfgGet("contentLocale"); if (contentLocale != null && contentLocale != "") dlgSetParm("contentLocale", contentLocale); // apparently we need to tell portal save us - that's it's us - le Agent Studio dlgSetParm("agsSave_m_app", "AS"); //and just in case it colapses immediately.... dlgSetParm("m_app", "AS"); } function dlgAddParm(n, v) { if (!isArray(dialogFormValues[n])) dialogFormValues[n] = makeArray(dialogFormValues[n]); addToArray(dialogFormValues[n], v); } // n is the parameter with 2 values // add to the n array a value x,y (unique, generated) // add x (generated) with value v1 and y (generated) with value v2 function dlgAddPairParm(n, v1, v2) { var first = "genX"; var second = "genY"; // get unique names for parameters var ii=0; while (dlgContains(first+ii)) ii++; first = first + ii; ii=0; while (dlgContains(second+ii)) ii++; second = second + ii; dlgAddParm(n, first + "," + second); dlgSetParm(first, v1); dlgSetParm(second, v2); } function dlgContains(n) { return contains(dialogFormValues, n); } function dlgShowMessage(p1, p2, p3) { dlgReset(); dlgSetParm("m", "/qs/message.xts"); if (p1 != null && p1 != "") dlgSetParm("xxParm1", p1); if (p2 != null && p2 != "") dlgSetParm("xxParm2", p2); if (p3 != null && p3 != "") dlgSetParm("xxParm3", p3); dlgSubmit(); } // // --------------- ASYNC ----------------- // function asyncGetParm(n) { if (asyncContains(n)) return asyncFormValues[n]; else return null; } function asyncSetParm(n, v) { asyncFormValues[n] = v; } function asyncRemoveParm(n) { if (asyncContains(n)) delete asyncFormValues[n]; } function asyncReset() { asyncFormValues = new Array(); asyncSetParm("b_action", "xts.run"); asyncSetParm("app", cfgGet("APPLICATION_NAME")); var productLocale = cfgGet("productLocale"); if (productLocale != null && productLocale != "") asyncSetParm("productLocale", productLocale); var contentLocale = cfgGet("contentLocale"); if (contentLocale != null && contentLocale != "") asyncSetParm("contentLocale", contentLocale); var dti = cfgGet("disp_trackingInfo"); if (dti != null && dti != "") asyncSetParm("disp_trackingInfo", dti); var pv = getConnectionParameterValues(); if (pv != null && pv != "") asyncSetParm("connectionParameterValues", pv); // -- debug stuff -- // BIQ writes the generatedrequest.xml asyncSetParm("BIQ", cfgGet("BIQ")); if (cfgGet("__DBG__")) asyncSetParm("debug", true); } function asyncAddParm(n, v) { if (!isArray(asyncFormValues[n])) asyncFormValues[n] = makeArray(asyncFormValues[n]); addToArray(asyncFormValues[n], v); } function asyncContains(n) { return contains(asyncFormValues, n); } function displayForm(f) { var t = "Parameters for form [" + f.id + "] for window \"" + f.target + "\" using " + f.action; var parms = f.document.getElementsByTagName("INPUT"); for (var i = parms.length-1; i >= 0; i--) t += "\n\t" + parms[i].name + " = " + parms[i].value; trace(t); } function qsDefaults() { cfgSet("RowsDesired", 20); cfgSet("StartRow", 1); cfgSet("ReportTitle", ""); cfgSet("ReportShowTitle", 0); /* 0 = "title" 1 = text */ cfgSet("ReportShowSubTitle", 1); /* 0 = No subtitle, 1 = filters, 2 = text */ cfgSet("ReportSubTitle", ""); cfgSet("PDFUsePortrait", true); cfgSet("PDFPaperSize", "Letter"); cfgSet("bUsePortrait", true); cfgSet("PaperSize", "Letter"); cfgRemove("QueryIDs"); cfgRemove("SelColumns"); cfgRemove("ColLabels"); cfgRemove("ColType"); cfgRemove("ColUsage"); cfgRemove("IsFakeMeasure"); cfgRemove("ColExp"); cfgRemove("ColIDs"); cfgRemove("CutColumns"); cfgRemove("ColRole"); cfgRemove("ColGroupIDs"); cfgRemove("HasSummaries"); cfgRemove("IsHidden"); cfgRemove("IsMeasure"); cfgRemove("OriginalLabels"); cfgRemove("ReportType"); cfgRemove("ContextMenuActive"); cfgRemove("ActionRunning"); cfgRemove("DialogSize"); cfgRemove("DialogExecFunc"); cfgRemove("DialogSelCols"); cfgRemove("FormatType"); cfgRemove("FormatDecimals"); cfgRemove("FormatScale"); cfgRemove("FormatThousandSep"); cfgRemove("FormatNegSign"); cfgRemove("FormatCurrencySymbol"); cfgRemove("ColSort"); cfgRemove("ColSortBy"); cfgRemove("IsCollapsed"); cfgRemove("DetailAgg"); cfgRemove("RegularAgg"); cfgRemove("SummaryAgg"); cfgRemove("ExpFilter"); cfgRemove("ColFilterIdx"); cfgRemove("FilterStrings"); cfgRemove("PromptType"); } function rvDefaults(){ cfgSet("RowsDesired", 20); cfgSet("StartRow", 1); cfgRemove("QueryIDs"); cfgRemove("SelColumns"); cfgRemove("ColLabels"); cfgRemove("ColType"); cfgRemove("ColExp"); cfgRemove("ColIDs"); cfgRemove("CutColumns"); cfgRemove("ColRole"); cfgRemove("ColGroupIDs"); cfgRemove("HasSummaries"); cfgRemove("IsMeasure"); cfgRemove("ReportType"); cfgRemove("ContextMenuActive"); cfgRemove("ActionRunning"); cfgRemove("DialogSize"); cfgRemove("DialogExecFunc"); cfgRemove("DialogSelCols"); } function setScriptEngine() { cfgSet("APPLICATION_NAME", applicationName); cfgSet("SERVER_URL", serverURL); cfgSet("SCRIPT_ENGINE", scriptEngine); cfgSet("REQUEST_METHOD", methodName); //cf.cfgSet("__DBG__", true); cfgSet("BIQ", BIQ); cfgSet("queryLoaded",true); } function setWindowTitle() { var fileName = cfgGet("ReportName"); if ( fileName != null ) fileName = fileName.replace(/\.xml$/gi,""); if (fileName==null || fileName=="") top.document.title = windowTitle_string; else top.document.title = fileName + " - " + windowTitle_string ; var captionText = ""; if (fileName!=null && fileName!="") captionText = " - " + fileName; else if (cfgGet("NewReport")) captionText = " - " + newFilename_string; var cp = document.getElementById("filenameCaption"); if (cp) { while (cp.hasChildNodes()) cp.removeChild(cp.firstChild); var newText = document.createTextNode(captionText); cp.appendChild(newText); } var returnLinkText = ( frameBackURL == null || frameBackURL == "") ? returnLink_string : exitLink_string; var cl = document.getElementById("returnLink"); if (cl) { while (cl.hasChildNodes()) cl.removeChild(cl.firstChild); var newText = document.createTextNode(returnLinkText); cl.appendChild(newText); } } function initQSUI() { reinitConfigValues(); setScriptEngine(); setWindowTitle(); var size = parseInt(document.getElementById("menuFrame").style.width) if (size == null || isNaN(size)) size = 200; cfgSet("MenuSize", size); redrawLayers(); } function initRVUI() { reinitConfigValues(); setScriptEngine(); setWindowTitle(); showDialogFrame(0); changeNavigationLinks(false,false,false,false); } function hideSplash(){ window.defaultStatus=''; var splashBT = document.getElementById("splashB"); splashBT.style.display ="none"; } function initASUI() { document.body.oWndObserver = new CWndObserver(window.id);//global observer document.body.getWndObserver = function() {return document.body.oWndObserver;} g_divProgressBar = new C_StartupBlocker(); reinitConfigValues(); setScriptEngine(); setWindowTitle(); // set up all the trees initDataItems(); initParameterItems(); initHistoryItems(); initMemberSearch(); var size = parseInt(document.getElementById("menuFrame").style.width) if (size == null || isNaN(size)) size = 200; cfgSet("MenuSize", size); // set the new report to true in here - it's in async/conv for report studio // but cannot see why that's the case cfgSet("NewReport", true); // move progress info further showLoadingMsg('20'); loadMenu(); // move progress info further showLoadingMsg('30'); setDispatcherErrorHandler(cDispatchErrorHandler); initEventNotification(); var loadStack = new CommandStack(new Array()); loadStack.failCommand = "parent.showLoadingMsg('100');setTimeout('parent.g_divProgressBar.F_Hide()', 300);parent.cfgSet('agsInit', false)"; loadStack.push("setInsertableObjectsTabContainerHeight()"); loadStack.push(new CommandStackObject("changeMenu(TAB_MODEL)")); loadStack.push("loadMessageFrame()"); loadStack.push(new CommandStackObject("cfgSet('agsInit', true)")); loadStack.push(new CommandStackObject("cfgSet('AGS_initialized', true)")); loadStack.push(new CommandStackObject("showLoadingMsg('75')")); loadStack.push("reloadFunctionsTree()"); loadStack.push(new CommandStackObject("showLoadingMsg('60')")); loadStack.push("reloadMetadataTree()"); loadStack.push(new CommandStackObject("showLoadingMsg('40')")); loadStack.push("loadMetadataFrame()"); getConfigFrame().getCommandStackManager().doCommandStack(loadStack); } function setInsertableObjectsTabContainerHeight(event) { /* lastMenu Model lastMenu DataItems lastMenu Functions lastMenu Parameters lastMenu History lastMenu MemberSearch */ visibleTree = cfgGet("lastMenu"); var oMenuContainer = document.getElementById("div_menu_"+visibleTree); var oInsertableObjectsHeader = document.getElementById("insertableObjectsHeader"); var iBottomPadding = 0; if (oMenuContainer && oInsertableObjectsHeader) { var oMetadataTreeOuterPane = document.getElementById("div_menu_parent_"+visibleTree); //set the default size oMetadataTreeOuterPane.style.height = "100px";; iBottomPadding += oInsertableObjectsHeader.offsetHeight; var iMenuHeight = oMenuContainer.offsetHeight; var iBottomElementsHeight = iBottomPadding; var iNewMetadataTreeHeight = iMenuHeight - iBottomElementsHeight; if (iMenuHeight && iBottomElementsHeight && iNewMetadataTreeHeight > 0) { oMetadataTreeOuterPane.style.height = iNewMetadataTreeHeight + "px"; } } } function showLoadingMsg(perc, msg){ showDialogFrame(0); g_divProgressBar.F_SetPercent(perc); if(msg != null){ g_divProgressBar.F_SetMessage(msg); } else { g_divProgressBar.F_SetMessage(perc + "%"); } } //This code is copied from hal.js. Suggested by David Lilly //Since we can not use the hal.js I copied over the CSS and //the code below. Added the idHALStartupBlocker element to //ags.xts. function C_StartupBlocker( v_bHideProgressBar ) { if ( document.getElementById( "idHALStartupBlocker" ) ) { return; } } C_StartupBlocker.prototype.F_SetPercent = function(v_iPercent) { this.m_iPercent = v_iPercent; var div = document.getElementById( "idHALStartupBar" ); if ( div ) { div.style.width = Math.min( 100, v_iPercent ) + "%"; } } C_StartupBlocker.prototype.F_Hide = function() { var el = document.getElementById( "idHALStartupBlocker" ); if ( el ) { el.parentNode.removeChild( el ); } } C_StartupBlocker.prototype.F_SetMessage = function(s) { if ( this.m_iPercent >= 100 ) { var div = document.getElementById( "idHALStartupBar" ); if ( div ) { div.innerText = s; } } } function initEventNotification() { //intercept hotkey combinations eventHandlerChainUtil.doEventHandlerChain(document, "keydown",keyDownChecker.check); //initialize any items for(var i = 0; i < toolbar.m_items.length; i++) { var tbItem = toolbar.m_items[i]; if (tbItem.onmouseup) { tbItem.getObservers().attach(toolbar, toolbar.closeMenus, tbItem.onmouseup); } } toolbar.getObservers().attach(document.body.getWndObserver(),document.body.getWndObserver().mouseup,toolbar.onmouseup); m_menu.getObservers().attach(document.body.getWndObserver(),document.body.getWndObserver().mouseup,m_menu.onmouseup); document.body.getWndObserver().attachEvent(document.body, "mouseup"); if (document.all) { document.body.getWndObserver().attachEvent(document.body, "resize"); } else { document.body.getWndObserver().attachEvent(window, "resize"); } document.body.getWndObserver().addListener(toolbar, toolbar.closeMenus, "mouseup"); document.body.getWndObserver().addListener(m_menu, m_menu.closeMenus, "mouseup"); document.body.getWndObserver().addListener(taskMenu, taskMenu.remove, "mouseup"); var metadataFrame = document.getElementById("metadataIFrame"); //for FF only, manage the resizing left hand data items panel. This needs to be revisited //and fixed for IE as well. The original code to resize for IE has been retained. if (!browserCheck.isIE5Up()) { var splitter = new Splitter(); } } function handleBackSpace(evt) { var targ; if (!evt) var evt = window.event; if (evt.target) targ = evt.target; else if (evt.srcElement) targ = evt.srcElement; if (targ.nodeType == 3) // defeat Safari bug targ = targ.parentNode; if(targ.tagName != "TEXTAREA" && targ.tagName != "INPUT" && targ.tagName != "BODY"){ stopEventPropagation(evt); }else if(targ.tagName == "BODY" && targ.id == ""){ //this distinguishes between the whole page body and the body used in the div of the html edit page stopEventPropagation(evt); } } function stopEventPropagation(evt){ //prevent the click from proceeding to other nodes if (typeof evt.cancelBubble != 'undefined'){ evt.returnValue = false; evt.cancelBubble = true; } if (typeof evt.stopPropagation != 'undefined') { evt.stopPropagation(); } } /* * check for, and discard the event for any CTRL- hotkey combinations */ function checkForHotKeyActions(evt) { if(evt.keyCode == 8){ handleBackSpace(evt); return; } var ctrlPressed = false; var found = false; //the event could have occurred in any of the frames so we need //to check each one and grab the event object if (evt.ctrlKey==undefined) { var extractedEvent = window.event; for (var i=0;(i < document.frames.length && !found && extractedEvent == undefined);i++) { var frame = document.frames[i]; if (frame.window.event != null) { found = true; extractedEvent = frame.window.event; } } evt = extractedEvent; } // fix for bug: COGCQ00224409 Belgian issue - unable to type chars pressing Altgr if (evt.altKey) { return true; } //IE if (browserCheck.isIE5dot5Up()) { ctrlPressed = evt.ctrlKey; } //Mozilla/firefox else { ctrlPressed & Event.CONTROL_MASK; } if (evt.keyCode!=K_sKeyCode_Ctrl) { var allowed = isHotKeyAllowed(evt.keyCode) if (ctrlPressed==true && !allowed) { //prevent the click from proceeding to other nodes stopEventPropagation(evt); } } } function isHotKeyAllowed(keyCode) { var allowed = allowedHotkeys[String(keyCode)]; if (allowed == undefined) { allowed=false; } return allowed; } function loadMessageFrame() { //there is a problem with loading the message frame and the metadata pane //simultaneously, due to http connections, see bug 488327 if(applicationActionManager.isBlocked()){ setTimeout("loadMessageFrame()", 1000); return; } dlgReset(); // we saved the Params for the message frame in the scripts - for (var param in messageFrame_Params) { //set the params dlgSetParm(param, messageFrame_Params[param]); } //submit the form using POST. dlgSubmit("messageIFrame", false); } function loadMetadataFrame() { dlgReset(); // we saved the Params for the message frame in the scripts - for (var param in metadataFrame_Params) { //set the params dlgSetParm(param, metadataFrame_Params[param]); } //submit the form using POST. dlgSubmit("metadataIFrame", false); } function redrawSelf() { previewType = getPreviewType(); var previewTitleTop = document.getElementById("previewTitleTop"); if (previewTitleTop) { while (previewTitleTop.hasChildNodes()) previewTitleTop.removeChild(previewTitleTop.firstChild); previewTitleTop.appendChild(document.createTextNode(previewType=="none" ? runnodata_string : runlimited_string)); } var previewTitleBottom = document.getElementById("previewTitleBottom"); if (previewTitleBottom) { var previewLink = document.getElementById("previewLink"); while (previewTitleBottom.hasChildNodes()) previewTitleBottom.removeChild(previewTitleBottom.firstChild); previewTitleBottom.appendChild(document.createTextNode(previewType=="none" ? runnodata_string : runlimited_string)); while (previewLink.hasChildNodes()) previewLink.removeChild(previewLink.firstChild); previewLink.appendChild(document.createTextNode(previewType=="none" ? runlimitedlink_string : runnodatalink_string)); /* Here is the link to change the preview mode ( if in no data, you want to show the link to go to limited data, and vice-versa ) */ if(previewType=="none") { previewLink.onclick = function() { getConfigFrame().run("partial"); } } else { previewLink.onclick = function() { getConfigFrame().run("none"); } } } } /* * Submit the dialog using the GET method */ function dlgSubmitGet() { var cf = getConfigFrame(); var df = getFrame(DIALOG_FRAME_ID); if (!df) { df=this; } var url = cfgGet("SCRIPT_ENGINE"); var sepChar="?"; for (var n in dialogFormValues) { var values = makeArray(dialogFormValues[n]); for (var v in values) { url += sepChar+n+"="+values[v]; sepChar="&"; } } // Add in the cafcontextid url = cf.constructGETRequestParamsString(url); df.document.location.replace(url); } /* * Submit the dialog using the POST method */ function dlgSubmitPost(tgt) { tgt = tgt ? tgt : DIALOG_FRAME_ID; checkLogin(undefined,"processSubmitPost('"+ tgt + "')"); } //Do not call directly. function processSubmitPost(tgt) { var srcFrame = getFrame(tgt); if (!srcFrame) { srcFrame=this; } var srcForm = srcFrame.document.createElement("FORM"); srcForm.target = tgt; srcForm.method = "POST"; srcForm.action = cfgGet("SCRIPT_ENGINE"); srcForm.style.margin="0px"; //get the document body var srcBody = srcFrame.document.getElementsByTagName("BODY"); if (srcBody!=null && srcBody[0]!=null) { srcBody=srcBody[0]; } else { srcBody = srcFrame.document.documentElement; } // Remove all form objects from the srcBody while(srcBody.hasChildNodes())srcBody.removeChild(srcBody.childNodes.item(0)); srcBody.appendChild(srcForm); // Put all parms in dialogFormValues in the form for (var n in dialogFormValues) { var values = makeArray(dialogFormValues[n]); for (var value in values) { var hiddenInput = srcFrame.document.createElement("textarea"); hiddenInput.setAttribute("id", n); hiddenInput.setAttribute("name", n); //Firefox does not like setAttribute('value',n) but IE does //both like this syntax :-) hiddenInput.value=values[value]; // set the style to invisible hiddenInput.style.display='none'; // add the control srcForm.appendChild(hiddenInput); } } addCAFContextIdToForm(srcFrame,srcForm); // Remove onBeforeUnLoad for this submission but set it back after. var oldUnload=window.onbeforeunload; window.onbeforeunload=null; // Submit the form srcForm.submit(); window.onbeforeunload=oldUnload; } /* * Check for unsaved changes to a dialog in the dialog frame. The user will be asked whether the changes * should be saved. For the changes to be commited the dialog must implement the following functions : * * doApply() - validate the dialog and apply unsaved changes. Return false if the dialog could not be validated * hasChanged() - if not implemented this will default to true */ function commitDialogFrameChanges() { //guard clause, the dialog frame is closed if (isDialogFrameShowing()==false) { return; } var currStack=getCommandStackManager().getCommandStack(); if (currStack.isEmpty()==false) { var dialogFrame = getDialogFrame(); //determine whether the doApply() function is available for the current dialog var canApply = typeof dialogFrame.doApply == "function"; //if the dialog does not support the hasChanged() function //then always assume the dialog contents are dirty var hasChanged=true; if (typeof dialogFrame.hasChanged == "function") { hasChanged = dialogFrame.hasChanged(); } //unsaved dialog found if (hasChanged && canApply) { //show the popup if we haven't been here before, if the validation //fails we don't want to keep showing the same message asking the //user if they want to save the dialog when they have already made //the decision if (saveChangesToDialogFrame==false) { saveChangesToDialogFrame = confirm(commitChangesWarning) } //if the user chose to save the dialog and the dialog validation //failed then clear the command stack if (saveChangesToDialogFrame && dialogFrame.doApply()==false) { currStack.clear(); } //Reset the flag when : // 1. We don't care about dialog changes // 2. The dialog changes were applied successfully else { saveChangesToDialogFrame=false; } } } } /* * This method will call doLoginProxy.xts to perform a pre-emptive * session expiry check. This is to make sure we are always logged on. * In some cases if a logon fault is encountered it will end up being * redirected here from XMLHTTP calls, with the htmlFrgament, which is * then redirected to the portal handleFault.xts. */ function checkLogin(holder,callBackfunc) { //Check if holder is there already. if (holder == undefined) { holder = new Object(); } //If m already defined do not bother resetting. if (holder['m'] == undefined) { holder['m'] = "/ags/doLoginProxy.xts"; } var callBack = function(responseArray) { var isLoginOk = processLogin(responseArray); if (callBackfunc != undefined) { if (isLoginOk) { eval(callBackfunc); } else { getCommandStackManager().getCommandStack().push(callBackfunc); } } }; var dispatcher = new XHTTPDispatcher(callBack, holder); applicationActionManager.httpStart(); try{ dispatcher.dispatch(); }catch(ex){ applicationActionManager.httpStop(); } } function processLogin(responseArray) { var responseXML = responseArray[0]; var responseText = responseArray[1]; applicationActionManager.httpStop(); var parsedResponse = parseResponse(responseXML,responseText); if (parsedResponse.isLogonFault()) { // Get the HTML fault from the EMF rendered response. var htmlFaultHtml = parsedResponse.getTextValueForXPath( "//fault//html" ); var popUpFrame = getPopUpFrame(); popUpFrame.document.open(); popUpFrame.document.write(htmlFaultHtml); popUpFrame.document.close(); return false; } else if (parsedResponse.isHTML() && !parsedResponse.isEmptyBody()) { if (parsedResponse.contains('CAF_VALIDATION_FAILURE')) { doHTMLResponse(responseText); } else { var popUpFrame = getPopUpFrame(); popUpFrame.document.open(); popUpFrame.document.write(responseText); popUpFrame.document.close(); } return false; } return true; } /* * helper function to check for invalid strings in the message frame input form * and optionally popup an alert */ function checkCAF() { var messageIFrame = getMessageIFrame(); var messageIFrame_doc = getFrameDocument(messageIFrame); var failed = false; var formsArray = messageIFrame_doc.forms; //we cannot find a form, something is awry if (formsArray.length==0) { failed=true; } else { failed = CAFValidateForm(formsArray[0]); if (!failed) { //commit the contents of the pending dialog frame is necessary commitDialogFrameChanges(); var stackMgr = getCommandStackManager(); var currentStack = stackMgr.getCommandStack(); if (currentStack) { //process the next command if (currentStack.isEmpty()==false) { stackMgr.processCommandStack(); } } } } return failed; } /* * check the form type 'text' or 'textarea' inputs for invalid characters * form - the form, must not be null or undefined * popup - popup an alert when not valid, this is optional, the default is true * returns true when validation has failed */ function CAFValidateForm(form,popup) { var items = new Array(); var failed=false; for (var i = 0; i < form.elements.length && !failed; ++i) { var control = form.elements[i]; // get the type of the control var type = control.type; //we only care about text controls if (type == 'textarea' || type=='text' || control.tagName=='TEXTAREA') { var ctrlName = form.elements[i].name; var ctrlValue = control.value; //check for a valid name if (ctrlName!='') { var res = CAFContainsInvalidString(ctrlValue); //check the string if (res) { failed=true; //check if the alert should be shown if (popup == undefined || popup==true) { window.alert(cafInvalidStringMsg + res); } //clear the command stack if commands exist if (getCommandStackManager().getCommandStack().isEmpty()==false) { getCommandStackManager().getCommandStack().clear(); } //unblock if(applicationActionManager.isBlocked()){ applicationActionManager.allowActions(); } } } } } return failed; } /* * A helper function to append the CAF context id to a form. The context id is added * as a hidden input variable. If the context id is already present in the form no action is taken * docFrame the current frame * docForm the input form */ function addCAFContextIdToForm(docFrame,docForm) { // Add in the cafcontextid to the post request, this is accomplished by creating //a hidden form variable and then setting the context id into it var cf = getConfigFrame(); //check if a valid context id is present and the form does not already have it if (cf.cafContextId != "" && docFrame.document.getElementById("cafcontextid")==null) { //create the hidden caf context id input element var i = docFrame.document.createElement("INPUT"); i.setAttribute("name", "cafcontextid"); i.setAttribute("value",cf.cafContextId); i.setAttribute("id", "cafcontextid"); i.setAttribute("type", "hidden"); //add the caf context id to the form docForm.appendChild(i); } } /* * Translates a string into javascript-encoded format according to the following rules: * Double quote (") is converted to (\") * Single quote (') is converted to (\') * Backslash (\) is converted to (\\) * Open angle bracket (<) is converted to (\<) * Close angle bracket (>) is converted to (\>) */ function jsStrEncode(str) { if (typeof str != "string") { return str; } if (typeof str == "undefined" || str == "") { str=""; } else { str = str.replace(/\\/g, '\\\\'); str = str.replace(/"/g, '\\"'); str = str.replace(/'/g, "\\'"); str = str.replace(//g, '\\>'); } return str; } /* htmlEncode translates a string into html encoded format according to the following rules: * Double quote (") is converted to (\") * ampersand (&) is converted to (\&) * Open angle bracket (<) is converted to (\<) * Close angle bracket (>) is converted to (\>) */ function htmlEncode(str) { if (typeof str != "string") { return str; } var tempString = str.replace(/&/g,"&"); tempString = tempString.replace(/"/g,"""); tempString = tempString.replace(//g,">"); return tempString; } /* * submit the dialog */ function dlgSubmit(tgt, useGet) { if(cf.applicationActionManager.isBlocked()){ return; } //block until page is reloaded cf.applicationActionManager.blockActions(); if (useGet) { dlgSubmitGet(); } else { dlgSubmitPost(tgt); } } function asyncSubmit(tgt) { // Create a new form object var rf = getReportFrame(); if(!rf) rf=this; var f = rf.document.createElement("FORM"); f.method = "POST"; f.action = cfgGet("SCRIPT_ENGINE"); if (tgt != null) f.target = tgt; else f.target = rf.name; f.style.margin="0px"; var b = rf.document.getElementsByTagName("BODY"); if (b!=null && b[0]!=null) b=b[0]; else b= rf.document.documentElement; b.appendChild(f); while (f.hasChildNodes()) f.removeChild(f.firstChild); // Put all parms in asyncFormValues in the form for (var n in asyncFormValues) { var values = makeArray(asyncFormValues[n]); for (var v in values) { var i = rf.document.createElement("TEXTAREA"); i.setAttribute("name", n); i.setAttribute("value", values[v]); i.setAttribute("id", n); // make this invisible i.style.display='none'; // add the form control f.appendChild(i); } } addCAFContextIdToForm(rf,f); hideDialogFrame(); // Remove onBeforeUnLoad for this submission but set it back after. var oldUnload=window.onbeforeunload; window.onbeforeunload=null; // Submit the form f.submit(); window.onbeforeunload=oldUnload; } /* * Set the boolean configuration variable 'agentHasChanged' */ function agentHasChanged(v_bChanged) { if (v_bChanged == null) { v_bChanged = false; } cfgSet("agentHasChanged", v_bChanged); } /* * check if the agent has changed since the last save/load */ function hasAgentChanged() { var changed = cfgGet("agentHasChanged"); //need to track this for prompting to save var last_known_condition = cfgGet("saved_agent_condition"); var current_condition = buildFilterCondition(); if(!last_known_condition || last_known_condition == ""){ //we have no saved condition changed = changed || (current_condition && current_condition != ""); }else{ //we have a saved condition changed = changed || new String(last_known_condition).localeCompare(current_condition) != 0; } return changed; } function setConditionError(errors, error_div_id){ if(!error_div_id){ //this may have been set by a calling page, to prevent passing it error_div_id = cfgGet(CURRENT_ERROR_DIV_ID_KEY); } cfgSet(error_div_id, errors); displayConditionError(errors); } function updateConditionError(error_div_id){ if (cfgGet(error_div_id)) { displayConditionError(cfgGet(error_div_id)); } } var wait_interval = 500; var wait_time = 10000; function displayConditionError(errors, time_left){ var msgFrame = getMessageIFrame(); var msgDoc = getFrameDocument(msgFrame); var error_div_id = cfgGet(CURRENT_ERROR_DIV_ID_KEY); if(!errors){ errors = cfgGet(error_div_id); } if (!error_div_id) { //Just incase so we do not lose the error error_div_id = CURRENT_TIP; } var errorDiv=agsFormUtils.getElementByIdOrName(error_div_id); if(!errorDiv){ time_left = time_left ? time_left - wait_interval : wait_time; if(time_left > 0){ //get the error out of the cfg - the formatting is hard to handle through a setTimeout // time_left is a number setTimeout("displayConditionError(null, '" + time_left + "')", wait_interval); }else{ //if its not there there has been a worse error.... //dont kick the user when theyre down //alert(error); } }else{ setErrorDisplay(errorDiv,errorDiv.ownerDocument,errors); } } /* * This function retrieves any function tip information when available from the configuration * and sets it into the tip frame */ function updateInformationTip() { setInformationTip(cfgGet(CURRENT_TIP),cfgGet(CURRENT_TIP_SYNTAX)); } /* * Tell the info panel that a function has been selected. This causes * a tip and function syntax to be rendered in the message frame */ function displayInformationTip(node) { // save the current tip and syntax cfgSet(CURRENT_TIP, node.tip); cfgSet(CURRENT_TIP_SYNTAX,node.syntax); // set the display setInformationTip(node.tip, node.syntax); } /* * Convenience method for setting the tip and syntax info the information panel */ function setInformationTip(tipName,tipSyntax) { var msgFrame = getMessageIFrame(); var msgDoc = getFrameDocument(msgFrame); var dialogFrame = getDialogFrame(); var dialogDoc = getFrameDocument(dialogFrame); var infoItemTipDiv = msgDoc.getElementById(CURRENT_TIP); var infoItemSyntaxDiv = msgDoc.getElementById(CURRENT_TIP_SYNTAX); var infoItemTipDialogDiv = dialogDoc.getElementById(CURRENT_TIP); var infoItemSyntaxDialogDiv = dialogDoc.getElementById(CURRENT_TIP_SYNTAX); if (tipName != null && tipName.length > 0) { setInfoItem(infoItemTipDiv,msgDoc,tipName); setInfoItem(infoItemTipDialogDiv,dialogDoc,tipName); } else { resetDiv(infoItemTipDiv,false); resetDiv(infoItemTipDialogDiv,false); } if (tipSyntax != null && tipSyntax.length > 0) { setInfoItem(infoItemSyntaxDiv,msgDoc,tipSyntax); setInfoItem(infoItemSyntaxDialogDiv,dialogDoc,tipSyntax); } else { resetDiv(infoItemSyntaxDiv,true); resetDiv(infoItemSyntaxDialogDiv,true); } if ((!tipName || tipName.length < 0) && (!tipSyntax || tipSyntax.length < 0)) { //Default Messages. setInfoItem(infoItemTipDiv,msgDoc,agentConditionTipsMessage_string ); setInfoItem(infoItemTipDialogDiv,dialogDoc,dataItemTipsMessage_string ); setInfoItem(infoItemSyntaxDiv,msgDoc,agentConditionTipsSyntaxMessage_string); setInfoItem(infoItemSyntaxDialogDiv,dialogDoc,dataItemTipsSyntaxMessage_string); } } /* * Empty the div that is passed. Set it to hidden if hide is true. * This would be needed for functions where no tip but synatx is * provided or vice versa. */ function resetDiv(divNode,hide) { if (divNode !=null) { // remove the contents while (divNode.hasChildNodes()) { divNode.removeChild(divNode.firstChild); } if (hide) { divNode.style.display = "none"; } } else { return false; } return true; } function setErrorsToDiv(divNode,msgDoc,errors){ if(!errors || errors.length == 0){ errors = new Array(new DefectMessage(validateNoErrors_string, "info", null)); } var table = msgDoc.createElement("table"); var tbody = msgDoc.createElement("tbody"); table.appendChild(tbody); for(var i = 0; i < errors.length; i++){ var row = msgDoc.createElement("tr"); var td1 = msgDoc.createElement("td"); var img = msgDoc.createElement("img"); img.setAttribute("src", errors[i].severity.img_src); td1.appendChild(img); row.appendChild(td1); var td2 = msgDoc.createElement("td"); var p = msgDoc.createElement("p"); p.innerHTML=errors[i]; p.className = "infoErrorTabText"; td2.appendChild(p); row.appendChild(td2); tbody.appendChild(row); } divNode.appendChild(table); } /* *Set some content into the function tip information area if it is available */ function setErrorDisplay(divNode,msgDoc,errors) { if (resetDiv(divNode)) { setErrorsToDiv(divNode,msgDoc,errors); } divNode.style.display = ""; var msgFrame = getMessageIFrame(); if(divNode.id && divNode.id.indexOf('DataItem') != -1){ msgFrame = getDialogFrame(); } if (msgFrame.doInfoTabChange) { msgFrame.doInfoTabChange(divNode.id ? divNode.id : divNode.name); } } /* *Set some content into the function tip information area if it is available */ function setInfoItem(divNode,msgDoc,content) { if (resetDiv(divNode)) { // split the content based on CR-LF's var lines = content.split("\n"); // loop over the lines -converting all the preceding spaces into  's for (var i = 0; i < lines.length; ++i) { // split the line after the first non whitespace char var re = /^(\s*)(.*)/; var pre_space = lines[i].replace(re, "$1"); var after_space = lines[i].replace(re, "$2"); // convert all the prespace into  s - use charcode instead though pre_space = pre_space.replace(/\s/g, "\u00A0"); // add the two together lines[i] = pre_space + after_space; // make a textNode var textNode = msgDoc.createTextNode(lines[i]); divNode.appendChild(textNode); // add a break var br = msgDoc.createElement("BR"); divNode.appendChild(br); } divNode.style.display = ""; var msgFrame = getMessageIFrame(); if(divNode.id && divNode.id.indexOf('DataItem') != -1){ msgFrame = getDialogFrame(); } if (msgFrame.doInfoTabChange) { msgFrame.doInfoTabChange(divNode.id ? divNode.id : divNode.name); } } } function ParmValues(valueString){ this.properties = new Object(); if(valueString){ this.parseValueString(valueString); } } ParmValues.prototype.parseValueString = function(valueString){ this.cleanProperties(); var nameValues = valueString.split("&"); for(var i = 0; nameValues && i < nameValues.length; i++){ nameValue = nameValues[i].split("="); if(nameValue.length == 2){ var name = this.cleanString(nameValue[0]); //set a property on this parser this.properties[name] = this.cleanString(nameValue[1]); } //grab the first occurrence else if (nameValue.length > 2){ var pos = nameValues[i].indexOf("="); var name=this.cleanString(nameValues[i].substring(0,pos)); var value=this.cleanString(nameValues[i].substring(pos+1,nameValues[i].length)); this.properties[name] = value; } } } ParmValues.prototype.createValueString = function(){ var valueString = ""; for (var i in this.properties) { valueString += "&" + i + "=" + this.properties[i]; } return valueString; } ParmValues.prototype.setProperty = function(name, value){ this.properties[name] = value; } ParmValues.prototype.cleanProperties = function(){ this.properties = new Object(); } ParmValues.prototype.cleanString = function(valueString){ var re = /^['"](.*)['"]$/; return valueString.replace(re,"$1"); }