/* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| IBM Cognos Products: Viewer *| (C) Copyright IBM Corp. 2001, 2018 *| *| US Government Users Restricted Rights - Use, duplication or *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *| *+------------------------------------------------------------------------+ */ // This JavaScript file is used for conducting drill through // It delegates drill functionality to the parent (normaly the RV) // Otherwise it does nothing. function sXmlEncode(sInputString) { var sOutputString = "" + sInputString; if ((sOutputString == '0') || ((sInputString != null) && (sInputString != false))) { //& sOutputString = sOutputString.replace(/&/g, "&"); //< sOutputString = sOutputString.replace(//g, ">"); //" sOutputString = sOutputString.replace(/"/g, """); //' sOutputString = sOutputString.replace(/'/g, "'"); } else if (sInputString == null) { //return empty string if the value is null or false sOutputString = ""; } return sOutputString; } function createFormField(name, value) { var formField = document.createElement("input"); formField.setAttribute("type", "hidden"); formField.setAttribute("name", name); formField.setAttribute("value", value); return(formField); } function setBackURLToCloseWindow(oForm) { var aInputNodes = oForm.childNodes; if(aInputNodes) { for(var iChildIdx = 0; iChildIdx < aInputNodes.length; ++iChildIdx) { var oInput = aInputNodes[iChildIdx]; var sName = oInput.getAttribute("name"); if(sName && sName == "ui.backURL") { oForm.removeChild(oInput); } } } oForm.appendChild(createFormField("ui.backURL", "javascript:window.close();")); } // // There are multiple drill targets, the XTS page will take care of it // function doMultipleDrills(drillTargets,cvId) { if (parent != this && parent.doMultipleDrills) { if (getCVId() != "" && getCVId() != cvId) { cvId = getCVId(); } return parent.doMultipleDrills(drillTargets, cvId); } else { if (window.gViewerLogger) { window.gViewerLogger.log('Drill Targets', drillTargets, "text"); } var oCV = null; try { oCV = getCognosViewerObjectRef(cvId); } catch(exception){} var drillForm = buildDrillForm(oCV); addDrillEnvironmentFormFields(drillForm, oCV); if(typeof oCV != "undefined" && oCV != null) { var modelPath = oCV.getModelPath(); drillForm.appendChild(createFormField("modelPath", modelPath)); var selectionController = oCV.getSelectionController(); var sSelectionContext = ""; if(typeof getViewerSelectionContext != "undefined" && typeof CSelectionContext != "undefined") { sSelectionContext = getViewerSelectionContext(selectionController, new CSelectionContext(modelPath)); } drillForm.appendChild(createFormField("drillContext", sSelectionContext)); drillForm.appendChild(createFormField("modelDrillEnabled", selectionController.getModelDrillThroughEnabled())); if(typeof document.forms["formWarpRequest" + oCV.getId()]["ui.object"] != "undefined" && document.forms["formWarpRequest" + oCV.getId()]["ui.object"].value != "") { drillForm.appendChild(createFormField("drillSource", document.forms["formWarpRequest" + oCV.getId()]["ui.object"].value)); } else if(typeof oCV.envParams["ui.spec"] != "undefined") { drillForm.appendChild(createFormField("sourceSpecification", oCV.envParams["ui.spec"])); } } drillForm.setAttribute("launchGotoPage", "true"); drillForm.appendChild(createFormField("drillTargets", drillTargets)); drillForm.appendChild(createFormField("invokeGotoPage", "true")); drillForm.appendChild(createFormField("m", "portal/drillthrough.xts")); drillForm.appendChild(createFormField("b_action", "xts.run")); var target = "winNAT_" + ( new Date() ).getTime(); var sWebContentRoot = ".."; if (oCV != null) { sWebContentRoot = oCV.getWebContentRoot(); var sExecutionParameters = oCV.getExecutionParameters(); if(sExecutionParameters != "") { drillForm.appendChild(createFormField("encExecutionParameters", sExecutionParameters)); } } // Used to override the default behavior when we're in mobile so that we // call their proxy if (!oCV || !oCV.launchGotoPageForIWidgetMobile(drillForm)) { if (oCV && typeof oCV.launchGotoPage === "function") { oCV.launchGotoPage(drillForm); } else { var sPath = sWebContentRoot + "/rv/blankDrillWin.html"; drillForm.target = target; window.open( sPath, target ); } } } } function buildDrillForm(oCV) { var drillForm = document.getElementById("drillForm"); if(drillForm) { document.body.removeChild(drillForm); } drillForm = document.createElement("form"); if(typeof oCV != "undefined" && oCV != null) { var mainForm = document.getElementById("formWarpRequest" + oCV.getId()); drillForm.setAttribute("target", mainForm.getAttribute("target")); drillForm.setAttribute("action", mainForm.getAttribute("action")); } else { drillForm.setAttribute("action", location.pathname); } drillForm.setAttribute("id", "drillForm"); drillForm.setAttribute("name", "drillForm"); drillForm.setAttribute("method", "post"); drillForm.style.display = "none"; document.body.appendChild(drillForm); return drillForm; } function addDrillEnvironmentFormFields(drillForm, oCV) { if (window.g_dfEmail) { drillForm.appendChild(createFormField("dfemail", window.g_dfEmail)); } if(oCV != null) { drillForm.appendChild(createFormField("cv.id", oCV.getId())); if(typeof oCV.envParams["ui.sh"] != "undefined") { drillForm.appendChild(createFormField("ui.sh", oCV.envParams["ui.sh"])); } if(oCV.getViewerWidget() == null) { if(typeof oCV.envParams["cv.header"] != "undefined") { drillForm.appendChild(createFormField("cv.header", oCV.envParams["cv.header"])); } if(typeof oCV.envParams["cv.toolbar"] != "undefined") { drillForm.appendChild(createFormField("cv.toolbar", oCV.envParams["cv.toolbar"])); } else { var passPortletToolbarStateOnDrillThrough = oCV.getAdvancedServerProperty("VIEWER_PASS_PORTLET_TOOLBAR_STATE_ON_DRILLTHROUGH"); if(oCV.m_viewerFragment && passPortletToolbarStateOnDrillThrough != null && passPortletToolbarStateOnDrillThrough === true ) { var showToolbar = oCV.m_viewerFragment.canShowToolbar() ? "true" : "false"; drillForm.appendChild(createFormField("cv.toolbar", showToolbar)); } } } if(typeof oCV.envParams["ui.backURL"] != "undefined") { drillForm.appendChild(createFormField("ui.backURL", oCV.envParams["ui.backURL"])); } if(typeof oCV.envParams["ui.postBack"] != "undefined") { drillForm.appendChild(createFormField("ui.postBack", oCV.envParams["ui.postBack"])); } if(typeof oCV.envParams["savedEnv"] != "undefined") { drillForm.appendChild(createFormField("savedEnv", oCV.envParams["savedEnv"])); } if(typeof oCV.envParams["ui.navlinks"] != "undefined") { drillForm.appendChild(createFormField("ui.navlinks", oCV.envParams["ui.navlinks"])); } if(typeof oCV.envParams["lang"] != "undefined") { drillForm.appendChild(createFormField("lang", oCV.envParams["lang"])); } if(typeof oCV.envParams["ui.errURL"] != "undefined") { drillForm.appendChild(createFormField("ui.errURL", oCV.envParams["ui.errURL"])); } var routingServerGroup = ""; if(oCV.envParams["ui.routingServerGroup"]) { routingServerGroup = oCV.envParams["ui.routingServerGroup"]; } drillForm.appendChild(createHiddenFormField("ui.routingServerGroup", routingServerGroup)); } else { drillForm.appendChild(createFormField("cv.header", "false")); drillForm.appendChild(createFormField("cv.toolbar", "false")); } } function appendReportHistoryObjects(oCV,drillForm) { if(oCV != null && typeof oCV.rvMainWnd != "undefined" && drillForm != null) { oCV.rvMainWnd.addCurrentReportToReportHistory(); var reportHistorySpecification = oCV.rvMainWnd.saveReportHistoryAsXML(); drillForm.appendChild(createFormField("cv.previousReports", reportHistorySpecification)); } } function doSingleDrill(target,args,method,format,locale,bookmark,sourceContext,objectPaths,cvId,sPrompt,dynamicDrill) { var sCVId = ""; if (typeof cvId == "string") { sCVId = cvId; } var oCV = null; try { oCV = getCognosViewerObjectRef(cvId); } catch(exception){} if (!oCV && parent != this && parent.doSingleDrill) { // if we're currently in an iframe, try and get the correct cvId from the iframe if (getCVId() != "" && getCVId() != cvId) { cvId = getCVId(); } // Call the method in the parent which is most likely the RV return parent.doSingleDrill(target, args, method, format, locale, bookmark, sourceContext, objectPaths,cvId,sPrompt,dynamicDrill); } else { if(typeof method == "undefined") { method = "default"; } else if(method == "execute") { method = "run"; } // always open a new window if the drill through is set to edit and we're in a portlet if (method == "edit" && oCV != null && typeof oCV.m_viewerFragment) { target = "_blank"; } var drillForm = buildDrillForm(oCV); var sDrillSpecification = ""; sDrillSpecification += "" + sXmlEncode(method) + ""; sDrillSpecification += "" + sXmlEncode(args[0][1]) + ""; sDrillSpecification += "" + sXmlEncode(format) + ""; sDrillSpecification += "" + sXmlEncode(locale) + ""; sDrillSpecification += "" + sXmlEncode(sPrompt) + ""; sDrillSpecification += "" + sXmlEncode(dynamicDrill) + ""; if(typeof oCV != "undefined" && oCV != null) { sDrillSpecification += "" + oCV.getTracking() + ""; if(typeof document.forms["formWarpRequest" + oCV.getId()]["ui.object"] != "undefined") { sDrillSpecification += "" + sXmlEncode(document.forms["formWarpRequest" + oCV.getId()]["ui.object"].value) + ""; } var modelPath = oCV.getModelPath(); sDrillSpecification += "" + sXmlEncode(modelPath) + ""; sDrillSpecification += "" + sXmlEncode(getViewerSelectionContext(oCV.getSelectionController(), new CSelectionContext(modelPath))) + ""; if(typeof document.forms["formWarpRequest" + oCV.getId()]["ui.object"] != "undefined" && document.forms["formWarpRequest" + oCV.getId()]["ui.object"].value != "") { sDrillSpecification += "" + sXmlEncode(document.forms["formWarpRequest" + oCV.getId()]["ui.object"].value) + ""; } else if(typeof oCV.envParams["ui.spec"] != "undefined") { sDrillSpecification += "" + sXmlEncode(oCV.envParams["ui.spec"]) + ""; } } if (bookmark != "") { sDrillSpecification += "" + bookmark + ""; } if(method != "view") { if(typeof sourceContext != "undefined") { sDrillSpecification += "" + sXmlEncode(sourceContext) + ""; } if(typeof objectPaths != "undefined") { sDrillSpecification += "" + sXmlEncode(objectPaths) + ""; } } var idxArg = 0; sDrillSpecification += ""; var aDrillSpecParams = []; for (idxArg = 1; idxArg < args.length; idxArg++) { // HS 622739 : RSVP currently inconsistent about substituting MUN for useValue. This code can be // reverted once a clear contract is designed between RSVP and Viewer. var sSel = args[idxArg][1]; if ( format == 'HTML' && (sSel.indexOf(""; } } } // End HS 622739. var paramName = args[idxArg][0]; var bFound = false; for (var i = 0; i < aDrillSpecParams.length; i++) { var param = aDrillSpecParams[i]; if (param.name === paramName && param.value === sSel) { bFound = true; break; } } if (!bFound) { aDrillSpecParams.push({"name" : paramName, "value" : sSel}); sDrillSpecification += "" + sXmlEncode(sSel) + ""; } } sDrillSpecification += ""; sDrillSpecification += getExecutionParamNode(oCV); sDrillSpecification += ""; drillForm.appendChild(createFormField("authoredDrill.request", sDrillSpecification)); drillForm.appendChild(createFormField("ui.action", "authoredDrillThrough2")); drillForm.appendChild(createFormField("b_action", "cognosViewer")); addDrillEnvironmentFormFields(drillForm, oCV); // executeDrillThroughForIWidgetMobile will return true if it executed the drill through if (!oCV || !oCV.executeDrillThroughForIWidgetMobile(drillForm)) { // Used to override the default drill of submitting a form if (oCV && typeof oCV.sendDrillThroughRequest === "function") { oCV.sendDrillThroughRequest(drillForm); } // else if(target == "" && oCV != null && typeof oCV.m_viewerFragment != "undefined") { oCV.m_viewerFragment.raiseAuthoredDrillEvent(sDrillSpecification); } else if( (oCV != null && oCV.getViewerWidget() != null) || target != "" ) { setBackURLToCloseWindow(drillForm); var sTarget = "winNAT_" + ( new Date() ).getTime(); var sWebContentRoot = ".."; if (oCV != null) { sWebContentRoot = oCV.getWebContentRoot(); } var sPath = sWebContentRoot + "/rv/blankDrillWin.html"; if (sCVId) { sPath += "?cv.id=" + sCVId; } // if there is no classic viewer (oCV) we should be able to // assume that there is no glass either // in that case we should call the classicviewer perspective // and pass in the drillForm. if (oCV == null) { // window.location.hrefwould look similar to the following // http://localhost/ibmcognos/bidev/v1/disp/repository/sid/cm/oid/id68a0f47a5a24cfd98a120bdba15882b/content // we want to get everything from the beginning of the string to /v1 sPath = window.location.href.substring(0,window.location.href.indexOf("/v1")); // sPath now equals // http://localhost/ibmcognos/bidev sPath += "/?perspective=classicviewer"; // sPath now equals // http://localhost/ibmcognos/bidev/?perspective=classicviewer // we want to use the alternative drill path sPath += "&altDrillFlag=true"; // add the format (really for PDF so the perspective can react accordingly) sPath += "&format=" + sXmlEncode(format); // Give the form a unique name var v_sLabel = drillForm.getAttribute("name") + Date.now().toString(); drillForm.setAttribute("name", v_sLabel); // store the form (in string form) into the browser storage if (typeof(Storage) !== "undefined") { localStorage.setItem(v_sLabel, drillForm.outerHTML); // put this unique identifer into the parameters to pass sPath += "&drillFormLabel=" + v_sLabel; // sPath now equals // http://localhost/ibmcognos/bidev/?perspective=classicviewer&drillFormLabel= } else { console.log("Sorry! No Web Storage support..."); } } if (window.gViewerLogger) { window.gViewerLogger.log('Drill Specification', sDrillSpecification, "xml"); } drillForm.target = sTarget; newWindow = window.open( sPath, sTarget ); } else { appendReportHistoryObjects(oCV, drillForm); if (window.gViewerLogger) { window.gViewerLogger.log('Drill Specification', sDrillSpecification, "xml"); } drillForm.target = (oCV && oCV.getDrillFormTarget) ? oCV.getDrillFormTarget() : "_self"; drillForm.submit(); if (oCV != null && !oCV.getDrillFormTarget) { setTimeout(getCognosViewerObjectRefAsString(oCV.getId())+".getRequestIndicator().show()",10); } } } } } function getExecutionParamNode(oCV) { var sExecutionParamNode = ""; if(typeof oCV != "undefined" && oCV != null) { var sExecutionParameters = oCV.getExecutionParameters(); if(sExecutionParameters != "") { sExecutionParamNode += ""; sExecutionParamNode += sXmlEncode(sExecutionParameters); sExecutionParamNode += ""; } } return sExecutionParamNode; } function doSingleDrillThrough(drillThroughContext, bookmarkRef, cvId) { // handle a single drill var drillTargetRefIdx = drillThroughContext[0][0]; if(typeof drillTargetRefIdx == "undefined" || drillTargetRefIdx == null) { return; } var drillTargetRef = cvId && window[cvId + "drillTargets"] ? window[cvId + "drillTargets"][drillTargetRefIdx] : drillTargets[drillTargetRefIdx]; if(typeof drillTargetRef == "undefined") { return; } // check for the case of a local bookmark if(bookmarkRef != '' && drillTargetRef.getPath() == '') { document.location = "#" + bookmarkRef; } else { var args = []; args[args.length] = ["ui.object", drillTargetRef.getPath()]; for(var drillParmIdx = 1; drillParmIdx < drillThroughContext.length; ++drillParmIdx) { args[args.length] = drillThroughContext[drillParmIdx]; } var target=""; if(drillTargetRef.getShowInNewWindow()=='true') { target = "_blank"; } var parametersString = drillTargetRef.getParameters(); var objectPaths = drillTargetRef.getObjectPaths(); var oCVId = cvId; if (!cvId) { oCVId = getCVId(); } doSingleDrill(target, args, drillTargetRef.getMethod(), drillTargetRef.getOutputFormat(), drillTargetRef.getOutputLocale(), bookmarkRef, parametersString, objectPaths, oCVId, drillTargetRef.getPrompt(), false); } } function getCVId() { var sCVId = ""; try { sCVId = this.frameElement.id.substring("CVIFrame".length); } catch(exception){} return sCVId; } function doMultipleDrillThrough(drillThroughContext, cvId) { // handle multiple drills var drillThroughTargetStr = ''; for(var drillTargetIdx = 0; drillTargetIdx < drillThroughContext.length; ++drillTargetIdx) { var currentDrillThroughContext = drillThroughContext[drillTargetIdx]; if(currentDrillThroughContext.length < 3) { // there must be three or more parameters (drill idx, drill label and the drill parameters) continue; } var drillTargetRefIdx = currentDrillThroughContext[0]; if(typeof drillTargetRefIdx == "undefined" || drillTargetRefIdx == null) { continue; } var drillTargetLabel = currentDrillThroughContext[1]; if (typeof drillTargetLabel == "undefined" || drillTargetLabel == null) { continue; } var drillTargetRef = cvId && window[cvId + "drillTargets"] ? window[cvId + "drillTargets"][drillTargetRefIdx] : drillTargets[drillTargetRefIdx]; if(typeof drillTargetRef == "undefined" || drillTargetRef == null) { continue; } if(drillTargetLabel === null || drillTargetLabel === "") { drillTargetLabel = drillTargetRef.getLabel(); } drillThroughTargetStr += '