/******************************************************************************************************************************** * Licensed Materials - Property of IBM * * * * IBM Cognos Products: AGS * * * * (C) Copyright IBM Corp. 2005, 2017 * * * * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. * *********************************************************************************************************************************/ //any commands that load another page must ensure that those loaded pages process the command stack in case there //are other commands that come after //any commands that dont load other pages, must call process command stack to call any following functions var addColumnId = 0; var previewHasChanged = false; var report_viewer_window = null; var IFRM_ACTION_SAVE = "save"; var IFRM_ACTION_SAVE_AS = "create"; var IFRM_ACTION_VALIDATE = "validate"; var IFRM_ACTION_VALIDATE_SAVE = "validate_save"; var IFRM_ACTION_VALIDATE_TASK = "validate_task"; var IFRM_ACTION_VALIDATE_CONDITION = "validate_condition"; //the secondary action command enum is not the same as the ifrmCmd enum var SECONDARY_ACTION_NEW = "new"; var CONDITION_TAB = "AgentTask-condition"; var TAB_SELECTED = "tabSelectedID"; var BLANK_HTML_DOCUMENT = "../ags/blank.html"; var MSXML_DOM_DOCUMENT = "Msxml2.DOMDocument.3.0"; function parseXMLString(reportSpec) { var d; try { if (window.clipboardData) { d = new ActiveXObject( MSXML_DOM_DOCUMENT ); d.async = false; d.resolveExternals = false; d.validateOnParse = false; d.loadXML(reportSpec); } else { var domParser = new DOMParser(); d = domParser.parseFromString(reportSpec, "text/xml"); } } catch ( e ) { d = null; } return d; } function showErrorPage(height) { if(!popUpIsOpen()){ dlgReset(); //this is in cmd initialiseDialog(); var cf = getConfigFrame(); cf.applicationActionManager.allowActions(); if(height==null){ height = 180; } cf.cfgSet('errAreaHt', height); dlgSetParm("m", "/ags/errorDialog.xts"); dlgSubmit("popUpFrame"); } } function sendCmdToTarget(cmdStr, xslref, resetRows, sTarget) { if (resetRows) cmdStr = "PF;" + cmdStr; // first page if (xslref.length <= 0){ xslref = '_QS_'; } // need to keep old spec in case of a cancel cfgSet("OLD_qs_spec", cfgGet("conversation_qs_spec")); asyncReset(); asyncSetParm("m", "async/conv.xts"); asyncSetParm("method", "editQuery"); var s=cfgGet("conversation_qs_spec"); if (s) { asyncSetParm("inlineSpec", s); var objid = cfgGet("SearchPath"); if (objid != null && objid != "") asyncSetParm("obj", objid); } else { s=cfgGet("conversation_qs_obj"); if (s) asyncSetParm("obj", s); } asyncSetParm("action", cmdStr); asyncSetParm("xslURL", xslref); asyncSetParm("prompt", "false"); var promptValuesArray = cfgGet("filter_promptValues"); if (promptValuesArray!=null && typeof promptValuesArray == "object") { for (var i in promptValuesArray) { var promptValues = promptValuesArray[i]; asyncSetParm(promptValues[0], promptValues[1]); } } asyncSubmit(sTarget); } function sendCmd(cmd, xslref, resetRows) { sendCmdToTarget(cmd, xslref, resetRows, ""); cfgSet("ActionRunning", true); } //guts of this in util.js function deleteSelectedItem(){ deletionCandidateManager.deleteSelectedItem(); cf.agentHasChanged(true); } /** get the dialog frame ready to execute a particular frmcmd.... */ function setUpFrmCmd(frmAction, ignoreReport) { //set in form vars initialiseDialog(); // generate any other variables that we want - and prefix them with agsSave_ so // pre-save can spot them and leave them alone - prefix is stripped in pre_save dlgSetParm("m", "/ags/pre_submit.xts"); dlgSetParm("agsSave_metaModel", cfgGet("cmLastModel")); dlgSetParm("agsSave_packageRoot", cfgGet("PackageRoot")); if(!ignoreReport){ var reportSpec = getConfigFrame().cfgGet("inlineSpec"); dlgSetParm("agsSave_inlineSpec", reportSpec); } dlgSetParm("agsSave_searchPath", cfgGet("SearchPath")); dlgSetParm("agsSave_ifrmcmd", frmAction); if(cfgGet("wizardURL")){ dlgSetParm("agsSave_wizardURL", cfgGet("wizardURL")); } // also have to tell it what sort of object we're creating dlgSetParm("agsSave_m_new_class", "agentDefinition"); // save the current path dlgSetParm("agsSave_m_path", decodeURIComponent(cf.cfgGet('PackageRoot'))); //need to track this for prompting to save cfgSet("saved_agent_condition", buildFilterCondition()); } /** add all the message frame state into the dialog frame ready for submission */ function initialiseDialog(){ var messageIFrame = getMessageIFrame(); var messageIFrame_doc = getFrameDocument(messageIFrame); // make sure that we are in a correct state before copying form variables. // this applies to all forms of save/validate if(messageIFrame.leavingDialog){ // correct the state of the messageIFrame messageIFrame.leavingDialog(); } //we can get here while loading or during page transition if(!messageIFrame_doc || !messageIFrame_doc.forms || messageIFrame_doc.forms.length == 0 || !messageIFrame_doc.forms[0]){ return; } // send in all the values from messageIFrame for (var i = 0; i < messageIFrame_doc.forms[0].elements.length; ++i) { // get the type of the control var type = messageIFrame_doc.forms[0].elements[i].type; // we have to do something different in the case when we have different types of inputs // radio control if (type == 'radio') { // get the name of the control var n = messageIFrame_doc.forms[0].elements[i].name; // have we seen this before - we will if find a subsequent radio control in the same group if (!dlgContains(n)) { // get all the elements in the group var radioGrp = messageIFrame_doc.getElementsByName(n); // have to look over them all and find the one that's selected for (var j = 0; j < radioGrp.length; ++j) { // get the element var radioItem = radioGrp[j]; // are you selected if (radioItem.checked) { // get the value of the item var v = radioItem.value; // save this dlgSetParm(n, v); } } } } else if (type == 'checkbox') { var n = messageIFrame_doc.forms[0].elements[i].name; var v = messageIFrame_doc.forms[0].elements[i].value; // only add this element if it's checked if (messageIFrame_doc.forms[0].elements[i].checked && n!='') { // save the value dlgAddParm(n, v); } } else { var n = messageIFrame_doc.forms[0].elements[i].name; var v = messageIFrame_doc.forms[0].elements[i].value; // store this only if have a valid name if (n!='') { // save the value into the hidden frame dlgAddParm(n, v); } } // might have to do something special for select-and multi select. } } function initialiseAgentInfo(){ var messageIFrame = getMessageIFrame(); var messageIFrameDoc = getFrameDocument(messageIFrame); if (messageIFrameDoc && messageIFrameDoc.pform && messageIFrameDoc.pform.agent_definition_blob) { var blob = messageIFrameDoc.pform.agent_definition_blob.value dlgSetParm("agent_definition_blob",blob); } } //this method asks report server for a screen //to get parameters. these then have to be stashed //away for use in the validate or preview call function getConditionParameters(){ var rspec = getConfigFrame().cfgGet("inlineSpec"); if(rspec){ //have it doXHTTPCollectParameterValues(); }else{ //no report no cry - just get on with the next command getCommandStackManager().processCommandStack(); } } /*function doDebugTest(){ alert("start"); getConditionParameters(); setTimeout("getConditionParameters();alert('finish')", 60400); } */ /** call preview with a flag of 'preview_all', 'preview_task' or 'preview_count' where the default is 'preview_all' **/ function preview(previewStyle) { try { var agentAction = null; // get the value of tabSelectedID. var msgFrame = getMessageIFrame(); var tabSelectedIDElement = msgFrame.document.getElementById("tabSelectedID"); var tabSelectedID = (tabSelectedIDElement == null ? null : tabSelectedIDElement.value); // check to see if we're on the condition page and running a preview_task if(null!=tabSelectedID && tabSelectedID==CONDITION_TAB && previewStyle=="preview_task"){ //this is special for condition page doClosePopUp(); run(); return; } // clear the dialogFrame - do before both calls - otherwise the call // to noData.xts will be missing values. dlgReset(); // Preview only if there are items in the report spec. // If no items, we redirect to the file noData.xts. // if (noDataItems()) { dlgSetParm("m", "/ags/noData.xts"); dlgSubmit("popUpFrame"); return; } var frm_cmd = previewStyle; var m_rp_parameters; var method = "previewAgent"; // call the preview function doXHTTPPreview(method, cfgGet("AGENT_STATE"), frm_cmd, tabSelectedID); }catch(ex){ //alert(ex); if(doClosePopUp){ doClosePopUp(); } } } /* just validate the agent condition given the array of items passed in */ function validateAgentCondition(div_id) { if(div_id){ //set the div id to update cfgSet(CURRENT_ERROR_DIV_ID_KEY, div_id); } // do the validate agent condition dance doXHTTPValidateCondition(); } /* validate the agent and its tasks and the agent condition, and store the messages in jscript */ function getAgentValidateMessages(){ var frm_cmd = null; // get the value of tabSelectedID var msgFrame = getMessageIFrame(); var tabSelectedIDElement = msgFrame.document.getElementById("tabSelectedID"); var tabSelectedID = (tabSelectedIDElement == null ? null : tabSelectedIDElement.value); if(null!=tabSelectedID && tabSelectedID != CONDITION_TAB) { frm_cmd = IFRM_ACTION_VALIDATE_TASK }else{ frm_cmd = IFRM_ACTION_VALIDATE; } getValidateMessages(frm_cmd); } //once errors are cached, display them function displayValidateMessages(){ dlgReset(); //this is in cmd initialiseDialog(); dlgSetParm("m", "/ags/validatePage.xts"); //this part of the validate sequence dlgSubmit(); } /* * Open the wait dialog. must be closed by another script * the wait messages are switched on a waitDialogStyle var */ function doWait(waitStyle) { if(!waitStyle){ waitStyle = IFRM_ACTION_VALIDATE; } //there is an active dialog in the pop up frame if(popUpIsOpen() && dlgGetParm("m") == "/ags/wait.xts" && dlgGetParm('waitDialogStyle') == waitStyle){ //already waiting getCommandStackManager().processCommandStack(); return; } dlgReset(); //st in form vars initialiseDialog(); if(waitStyle == 'resetEventList'){ //caf doesnt support this yet waitStyle = ""; } dlgSetParm('waitDialogStyle', waitStyle); dlgSetParm("m", '/ags/wait.xts'); dlgSubmit("popUpFrame"); } function getSaveCommandStack() { var saveCommand; if (cfgGet("NewReport") == true){ saveCommand = getCommandStackManager().createCommandStack("checkCAF()","getReportSpec()","commandStackHideDialogFrame()","calcAgentState()","getSaveValidateMessages()", "displayValidateMessages()", "saveas()"); } else{ saveCommand = getCommandStackManager().createCommandStack("checkCAF()","getReportSpec()","commandStackHideDialogFrame()", "doWait('save')", "calcAgentState()","getSaveValidateMessages()", "displayValidateMessages()", 'save()'); } return saveCommand; } function save() { // clear the dialogFrame dlgReset(); dlgSetParm("agsSave_m_p_defaultName", cfgGet("ReportName")); //do the do setUpFrmCmd(IFRM_ACTION_SAVE, false); //flag the dialog type agsDialogTypes.setCurrentType(agsDialogTypes.SAVE_SAVEAS); // submit the dialogFrame, this will call pre_submit.xts dlgSubmit(); } //a function that can be tacked onto a command stack.... just hides the dialog frame and processes the stack function commandStackHideDialogFrame(){ hideDialogFrame(); getCommandStackManager().processCommandStack(); } /* do a save style validate where we dont worry about warnings... only errors errors stop the agent saving and store the messages in jscript */ function getSaveValidateMessages(){ getValidateMessages(IFRM_ACTION_VALIDATE_SAVE); } //utility for the common validate features function getValidateMessages(frm_cmd) { try{ var agentAction = null; // clear the dialogFrame dlgReset(); var m_rp_parameters; var msgFrame = getMessageIFrame(); var tabSelectedIDElement = msgFrame.document.getElementById("tabSelectedID"); var tabSelectedID = (tabSelectedIDElement == null ? null : tabSelectedIDElement.value); var method = "validateAgent"; // call the preview function doXHTTPValidate(method, cfgGet("AGENT_STATE"), frm_cmd, tabSelectedID); //flag the dialog type agsDialogTypes.setCurrentType(agsDialogTypes.VALIDATE); }catch(ex){ //alert(ex); if(doClosePopUp){ doClosePopUp(); } } } /* * Perform the agent 'Save as' action * bLeaveAfterSave Leave Agent Studio when the agent has been saved and any final action has been completed * secondaryAction, The action to take place when the save has completed. e.g. new,wizard,open etc. * Set to 'noAction' if the save should be the final action * all saves are preceded by a validate action */ function saveas() { // clear the dialogFrame dlgReset(); //do the save as frm cmd setUpFrmCmd(IFRM_ACTION_SAVE_AS, false); dlgSetParm("agsSave_m_class", ""); // also have to retell it what sort of object we're creating dlgSetParm("agsSave_m_new_class", "agentDefinition"); //waiting on a portal fix to use these to display the agents for browsing dlgSetParm("agsSave_cfilter", "[@objectClass = 'folder' or @objectClass = 'namespaceFolder' or @objectClass = 'package' or @objectClass = 'configurationFolder' or @objectClass = 'configuration' or @objectClass = 'portletFolder' or @objectClass = 'adminFolder' or @objectClass = 'agentDefinition' or @objectClass = 'agentDefinitionView']"); dlgSetParm("agsSave_cSelectionCriteria", " folder namespaceFolder package configurationFolder configuration portletFolder adminFolder "); //flag the dialog type agsDialogTypes.setCurrentType(agsDialogTypes.SAVE_SAVEAS); // submit the dialogFrame dlgSubmit(); } /* * Called from portal code: * ps/portal/iFaultHandler/handleFault.xts */ function handleFaultInit(w){ //hide the dialog var dialog = parent.agsFormUtils.getElementFromFrame(parent,parent.DIALOG_FRAME_ID); if (dialog && dialog.style.display=='') { hideDialogFrame(); } //If we are in message frame do not bother //Message frame will display this fault //This works in the case of Login only. //I do not know when you get a guenuine soap fault //what will happen? if (w && w.name == DIALOG_FRAME_ID) { showDialogFrame(300); } else if (isPopUpFrame(w)) { doOpenPopUp(); } } /* * Called from portal code: * ps/portal/save_as.xts */ function saveAsDlgInit(w) { //flag the dialog type agsDialogTypes.setCurrentType(agsDialogTypes.SAVE_SAVEAS); showDialogFrame(385); } /* * Called from portal code: * ps/portal/specify_location.xts NB this has been suplanted by portal/select/select.xts but keep this here for now just in case! * showDialogFrame should not be called by age components */ function doSelectPathDlgInit(dialog){ if(isPopUpFrame(dialog)){ doOpenPopUp(); }else{ //get the dialog td var dialogTD = agsFormUtils.getElementFromFrame(getConfigFrame(), getFrameBorderId(DIALOG_FRAME_ID)); //flag the dialog type agsDialogTypes.setCurrentType(agsDialogTypes.OPEN_FILE); var size = new SizeParser(dialogTD.style.height); //only show when the dialog frame is hidden if(size.leq(0)) { showDialogFrame(385); } } } function doSaveAs(path, name, description, screenTip) { // we already have variables for these. document.pform.m_path.value = path; document.pform.m_p_defaultName.value = name; document.pform.m_p_defaultDescription.value = description; document.pform.m_p_defaultScreenTip = screenTip; // now have to forward to submit and let it do it's job document.pform.m.value = "/ags/submit.xts"; document.pform.ps_nav_op.value = "maintain"; //flag the dialog type agsDialogTypes.setCurrentType(agsDialogTypes.SAVE_SAVEAS); // fire document.pform.submit(); } /* * Load the definition, the dialogue can be either be * the edit parameter or edit calculations dialogues. More * may be added in the future... * selectedNodes The selected nodes from a tree * fn The call that will display a dialogue */ function loadDefinitionEditPage(selectedNode,fn) { if (selectedNode && selectedNode != 'undefined') { if (fn) { eval(fn); } } else { alert(editDefinitionSelectionWarning); } } function editDefinition(){ var visibleTree = cfgGet("lastMenu"); var selectedNodes = null; var prmData=null; var ags_tree_node=null; var fn=null; //handle parameters if (visibleTree == TAB_PARAMETERS) { //get the params //selectedNodes = getSelectedParameterNodes(); selectedNodes = getParametersTree().getSelectedLeafNodes(); if (selectedNodes && selectedNodes.length > 0) { ags_tree_node=selectedNodes[0]; //set action fn = "getConfigFrame().showParameters('edit','" + ags_tree_node.getTreeRef() + "');"; } } //handle data items else if (visibleTree == TAB_DATAITEMS) { //selectedNodes = getSelectedQueryItemNodes(); selectedNodes = getDataItemsTree().getSelectedLeafNodes(); if (selectedNodes && selectedNodes.length > 0) { ags_tree_node = selectedNodes[0]; //set action fn = "getConfigFrame().showDataItem('edit','" + ags_tree_node.getTreeRef() + "');"; } } //display the selected dialogue loadDefinitionEditPage(ags_tree_node,fn); } function createHiddenInput(document, name, value){ var inline = document.createElement("INPUT"); inline.setAttribute("name", name); inline.setAttribute("value", value); inline.setAttribute("id", name); inline.setAttribute("type", "hidden"); return inline; } /* * Fire the 'copy' action. This function will place any selected text onto the clipboard */ function copy() { var msgFrame = getMessageIFrame(); var control = getSelectionControl(); //only copy from valid controls if (control) { selText = getSelectedText(); if (selText != '') { //IE if (browserCheck.isIE5dot5Up()) { //copy the text to the clipboard window.clipboardData.setData("Text",selText); } //Firefox else if (dlgContains(K_sSelectionId)) { var sel = dlgGetParm(K_sSelectionId); sel.copiedText=selText; } } } } /* * Fire the 'paste' action. This function will copy the clipboard data to the current control. * The control that received the last blur event is deemed to be the last active control * toBePasted Optional text to be pasted into the control */ function paste(toBePasted) { var msgFrame = getMessageIFrame(); var sel = null; var text=""; //set the text if it has been passed into the function if (toBePasted != undefined) { text=toBePasted; } //get the selection control that either has a selection or the selection caret var control = getSelectionControl(); if (control != null) { var selObj = getSelectionObject(control.ownerDocument); //get the id var id = control.name; //check if this dialog has paste enabled if (isPasteEnabled(id)) { //check if the current control has hint text, if it has we need to clear it //properly using the drag/drop handler. This is defined in dragDropHandler.js if (msgFrame.droppy != undefined && msgFrame.droppy.registeredObjectsIndex[id] != undefined && msgFrame.droppy.registeredObjectsIndex[id].isDefaultMode()) { msgFrame.droppy.removeDefault(id); } if (browserCheck.isIE5dot5Up()) { if (toBePasted == undefined) { //get the clipboard info text = window.clipboardData.getData("Text"); } //important!!!!!!!! if the control is not set as active the clipboard info may be pasted into arbitrary non-input controls on the page control.setActive(); //create the range var range = selObj.createRange(); if (text != null) { //reset the selection if we have one if (selObj.type=="Text") { selObj.clear(); } //need to paste as HTML if (control.canHaveHTML && (control.id=='editbody' || (control.ownerDocument.pform && control.ownerDocument.pform.richEditMode && control.ownerDocument.pform.richEditMode.value=="true"))) { range.pasteHTML(text); } //paste as simple text else { //convert to plain text var ele = document.createElement("div"); ele.innerHTML=text; //paste the clipboard contents range.text=ele.innerText; } } } else if (dlgContains(K_sSelectionId)) { var pos=0; var sel = dlgGetParm(K_sSelectionId); if (toBePasted == undefined) { text = sel.copiedText; } var startPos = control.selectionStart; var endPos = control.selectionEnd; //control.focus(); //remove the selected text clearSelectionText(selObj); control.value = control.value.substring(0, startPos) + text + control.value.substr(endPos); } } } } /* * Fire the 'cut' action. This function will copy active control data into the clipboard and then * clear the current control value. The control that received the last blur event is deemed to be the last active control */ function cut() { var sel = null; var control = getSelectionControl(); if (control) { sel = getSelectionObject(control.ownerDocument); if (isValidSelection(sel)) { //save the current selection to the clipboard copy(); //remove the selected text clearSelectionText(sel); } } } function getCaption(){ getFunction(K_sCaptionFunctionText); } // inserts previous value function in the selected text for agent task function getPreviousValue() { getFunction(K_sPreviousFunctionText); } // inserts previous value function in the selected text for agent task function getFunction(funtion_text, secondGo) { var empty_warning = funtion_text == K_sPreviousFunctionText ? agentStudioWarningForInsertingPreviousValueFunctionInEmptyValueBox : agentStudioWarningForInsertingCaptionFunctionInEmptyValueBox; var dialog_warning = funtion_text == K_sPreviousFunctionText ? agentStudioWarningForInsertPreviuosValue : agentStudioWarningForInsertCaption; // To check if it is the condition or Dataitems page then // don't do the paste var currentSel = dlgGetParm(K_sSelectionId); if (currentSel != null) { if (currentSel.id != K_sDataItemExpression && currentSel.id != K_sDataItemName && currentSel.id != K_sDetailExpression) { //check whether this is read only input eg.Store procedrue, Web services, prompted report etc have. var msgFrame = getMessageIFrame(); // this is the messagedoc for message frame var msgDoc = getFrameDocument(msgFrame); var el = msgDoc.getElementById(currentSel.id); var isDropZone = msgFrame.droppy != null ? msgFrame.droppy.isDropZone(currentSel.id) : false; var isPrompt = el != null && el.closePrevious != null && el.closePrevious == 'true'; var isOverWrite = msgFrame.droppy != null ? msgFrame.droppy.isOverWrite(currentSel.id) : false; if (isDropZone && (isPrompt || isOverWrite)) { if(el.value == '' && !secondGo){ //we have a drop zone targeted... do a drop insertStartMC(currentSel.id); setTimeout("getFunction('"+ funtion_text +"', true)"); }else if (el.value != '') { var function_matcher = /\([^(^)]+\)/g; var functions = el.value.match(function_matcher); if(functions != null && functions.length > 0){ //we already have functions..so blat whats there insertStartMC(currentSel.id); setTimeout("getFunction('"+ funtion_text +"', true)"); }else{ // check the label is not empty //we need to get the data Item and wrapp it in a function so it looks like "previous([Item name])") var textToBePasted = funtion_text + el.value + ')'; el.value = textToBePasted; } }else { // the value is empty and cant be filled...warn the user window.alert(empty_warning); } } else if(isDropZone) { paste(funtion_text); insertStartMC(currentSel.id); paste(")"); } }else { window.alert(dialog_warning); } } } // inserts selected itiem from source tab into data items tab function insertItem() { parent.insertStartMC(); } /* * Check if the input control with the given id can have text pasted into it * id The input control id */ function isPasteEnabled(id) { var isEnabled = true; dlgArray = dlgGetParm("pasteEnabled"); if (dlgArray != null && dlgArray[id] != undefined) { isEnabled = dlgArray[id]; } return isEnabled; } /* * Set the paste enabled state for the dialog * id The input control id * enabled true if pasted is enabled for this control */ function setPasteEnabled(id,enabled) { var dlgArray = null; dlgArray = dlgGetParm("pasteEnabled"); //create and set the parameter the first time if (dlgArray==null) { dlgArray = new Array(); dlgSetParm("pasteEnabled",dlgArray); } //set the state dlgArray[id]=enabled; } /* * Perform the undo function. If a tree item has been deleted then it will be resurrected here */ function undo() { getRedoUndoManager().reverseLastEditAction(); } function redo() { getRedoUndoManager().redoLastEditAction(); } // this is to hide the droptasks list and list when not in focus function hideFlyout() { var messageFrame = window.parent.getConfigFrame(); } /* * attach the event handler for the fl */ function onDialogFrameLoad() { // get us the dialog frame var dialogFrame = getDialogFrame(); // this is the messagedoc for dialog frame var dialogDoc = getFrameDocument(dialogFrame); var forms = dialogDoc.forms; if (forms['pform']) { DialogFrame_hookFormSubmit(forms['pform']); } handleEmailBody(); // attach the handlers for dialog frame attachHandlers(forms); // this is to hide the drop down task list and drop down tools list in dialog frame when not in focus. if (dialogDoc.body != null && dialogFrame.parent.document.body.getWndObserver) { dialogFrame.parent.document.body.getWndObserver().attachFrames('mouseup'); dialogFrame.document.body.getWndObserver().attachFrames('mouseup',dialogFrame); //register a key down handler to detect changes eventHandlerChainUtil.doEventHandlerChain(dialogDoc, "keydown",keyDownChecker.check); } if(isDialogFrameShowing()){ applicationActionManager.allowActions(); //decide if the task list state needs to be updated if (dialogDoc.forms.length > 0 && dialogDoc.forms[0].m != undefined) { var morphlet=dialogDoc.forms[0].m.value; var selType; //manage the task execution rules if (morphlet.match('suppression')) { selType=K_sSuppression; } //schedule the agent else if(morphlet.match('schedule')) { selType=K_sSchedule; } //reorder the tasks else if (morphlet.match('seq_agent_tasks')) { selType=K_sSetSubmit; } //update the selected item task list if (selType!=undefined) { makeSelection(selType); } } } } // This method check login for every dialog frame submit // function DialogFrame_hookFormSubmit(form) { // Hook the form submit() method. form.old_mf_submit = form.submit; form.submit = function() { checkLogin(undefined,"processDlgSubmit()"); } } function processDlgSubmit() { // get us the dialog frame var dialogFrame = getDialogFrame(); // this is the messagedoc for dialog frame var dialogDoc = getFrameDocument(dialogFrame); //Get this nasty form out. //I had to make this change cos the createCommandStackObject process next command. //In the case of File-> Exit on a new agent the Studio exits when change location //for save as. Bug: 575574. var forms = dialogDoc.forms; var form = forms['pform']; if (form) { // Submit this form. form.old_mf_submit(); } } function MessageFrame_hookOnClick(msgFrame) { msgFrame.document.body.onclick = function(e) { if (!e) e = msgFrame.window.event; e = (e.target ? e.target : e.srcElement); if (e.tagName=='A') { // Clicked on an A element. // Is the href=='#'? // s = e.href; if (s.indexOf('#')==s.length-1) { // Cancel the click, stops IE navigating // to the top of the page. // e.cancelBubble = true; if (e.stopPropagation) e.stopPropagation(); return false; } } } } // This method disables links and form submits so that the // server is not interrupted while processing a request // A submit response is always a new HTML page. // function MessageFrame_hookFormSubmit(form) { // Hook the form submit() method. form.old_mf_submit = form.submit; form.submit = function() { var target = this.target; checkLogin(undefined,"processMsgSubmit('"+ target + "')"); } } function processMsgSubmit(target) { var msgFrame = getMessageIFrame(); // this is the messagedoc for message frame var msgDoc = getFrameDocument(msgFrame); var form = msgDoc.forms['pform']; //Dont know why we are losing the target. form.target = target; // Submit this form. form.old_mf_submit(); // Disable the A elements. var tags = form.ownerDocument.getElementsByTagName("a"); for (var i=0; i!=tags.length; i++) { tags[i].href='#'; tags[i].onclick="return false;"; // Dont change color? Inconsistent with other CRN studios. //tags[i].className = "inactiveHRef"; } // Block all further submits in this page. tags = form.ownerDocument.getElementsByTagName("form"); for (var i=0; i!=tags.length; i++) { tags[i].submit = function dummy(event) { }; } } /* * Loop through all the input controls in the message frame and attach a focus out handler to each one. * The deletion candidate variable is set each time a control receives a focus out. This is then used to decide * which control is to be deleted */ function onMessageFrameLoad() { var msgFrame = getMessageIFrame(); // this is the messagedoc for message frame var msgDoc = getFrameDocument(msgFrame); var forms = msgDoc.forms; // Trap the onClick() event so that we can monitor the A elements and prevent IE from navigating // to the top of a page when a href contains '#'. Otherwise the message frame will shift to 0,0 // relative to the left of the main window window when such a link is clicked. // MessageFrame_hookOnClick(msgFrame); if (msgFrame.document.forms['pform']) MessageFrame_hookFormSubmit(msgFrame.document.forms['pform']); //this is to hide the drop down list and drop down tools list in message frame when not in focus if (msgDoc.body != null && msgFrame.parent.document.body.getWndObserver) { msgFrame.parent.document.body.getWndObserver().attachFrames('mouseup'); msgFrame.parent.document.body.getWndObserver().removeListenerById(msgFrame.document.body.getWndObserver().id); msgFrame.parent.document.body.getWndObserver().addListener(msgFrame.document.body.getWndObserver(),msgFrame.document.body.getWndObserver().notify, "mouseup"); msgFrame.document.body.getWndObserver().attachFrames('mouseup',msgFrame); //register a key down handler to intercept and discard hotkey combinations eventHandlerChainUtil.doEventHandlerChain(msgDoc, "keydown",keyDownChecker.check); } // should we also hide the popUpFrame if (popUpIsFlaggedForClosure()) { // close it doClosePopUp(); parent.document.getElementById("metadataIFrame").focus(); } //clear the undo data when we move page getRedoUndoManager().resetTreeAction(); //attach the events to the email body which is not part //of the message frame form handleEmailBody(); //attach commaons handlers common to the message frame and the dialog frame attachHandlers(forms,msgFrame); //unblock actions now its all calmed down applicationActionManager.allowActions(); //register key down handler for A11Y keyboard if (AccessibilityHandler.isEnabled()) { msgFrame.document.body.onkeydown = AccessibilityHandler.onkeydown; } } function attachAgentChangeHandler(control) { //register a key down handler to detected changes eventHandlerChainUtil.doEventHandlerChain(control, "keydown", function(evt) { if (cf.hasAgentChanged()==false) { cf.agentHasChanged(true); } }); } /* * Attach event handlers to the input controls in the frame * forms - an array of forms, must not be null or undefined * sourceFrame - The parent frame, this parameter is optional */ function attachHandlers(forms,sourceFrame) { var intended=/INPUT|TEXTAREA|SELECT|OPTION/; //loop through the forms in the message frame for (var i=0;i 0) { var j=0; //for (;j < diNodes.length;j++) { if (window.clipboardData) { getConfigFrame().cfgSet("inlineSpec_promptPages", diNodes.item(j)); } else { getConfigFrame().cfgSet("inlineSpec_promptPages", diNodes[j]); } agentUpdated = true; //} } return agentUpdated; } function updateExtraQueries(reportSpecDoc) { // parse all the extra queries var agentUpdated = false; var pattern; if (window.clipboardData) { pattern = "/report/queries/query"; } else { pattern = "/*[local-name()='report']/*[local-name()='queries']/*[local-name()='query']"; } var diNodes = selectNodes(pattern,reportSpecDoc); // if we only have one query then assume there are no extra queries we have to care about ... if (diNodes != null && diNodes.length > 1) { var extraQueries = new Array(); var extraSize = -1; for (var j=0;j < diNodes.length;j++) { var name = "x"; if (window.clipboardData) { var nameNode = selectSingleNode("./@name",diNodes.item(j)); if (nameNode != null) { name = nameNode.text; } if (name != "Query1") { extraSize += 1; extraQueries[extraSize] = diNodes.item(j); } } else { var nameNode = selectSingleNode("./@name",diNodes[j]); if (nameNode != null) { name = nameNode.textContent; } if (name != "Query1") { extraSize += 1; extraQueries[extraSize] = diNodes[j]; } } } if (extraSize >= 0) { getConfigFrame().cfgSet("inlineSpec_extraQueries", extraQueries); agentUpdated = true; } } return agentUpdated; } function updateAgentItems(reportSpecDoc) { var agentUpdated = false; var pattern; if (window.clipboardData) { pattern = "/report/queries/query[@name='Query1']/selection/dataItem"; } else { pattern = "/*[local-name()='report']/*[local-name()='queries']/*[local-name()='query'][@name='Query1']/*[local-name()='selection']/*[local-name()='dataItem']"; } // parse all the data items, and chuck them in the agent data item tree var expressionText = ""; var name = "x"; var diNodes = selectNodes(pattern,reportSpecDoc); if (diNodes != null && diNodes.length > 0) { for (var j=0;j < diNodes.length;j++) { if (window.clipboardData) { var nameNode = selectSingleNode("./@name",diNodes.item(j)); if (nameNode != null) { name = nameNode.text; } var expressionNode = selectNodes("./expression",diNodes.item(j)); if (expressionNode != null && expressionNode.length > 0) { expressionText = expressionNode.item(0).text; } } else { var nameNode = selectSingleNode("./@name",diNodes[j]); if (nameNode != null) { name = nameNode.textContent; } var expressionNode = selectSingleNode("./*[local-name()='expression']",diNodes[j]); if (expressionNode != null) { expressionText = expressionNode.textContent; } } var aggregate = "none"; var displayType = "textItem"; // These are almost always a textItem ... so skip looking through the layout for the type. //if (window.clipboardData) { // pattern = "/report//listColumnBody/contents/*[.//dataItemValue/@refDataItem='" + name + "']"; //} else { // pattern = "/*[local-name()='report']//*[local-name()='listColumnBody']/*[local-name()='contents']/*[.//local-name()='dataItemValue']/@refDataItem='" + name + "']"; //} //var diNode = selectSingleNode(pattern,reportSpecDoc); //displayType = diNode.text; generateAgentItem(name, expressionText, aggregate, displayType); agentUpdated = true; } } return agentUpdated; } function updateAgentFilter(reportSpecDoc,filterText) { var pattern; var postAutoAggregation = ""; if (filterText == "detail") { postAutoAggregation = "[not(@postAutoAggregation) or @postAutoAggregation='false']"; } if (window.clipboardData) { pattern = "//" + filterText + "Filters/" + filterText + "Filter" + postAutoAggregation + "/filterExpression"; } else { pattern = "//*[local-name()='" + filterText + "Filters']/*[local-name()='" + filterText + "Filter']" + postAutoAggregation + "/*[local-name()='filterExpression']"; } var expressionText = ""; //a flag to determine whether the agent has changed since loading/saving var v_bChanged = false; // get the filter var selNodes = selectNodes(pattern,reportSpecDoc); if (selNodes != null && selNodes.length > 0) { for (var j=0;j< selNodes.length;j++) { if (j > 0) { expressionText = expressionText + " and "; } if (window.clipboardData) { expressionText = expressionText + selNodes.item(j).text; } else { expressionText = expressionText + selNodes[j].textContent; } } var obj; var filterExpression = filterText + "Expression"; var msgFrame = getMessageIFrame(); var msgDoc = getFrameDocument(msgFrame); if (browserCheck.isIE5Up()) { obj = msgDoc.getElementById(filterExpression); } else { obj = msgDoc.getElementsByName(filterExpression)[0]; } obj.className="hintText_inactive"; obj.value = expressionText; v_bChanged = true; } return v_bChanged; } function selectNodes(aExpr,aNode) { if (window.clipboardData) { return aNode.selectNodes(aExpr); } else { var xpe = new XPathEvaluator(); var nsResolver = xpe.createNSResolver(aNode); var expression = xpe.createExpression(aExpr,nsResolver); var result = expression.evaluate(aNode, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null); var found = []; while (res = result.iterateNext()) found.push(res); return found; } } function selectSingleNode(aExpr,aNode) { if (window.clipboardData) { return aNode.selectSingleNode(aExpr); } else { var xpe = new XPathEvaluator(); var nsResolver = xpe.createNSResolver(aNode); var expression = xpe.createExpression(aExpr,nsResolver); var result = expression.evaluate(aNode, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null); return result.iterateNext(); } } function showAgentSpecification() { var text = getConfigFrame().cfgGet("inlineSpec"); try { if (text != null) { var height = ( window.screen.availHeight - 170 ); var width = ( window.screen.availWidth - 100 ); var agent_spec_window = window.open("../ags/prettyprint.html", "_blank", "directories=no,location=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,top=80,left=50,height=" + height + ",width=" + width); if (agent_spec_window == null) { // popup blocked alert(newWindowBlockedFromOpening); return; } agent_spec_window.focus(); } else { alert(noSpecificationToDisplay); } } catch ( e ) { alert(errorShowingSpecification); } } function leaveAGS(){ dlgReset(); dlgSetParm("actionAfterSubmit", "open"); dlgSetParm("m", "/ags/leavingAGS.xts"); initialiseAgentInfo(); dlgSubmit(); } function closeAGS() { window.onbeforeunload=null; window.close(); } /* * warn the user of changes to the agent when closing event studio */ function confirmClose() { if(hasAgentChanged()) { return agentStudioExitWarning_string; } } function doFileOpen() { doSelectObject("agents.es"); } function selectValue(target_id,frameName) { // build the url for the window we're going to open - just want to run the run_report.xts in it var url = cfgGet("SCRIPT_ENGINE"); url += "?b_action=xts.run"; url += "&m=/ags/selectValueUI.xts"; url += "&target_id=" + target_id; url += "&frameName=" + frameName; // append the target id, XSS encode the variables and add the context id url = constructGETRequestURLString(url); // see if we have any leaf nodes selected in the metadata tree if (dataItemSingleSelection()) { // get the single item which is selected var v_aItems = metadataSelectedQueryItems(); // get the item - we know there is only one var v_oItem = v_aItems[0]; // get the type var v_sType = (v_oItem.type ? v_oItem.type : null); // if we have a hierarchy type we might want to abort //guard clause to check the QOSLevel if it exists // Note - this doesn't stop a hierarchy select values if the hierarchy is a selected dataItem // no way to detect that if (v_sType != null && v_sType == K_sHIERARCHY && cfgGet(MEMBER_SEARCH_IN_HIERARCHY) && cfgGet(MEMBER_SEARCH_IN_HIERARCHY) == QOS_UNAVAILABLE) { return; } // make the selectValues window - now FF and IE both can resize this window var select_query_window = window.open(url, "SelectValue", "height=675,width=520,resizable=1"); // bring it to the front if (select_query_window != null) { select_query_window.focus(); } } } function selectMember(sPath, sType) { dlgReset(); dlgSetParm("m","/ags/selectMembersUI.xts"); dlgSetParm("startAtPath", sPath); //determine whether the package has the MEMBER_SEARCH_IN_HIERARCHY option set to search descendents var sSearchDescendants = (cfgGet(MEMBER_SEARCH_IN_HIERARCHY) && cfgGet(MEMBER_SEARCH_IN_HIERARCHY) == QOS_OK) ? "true" : "false"; if (sType == K_sMEMBER) { dlgSetParm("searchDescendantsAllowed",sSearchDescendants); } dlgSubmit("popUpFrame"); } function editTitle() { cfgRemove("LAST_DIALOG"); dlgReset(); dlgSetParm("m", "/ags/editTitle.xts"); dlgSubmit(); } function noCapability() { alert(capabilities_msg); if (frameBackURL==null || frameBackURL=="") { history.back(); document.location.replace(BLANK_HTML_DOCUMENT); window.close(); } else document.location.replace(frameBackURL); } /* * load a dialog page * path Should point to a valid morphlet. The page will be opened in the message frame * opvalue The operation type, if missing or null the operation type will default to 'push' */ function loadPage(path,opvalue) { //check the path validity if (path != null && path != undefined && path != '') { //block until page is reloaded parent.applicationActionManager.blockActions(); var msgFrame = getMessageIFrame(); var msgDoc = getFrameDocument(msgFrame); //set the dialog morphlet msgDoc.pform.m.value=path; if (opvalue == undefined || opvalue == null) { msgDoc.pform.ps_nav_op.value = 'push'; } else { // we set the opvalue to the one given msgDoc.pform.ps_nav_op.value = opvalue; } msgDoc.pform.submit(); } } /* * XSS encode one or more URL parameters. * urlParams The parameters e.g. p1=abc&p2=def * * return the XSS encoded parameters. If the XSS library is unavailable then the * parameters will be returned unchanged. The context id for the session is also appended to the parameter string * with the name 'cafcontextid' * * NOTE : THIS SHOULD NOT BE CALLED FOR 'POST' REQUESTS */ function constructGETRequestURLString(urlParams) { var newUrlParams = ""; //check if the XSS library is available if (typeof CAFXSSEncodeURL == "function") { newUrlParams = CAFXSSEncodeURL(urlParams); } else { newUrlParams = urlParams; } // add in the CAF context ID newUrlParams = appendCAFContextId(newUrlParams); return newUrlParams; } /* * XSS encode one or more URL parameters. * urlParams The parameters e.g. p1=abc&p2=def * * return the XSS encoded parameters. If the XSS library is unavailable then the * parameters will be returned unchanged. The context id for the session is also appended to the parameter string * with the name 'cafcontextid' * * NOTE : THIS SHOULD NOT BE CALLED FOR 'POST' REQUESTS */ function constructGETRequestParamsString(urlParams) { var newUrlParams = ""; //check if the XSS library is available if (typeof CAFXSSEncode == "function") { newUrlParams = CAFXSSEncode(urlParams); } else { newUrlParams = urlParams; } // add in the CAF context ID newUrlParams = appendCAFContextId(newUrlParams); return newUrlParams; } /* * append the context id to the url parameters. the url is returned unchanged if the context id exists in the url */ function appendCAFContextId(urlParams) { //check for a context id and assign it to the query if (cafContextId != "" && urlParams.indexOf("cafcontextid")==-1) { if (urlParams != "") { urlParams += "&cafcontextid=" + cafContextId; } else { urlParams = "cafcontextid=" + cafContextId; } } return urlParams; } function showDefaultTasksOptions() { dlgReset(); dlgSetParm("m", "/ags/set_agent_defaults.xts"); initialiseAgentInfo(); //flag the dialog type agsDialogTypes.setCurrentType(agsDialogTypes.DEFAULT_TASKS_OPTIONS); dlgSubmit(); } function showNotificationList() { dlgReset(); dlgSetParm("m", "/ags/notificationList.xts"); initialiseAgentInfo(); //flag the dialog type agsDialogTypes.setCurrentType(agsDialogTypes.NOTIFICATION_LIST); dlgSubmit(); } function showSequenceAgentTasks() { dlgReset(); dlgSetParm("m", "/ags/seq_agent_tasks.xts"); initialiseAgentInfo(); //flag the dialog type agsDialogTypes.setCurrentType(agsDialogTypes.SEQUENCE_AGENT_TASKS); dlgSubmit(); } function showSuppressionDialog() { changeMenu('DataItems'); dlgReset(); //set in form vars initialiseAgentInfo(); dlgSetParm("m", "/ags/suppressionDialog.xts"); //flag the dialog type agsDialogTypes.setCurrentType(agsDialogTypes.SUPPRESSION); dlgSubmit(); } function showSchedule() { dlgReset(); dlgSetParm("m", "/ags/scheduleController.xts"); dlgSetParm("ui.routingServerGroup", UI_ROUTING_SERVER_GROUP); setScheduleParams(); //flag the dialog type agsDialogTypes.setCurrentType(agsDialogTypes.SCHEDULE); dlgSubmit(); } function setScheduleParams() { // 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"); var messageIFrame = getMessageIFrame(); var messageIFrame_doc = getFrameDocument(messageIFrame); var need_cred = true; // send in all the values from messageIFrame for (var i = 0; i < messageIFrame_doc.pform.elements.length; ++i) { // get the type of the control var ele = messageIFrame_doc.forms[0].elements[i] var type = ele.type; var name = ele.name; if (type == 'hidden') { if (name.indexOf("AgentTask-schedule") > -1) { dlgSetParm("scheduleParameters",ele.value); } else if (name.indexOf("AgentTask-") > -1) { dlgSetParm(name,ele.value); } else if (name.indexOf("agent_definition_blob") > -1) { dlgSetParm(name,ele.value); } else if (name.indexOf("m_sp_credential") > -1 && (!ele.value || ele.value != '')) { need_cred = false; } } } if(need_cred){ dlgSetParm("h_CAM_action", "generateTC"); } var spec = getConfigFrame().cfgGet('inlineSpec'); dlgSetParm("agentReportSpec",spec); } function showDataItem(action,nodeRef) { if(action== 'add' || confirm(agentItemsChangeWarning)) { dlgReset(); if (nodeRef && nodeRef != 'undefined' && nodeRef != '') { dlgSetParm("nodeRef", nodeRef); } dlgSetParm("m", "/ags/defineDataItem.xts"); dlgSetParm("method", action); //flag the dialog type agsDialogTypes.setCurrentType(agsDialogTypes.DATAITEMS); dlgSubmit(); } } function showParameters(action, nodeRef) { if(action== 'add' || confirm(parameterChangeWarning)) { commandStackHideDialogFrame() dlgReset(); if (nodeRef && nodeRef != 'undefined' && nodeRef != '') { dlgSetParm("nodeRef", nodeRef); } dlgSetParm("m", "/ags/defineParameter.xts"); dlgSetParm("method", action); //flag the dialog type agsDialogTypes.setCurrentType(agsDialogTypes.PARAMETERS); dlgSubmit(); } } function insertDataItem(uiNodeTreeRef, tree) { if (!uiNodeTreeRef || uiNodeTreeRef == 'undefined' || !tree || tree == 'undefined') { return false; } var node = getTreeNode(tree, uiNodeTreeRef); var selectedTreeObj = node.getTree(); // get all the selected nodes var selectedNodes = selectedTreeObj.getSelectionOrder(); for (var i = 0; i < selectedNodes.length; i++) { var nodeObj = selectedNodes[i]; addAgentItem(nodeObj.getValue()); } //the agent has changed, so set the global configuration variable cf.agentHasChanged(true); } function showContextMenu(event,isSourceMainDiv) { // Menu Styles var gMenuStyle = new CUIStyle('menuContainer', '', '', '', ''); var gMenuItemStyle = new CUIStyle('menuItem_normal', 'menuItem_hover', 'menuItem_pressed', '', 'menuItem_disabled'); var cf = getConfigFrame(); var uiNodeTreeRef = ''; if (!isSourceMainDiv || isSourceMainDiv == 'undefined') { //get UI Node var uiNode = getUINode(event); uiNodeTreeRef = uiNode.getAttribute('treeRef').toString(); //get the tree object var tree = uiNode.getAttribute('tree').toString(); //get tree Node var node = getTreeNode(tree, uiNodeTreeRef); if (node && !node.isSelected()) { node.getTree().deSelectAll(); selectNode(event); } } cf.gQsContextMenu = new CMenu('contextMenu',gMenuStyle); var visibleTree = cfgGet("lastMenu"); var editAction = ""; var deleteAction = ""; var command = "getConfigFrame().getCommandStackManager().initiateCommandStack('checkCAF()',"; if ((visibleTree == TAB_MODEL || visibleTree == TAB_MEMBERS) && node && node.isSelected) { var nodeType = node.getNodeType(); var nodeTypeObject = node.getNodeTypeObject(); var nodeTypeValue = node.getValue().type; var menuItem = menuItemMap['asDataItem']; if (nodeTypeObject.m_oProps.isAgentItemsInsertable()) { menuItem.enable(); cfgSet("asDataItemState", true); new CMenuItem(cf.gQsContextMenu, dialogContextMenuInsertDataItem_string, "DIALOG_CONTEXTMENU_INSERT_DATAITEM", 'getConfigFrame().insertDataItem("' + uiNodeTreeRef + '","' + tree + '");', '', gMenuItemStyle); } else { menuItem.disable(); cfgSet("asDataItemState", false); } // also want to add search capabilities too if (nodeTypeValue == K_sHIERARCHY || nodeTypeValue == K_sLEVEL || nodeTypeValue == K_sMEMBER) { var nodeValuePath = node.getValue().path; var nodeValueType = node.getValue().type; new CMenuItem(cf.gQsContextMenu, dialogContextMenuSearch_string, "DIALOG_CONTEXTMENU_SEARCH", 'getConfigFrame().selectMember("' + nodeValuePath + '","' + nodeValueType + '");', '../ags/images/tree/member_search.gif', gMenuItemStyle); } } else if (visibleTree == TAB_DATAITEMS) { new CMenuItem(cf.gQsContextMenu, dialogContextMenuCalculation_string, "DIALOG_CONTEXTMENU_CALCULATION", command + "'showDataItem(\"add\")');", '../ags/images/menu/action_new_calculation.gif', gMenuItemStyle); editAction = command + "'showDataItem(\"edit\",\"" + uiNodeTreeRef + "\")');"; deleteAction = command + "'deleteAgentItems()');"; } else if (visibleTree == TAB_PARAMETERS) { new CMenuItem(gQsContextMenu, dialogContextMenuParameter_string, "DIALOG_CONTEXTMENU_PARAMETER", command + "'showParameters(\"add\")');", '../ags/images/menu/action_new_parameter.gif', gMenuItemStyle); editAction = command + "'showParameters(\"edit\",\"" + uiNodeTreeRef + "\")');"; deleteAction = command + "'deleteParameters()');"; } if (editAction && editAction.length > 0 && node && node.isSelected) { new CMenuItem(gQsContextMenu, dialogContextMenuEditCalculation_string, "DIALOG_CONTEXTMENU_EDIT_DEFINITION", editAction, '', gMenuItemStyle); new CMenuItem(gQsContextMenu, dialogContextMenuDeleteCalculation_string, "DIALOG_CONTEXTMENU_DELETE", deleteAction, '../ags/images/menu/action_delete.gif', gMenuItemStyle); } if (cf.gQsContextMenu.getNumItems() > 0) { displayContextMenu(event); } } function displayContextMenu(event) { cf.gQsContextMenu.draw(); menu = cf.gQsContextMenu.getHTMLDiv(); menu.style.position="absolute"; var event_source = event.srcElement?event.srcElement:event.target; var pos_x = 0; var pos_y = 0; if (event.pageX) { pos_x = event.pageX; pos_y = event.pageY; } else if (event.clientX) { pos_x = event.clientX; pos_y = event.clientY; } cf.gQsContextMenu.setXCoord(pos_x); cf.gQsContextMenu.setYCoord(pos_y); cf.document.body.getWndObserver().addListener(cf.gQsContextMenu, removeContextMenu, "mouseup"); cf.document.body.getWndObserver().addListener(cf.gQsContextMenu, removeContextMenu, "resize"); //setRemoveMenu(); cf.gQsContextMenu.show(); } function removeContextMenu() { cf.gQsContextMenu.remove(); //Remove the listener cf.document.body.getWndObserver().removeListener(cf.gQsContextMenu); } function resendResetEventList() { getCommandStackManager().getCommandStack().push("resetEventList()"); getCommandStackManager().getCommandStack().push("doWait('resetEventList')"); } function resetEventList() { var msgFrame = getMessageIFrame(); var frameDoc = getFrameDocument(msgFrame); var holder = new Object(); var blob = frameDoc.pform.agent_definition_blob.value; holder['agent_definition_blob'] = blob; holder['m'] = "/ags/reset_event_list.xts"; holder['forceSOAPFault']='false'; var dispatcher = new parent.cf.XHTTPDispatcher(resetEventListProcessResponse, holder); applicationActionManager.httpStart(); try{ dispatcher.dispatch(); }catch(ex){ applicationActionManager.httpStop(); } } function resetEventListProcessResponse(responseArray) { var responseXML = responseArray[0]; var responseText = responseArray[1]; if(doClosePopUp){ //Now close the popup wait. doClosePopUp(); } applicationActionManager.httpStop(); var messageNode = responseXML.getElementsByTagName('message'); var parsedResponse = parseResponse(responseXML,responseText); // decide what we're going to do if (parsedResponse.isLogonFault()) { // if the passport expired doPassportExpire(responseXML,resendResetEventList,parsedResponse); } else if (parsedResponse.isSoapFault()) { // we have a fault which is a genuine fault fault doSOAPFault(responseXML,null,parsedResponse); } else if (messageNode.length == 1) { var message = getTextNodeValue(messageNode[0]); var command = "resetEventListDisplayResponse('" + message + "');"; setTimeout(command,100); } else { // check the text response to see if we got a html page back in the response if (parsedResponse.isHTML() && !parsedResponse.isEmptyBody()) { doHTMLResponse(responseText); } } } function resetEventListDisplayResponse(message) { if (message) { // none of the above alert(message); } } /* * Highlight one of the items in the task list menu */ function makeSelection(type){ if(applicationActionManager.isBlocked()){ return; } if(type != K_sCondition && type != K_sSchedule && type != K_sSuppression && type != K_sSetSubmit){ type = K_sAddAgentTask; } //reset the task list so that all the items are deselected deSelectAll(); //set the style for the current item setTaskState(type,K_cssTaskActive); } /* * deselect all tasks */ function deSelectAll(){ var taskList = new Array(5); taskList[0] = K_sCondition; taskList[1] = K_sSchedule; taskList[2] = K_sAddAgentTask; taskList[3] = K_sSuppression; taskList[4] = K_sSetSubmit; //set all tasks as inactive for (i=0; i<5; i++) { setTaskState(taskList[i],K_cssTaskInactive); } } /* * common function to set a task type as active or inactive * no action is taken if the task is already in the target state */ function setTaskState(taskType,style) { //get the task div var selTask = agsFormUtils.getElementByIdOrName(taskType); //set the active style if not already set if(selTask!=null && selTask.className != style) { //alert('setting state '+style+' for '+taskType); selTask.className=style; } } /* general handler for the response generated by the select Object modal dialog if more dialogs use the modal way (the way of the modal), this could be moddeded */ function ccModalCallBack(cmd, response){ if(cmd != 'ok' || !response){ //perhaps a reason on cancel? doClosePopUp(); parent.document.getElementById("messageIFrame").focus(); }else{ reloadAfterSelectObject(response); } } // select the tab function doSelectObject(mode, defaultObject) { if(applicationActionManager.isBlocked()){ return; } hideDialogFrame(); dlgReset(); //this is in cmd initialiseDialog(); dlgSetParm("m_app", "AS"); dlgSetParm("m", '/portal/select/select.xts'); dlgSetParm("so.select", mode); dlgSetParm("so.return_m", "/ags/dialogAdapter.xts"); dlgSetParm("md.callBack", "data"); if(defaultObject){ dlgSetParm("so.defaultObject", defaultObject); dlgSetParm("so.defaultLocation", defaultObject + "/.."); } else { var path = cfgGet("so.defaultLocation"); var selectedPath = getSelectedPath(mode); if (path && selectedPath == false) { dlgSetParm("so.defaultLocation", path); } } dlgSubmit("popUpFrame"); } /*Check to see if it is type of these tasks if so we don't want to set the defaultLocation. Must be Administrator folder let the portal handle it.*/ function getSelectedPath(mode) { if (mode == "importDeployment.es" || mode == "exportDeployment.es" || mode == "contentTask.es" || mode == "indexUpdateTask.es" || mode == "migrationTask.es" || mode == "planningMacroTask.es") { return true; } return false; } // check browser function isIE() { return (navigator.userAgent.indexOf('MSIE') != -1); } //looking for return/object/value function reloadAfterSelectObject(response){ if(!response){ doClosePopUp(); return } response = decode(response); var xml = new XMLBuilderLoadXMLFromString(response); if(!xml){ doClosePopUp(); return; } var items = xml.getElementsByTagName("item"); var searchPath = ""; for(var i = 0; i < items.length; i++){ var nameEl = items[i].firstChild; if (window.clipboardData) { if(typeof nameEl.text != "undefined" && nameEl.text == "storeID"){ searchPath = items[i].lastChild ? items[i].lastChild.text : ""; break; } //In IE11, the "text" attribute was removed from IXMLDOMElement. else if(typeof nameEl.text == "undefined" && nameEl.textContent == "storeID"){ searchPath = items[i].lastChild ? items[i].lastChild.textContent : ""; break; } } else { if(nameEl.textContent.toString() == "storeID"){ searchPath = items[i].lastChild ? items[i].lastChild.textContent.toString() : ""; break; } } } dlgReset(); //this is in cmd initialiseDialog(); var use_case = getSelectUseCase(); if(use_case && use_case == "agents.es"){ dlgSetParm("m", "/ags/pre_load_agent.xts"); }else{ dlgSetParm("m", "/ags/dialogAdapter.xts"); } dlgSetParm("selected_path", searchPath); // set agent state cf.agentHasChanged(true); //flag the pop up for closure doSetPopUpClosureFlag(); applicationActionManager.allowActions(); dlgSubmit("messageIFrame"); //the loading frame will unblock this applicationActionManager.blockActions(); } function getSelectUseCase(){ var selectUseCase = ""; var puf = getPopUpFrame(); var popUpForm; if(puf && puf.document && puf.document.forms && puf.document.forms.length > 0 && puf.document.forms[0]){ //that was bordering on paranoia! popUpForm = puf.document.forms[0]; }else{ return selectUseCase; } if(popUpForm["so.select"]){ selectUseCase = popUpForm["so.select"].value; } return selectUseCase; } /** Go through the three sets of menus that we have. for each one obtain its capabilty and make sure it is valid. If it is the menu will be shown otherwise it will be hidden. This is called from init_model.xts where the package capabilities are obtained and added into and array and set using cfgSet. The 3 menu arrays come from menu.xslt, toolbar.xslt, and menubar.xslt. Only menus that have capabilities are added here. The excpetion is menuItemMap where menus with keys are added additionaly. */ function resetMenus() { var capabilities = cfgGet("userCapabilities"); for (var obj in menuItemMap) { checkMenuCapability(menuItemMap[obj],capabilities); } for (var obj in tasksMenuMap) { checkMenuCapability(tasksMenuMap[obj],capabilities); } // this contains menus and toolbar buttons. (both implement getCapability) for (var obj in toolbarMenuMap) { checkMenuCapability(toolbarMenuMap[obj],capabilities); } var topSpacer = document.getElementById("schedule_topSpacer"); var scheduleSpacer = document.getElementById("schedule_spacer"); var scheduleElement = document.getElementById("schedule"); //alert(topSpacer + ", " + scheduleSpacer + ", " + scheduleElement); var canUseSchedule = new RegExp("canUseScheduling","i").test(capabilities); if (topSpacer) { topSpacer.style.display = canUseSchedule?"":"none"; } if (scheduleSpacer) { scheduleSpacer.style.display = canUseSchedule?"":"none"; } if (scheduleElement) { scheduleElement.style.display = canUseSchedule?"":"none"; } } function checkMenuCapability(menuItem,capabilities) { if (menuItem) { var capability = menuItem.getCapability(); if (capability && capability != "") { var found = new RegExp(capability,"i").test(capabilities); if (found) { menuItem.show(); } else { menuItem.hide(); } } } } //copied from rv function processViewerMarkup(sId, sHTML) { var markup = sHTML; var context = window[sId + "iContext"]; if (context != null && typeof context != "undefined") { markup = context.processMarkup(sHTML); } return markup; }