1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773 |
- /********************************************************************************************************************************
- * 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<forms.length;i++) {
-
- var form = forms[i];
-
- //loop through the controls in the form
- for (var j=0;j<form.length;j++) {
-
- var control = form.elements[j];
-
- //only add the selection handler to input controls(not hidden), textarea, select and option
- if (intended.test(control.tagName) && control.getAttribute('type')!='hidden') {
-
- //register a custom handler to store any selections
- eventHandlerChainUtil.doEventHandlerChain(control, "select", handleSelection);
- eventHandlerChainUtil.doEventHandlerChain(control, "focus", setSelectionId);
- eventHandlerChainUtil.doEventHandlerChain(control, "focus", function(event) {
- //security problem to cache the whole object
- var id = agsFormUtils.getEventId(event);
- parent.deletionCandidateManager.setCandidate(id,K_sControlCandidate);
- });
-
- //only attach the agent change handler for message frame controls
- if (arguments.length==2 && sourceFrame && sourceFrame.name==MESSAGE_FRAME_ID) {
- attachAgentChangeHandler(control);
- }
- }
- }
- }
- }
- function addEvent(obj, evType, fn, useCapture){
- //FF
- if (obj.addEventListener){
- if (arguments.length < 4) {
- useCapture=false;
- }
- obj.addEventListener(evType, fn, useCapture);
- return true;
- }
- //IE
- else if (obj.attachEvent){
- var r = obj.attachEvent("on"+evType, fn);
- return r;
- }
- }
- function removeEvent(obj, evType, fn, useCapture){
- //FF
- if (obj.removeEventListener) {
- if (arguments.length < 4) {
- useCapture=false;
- }
- obj.removeEventListener (evType, fn, useCapture);
- }
- //IE
- else if (obj.detachEvent){
- obj.detachEvent ("on"+evType, fn);
- }
- }
- function handleEmailBody() {
- var editBody = agsFormUtils.getElementByIdOrName('editbody');
- if (editBody) {
- //register a key down handler to intercept and discard hotkey combinations
- eventHandlerChainUtil.doEventHandlerChain(editBody, "keydown",keyDownChecker.check);
- eventHandlerChainUtil.doEventHandlerChain(editBody, "select", handleSelection);
- eventHandlerChainUtil.doEventHandlerChain(editBody, "focus", setSelectionId);
- attachAgentChangeHandler(editBody);
- }
- }
- /*
- * get the selection object in a cross-browser fashion
- */
- function getSelectionObject(selDocument) {
- var selObj = null;
- if (window.getSelection) {
- selObj = window.getSelection();
- }
- else if (selDocument.getSelection) {
- selObj = selDocument.getSelection();
- }
- else if (selDocument.selection) {
- selObj = selDocument.selection;
- }
-
- return selObj;
- }
- function clearSelectionText(selObj) {
- if (browserCheck.isIE5dot5Up()) {
- selObj.clear();
- }
- else if (dlgContains(K_sSelectionId)) {
- var sel = dlgGetParm(K_sSelectionId);
- var control = agsFormUtils.getElementByIdOrName(sel.id);
-
- var value = control.value;
-
- var selText = sel.text;
- var firstStr = value.slice(0,control.selectionStart)
- var secondStr = value.slice(control.selectionEnd,value.length);
-
- control.value = firstStr+secondStr;
- }
- else if (selObj.focusNode) {
- selObj.removeAllRanges();
- }
- }
- function getSelectionControl() {
- var control = null;
- //we have a selection
- if (dlgContains(K_sSelectionId)) {
- //get the selection id
- var id = dlgGetParm(K_sSelectionId).id;
- //we have an id
- if (id) {
- control = agsFormUtils.getElementByIdOrName(id);
- if (control) {
- //control.setActive();
- var parent = getSelectionParent(control.ownerDocument);
-
- //we have a selection parent
- if (parent) {
- var intended=/INPUT|TEXTAREA|SELECT|OPTION/;
- if (!intended.test(parent.tagName)) {
- while (parent != null) {
- // This is a special case for HTML email body
- if (parent.tagName != 'BODY' && parent.id != 'editbody') {
- parent = parent.parentElement;
- }
- else {
- break;
- }
- }
- if (parent.tagName == 'BODY' && parent.id == 'editbody') {
- intended = /BODY/;
- }
- }
- //test that the selection has been made on a valid input control
- if (parent != null && (intended.test(parent.tagName) || intended.test(parent.parentElement.tagName)) && parent.getAttribute('type') != 'hidden') {
- control = parent;
- if (browserCheck.isIE5dot5Up()) {
- control.setActive();
- }
- }
- }
- }
- }
- }
- return control;
- }
- /*
- * Get the selection parent in a cross-browser fashion
- */
- function getSelectionParent(selDocument) {
- var parent=null;
-
- //get the stored selection if available
- if (dlgContains(K_sSelectionId)) {
- var sel = dlgGetParm(K_sSelectionId);
- var control = agsFormUtils.getElementByIdOrName(sel.id);
-
- if (control) {
- parent = control;
- }
- }
-
- if (browserCheck.isIE5dot5Up() && selDocument) {
- parent = selDocument.selection.createRange().parentElement();
- }
- return parent;
- }
- /*
- * check the selection object. We test the selection object
- * and also the selection text
- */
- function isValidSelection(selObj) {
- var isValid = selObj != null && selObj != undefined;
- if (browserCheck.isIE5dot5Up()) {
- isValid = isValid && selObj.type=="Text"
- }
-
- if (dlgContains(K_sSelectionId)) {
- isValid = isValid && dlgGetParm(K_sSelectionId).text != '';
- }
- return isValid;
- }
- /*
- * Get the text selection from the dialog parameter
- */
- function getSelectedText() {
- var selText = '';
- if (dlgContains(K_sSelectionId)) {
- selText = dlgGetParm(K_sSelectionId).text;
- }
-
- return selText;
- }
- /*
- * The control has been focussed so set the current selection id
- */
- function setSelectionId(event) {
- var sel = null;
- if (dlgContains(K_sSelectionId)) {
- sel = dlgGetParm(K_sSelectionId);
- }
- else {
- sel = new TextSelection(id,'');
- dlgSetParm(K_sSelectionId,sel);
- }
-
- var control=event.srcElement || event.currentTarget || event.target;
- //get the id/name from the event source
- var id = control.id ? control.id : control.name;
- sel.id = id;
- }
- /*
- * Store the selection if available as a dialog parameter K_sSelectionId( defined in constants.js)
- */
- function handleSelection(event) {
- var selText = "";
- var sel=null;
- var id = null;
- var start=0;
- var end=0;
- var control=event.srcElement || event.currentTarget || event.target;
- //get the id/name from the event source
- id = control.id ? control.id : control.name;
-
- var selection = getSelectionObject(control.ownerDocument);
-
- //IE
- if (browserCheck.isIE5dot5Up()) {
- if (selection.type=="Text") {
- var textRange=selection.createRange();
-
- if (id=='editbody' || control.ownerDocument.pform && control.ownerDocument.pform.richEditMode && control.ownerDocument.pform.richEditMode.value=="true") {
- selText = textRange.htmlText;
- }
- else {
- selText = textRange.text;
- }
- }
- }
- //Firefox
- else {
- start = control.selectionStart;
- end = control.selectionEnd;
- selText = control.value.substring(start,end);
- }
-
- if(dlgContains(K_sSelectionId)) {
- sel = dlgGetParm(K_sSelectionId);
-
- //update the id
- sel.id = id;
- }
- //create the selection
- else {
- sel = new TextSelection(id,selText);
- //set the new selection
- dlgSetParm(K_sSelectionId,sel);
- }
-
- //a selection has been found, set the start and end positions
- if (selText !='') {
- sel.start=start;
- sel.end=end;
- sel.text=selText;
- }
- }
- /*
- * An object to hold details about a text selection
- */
- function TextSelection(id,text) {
- this.id = id;
- this.text = text;
- this.copiedText="";
- this.toString=toString;
- this.start=0;
- this.end=0;
- function toString() {
- return "TextSelection[id:"+this.id+",text:"+this.text+",copied:"+this.copiedText+",start:"+this.start+",end:"+this.end+"]";
- }
- }
- function getPackage(){
- var model = parent.cfgGet("cmLastModel");
- // can't have the following variable named package - Netscape barfs with a syntax error.
- var ret_value = model.substring(0, model.indexOf("/model"));
- return ret_value;
- }
- function doPackageUpdatedCheck(){
-
- if(cf.cfgGet('updatedModel')){
- alert(packageUpdatedMessage1_string + "\n" + packageUpdatedMessage2_string);
- }
- getCommandStackManager().processCommandStack();
- }
- function notYet()
- {
- alert("Not available in this version.");
- }
- function doWizard(wizard){
-
- // if going to the new agent wizard then change the taskMenu
- if(wizard == '/ags/new_agent_wizard_controller.xts'){
- parent.changeTaskMenu('wizard');
- }
- // load the wizard page by forcing a submit on the message frame. CAlling loadAgentXTS will
- // delete all currently stored variables.
- loadPage(wizard, 'push');
- }
- function doNewAgent(){
- //set the expression locale to the current content locale
- resetExpressionLocale();
- loadAgentXTS("dialogAdapter.xts&tabSelectedID=AgentTask-condition&prevTabID=AgentTask-condition");
- // have to re-init the model tree because the previous meta data tree
- // may have nodes open with a different expression locale
- cf.resetMetadataTree();
- // have to re-init the function tree too - we might have different functions defined
- cf.resetFunctionsTree();
- //Will also call the functions tree.
- cf.initMetadataTree();
-
- clearAgentScript();
- }
- //js object for the agent
- var agent_definitions;
- function getAgentDefinition(){
- return agent_definitions;
- }
- function setAgentDefinition(agent) {
- agent_definitions = agent;
- }
-
- function loadAgentXTS(page)
- {
- // reset the message frame to the original page - this will kill all variables
- // in the xts
- var req = "&m_path=" + cfgGet("PackageRoot");
- var se = cfgGet("SCRIPT_ENGINE");
- var mf = document.getElementById("messageIFrame");
- if ( mf != null) {
- //include the context id in the url
- var url = se + "?b_action=xts.run&m=/ags/"+ page + constructGETRequestParamsString(req);
- mf.src = url;
- }
- }
- function clearAgentScript()
- {
- // change to the model tab - though why you want to
- // do that I don't know.
- changeMenu(TAB_MODEL);
-
- // need to figure out how to remove items from the agentItemsTree
- resetAgentItems();
-
- //start the script
- getRedoUndoManager().clearAgentItemsTracking();
-
- // we are dealing with a new report now
- cfgSet("NewAgent", true);
- cfgSet("NewReport", true);
- // set the name of the report
- cfgSet("ReportName", cfgGet("DefaultReportName"));
- // hmmm
- cf.agentHasChanged(false);
- // do the name of agent
- setWindowTitle();
-
- cfgSet("numRows",20);
- cfgRemove("filter_promptValues");
- cfgRemove("SearchPath");
- dlgRemoveParm("searchPath");
- cfgSet("NewAgent", true);
- cfgRemove("AgentName");
- cfgRemove("saved_agent_condition");
- }
- function viewReportOutput(path){
- // 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") + "?" + constructGETRequestParamsString("b_action=cognosViewer&ui.action=view&cv.toolbar=false&cv.id=ES&errURL=javascript:window.close();&ui.object="+path);
-
- // make that thar window
- report_viewer_window = window.open(url, "reportRun", "height=480,width=640,resizable=yes");
- // bring it to the front
- if (report_viewer_window != null) {
- report_viewer_window.focus();
- }
- }
- function run()
- {
- // 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") + "?" + constructGETRequestParamsString("b_action=xts.run&m=ags/run_report.xts&cv.toolbar=false&cv.id=ES&ui.routingServerGroup="+UI_ROUTING_SERVER_GROUP);
-
- // make that thar window
- report_viewer_window = window.open(url, "reportRun", "height=480,width=640,resizable=yes,scrollbars=1");
- // bring it to the front
- if (report_viewer_window != null) {
- report_viewer_window.focus();
- }
- }
- function runCount()
- {
- // 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") + "?" + constructGETRequestParamsString("b_action=xts.run&m=ags/run_report.xts&cv.toolbar=false&runCount=true&cv.id=ES");
-
- // make that thar window
- report_viewer_window = window.open(url, "reportRun", "height=480,width=640,resizable=yes");
- // bring it to the front
- if (report_viewer_window != null) {
- report_viewer_window.focus();
- }
- }
- function copyAgentSpecificationToClipboard()
- {
- var xmlString = getConfigFrame().cfgGet("inlineSpec");
- try
- {
- if (xmlString != null) {
- if (window.clipboardData) {
- clipboardData.setData( "Text", xmlString );
- } else {
- //const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper);
- //gClipboardHelper.copyString("Put me on the clipboard, please.");
- //user_pref("capability.policy.policynames", "allowclipboard");
- //user_pref("capability.principal.myapp.id","file:///D|/bering/crn55/webcontent/ags/cmd.js");
- //user_pref("capability.principal.myapp.granted","UniversalXPConnect");
- //user_pref("capability.policy.allowclipboard.sites", "http://localhost");
- //user_pref("capability.policy.allowclipboard.Clipboard.cutcopy", "allAccess");
- //user_pref("capability.policy.allowclipboard.Clipboard.paste", "allAccess");
- // from: http://www.xulplanet.com/tutorials/xultu/clipboard.html
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-
- var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
- if (!str) {
- netscape.security.PrivilegeManager.revertPrivilege("UniversalXPConnect");
- return;
- }
- str.data=xmlString;
- var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
- if (!trans) {
- netscape.security.PrivilegeManager.revertPrivilege("UniversalXPConnect");
- return;
- }
- trans.addDataFlavor("text/unicode");
- trans.setTransferData("text/unicode",str,xmlString.length * 2);
- var clipid = Components.interfaces.nsIClipboard;
- var clip = Components.classes["@mozilla.org/widget/clipboard;1"].getService(clipid);
- if (!clip) {
- netscape.security.PrivilegeManager.revertPrivilege("UniversalXPConnect");
- return;
- }
- clip.setData(trans,null,clipid.kGlobalClipboard);
- netscape.security.PrivilegeManager.revertPrivilege("UniversalXPConnect");
- }
- alert(copiedSpecificationToClipboard);
- }
- }
- catch( e )
- {
- alert(errorCopyingSpecificationToClipboard);
- }
- }
- function copyAgentSpecificationFromClipboard()
- {
- try
- {
- var d;
- var text = "";
- if (window.clipboardData) {
- text = clipboardData.getData( "Text" );
- if (text != null) {
- d = new ActiveXObject( MSXML_DOM_DOCUMENT );
- d.async = false;
- d.resolveExternals = false;
- d.validateOnParse = false;
- d.loadXML(text);
- }
- } else {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var clip = Components.classes["@mozilla.org/widget/clipboard;1"].getService(Components.interfaces.nsIClipboard);
- if (!clip) {
- netscape.security.PrivilegeManager.revertPrivilege("UniversalXPConnect");
- return;
- }
- var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
- if (!trans) {
- netscape.security.PrivilegeManager.revertPrivilege("UniversalXPConnect");
- return;
- }
- trans.addDataFlavor("text/unicode");
- clip.getData(trans,clip.kGlobalClipboard);
- var str = new Object();
- var strLength = new Object();
- trans.getTransferData("text/unicode",str,strLength);
- if (str) str = str.value.QueryInterface(Components.interfaces.nsISupportsString);
- if (str) text = str.data.substring(0,strLength.value / 2);
- netscape.security.PrivilegeManager.revertPrivilege("UniversalXPConnect");
- // parse the specification
- var domParser = new DOMParser();
- d = domParser.parseFromString(text, "text/xml");
- }
- var detailChanged = updateAgentFilter(d,"detail");
- var summaryChanged = updateAgentFilter(d,"summary");
- var itemsChanged = updateAgentItems(d);
- var promptPages = updatePromptPages(d);
- var extraQueries = updateExtraQueries(d);
- if (detailChanged || summaryChanged || itemsChanged || promptPages || extraQueries) {
- cf.agentHasChanged(true);
- alert(updatedAgentFromSpecificationInClipboard);
- }
- else
- {
- alert(noSuitableFiltersFoundInClipboardTextToUpdateAgent);
- }
- }
- catch ( e )
- {
- alert(errorParsingClipboardTextInCopyAgentSpecificationFromClipboard);
- }
- }
- function updatePromptPages(reportSpecDoc)
- {
- // parse all the extra queries
- var agentUpdated = false;
- var pattern;
- if (window.clipboardData) {
- pattern = "/report/layouts/layout/promptPages";
- } else {
- pattern = "/*[local-name()='report']/*[local-name()='layouts']/*[local-name()='layout']/*[local-name()='promptPages']";
- }
- var diNodes = selectNodes(pattern,reportSpecDoc);
- if (diNodes != null && diNodes.length > 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;
- }
|