cmd.js 84 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773
  1. /********************************************************************************************************************************
  2. * Licensed Materials - Property of IBM *
  3. * *
  4. * IBM Cognos Products: AGS *
  5. * *
  6. * (C) Copyright IBM Corp. 2005, 2017 *
  7. * *
  8. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *
  9. *********************************************************************************************************************************/
  10. //any commands that load another page must ensure that those loaded pages process the command stack in case there
  11. //are other commands that come after
  12. //any commands that dont load other pages, must call process command stack to call any following functions
  13. var addColumnId = 0;
  14. var previewHasChanged = false;
  15. var report_viewer_window = null;
  16. var IFRM_ACTION_SAVE = "save";
  17. var IFRM_ACTION_SAVE_AS = "create";
  18. var IFRM_ACTION_VALIDATE = "validate";
  19. var IFRM_ACTION_VALIDATE_SAVE = "validate_save";
  20. var IFRM_ACTION_VALIDATE_TASK = "validate_task";
  21. var IFRM_ACTION_VALIDATE_CONDITION = "validate_condition";
  22. //the secondary action command enum is not the same as the ifrmCmd enum
  23. var SECONDARY_ACTION_NEW = "new";
  24. var CONDITION_TAB = "AgentTask-condition";
  25. var TAB_SELECTED = "tabSelectedID";
  26. var BLANK_HTML_DOCUMENT = "../ags/blank.html";
  27. var MSXML_DOM_DOCUMENT = "Msxml2.DOMDocument.3.0";
  28. function parseXMLString(reportSpec)
  29. {
  30. var d;
  31. try {
  32. if (window.clipboardData) {
  33. d = new ActiveXObject( MSXML_DOM_DOCUMENT );
  34. d.async = false;
  35. d.resolveExternals = false;
  36. d.validateOnParse = false;
  37. d.loadXML(reportSpec);
  38. } else {
  39. var domParser = new DOMParser();
  40. d = domParser.parseFromString(reportSpec, "text/xml");
  41. }
  42. }
  43. catch ( e )
  44. {
  45. d = null;
  46. }
  47. return d;
  48. }
  49. function showErrorPage(height)
  50. {
  51. if(!popUpIsOpen()){
  52. dlgReset();
  53. //this is in cmd
  54. initialiseDialog();
  55. var cf = getConfigFrame();
  56. cf.applicationActionManager.allowActions();
  57. if(height==null){
  58. height = 180;
  59. }
  60. cf.cfgSet('errAreaHt', height);
  61. dlgSetParm("m", "/ags/errorDialog.xts");
  62. dlgSubmit("popUpFrame");
  63. }
  64. }
  65. function sendCmdToTarget(cmdStr, xslref, resetRows, sTarget)
  66. {
  67. if (resetRows)
  68. cmdStr = "PF;" + cmdStr; // first page
  69. if (xslref.length <= 0){
  70. xslref = '_QS_';
  71. }
  72. // need to keep old spec in case of a cancel
  73. cfgSet("OLD_qs_spec", cfgGet("conversation_qs_spec"));
  74. asyncReset();
  75. asyncSetParm("m", "async/conv.xts");
  76. asyncSetParm("method", "editQuery");
  77. var s=cfgGet("conversation_qs_spec");
  78. if (s) {
  79. asyncSetParm("inlineSpec", s);
  80. var objid = cfgGet("SearchPath");
  81. if (objid != null && objid != "")
  82. asyncSetParm("obj", objid);
  83. }
  84. else {
  85. s=cfgGet("conversation_qs_obj");
  86. if (s) asyncSetParm("obj", s);
  87. }
  88. asyncSetParm("action", cmdStr);
  89. asyncSetParm("xslURL", xslref);
  90. asyncSetParm("prompt", "false");
  91. var promptValuesArray = cfgGet("filter_promptValues");
  92. if (promptValuesArray!=null && typeof promptValuesArray == "object") {
  93. for (var i in promptValuesArray) {
  94. var promptValues = promptValuesArray[i];
  95. asyncSetParm(promptValues[0], promptValues[1]);
  96. }
  97. }
  98. asyncSubmit(sTarget);
  99. }
  100. function sendCmd(cmd, xslref, resetRows)
  101. {
  102. sendCmdToTarget(cmd, xslref, resetRows, "");
  103. cfgSet("ActionRunning", true);
  104. }
  105. //guts of this in util.js
  106. function deleteSelectedItem(){
  107. deletionCandidateManager.deleteSelectedItem();
  108. cf.agentHasChanged(true);
  109. }
  110. /**
  111. get the dialog frame ready to execute a particular frmcmd....
  112. */
  113. function setUpFrmCmd(frmAction, ignoreReport)
  114. {
  115. //set in form vars
  116. initialiseDialog();
  117. // generate any other variables that we want - and prefix them with agsSave_ so
  118. // pre-save can spot them and leave them alone - prefix is stripped in pre_save
  119. dlgSetParm("m", "/ags/pre_submit.xts");
  120. dlgSetParm("agsSave_metaModel", cfgGet("cmLastModel"));
  121. dlgSetParm("agsSave_packageRoot", cfgGet("PackageRoot"));
  122. if(!ignoreReport){
  123. var reportSpec = getConfigFrame().cfgGet("inlineSpec");
  124. dlgSetParm("agsSave_inlineSpec", reportSpec);
  125. }
  126. dlgSetParm("agsSave_searchPath", cfgGet("SearchPath"));
  127. dlgSetParm("agsSave_ifrmcmd", frmAction);
  128. if(cfgGet("wizardURL")){
  129. dlgSetParm("agsSave_wizardURL", cfgGet("wizardURL"));
  130. }
  131. // also have to tell it what sort of object we're creating
  132. dlgSetParm("agsSave_m_new_class", "agentDefinition");
  133. // save the current path
  134. dlgSetParm("agsSave_m_path", decodeURIComponent(cf.cfgGet('PackageRoot')));
  135. //need to track this for prompting to save
  136. cfgSet("saved_agent_condition", buildFilterCondition());
  137. }
  138. /**
  139. add all the message frame state into the dialog frame ready for submission
  140. */
  141. function initialiseDialog(){
  142. var messageIFrame = getMessageIFrame();
  143. var messageIFrame_doc = getFrameDocument(messageIFrame);
  144. // make sure that we are in a correct state before copying form variables.
  145. // this applies to all forms of save/validate
  146. if(messageIFrame.leavingDialog){
  147. // correct the state of the messageIFrame
  148. messageIFrame.leavingDialog();
  149. }
  150. //we can get here while loading or during page transition
  151. if(!messageIFrame_doc || !messageIFrame_doc.forms || messageIFrame_doc.forms.length == 0 || !messageIFrame_doc.forms[0]){
  152. return;
  153. }
  154. // send in all the values from messageIFrame
  155. for (var i = 0; i < messageIFrame_doc.forms[0].elements.length; ++i) {
  156. // get the type of the control
  157. var type = messageIFrame_doc.forms[0].elements[i].type;
  158. // we have to do something different in the case when we have different types of inputs
  159. // radio control
  160. if (type == 'radio') {
  161. // get the name of the control
  162. var n = messageIFrame_doc.forms[0].elements[i].name;
  163. // have we seen this before - we will if find a subsequent radio control in the same group
  164. if (!dlgContains(n)) {
  165. // get all the elements in the group
  166. var radioGrp = messageIFrame_doc.getElementsByName(n);
  167. // have to look over them all and find the one that's selected
  168. for (var j = 0; j < radioGrp.length; ++j) {
  169. // get the element
  170. var radioItem = radioGrp[j];
  171. // are you selected
  172. if (radioItem.checked) {
  173. // get the value of the item
  174. var v = radioItem.value;
  175. // save this
  176. dlgSetParm(n, v);
  177. }
  178. }
  179. }
  180. } else if (type == 'checkbox') {
  181. var n = messageIFrame_doc.forms[0].elements[i].name;
  182. var v = messageIFrame_doc.forms[0].elements[i].value;
  183. // only add this element if it's checked
  184. if (messageIFrame_doc.forms[0].elements[i].checked && n!='') {
  185. // save the value
  186. dlgAddParm(n, v);
  187. }
  188. } else {
  189. var n = messageIFrame_doc.forms[0].elements[i].name;
  190. var v = messageIFrame_doc.forms[0].elements[i].value;
  191. // store this only if have a valid name
  192. if (n!='') {
  193. // save the value into the hidden frame
  194. dlgAddParm(n, v);
  195. }
  196. }
  197. // might have to do something special for select-and multi select.
  198. }
  199. }
  200. function initialiseAgentInfo(){
  201. var messageIFrame = getMessageIFrame();
  202. var messageIFrameDoc = getFrameDocument(messageIFrame);
  203. if (messageIFrameDoc && messageIFrameDoc.pform && messageIFrameDoc.pform.agent_definition_blob) {
  204. var blob = messageIFrameDoc.pform.agent_definition_blob.value
  205. dlgSetParm("agent_definition_blob",blob);
  206. }
  207. }
  208. //this method asks report server for a screen
  209. //to get parameters. these then have to be stashed
  210. //away for use in the validate or preview call
  211. function getConditionParameters(){
  212. var rspec = getConfigFrame().cfgGet("inlineSpec");
  213. if(rspec){
  214. //have it
  215. doXHTTPCollectParameterValues();
  216. }else{
  217. //no report no cry - just get on with the next command
  218. getCommandStackManager().processCommandStack();
  219. }
  220. }
  221. /*function doDebugTest(){
  222. alert("start");
  223. getConditionParameters();
  224. setTimeout("getConditionParameters();alert('finish')", 60400);
  225. }
  226. */
  227. /**
  228. call preview with a flag of 'preview_all', 'preview_task' or 'preview_count'
  229. where the default is 'preview_all'
  230. **/
  231. function preview(previewStyle)
  232. {
  233. try {
  234. var agentAction = null;
  235. // get the value of tabSelectedID.
  236. var msgFrame = getMessageIFrame();
  237. var tabSelectedIDElement = msgFrame.document.getElementById("tabSelectedID");
  238. var tabSelectedID = (tabSelectedIDElement == null ? null : tabSelectedIDElement.value);
  239. // check to see if we're on the condition page and running a preview_task
  240. if(null!=tabSelectedID && tabSelectedID==CONDITION_TAB && previewStyle=="preview_task"){
  241. //this is special for condition page
  242. doClosePopUp();
  243. run();
  244. return;
  245. }
  246. // clear the dialogFrame - do before both calls - otherwise the call
  247. // to noData.xts will be missing values.
  248. dlgReset();
  249. // Preview only if there are items in the report spec.
  250. // If no items, we redirect to the file noData.xts.
  251. //
  252. if (noDataItems()) {
  253. dlgSetParm("m", "/ags/noData.xts");
  254. dlgSubmit("popUpFrame");
  255. return;
  256. }
  257. var frm_cmd = previewStyle;
  258. var m_rp_parameters;
  259. var method = "previewAgent";
  260. // call the preview function
  261. doXHTTPPreview(method, cfgGet("AGENT_STATE"), frm_cmd, tabSelectedID);
  262. }catch(ex){
  263. //alert(ex);
  264. if(doClosePopUp){
  265. doClosePopUp();
  266. }
  267. }
  268. }
  269. /*
  270. just validate the agent condition
  271. given the array of items passed in
  272. */
  273. function validateAgentCondition(div_id)
  274. {
  275. if(div_id){
  276. //set the div id to update
  277. cfgSet(CURRENT_ERROR_DIV_ID_KEY, div_id);
  278. }
  279. // do the validate agent condition dance
  280. doXHTTPValidateCondition();
  281. }
  282. /*
  283. validate the agent and its tasks and the agent condition, and store the messages in jscript
  284. */
  285. function getAgentValidateMessages(){
  286. var frm_cmd = null;
  287. // get the value of tabSelectedID
  288. var msgFrame = getMessageIFrame();
  289. var tabSelectedIDElement = msgFrame.document.getElementById("tabSelectedID");
  290. var tabSelectedID = (tabSelectedIDElement == null ? null : tabSelectedIDElement.value);
  291. if(null!=tabSelectedID && tabSelectedID != CONDITION_TAB) {
  292. frm_cmd = IFRM_ACTION_VALIDATE_TASK
  293. }else{
  294. frm_cmd = IFRM_ACTION_VALIDATE;
  295. }
  296. getValidateMessages(frm_cmd);
  297. }
  298. //once errors are cached, display them
  299. function displayValidateMessages(){
  300. dlgReset();
  301. //this is in cmd
  302. initialiseDialog();
  303. dlgSetParm("m", "/ags/validatePage.xts");
  304. //this part of the validate sequence
  305. dlgSubmit();
  306. }
  307. /*
  308. * Open the wait dialog. must be closed by another script
  309. * the wait messages are switched on a waitDialogStyle var
  310. */
  311. function doWait(waitStyle) {
  312. if(!waitStyle){
  313. waitStyle = IFRM_ACTION_VALIDATE;
  314. }
  315. //there is an active dialog in the pop up frame
  316. if(popUpIsOpen() && dlgGetParm("m") == "/ags/wait.xts" && dlgGetParm('waitDialogStyle') == waitStyle){
  317. //already waiting
  318. getCommandStackManager().processCommandStack();
  319. return;
  320. }
  321. dlgReset();
  322. //st in form vars
  323. initialiseDialog();
  324. if(waitStyle == 'resetEventList'){
  325. //caf doesnt support this yet
  326. waitStyle = "";
  327. }
  328. dlgSetParm('waitDialogStyle', waitStyle);
  329. dlgSetParm("m", '/ags/wait.xts');
  330. dlgSubmit("popUpFrame");
  331. }
  332. function getSaveCommandStack() {
  333. var saveCommand;
  334. if (cfgGet("NewReport") == true){
  335. saveCommand = getCommandStackManager().createCommandStack("checkCAF()","getReportSpec()","commandStackHideDialogFrame()","calcAgentState()","getSaveValidateMessages()", "displayValidateMessages()", "saveas()");
  336. }
  337. else{
  338. saveCommand = getCommandStackManager().createCommandStack("checkCAF()","getReportSpec()","commandStackHideDialogFrame()", "doWait('save')", "calcAgentState()","getSaveValidateMessages()", "displayValidateMessages()", 'save()');
  339. }
  340. return saveCommand;
  341. }
  342. function save() {
  343. // clear the dialogFrame
  344. dlgReset();
  345. dlgSetParm("agsSave_m_p_defaultName", cfgGet("ReportName"));
  346. //do the do
  347. setUpFrmCmd(IFRM_ACTION_SAVE, false);
  348. //flag the dialog type
  349. agsDialogTypes.setCurrentType(agsDialogTypes.SAVE_SAVEAS);
  350. // submit the dialogFrame, this will call pre_submit.xts
  351. dlgSubmit();
  352. }
  353. //a function that can be tacked onto a command stack.... just hides the dialog frame and processes the stack
  354. function commandStackHideDialogFrame(){
  355. hideDialogFrame();
  356. getCommandStackManager().processCommandStack();
  357. }
  358. /*
  359. do a save style validate where we dont worry about warnings... only errors
  360. errors stop the agent saving and store the messages in jscript
  361. */
  362. function getSaveValidateMessages(){
  363. getValidateMessages(IFRM_ACTION_VALIDATE_SAVE);
  364. }
  365. //utility for the common validate features
  366. function getValidateMessages(frm_cmd)
  367. {
  368. try{
  369. var agentAction = null;
  370. // clear the dialogFrame
  371. dlgReset();
  372. var m_rp_parameters;
  373. var msgFrame = getMessageIFrame();
  374. var tabSelectedIDElement = msgFrame.document.getElementById("tabSelectedID");
  375. var tabSelectedID = (tabSelectedIDElement == null ? null : tabSelectedIDElement.value);
  376. var method = "validateAgent";
  377. // call the preview function
  378. doXHTTPValidate(method, cfgGet("AGENT_STATE"), frm_cmd, tabSelectedID);
  379. //flag the dialog type
  380. agsDialogTypes.setCurrentType(agsDialogTypes.VALIDATE);
  381. }catch(ex){
  382. //alert(ex);
  383. if(doClosePopUp){
  384. doClosePopUp();
  385. }
  386. }
  387. }
  388. /*
  389. * Perform the agent 'Save as' action
  390. * bLeaveAfterSave Leave Agent Studio when the agent has been saved and any final action has been completed
  391. * secondaryAction, The action to take place when the save has completed. e.g. new,wizard,open etc.
  392. * Set to 'noAction' if the save should be the final action
  393. * all saves are preceded by a validate action
  394. */
  395. function saveas()
  396. {
  397. // clear the dialogFrame
  398. dlgReset();
  399. //do the save as frm cmd
  400. setUpFrmCmd(IFRM_ACTION_SAVE_AS, false);
  401. dlgSetParm("agsSave_m_class", "");
  402. // also have to retell it what sort of object we're creating
  403. dlgSetParm("agsSave_m_new_class", "agentDefinition");
  404. //waiting on a portal fix to use these to display the agents for browsing
  405. 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']");
  406. dlgSetParm("agsSave_cSelectionCriteria", " folder namespaceFolder package configurationFolder configuration portletFolder adminFolder ");
  407. //flag the dialog type
  408. agsDialogTypes.setCurrentType(agsDialogTypes.SAVE_SAVEAS);
  409. // submit the dialogFrame
  410. dlgSubmit();
  411. }
  412. /*
  413. * Called from portal code:
  414. * ps/portal/iFaultHandler/handleFault.xts
  415. */
  416. function handleFaultInit(w){
  417. //hide the dialog
  418. var dialog = parent.agsFormUtils.getElementFromFrame(parent,parent.DIALOG_FRAME_ID);
  419. if (dialog && dialog.style.display=='') {
  420. hideDialogFrame();
  421. }
  422. //If we are in message frame do not bother
  423. //Message frame will display this fault
  424. //This works in the case of Login only.
  425. //I do not know when you get a guenuine soap fault
  426. //what will happen?
  427. if (w && w.name == DIALOG_FRAME_ID) {
  428. showDialogFrame(300);
  429. }
  430. else if (isPopUpFrame(w)) {
  431. doOpenPopUp();
  432. }
  433. }
  434. /*
  435. * Called from portal code:
  436. * ps/portal/save_as.xts
  437. */
  438. function saveAsDlgInit(w)
  439. {
  440. //flag the dialog type
  441. agsDialogTypes.setCurrentType(agsDialogTypes.SAVE_SAVEAS);
  442. showDialogFrame(385);
  443. }
  444. /*
  445. * Called from portal code:
  446. * ps/portal/specify_location.xts
  447. NB this has been suplanted by portal/select/select.xts
  448. but keep this here for now just in case!
  449. * showDialogFrame should not be called by age components
  450. */
  451. function doSelectPathDlgInit(dialog){
  452. if(isPopUpFrame(dialog)){
  453. doOpenPopUp();
  454. }else{
  455. //get the dialog td
  456. var dialogTD = agsFormUtils.getElementFromFrame(getConfigFrame(), getFrameBorderId(DIALOG_FRAME_ID));
  457. //flag the dialog type
  458. agsDialogTypes.setCurrentType(agsDialogTypes.OPEN_FILE);
  459. var size = new SizeParser(dialogTD.style.height);
  460. //only show when the dialog frame is hidden
  461. if(size.leq(0)) {
  462. showDialogFrame(385);
  463. }
  464. }
  465. }
  466. function doSaveAs(path, name, description, screenTip)
  467. {
  468. // we already have variables for these.
  469. document.pform.m_path.value = path;
  470. document.pform.m_p_defaultName.value = name;
  471. document.pform.m_p_defaultDescription.value = description;
  472. document.pform.m_p_defaultScreenTip = screenTip;
  473. // now have to forward to submit and let it do it's job
  474. document.pform.m.value = "/ags/submit.xts";
  475. document.pform.ps_nav_op.value = "maintain";
  476. //flag the dialog type
  477. agsDialogTypes.setCurrentType(agsDialogTypes.SAVE_SAVEAS);
  478. // fire
  479. document.pform.submit();
  480. }
  481. /*
  482. * Load the definition, the dialogue can be either be
  483. * the edit parameter or edit calculations dialogues. More
  484. * may be added in the future...
  485. * selectedNodes The selected nodes from a tree
  486. * fn The call that will display a dialogue
  487. */
  488. function loadDefinitionEditPage(selectedNode,fn) {
  489. if (selectedNode && selectedNode != 'undefined') {
  490. if (fn) {
  491. eval(fn);
  492. }
  493. }
  494. else {
  495. alert(editDefinitionSelectionWarning);
  496. }
  497. }
  498. function editDefinition(){
  499. var visibleTree = cfgGet("lastMenu");
  500. var selectedNodes = null;
  501. var prmData=null;
  502. var ags_tree_node=null;
  503. var fn=null;
  504. //handle parameters
  505. if (visibleTree == TAB_PARAMETERS) {
  506. //get the params
  507. //selectedNodes = getSelectedParameterNodes();
  508. selectedNodes = getParametersTree().getSelectedLeafNodes();
  509. if (selectedNodes && selectedNodes.length > 0) {
  510. ags_tree_node=selectedNodes[0];
  511. //set action
  512. fn = "getConfigFrame().showParameters('edit','" + ags_tree_node.getTreeRef() + "');";
  513. }
  514. }
  515. //handle data items
  516. else if (visibleTree == TAB_DATAITEMS) {
  517. //selectedNodes = getSelectedQueryItemNodes();
  518. selectedNodes = getDataItemsTree().getSelectedLeafNodes();
  519. if (selectedNodes && selectedNodes.length > 0) {
  520. ags_tree_node = selectedNodes[0];
  521. //set action
  522. fn = "getConfigFrame().showDataItem('edit','" + ags_tree_node.getTreeRef() + "');";
  523. }
  524. }
  525. //display the selected dialogue
  526. loadDefinitionEditPage(ags_tree_node,fn);
  527. }
  528. function createHiddenInput(document, name, value){
  529. var inline = document.createElement("INPUT");
  530. inline.setAttribute("name", name);
  531. inline.setAttribute("value", value);
  532. inline.setAttribute("id", name);
  533. inline.setAttribute("type", "hidden");
  534. return inline;
  535. }
  536. /*
  537. * Fire the 'copy' action. This function will place any selected text onto the clipboard
  538. */
  539. function copy() {
  540. var msgFrame = getMessageIFrame();
  541. var control = getSelectionControl();
  542. //only copy from valid controls
  543. if (control) {
  544. selText = getSelectedText();
  545. if (selText != '') {
  546. //IE
  547. if (browserCheck.isIE5dot5Up()) {
  548. //copy the text to the clipboard
  549. window.clipboardData.setData("Text",selText);
  550. }
  551. //Firefox
  552. else if (dlgContains(K_sSelectionId)) {
  553. var sel = dlgGetParm(K_sSelectionId);
  554. sel.copiedText=selText;
  555. }
  556. }
  557. }
  558. }
  559. /*
  560. * Fire the 'paste' action. This function will copy the clipboard data to the current control.
  561. * The control that received the last blur event is deemed to be the last active control
  562. * toBePasted Optional text to be pasted into the control
  563. */
  564. function paste(toBePasted)
  565. {
  566. var msgFrame = getMessageIFrame();
  567. var sel = null;
  568. var text="";
  569. //set the text if it has been passed into the function
  570. if (toBePasted != undefined) {
  571. text=toBePasted;
  572. }
  573. //get the selection control that either has a selection or the selection caret
  574. var control = getSelectionControl();
  575. if (control != null) {
  576. var selObj = getSelectionObject(control.ownerDocument);
  577. //get the id
  578. var id = control.name;
  579. //check if this dialog has paste enabled
  580. if (isPasteEnabled(id)) {
  581. //check if the current control has hint text, if it has we need to clear it
  582. //properly using the drag/drop handler. This is defined in dragDropHandler.js
  583. if (msgFrame.droppy != undefined && msgFrame.droppy.registeredObjectsIndex[id] != undefined && msgFrame.droppy.registeredObjectsIndex[id].isDefaultMode()) {
  584. msgFrame.droppy.removeDefault(id);
  585. }
  586. if (browserCheck.isIE5dot5Up()) {
  587. if (toBePasted == undefined) {
  588. //get the clipboard info
  589. text = window.clipboardData.getData("Text");
  590. }
  591. //important!!!!!!!! if the control is not set as active the clipboard info may be pasted into arbitrary non-input controls on the page
  592. control.setActive();
  593. //create the range
  594. var range = selObj.createRange();
  595. if (text != null) {
  596. //reset the selection if we have one
  597. if (selObj.type=="Text") {
  598. selObj.clear();
  599. }
  600. //need to paste as HTML
  601. if (control.canHaveHTML && (control.id=='editbody' || (control.ownerDocument.pform && control.ownerDocument.pform.richEditMode && control.ownerDocument.pform.richEditMode.value=="true"))) {
  602. range.pasteHTML(text);
  603. }
  604. //paste as simple text
  605. else {
  606. //convert to plain text
  607. var ele = document.createElement("div");
  608. ele.innerHTML=text;
  609. //paste the clipboard contents
  610. range.text=ele.innerText;
  611. }
  612. }
  613. }
  614. else if (dlgContains(K_sSelectionId)) {
  615. var pos=0;
  616. var sel = dlgGetParm(K_sSelectionId);
  617. if (toBePasted == undefined) {
  618. text = sel.copiedText;
  619. }
  620. var startPos = control.selectionStart;
  621. var endPos = control.selectionEnd;
  622. //control.focus();
  623. //remove the selected text
  624. clearSelectionText(selObj);
  625. control.value = control.value.substring(0, startPos)
  626. + text
  627. + control.value.substr(endPos);
  628. }
  629. }
  630. }
  631. }
  632. /*
  633. * Fire the 'cut' action. This function will copy active control data into the clipboard and then
  634. * clear the current control value. The control that received the last blur event is deemed to be the last active control
  635. */
  636. function cut()
  637. {
  638. var sel = null;
  639. var control = getSelectionControl();
  640. if (control) {
  641. sel = getSelectionObject(control.ownerDocument);
  642. if (isValidSelection(sel)) {
  643. //save the current selection to the clipboard
  644. copy();
  645. //remove the selected text
  646. clearSelectionText(sel);
  647. }
  648. }
  649. }
  650. function getCaption(){
  651. getFunction(K_sCaptionFunctionText);
  652. }
  653. // inserts previous value function in the selected text for agent task
  654. function getPreviousValue() {
  655. getFunction(K_sPreviousFunctionText);
  656. }
  657. // inserts previous value function in the selected text for agent task
  658. function getFunction(funtion_text, secondGo) {
  659. var empty_warning = funtion_text == K_sPreviousFunctionText ? agentStudioWarningForInsertingPreviousValueFunctionInEmptyValueBox : agentStudioWarningForInsertingCaptionFunctionInEmptyValueBox;
  660. var dialog_warning = funtion_text == K_sPreviousFunctionText ? agentStudioWarningForInsertPreviuosValue : agentStudioWarningForInsertCaption;
  661. // To check if it is the condition or Dataitems page then
  662. // don't do the paste
  663. var currentSel = dlgGetParm(K_sSelectionId);
  664. if (currentSel != null) {
  665. if (currentSel.id != K_sDataItemExpression &&
  666. currentSel.id != K_sDataItemName &&
  667. currentSel.id != K_sDetailExpression) {
  668. //check whether this is read only input eg.Store procedrue, Web services, prompted report etc have.
  669. var msgFrame = getMessageIFrame();
  670. // this is the messagedoc for message frame
  671. var msgDoc = getFrameDocument(msgFrame);
  672. var el = msgDoc.getElementById(currentSel.id);
  673. var isDropZone = msgFrame.droppy != null ? msgFrame.droppy.isDropZone(currentSel.id) : false;
  674. var isPrompt = el != null && el.closePrevious != null && el.closePrevious == 'true';
  675. var isOverWrite = msgFrame.droppy != null ? msgFrame.droppy.isOverWrite(currentSel.id) : false;
  676. if (isDropZone && (isPrompt || isOverWrite)) {
  677. if(el.value == '' && !secondGo){
  678. //we have a drop zone targeted... do a drop
  679. insertStartMC(currentSel.id);
  680. setTimeout("getFunction('"+ funtion_text +"', true)");
  681. }else if (el.value != '') {
  682. var function_matcher = /\([^(^)]+\)/g;
  683. var functions = el.value.match(function_matcher);
  684. if(functions != null && functions.length > 0){
  685. //we already have functions..so blat whats there
  686. insertStartMC(currentSel.id);
  687. setTimeout("getFunction('"+ funtion_text +"', true)");
  688. }else{
  689. // check the label is not empty
  690. //we need to get the data Item and wrapp it in a function so it looks like "previous([Item name])")
  691. var textToBePasted = funtion_text + el.value + ')';
  692. el.value = textToBePasted;
  693. }
  694. }else {
  695. // the value is empty and cant be filled...warn the user
  696. window.alert(empty_warning);
  697. }
  698. } else if(isDropZone) {
  699. paste(funtion_text);
  700. insertStartMC(currentSel.id);
  701. paste(")");
  702. }
  703. }else {
  704. window.alert(dialog_warning);
  705. }
  706. }
  707. }
  708. // inserts selected itiem from source tab into data items tab
  709. function insertItem() {
  710. parent.insertStartMC();
  711. }
  712. /*
  713. * Check if the input control with the given id can have text pasted into it
  714. * id The input control id
  715. */
  716. function isPasteEnabled(id) {
  717. var isEnabled = true;
  718. dlgArray = dlgGetParm("pasteEnabled");
  719. if (dlgArray != null && dlgArray[id] != undefined) {
  720. isEnabled = dlgArray[id];
  721. }
  722. return isEnabled;
  723. }
  724. /*
  725. * Set the paste enabled state for the dialog
  726. * id The input control id
  727. * enabled true if pasted is enabled for this control
  728. */
  729. function setPasteEnabled(id,enabled) {
  730. var dlgArray = null;
  731. dlgArray = dlgGetParm("pasteEnabled");
  732. //create and set the parameter the first time
  733. if (dlgArray==null) {
  734. dlgArray = new Array();
  735. dlgSetParm("pasteEnabled",dlgArray);
  736. }
  737. //set the state
  738. dlgArray[id]=enabled;
  739. }
  740. /*
  741. * Perform the undo function. If a tree item has been deleted then it will be resurrected here
  742. */
  743. function undo() {
  744. getRedoUndoManager().reverseLastEditAction();
  745. }
  746. function redo() {
  747. getRedoUndoManager().redoLastEditAction();
  748. }
  749. // this is to hide the droptasks list and list when not in focus
  750. function hideFlyout() {
  751. var messageFrame = window.parent.getConfigFrame();
  752. }
  753. /*
  754. * attach the event handler for the fl
  755. */
  756. function onDialogFrameLoad() {
  757. // get us the dialog frame
  758. var dialogFrame = getDialogFrame();
  759. // this is the messagedoc for dialog frame
  760. var dialogDoc = getFrameDocument(dialogFrame);
  761. var forms = dialogDoc.forms;
  762. if (forms['pform']) {
  763. DialogFrame_hookFormSubmit(forms['pform']);
  764. }
  765. handleEmailBody();
  766. // attach the handlers for dialog frame
  767. attachHandlers(forms);
  768. // this is to hide the drop down task list and drop down tools list in dialog frame when not in focus.
  769. if (dialogDoc.body != null && dialogFrame.parent.document.body.getWndObserver) {
  770. dialogFrame.parent.document.body.getWndObserver().attachFrames('mouseup');
  771. dialogFrame.document.body.getWndObserver().attachFrames('mouseup',dialogFrame);
  772. //register a key down handler to detect changes
  773. eventHandlerChainUtil.doEventHandlerChain(dialogDoc, "keydown",keyDownChecker.check);
  774. }
  775. if(isDialogFrameShowing()){
  776. applicationActionManager.allowActions();
  777. //decide if the task list state needs to be updated
  778. if (dialogDoc.forms.length > 0 && dialogDoc.forms[0].m != undefined) {
  779. var morphlet=dialogDoc.forms[0].m.value;
  780. var selType;
  781. //manage the task execution rules
  782. if (morphlet.match('suppression')) {
  783. selType=K_sSuppression;
  784. }
  785. //schedule the agent
  786. else if(morphlet.match('schedule')) {
  787. selType=K_sSchedule;
  788. }
  789. //reorder the tasks
  790. else if (morphlet.match('seq_agent_tasks')) {
  791. selType=K_sSetSubmit;
  792. }
  793. //update the selected item task list
  794. if (selType!=undefined) {
  795. makeSelection(selType);
  796. }
  797. }
  798. }
  799. }
  800. // This method check login for every dialog frame submit
  801. //
  802. function DialogFrame_hookFormSubmit(form) {
  803. // Hook the form submit() method.
  804. form.old_mf_submit = form.submit;
  805. form.submit = function() {
  806. checkLogin(undefined,"processDlgSubmit()");
  807. }
  808. }
  809. function processDlgSubmit() {
  810. // get us the dialog frame
  811. var dialogFrame = getDialogFrame();
  812. // this is the messagedoc for dialog frame
  813. var dialogDoc = getFrameDocument(dialogFrame);
  814. //Get this nasty form out.
  815. //I had to make this change cos the createCommandStackObject process next command.
  816. //In the case of File-> Exit on a new agent the Studio exits when change location
  817. //for save as. Bug: 575574.
  818. var forms = dialogDoc.forms;
  819. var form = forms['pform'];
  820. if (form) {
  821. // Submit this form.
  822. form.old_mf_submit();
  823. }
  824. }
  825. function MessageFrame_hookOnClick(msgFrame) {
  826. msgFrame.document.body.onclick = function(e) {
  827. if (!e) e = msgFrame.window.event;
  828. e = (e.target ? e.target : e.srcElement);
  829. if (e.tagName=='A') {
  830. // Clicked on an A element.
  831. // Is the href=='#'?
  832. //
  833. s = e.href;
  834. if (s.indexOf('#')==s.length-1) {
  835. // Cancel the click, stops IE navigating
  836. // to the top of the page.
  837. //
  838. e.cancelBubble = true;
  839. if (e.stopPropagation) e.stopPropagation();
  840. return false;
  841. }
  842. }
  843. }
  844. }
  845. // This method disables links and form submits so that the
  846. // server is not interrupted while processing a request
  847. // A submit response is always a new HTML page.
  848. //
  849. function MessageFrame_hookFormSubmit(form) {
  850. // Hook the form submit() method.
  851. form.old_mf_submit = form.submit;
  852. form.submit = function() {
  853. var target = this.target;
  854. checkLogin(undefined,"processMsgSubmit('"+ target + "')");
  855. }
  856. }
  857. function processMsgSubmit(target) {
  858. var msgFrame = getMessageIFrame();
  859. // this is the messagedoc for message frame
  860. var msgDoc = getFrameDocument(msgFrame);
  861. var form = msgDoc.forms['pform'];
  862. //Dont know why we are losing the target.
  863. form.target = target;
  864. // Submit this form.
  865. form.old_mf_submit();
  866. // Disable the A elements.
  867. var tags = form.ownerDocument.getElementsByTagName("a");
  868. for (var i=0; i!=tags.length; i++) {
  869. tags[i].href='#';
  870. tags[i].onclick="return false;";
  871. // Dont change color? Inconsistent with other CRN studios.
  872. //tags[i].className = "inactiveHRef";
  873. }
  874. // Block all further submits in this page.
  875. tags = form.ownerDocument.getElementsByTagName("form");
  876. for (var i=0; i!=tags.length; i++) {
  877. tags[i].submit = function dummy(event) { };
  878. }
  879. }
  880. /*
  881. * Loop through all the input controls in the message frame and attach a focus out handler to each one.
  882. * The deletion candidate variable is set each time a control receives a focus out. This is then used to decide
  883. * which control is to be deleted
  884. */
  885. function onMessageFrameLoad()
  886. {
  887. var msgFrame = getMessageIFrame();
  888. // this is the messagedoc for message frame
  889. var msgDoc = getFrameDocument(msgFrame);
  890. var forms = msgDoc.forms;
  891. // Trap the onClick() event so that we can monitor the A elements and prevent IE from navigating
  892. // to the top of a page when a href contains '#'. Otherwise the message frame will shift to 0,0
  893. // relative to the left of the main window window when such a link is clicked.
  894. //
  895. MessageFrame_hookOnClick(msgFrame);
  896. if (msgFrame.document.forms['pform'])
  897. MessageFrame_hookFormSubmit(msgFrame.document.forms['pform']);
  898. //this is to hide the drop down list and drop down tools list in message frame when not in focus
  899. if (msgDoc.body != null && msgFrame.parent.document.body.getWndObserver) {
  900. msgFrame.parent.document.body.getWndObserver().attachFrames('mouseup');
  901. msgFrame.parent.document.body.getWndObserver().removeListenerById(msgFrame.document.body.getWndObserver().id);
  902. msgFrame.parent.document.body.getWndObserver().addListener(msgFrame.document.body.getWndObserver(),msgFrame.document.body.getWndObserver().notify, "mouseup");
  903. msgFrame.document.body.getWndObserver().attachFrames('mouseup',msgFrame);
  904. //register a key down handler to intercept and discard hotkey combinations
  905. eventHandlerChainUtil.doEventHandlerChain(msgDoc, "keydown",keyDownChecker.check);
  906. }
  907. // should we also hide the popUpFrame
  908. if (popUpIsFlaggedForClosure()) {
  909. // close it
  910. doClosePopUp();
  911. parent.document.getElementById("metadataIFrame").focus();
  912. }
  913. //clear the undo data when we move page
  914. getRedoUndoManager().resetTreeAction();
  915. //attach the events to the email body which is not part
  916. //of the message frame form
  917. handleEmailBody();
  918. //attach commaons handlers common to the message frame and the dialog frame
  919. attachHandlers(forms,msgFrame);
  920. //unblock actions now its all calmed down
  921. applicationActionManager.allowActions();
  922. //register key down handler for A11Y keyboard
  923. if (AccessibilityHandler.isEnabled()) {
  924. msgFrame.document.body.onkeydown = AccessibilityHandler.onkeydown;
  925. }
  926. }
  927. function attachAgentChangeHandler(control) {
  928. //register a key down handler to detected changes
  929. eventHandlerChainUtil.doEventHandlerChain(control, "keydown", function(evt) {
  930. if (cf.hasAgentChanged()==false) {
  931. cf.agentHasChanged(true);
  932. }
  933. });
  934. }
  935. /*
  936. * Attach event handlers to the input controls in the frame
  937. * forms - an array of forms, must not be null or undefined
  938. * sourceFrame - The parent frame, this parameter is optional
  939. */
  940. function attachHandlers(forms,sourceFrame) {
  941. var intended=/INPUT|TEXTAREA|SELECT|OPTION/;
  942. //loop through the forms in the message frame
  943. for (var i=0;i<forms.length;i++) {
  944. var form = forms[i];
  945. //loop through the controls in the form
  946. for (var j=0;j<form.length;j++) {
  947. var control = form.elements[j];
  948. //only add the selection handler to input controls(not hidden), textarea, select and option
  949. if (intended.test(control.tagName) && control.getAttribute('type')!='hidden') {
  950. //register a custom handler to store any selections
  951. eventHandlerChainUtil.doEventHandlerChain(control, "select", handleSelection);
  952. eventHandlerChainUtil.doEventHandlerChain(control, "focus", setSelectionId);
  953. eventHandlerChainUtil.doEventHandlerChain(control, "focus", function(event) {
  954. //security problem to cache the whole object
  955. var id = agsFormUtils.getEventId(event);
  956. parent.deletionCandidateManager.setCandidate(id,K_sControlCandidate);
  957. });
  958. //only attach the agent change handler for message frame controls
  959. if (arguments.length==2 && sourceFrame && sourceFrame.name==MESSAGE_FRAME_ID) {
  960. attachAgentChangeHandler(control);
  961. }
  962. }
  963. }
  964. }
  965. }
  966. function addEvent(obj, evType, fn, useCapture){
  967. //FF
  968. if (obj.addEventListener){
  969. if (arguments.length < 4) {
  970. useCapture=false;
  971. }
  972. obj.addEventListener(evType, fn, useCapture);
  973. return true;
  974. }
  975. //IE
  976. else if (obj.attachEvent){
  977. var r = obj.attachEvent("on"+evType, fn);
  978. return r;
  979. }
  980. }
  981. function removeEvent(obj, evType, fn, useCapture){
  982. //FF
  983. if (obj.removeEventListener) {
  984. if (arguments.length < 4) {
  985. useCapture=false;
  986. }
  987. obj.removeEventListener (evType, fn, useCapture);
  988. }
  989. //IE
  990. else if (obj.detachEvent){
  991. obj.detachEvent ("on"+evType, fn);
  992. }
  993. }
  994. function handleEmailBody() {
  995. var editBody = agsFormUtils.getElementByIdOrName('editbody');
  996. if (editBody) {
  997. //register a key down handler to intercept and discard hotkey combinations
  998. eventHandlerChainUtil.doEventHandlerChain(editBody, "keydown",keyDownChecker.check);
  999. eventHandlerChainUtil.doEventHandlerChain(editBody, "select", handleSelection);
  1000. eventHandlerChainUtil.doEventHandlerChain(editBody, "focus", setSelectionId);
  1001. attachAgentChangeHandler(editBody);
  1002. }
  1003. }
  1004. /*
  1005. * get the selection object in a cross-browser fashion
  1006. */
  1007. function getSelectionObject(selDocument) {
  1008. var selObj = null;
  1009. if (window.getSelection) {
  1010. selObj = window.getSelection();
  1011. }
  1012. else if (selDocument.getSelection) {
  1013. selObj = selDocument.getSelection();
  1014. }
  1015. else if (selDocument.selection) {
  1016. selObj = selDocument.selection;
  1017. }
  1018. return selObj;
  1019. }
  1020. function clearSelectionText(selObj) {
  1021. if (browserCheck.isIE5dot5Up()) {
  1022. selObj.clear();
  1023. }
  1024. else if (dlgContains(K_sSelectionId)) {
  1025. var sel = dlgGetParm(K_sSelectionId);
  1026. var control = agsFormUtils.getElementByIdOrName(sel.id);
  1027. var value = control.value;
  1028. var selText = sel.text;
  1029. var firstStr = value.slice(0,control.selectionStart)
  1030. var secondStr = value.slice(control.selectionEnd,value.length);
  1031. control.value = firstStr+secondStr;
  1032. }
  1033. else if (selObj.focusNode) {
  1034. selObj.removeAllRanges();
  1035. }
  1036. }
  1037. function getSelectionControl() {
  1038. var control = null;
  1039. //we have a selection
  1040. if (dlgContains(K_sSelectionId)) {
  1041. //get the selection id
  1042. var id = dlgGetParm(K_sSelectionId).id;
  1043. //we have an id
  1044. if (id) {
  1045. control = agsFormUtils.getElementByIdOrName(id);
  1046. if (control) {
  1047. //control.setActive();
  1048. var parent = getSelectionParent(control.ownerDocument);
  1049. //we have a selection parent
  1050. if (parent) {
  1051. var intended=/INPUT|TEXTAREA|SELECT|OPTION/;
  1052. if (!intended.test(parent.tagName)) {
  1053. while (parent != null) {
  1054. // This is a special case for HTML email body
  1055. if (parent.tagName != 'BODY' && parent.id != 'editbody') {
  1056. parent = parent.parentElement;
  1057. }
  1058. else {
  1059. break;
  1060. }
  1061. }
  1062. if (parent.tagName == 'BODY' && parent.id == 'editbody') {
  1063. intended = /BODY/;
  1064. }
  1065. }
  1066. //test that the selection has been made on a valid input control
  1067. if (parent != null && (intended.test(parent.tagName) || intended.test(parent.parentElement.tagName)) && parent.getAttribute('type') != 'hidden') {
  1068. control = parent;
  1069. if (browserCheck.isIE5dot5Up()) {
  1070. control.setActive();
  1071. }
  1072. }
  1073. }
  1074. }
  1075. }
  1076. }
  1077. return control;
  1078. }
  1079. /*
  1080. * Get the selection parent in a cross-browser fashion
  1081. */
  1082. function getSelectionParent(selDocument) {
  1083. var parent=null;
  1084. //get the stored selection if available
  1085. if (dlgContains(K_sSelectionId)) {
  1086. var sel = dlgGetParm(K_sSelectionId);
  1087. var control = agsFormUtils.getElementByIdOrName(sel.id);
  1088. if (control) {
  1089. parent = control;
  1090. }
  1091. }
  1092. if (browserCheck.isIE5dot5Up() && selDocument) {
  1093. parent = selDocument.selection.createRange().parentElement();
  1094. }
  1095. return parent;
  1096. }
  1097. /*
  1098. * check the selection object. We test the selection object
  1099. * and also the selection text
  1100. */
  1101. function isValidSelection(selObj) {
  1102. var isValid = selObj != null && selObj != undefined;
  1103. if (browserCheck.isIE5dot5Up()) {
  1104. isValid = isValid && selObj.type=="Text"
  1105. }
  1106. if (dlgContains(K_sSelectionId)) {
  1107. isValid = isValid && dlgGetParm(K_sSelectionId).text != '';
  1108. }
  1109. return isValid;
  1110. }
  1111. /*
  1112. * Get the text selection from the dialog parameter
  1113. */
  1114. function getSelectedText() {
  1115. var selText = '';
  1116. if (dlgContains(K_sSelectionId)) {
  1117. selText = dlgGetParm(K_sSelectionId).text;
  1118. }
  1119. return selText;
  1120. }
  1121. /*
  1122. * The control has been focussed so set the current selection id
  1123. */
  1124. function setSelectionId(event) {
  1125. var sel = null;
  1126. if (dlgContains(K_sSelectionId)) {
  1127. sel = dlgGetParm(K_sSelectionId);
  1128. }
  1129. else {
  1130. sel = new TextSelection(id,'');
  1131. dlgSetParm(K_sSelectionId,sel);
  1132. }
  1133. var control=event.srcElement || event.currentTarget || event.target;
  1134. //get the id/name from the event source
  1135. var id = control.id ? control.id : control.name;
  1136. sel.id = id;
  1137. }
  1138. /*
  1139. * Store the selection if available as a dialog parameter K_sSelectionId( defined in constants.js)
  1140. */
  1141. function handleSelection(event) {
  1142. var selText = "";
  1143. var sel=null;
  1144. var id = null;
  1145. var start=0;
  1146. var end=0;
  1147. var control=event.srcElement || event.currentTarget || event.target;
  1148. //get the id/name from the event source
  1149. id = control.id ? control.id : control.name;
  1150. var selection = getSelectionObject(control.ownerDocument);
  1151. //IE
  1152. if (browserCheck.isIE5dot5Up()) {
  1153. if (selection.type=="Text") {
  1154. var textRange=selection.createRange();
  1155. if (id=='editbody' || control.ownerDocument.pform && control.ownerDocument.pform.richEditMode && control.ownerDocument.pform.richEditMode.value=="true") {
  1156. selText = textRange.htmlText;
  1157. }
  1158. else {
  1159. selText = textRange.text;
  1160. }
  1161. }
  1162. }
  1163. //Firefox
  1164. else {
  1165. start = control.selectionStart;
  1166. end = control.selectionEnd;
  1167. selText = control.value.substring(start,end);
  1168. }
  1169. if(dlgContains(K_sSelectionId)) {
  1170. sel = dlgGetParm(K_sSelectionId);
  1171. //update the id
  1172. sel.id = id;
  1173. }
  1174. //create the selection
  1175. else {
  1176. sel = new TextSelection(id,selText);
  1177. //set the new selection
  1178. dlgSetParm(K_sSelectionId,sel);
  1179. }
  1180. //a selection has been found, set the start and end positions
  1181. if (selText !='') {
  1182. sel.start=start;
  1183. sel.end=end;
  1184. sel.text=selText;
  1185. }
  1186. }
  1187. /*
  1188. * An object to hold details about a text selection
  1189. */
  1190. function TextSelection(id,text) {
  1191. this.id = id;
  1192. this.text = text;
  1193. this.copiedText="";
  1194. this.toString=toString;
  1195. this.start=0;
  1196. this.end=0;
  1197. function toString() {
  1198. return "TextSelection[id:"+this.id+",text:"+this.text+",copied:"+this.copiedText+",start:"+this.start+",end:"+this.end+"]";
  1199. }
  1200. }
  1201. function getPackage(){
  1202. var model = parent.cfgGet("cmLastModel");
  1203. // can't have the following variable named package - Netscape barfs with a syntax error.
  1204. var ret_value = model.substring(0, model.indexOf("/model"));
  1205. return ret_value;
  1206. }
  1207. function doPackageUpdatedCheck(){
  1208. if(cf.cfgGet('updatedModel')){
  1209. alert(packageUpdatedMessage1_string + "\n" + packageUpdatedMessage2_string);
  1210. }
  1211. getCommandStackManager().processCommandStack();
  1212. }
  1213. function notYet()
  1214. {
  1215. alert("Not available in this version.");
  1216. }
  1217. function doWizard(wizard){
  1218. // if going to the new agent wizard then change the taskMenu
  1219. if(wizard == '/ags/new_agent_wizard_controller.xts'){
  1220. parent.changeTaskMenu('wizard');
  1221. }
  1222. // load the wizard page by forcing a submit on the message frame. CAlling loadAgentXTS will
  1223. // delete all currently stored variables.
  1224. loadPage(wizard, 'push');
  1225. }
  1226. function doNewAgent(){
  1227. //set the expression locale to the current content locale
  1228. resetExpressionLocale();
  1229. loadAgentXTS("dialogAdapter.xts&tabSelectedID=AgentTask-condition&prevTabID=AgentTask-condition");
  1230. // have to re-init the model tree because the previous meta data tree
  1231. // may have nodes open with a different expression locale
  1232. cf.resetMetadataTree();
  1233. // have to re-init the function tree too - we might have different functions defined
  1234. cf.resetFunctionsTree();
  1235. //Will also call the functions tree.
  1236. cf.initMetadataTree();
  1237. clearAgentScript();
  1238. }
  1239. //js object for the agent
  1240. var agent_definitions;
  1241. function getAgentDefinition(){
  1242. return agent_definitions;
  1243. }
  1244. function setAgentDefinition(agent) {
  1245. agent_definitions = agent;
  1246. }
  1247. function loadAgentXTS(page)
  1248. {
  1249. // reset the message frame to the original page - this will kill all variables
  1250. // in the xts
  1251. var req = "&m_path=" + cfgGet("PackageRoot");
  1252. var se = cfgGet("SCRIPT_ENGINE");
  1253. var mf = document.getElementById("messageIFrame");
  1254. if ( mf != null) {
  1255. //include the context id in the url
  1256. var url = se + "?b_action=xts.run&m=/ags/"+ page + constructGETRequestParamsString(req);
  1257. mf.src = url;
  1258. }
  1259. }
  1260. function clearAgentScript()
  1261. {
  1262. // change to the model tab - though why you want to
  1263. // do that I don't know.
  1264. changeMenu(TAB_MODEL);
  1265. // need to figure out how to remove items from the agentItemsTree
  1266. resetAgentItems();
  1267. //start the script
  1268. getRedoUndoManager().clearAgentItemsTracking();
  1269. // we are dealing with a new report now
  1270. cfgSet("NewAgent", true);
  1271. cfgSet("NewReport", true);
  1272. // set the name of the report
  1273. cfgSet("ReportName", cfgGet("DefaultReportName"));
  1274. // hmmm
  1275. cf.agentHasChanged(false);
  1276. // do the name of agent
  1277. setWindowTitle();
  1278. cfgSet("numRows",20);
  1279. cfgRemove("filter_promptValues");
  1280. cfgRemove("SearchPath");
  1281. dlgRemoveParm("searchPath");
  1282. cfgSet("NewAgent", true);
  1283. cfgRemove("AgentName");
  1284. cfgRemove("saved_agent_condition");
  1285. }
  1286. function viewReportOutput(path){
  1287. // build the url for the window we're going to open - just want to run the run_report.xts in it
  1288. 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);
  1289. // make that thar window
  1290. report_viewer_window = window.open(url, "reportRun", "height=480,width=640,resizable=yes");
  1291. // bring it to the front
  1292. if (report_viewer_window != null) {
  1293. report_viewer_window.focus();
  1294. }
  1295. }
  1296. function run()
  1297. {
  1298. // build the url for the window we're going to open - just want to run the run_report.xts in it
  1299. 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);
  1300. // make that thar window
  1301. report_viewer_window = window.open(url, "reportRun", "height=480,width=640,resizable=yes,scrollbars=1");
  1302. // bring it to the front
  1303. if (report_viewer_window != null) {
  1304. report_viewer_window.focus();
  1305. }
  1306. }
  1307. function runCount()
  1308. {
  1309. // build the url for the window we're going to open - just want to run the run_report.xts in it
  1310. var url = cfgGet("SCRIPT_ENGINE") + "?" + constructGETRequestParamsString("b_action=xts.run&m=ags/run_report.xts&cv.toolbar=false&runCount=true&cv.id=ES");
  1311. // make that thar window
  1312. report_viewer_window = window.open(url, "reportRun", "height=480,width=640,resizable=yes");
  1313. // bring it to the front
  1314. if (report_viewer_window != null) {
  1315. report_viewer_window.focus();
  1316. }
  1317. }
  1318. function copyAgentSpecificationToClipboard()
  1319. {
  1320. var xmlString = getConfigFrame().cfgGet("inlineSpec");
  1321. try
  1322. {
  1323. if (xmlString != null) {
  1324. if (window.clipboardData) {
  1325. clipboardData.setData( "Text", xmlString );
  1326. } else {
  1327. //const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper);
  1328. //gClipboardHelper.copyString("Put me on the clipboard, please.");
  1329. //user_pref("capability.policy.policynames", "allowclipboard");
  1330. //user_pref("capability.principal.myapp.id","file:///D|/bering/crn55/webcontent/ags/cmd.js");
  1331. //user_pref("capability.principal.myapp.granted","UniversalXPConnect");
  1332. //user_pref("capability.policy.allowclipboard.sites", "http://localhost");
  1333. //user_pref("capability.policy.allowclipboard.Clipboard.cutcopy", "allAccess");
  1334. //user_pref("capability.policy.allowclipboard.Clipboard.paste", "allAccess");
  1335. // from: http://www.xulplanet.com/tutorials/xultu/clipboard.html
  1336. netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
  1337. var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
  1338. if (!str) {
  1339. netscape.security.PrivilegeManager.revertPrivilege("UniversalXPConnect");
  1340. return;
  1341. }
  1342. str.data=xmlString;
  1343. var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
  1344. if (!trans) {
  1345. netscape.security.PrivilegeManager.revertPrivilege("UniversalXPConnect");
  1346. return;
  1347. }
  1348. trans.addDataFlavor("text/unicode");
  1349. trans.setTransferData("text/unicode",str,xmlString.length * 2);
  1350. var clipid = Components.interfaces.nsIClipboard;
  1351. var clip = Components.classes["@mozilla.org/widget/clipboard;1"].getService(clipid);
  1352. if (!clip) {
  1353. netscape.security.PrivilegeManager.revertPrivilege("UniversalXPConnect");
  1354. return;
  1355. }
  1356. clip.setData(trans,null,clipid.kGlobalClipboard);
  1357. netscape.security.PrivilegeManager.revertPrivilege("UniversalXPConnect");
  1358. }
  1359. alert(copiedSpecificationToClipboard);
  1360. }
  1361. }
  1362. catch( e )
  1363. {
  1364. alert(errorCopyingSpecificationToClipboard);
  1365. }
  1366. }
  1367. function copyAgentSpecificationFromClipboard()
  1368. {
  1369. try
  1370. {
  1371. var d;
  1372. var text = "";
  1373. if (window.clipboardData) {
  1374. text = clipboardData.getData( "Text" );
  1375. if (text != null) {
  1376. d = new ActiveXObject( MSXML_DOM_DOCUMENT );
  1377. d.async = false;
  1378. d.resolveExternals = false;
  1379. d.validateOnParse = false;
  1380. d.loadXML(text);
  1381. }
  1382. } else {
  1383. netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
  1384. var clip = Components.classes["@mozilla.org/widget/clipboard;1"].getService(Components.interfaces.nsIClipboard);
  1385. if (!clip) {
  1386. netscape.security.PrivilegeManager.revertPrivilege("UniversalXPConnect");
  1387. return;
  1388. }
  1389. var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
  1390. if (!trans) {
  1391. netscape.security.PrivilegeManager.revertPrivilege("UniversalXPConnect");
  1392. return;
  1393. }
  1394. trans.addDataFlavor("text/unicode");
  1395. clip.getData(trans,clip.kGlobalClipboard);
  1396. var str = new Object();
  1397. var strLength = new Object();
  1398. trans.getTransferData("text/unicode",str,strLength);
  1399. if (str) str = str.value.QueryInterface(Components.interfaces.nsISupportsString);
  1400. if (str) text = str.data.substring(0,strLength.value / 2);
  1401. netscape.security.PrivilegeManager.revertPrivilege("UniversalXPConnect");
  1402. // parse the specification
  1403. var domParser = new DOMParser();
  1404. d = domParser.parseFromString(text, "text/xml");
  1405. }
  1406. var detailChanged = updateAgentFilter(d,"detail");
  1407. var summaryChanged = updateAgentFilter(d,"summary");
  1408. var itemsChanged = updateAgentItems(d);
  1409. var promptPages = updatePromptPages(d);
  1410. var extraQueries = updateExtraQueries(d);
  1411. if (detailChanged || summaryChanged || itemsChanged || promptPages || extraQueries) {
  1412. cf.agentHasChanged(true);
  1413. alert(updatedAgentFromSpecificationInClipboard);
  1414. }
  1415. else
  1416. {
  1417. alert(noSuitableFiltersFoundInClipboardTextToUpdateAgent);
  1418. }
  1419. }
  1420. catch ( e )
  1421. {
  1422. alert(errorParsingClipboardTextInCopyAgentSpecificationFromClipboard);
  1423. }
  1424. }
  1425. function updatePromptPages(reportSpecDoc)
  1426. {
  1427. // parse all the extra queries
  1428. var agentUpdated = false;
  1429. var pattern;
  1430. if (window.clipboardData) {
  1431. pattern = "/report/layouts/layout/promptPages";
  1432. } else {
  1433. pattern = "/*[local-name()='report']/*[local-name()='layouts']/*[local-name()='layout']/*[local-name()='promptPages']";
  1434. }
  1435. var diNodes = selectNodes(pattern,reportSpecDoc);
  1436. if (diNodes != null && diNodes.length > 0) {
  1437. var j=0;
  1438. //for (;j < diNodes.length;j++) {
  1439. if (window.clipboardData) {
  1440. getConfigFrame().cfgSet("inlineSpec_promptPages", diNodes.item(j));
  1441. }
  1442. else {
  1443. getConfigFrame().cfgSet("inlineSpec_promptPages", diNodes[j]);
  1444. }
  1445. agentUpdated = true;
  1446. //}
  1447. }
  1448. return agentUpdated;
  1449. }
  1450. function updateExtraQueries(reportSpecDoc)
  1451. {
  1452. // parse all the extra queries
  1453. var agentUpdated = false;
  1454. var pattern;
  1455. if (window.clipboardData) {
  1456. pattern = "/report/queries/query";
  1457. } else {
  1458. pattern = "/*[local-name()='report']/*[local-name()='queries']/*[local-name()='query']";
  1459. }
  1460. var diNodes = selectNodes(pattern,reportSpecDoc);
  1461. // if we only have one query then assume there are no extra queries we have to care about ...
  1462. if (diNodes != null && diNodes.length > 1) {
  1463. var extraQueries = new Array();
  1464. var extraSize = -1;
  1465. for (var j=0;j < diNodes.length;j++) {
  1466. var name = "x";
  1467. if (window.clipboardData) {
  1468. var nameNode = selectSingleNode("./@name",diNodes.item(j));
  1469. if (nameNode != null) {
  1470. name = nameNode.text;
  1471. }
  1472. if (name != "Query1") {
  1473. extraSize += 1;
  1474. extraQueries[extraSize] = diNodes.item(j);
  1475. }
  1476. }
  1477. else {
  1478. var nameNode = selectSingleNode("./@name",diNodes[j]);
  1479. if (nameNode != null) {
  1480. name = nameNode.textContent;
  1481. }
  1482. if (name != "Query1") {
  1483. extraSize += 1;
  1484. extraQueries[extraSize] = diNodes[j];
  1485. }
  1486. }
  1487. }
  1488. if (extraSize >= 0) {
  1489. getConfigFrame().cfgSet("inlineSpec_extraQueries", extraQueries);
  1490. agentUpdated = true;
  1491. }
  1492. }
  1493. return agentUpdated;
  1494. }
  1495. function updateAgentItems(reportSpecDoc)
  1496. {
  1497. var agentUpdated = false;
  1498. var pattern;
  1499. if (window.clipboardData) {
  1500. pattern = "/report/queries/query[@name='Query1']/selection/dataItem";
  1501. } else {
  1502. pattern = "/*[local-name()='report']/*[local-name()='queries']/*[local-name()='query'][@name='Query1']/*[local-name()='selection']/*[local-name()='dataItem']";
  1503. }
  1504. // parse all the data items, and chuck them in the agent data item tree
  1505. var expressionText = "";
  1506. var name = "x";
  1507. var diNodes = selectNodes(pattern,reportSpecDoc);
  1508. if (diNodes != null && diNodes.length > 0) {
  1509. for (var j=0;j < diNodes.length;j++) {
  1510. if (window.clipboardData) {
  1511. var nameNode = selectSingleNode("./@name",diNodes.item(j));
  1512. if (nameNode != null) {
  1513. name = nameNode.text;
  1514. }
  1515. var expressionNode = selectNodes("./expression",diNodes.item(j));
  1516. if (expressionNode != null && expressionNode.length > 0) {
  1517. expressionText = expressionNode.item(0).text;
  1518. }
  1519. }
  1520. else {
  1521. var nameNode = selectSingleNode("./@name",diNodes[j]);
  1522. if (nameNode != null) {
  1523. name = nameNode.textContent;
  1524. }
  1525. var expressionNode = selectSingleNode("./*[local-name()='expression']",diNodes[j]);
  1526. if (expressionNode != null) {
  1527. expressionText = expressionNode.textContent;
  1528. }
  1529. }
  1530. var aggregate = "none";
  1531. var displayType = "textItem";
  1532. // These are almost always a textItem ... so skip looking through the layout for the type.
  1533. //if (window.clipboardData) {
  1534. // pattern = "/report//listColumnBody/contents/*[.//dataItemValue/@refDataItem='" + name + "']";
  1535. //} else {
  1536. // pattern = "/*[local-name()='report']//*[local-name()='listColumnBody']/*[local-name()='contents']/*[.//local-name()='dataItemValue']/@refDataItem='" + name + "']";
  1537. //}
  1538. //var diNode = selectSingleNode(pattern,reportSpecDoc);
  1539. //displayType = diNode.text;
  1540. generateAgentItem(name, expressionText, aggregate, displayType);
  1541. agentUpdated = true;
  1542. }
  1543. }
  1544. return agentUpdated;
  1545. }
  1546. function updateAgentFilter(reportSpecDoc,filterText)
  1547. {
  1548. var pattern;
  1549. var postAutoAggregation = "";
  1550. if (filterText == "detail") {
  1551. postAutoAggregation = "[not(@postAutoAggregation) or @postAutoAggregation='false']";
  1552. }
  1553. if (window.clipboardData) {
  1554. pattern = "//" + filterText + "Filters/" + filterText + "Filter" + postAutoAggregation + "/filterExpression";
  1555. } else {
  1556. pattern = "//*[local-name()='" + filterText + "Filters']/*[local-name()='" + filterText + "Filter']" + postAutoAggregation + "/*[local-name()='filterExpression']";
  1557. }
  1558. var expressionText = "";
  1559. //a flag to determine whether the agent has changed since loading/saving
  1560. var v_bChanged = false;
  1561. // get the filter
  1562. var selNodes = selectNodes(pattern,reportSpecDoc);
  1563. if (selNodes != null && selNodes.length > 0) {
  1564. for (var j=0;j< selNodes.length;j++) {
  1565. if (j > 0) {
  1566. expressionText = expressionText + " and ";
  1567. }
  1568. if (window.clipboardData) {
  1569. expressionText = expressionText + selNodes.item(j).text;
  1570. }
  1571. else {
  1572. expressionText = expressionText + selNodes[j].textContent;
  1573. }
  1574. }
  1575. var obj;
  1576. var filterExpression = filterText + "Expression";
  1577. var msgFrame = getMessageIFrame();
  1578. var msgDoc = getFrameDocument(msgFrame);
  1579. if (browserCheck.isIE5Up()) {
  1580. obj = msgDoc.getElementById(filterExpression);
  1581. } else {
  1582. obj = msgDoc.getElementsByName(filterExpression)[0];
  1583. }
  1584. obj.className="hintText_inactive";
  1585. obj.value = expressionText;
  1586. v_bChanged = true;
  1587. }
  1588. return v_bChanged;
  1589. }
  1590. function selectNodes(aExpr,aNode) {
  1591. if (window.clipboardData) {
  1592. return aNode.selectNodes(aExpr);
  1593. }
  1594. else
  1595. {
  1596. var xpe = new XPathEvaluator();
  1597. var nsResolver = xpe.createNSResolver(aNode);
  1598. var expression = xpe.createExpression(aExpr,nsResolver);
  1599. var result = expression.evaluate(aNode, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
  1600. var found = [];
  1601. while (res = result.iterateNext())
  1602. found.push(res);
  1603. return found;
  1604. }
  1605. }
  1606. function selectSingleNode(aExpr,aNode) {
  1607. if (window.clipboardData) {
  1608. return aNode.selectSingleNode(aExpr);
  1609. }
  1610. else
  1611. {
  1612. var xpe = new XPathEvaluator();
  1613. var nsResolver = xpe.createNSResolver(aNode);
  1614. var expression = xpe.createExpression(aExpr,nsResolver);
  1615. var result = expression.evaluate(aNode, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
  1616. return result.iterateNext();
  1617. }
  1618. }
  1619. function showAgentSpecification()
  1620. {
  1621. var text = getConfigFrame().cfgGet("inlineSpec");
  1622. try
  1623. {
  1624. if (text != null) {
  1625. var height = ( window.screen.availHeight - 170 );
  1626. var width = ( window.screen.availWidth - 100 );
  1627. 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);
  1628. if (agent_spec_window == null) {
  1629. // popup blocked
  1630. alert(newWindowBlockedFromOpening);
  1631. return;
  1632. }
  1633. agent_spec_window.focus();
  1634. }
  1635. else {
  1636. alert(noSpecificationToDisplay);
  1637. }
  1638. } catch ( e ) {
  1639. alert(errorShowingSpecification);
  1640. }
  1641. }
  1642. function leaveAGS(){
  1643. dlgReset();
  1644. dlgSetParm("actionAfterSubmit", "open");
  1645. dlgSetParm("m", "/ags/leavingAGS.xts");
  1646. initialiseAgentInfo();
  1647. dlgSubmit();
  1648. }
  1649. function closeAGS() {
  1650. window.onbeforeunload=null;
  1651. window.close();
  1652. }
  1653. /*
  1654. * warn the user of changes to the agent when closing event studio
  1655. */
  1656. function confirmClose() {
  1657. if(hasAgentChanged()) {
  1658. return agentStudioExitWarning_string;
  1659. }
  1660. }
  1661. function doFileOpen()
  1662. {
  1663. doSelectObject("agents.es");
  1664. }
  1665. function selectValue(target_id,frameName)
  1666. {
  1667. // build the url for the window we're going to open - just want to run the run_report.xts in it
  1668. var url = cfgGet("SCRIPT_ENGINE");
  1669. url += "?b_action=xts.run";
  1670. url += "&m=/ags/selectValueUI.xts";
  1671. url += "&target_id=" + target_id;
  1672. url += "&frameName=" + frameName;
  1673. // append the target id, XSS encode the variables and add the context id
  1674. url = constructGETRequestURLString(url);
  1675. // see if we have any leaf nodes selected in the metadata tree
  1676. if (dataItemSingleSelection()) {
  1677. // get the single item which is selected
  1678. var v_aItems = metadataSelectedQueryItems();
  1679. // get the item - we know there is only one
  1680. var v_oItem = v_aItems[0];
  1681. // get the type
  1682. var v_sType = (v_oItem.type ? v_oItem.type : null);
  1683. // if we have a hierarchy type we might want to abort
  1684. //guard clause to check the QOSLevel if it exists
  1685. // Note - this doesn't stop a hierarchy select values if the hierarchy is a selected dataItem
  1686. // no way to detect that
  1687. if (v_sType != null && v_sType == K_sHIERARCHY &&
  1688. cfgGet(MEMBER_SEARCH_IN_HIERARCHY) && cfgGet(MEMBER_SEARCH_IN_HIERARCHY) == QOS_UNAVAILABLE) {
  1689. return;
  1690. }
  1691. // make the selectValues window - now FF and IE both can resize this window
  1692. var select_query_window = window.open(url, "SelectValue", "height=675,width=520,resizable=1");
  1693. // bring it to the front
  1694. if (select_query_window != null) {
  1695. select_query_window.focus();
  1696. }
  1697. }
  1698. }
  1699. function selectMember(sPath, sType)
  1700. {
  1701. dlgReset();
  1702. dlgSetParm("m","/ags/selectMembersUI.xts");
  1703. dlgSetParm("startAtPath", sPath);
  1704. //determine whether the package has the MEMBER_SEARCH_IN_HIERARCHY option set to search descendents
  1705. var sSearchDescendants = (cfgGet(MEMBER_SEARCH_IN_HIERARCHY) && cfgGet(MEMBER_SEARCH_IN_HIERARCHY) == QOS_OK) ? "true" : "false";
  1706. if (sType == K_sMEMBER) {
  1707. dlgSetParm("searchDescendantsAllowed",sSearchDescendants);
  1708. }
  1709. dlgSubmit("popUpFrame");
  1710. }
  1711. function editTitle()
  1712. {
  1713. cfgRemove("LAST_DIALOG");
  1714. dlgReset();
  1715. dlgSetParm("m", "/ags/editTitle.xts");
  1716. dlgSubmit();
  1717. }
  1718. function noCapability() {
  1719. alert(capabilities_msg);
  1720. if (frameBackURL==null || frameBackURL=="")
  1721. {
  1722. history.back();
  1723. document.location.replace(BLANK_HTML_DOCUMENT);
  1724. window.close();
  1725. }
  1726. else
  1727. document.location.replace(frameBackURL);
  1728. }
  1729. /*
  1730. * load a dialog page
  1731. * path Should point to a valid morphlet. The page will be opened in the message frame
  1732. * opvalue The operation type, if missing or null the operation type will default to 'push'
  1733. */
  1734. function loadPage(path,opvalue) {
  1735. //check the path validity
  1736. if (path != null && path != undefined && path != '') {
  1737. //block until page is reloaded
  1738. parent.applicationActionManager.blockActions();
  1739. var msgFrame = getMessageIFrame();
  1740. var msgDoc = getFrameDocument(msgFrame);
  1741. //set the dialog morphlet
  1742. msgDoc.pform.m.value=path;
  1743. if (opvalue == undefined || opvalue == null) {
  1744. msgDoc.pform.ps_nav_op.value = 'push';
  1745. } else {
  1746. // we set the opvalue to the one given
  1747. msgDoc.pform.ps_nav_op.value = opvalue;
  1748. }
  1749. msgDoc.pform.submit();
  1750. }
  1751. }
  1752. /*
  1753. * XSS encode one or more URL parameters.
  1754. * urlParams The parameters e.g. p1=abc&p2=def
  1755. *
  1756. * return the XSS encoded parameters. If the XSS library is unavailable then the
  1757. * parameters will be returned unchanged. The context id for the session is also appended to the parameter string
  1758. * with the name 'cafcontextid'
  1759. *
  1760. * NOTE : THIS SHOULD NOT BE CALLED FOR 'POST' REQUESTS
  1761. */
  1762. function constructGETRequestURLString(urlParams) {
  1763. var newUrlParams = "";
  1764. //check if the XSS library is available
  1765. if (typeof CAFXSSEncodeURL == "function") {
  1766. newUrlParams = CAFXSSEncodeURL(urlParams);
  1767. }
  1768. else {
  1769. newUrlParams = urlParams;
  1770. }
  1771. // add in the CAF context ID
  1772. newUrlParams = appendCAFContextId(newUrlParams);
  1773. return newUrlParams;
  1774. }
  1775. /*
  1776. * XSS encode one or more URL parameters.
  1777. * urlParams The parameters e.g. p1=abc&p2=def
  1778. *
  1779. * return the XSS encoded parameters. If the XSS library is unavailable then the
  1780. * parameters will be returned unchanged. The context id for the session is also appended to the parameter string
  1781. * with the name 'cafcontextid'
  1782. *
  1783. * NOTE : THIS SHOULD NOT BE CALLED FOR 'POST' REQUESTS
  1784. */
  1785. function constructGETRequestParamsString(urlParams) {
  1786. var newUrlParams = "";
  1787. //check if the XSS library is available
  1788. if (typeof CAFXSSEncode == "function") {
  1789. newUrlParams = CAFXSSEncode(urlParams);
  1790. }
  1791. else {
  1792. newUrlParams = urlParams;
  1793. }
  1794. // add in the CAF context ID
  1795. newUrlParams = appendCAFContextId(newUrlParams);
  1796. return newUrlParams;
  1797. }
  1798. /*
  1799. * append the context id to the url parameters. the url is returned unchanged if the context id exists in the url
  1800. */
  1801. function appendCAFContextId(urlParams)
  1802. {
  1803. //check for a context id and assign it to the query
  1804. if (cafContextId != "" && urlParams.indexOf("cafcontextid")==-1)
  1805. {
  1806. if (urlParams != "") {
  1807. urlParams += "&cafcontextid=" + cafContextId;
  1808. }
  1809. else {
  1810. urlParams = "cafcontextid=" + cafContextId;
  1811. }
  1812. }
  1813. return urlParams;
  1814. }
  1815. function showDefaultTasksOptions() {
  1816. dlgReset();
  1817. dlgSetParm("m", "/ags/set_agent_defaults.xts");
  1818. initialiseAgentInfo();
  1819. //flag the dialog type
  1820. agsDialogTypes.setCurrentType(agsDialogTypes.DEFAULT_TASKS_OPTIONS);
  1821. dlgSubmit();
  1822. }
  1823. function showNotificationList() {
  1824. dlgReset();
  1825. dlgSetParm("m", "/ags/notificationList.xts");
  1826. initialiseAgentInfo();
  1827. //flag the dialog type
  1828. agsDialogTypes.setCurrentType(agsDialogTypes.NOTIFICATION_LIST);
  1829. dlgSubmit();
  1830. }
  1831. function showSequenceAgentTasks() {
  1832. dlgReset();
  1833. dlgSetParm("m", "/ags/seq_agent_tasks.xts");
  1834. initialiseAgentInfo();
  1835. //flag the dialog type
  1836. agsDialogTypes.setCurrentType(agsDialogTypes.SEQUENCE_AGENT_TASKS);
  1837. dlgSubmit();
  1838. }
  1839. function showSuppressionDialog() {
  1840. changeMenu('DataItems');
  1841. dlgReset();
  1842. //set in form vars
  1843. initialiseAgentInfo();
  1844. dlgSetParm("m", "/ags/suppressionDialog.xts");
  1845. //flag the dialog type
  1846. agsDialogTypes.setCurrentType(agsDialogTypes.SUPPRESSION);
  1847. dlgSubmit();
  1848. }
  1849. function showSchedule() {
  1850. dlgReset();
  1851. dlgSetParm("m", "/ags/scheduleController.xts");
  1852. dlgSetParm("ui.routingServerGroup", UI_ROUTING_SERVER_GROUP);
  1853. setScheduleParams();
  1854. //flag the dialog type
  1855. agsDialogTypes.setCurrentType(agsDialogTypes.SCHEDULE);
  1856. dlgSubmit();
  1857. }
  1858. function setScheduleParams()
  1859. {
  1860. // apparently we need to tell portal save us - that's it's us - le Agent Studio
  1861. dlgSetParm("agsSave_m_app", "AS");
  1862. //and just in case it colapses immediately....
  1863. dlgSetParm("m_app", "AS");
  1864. var messageIFrame = getMessageIFrame();
  1865. var messageIFrame_doc = getFrameDocument(messageIFrame);
  1866. var need_cred = true;
  1867. // send in all the values from messageIFrame
  1868. for (var i = 0; i < messageIFrame_doc.pform.elements.length; ++i) {
  1869. // get the type of the control
  1870. var ele = messageIFrame_doc.forms[0].elements[i]
  1871. var type = ele.type;
  1872. var name = ele.name;
  1873. if (type == 'hidden') {
  1874. if (name.indexOf("AgentTask-schedule") > -1) {
  1875. dlgSetParm("scheduleParameters",ele.value);
  1876. } else if (name.indexOf("AgentTask-") > -1) {
  1877. dlgSetParm(name,ele.value);
  1878. } else if (name.indexOf("agent_definition_blob") > -1) {
  1879. dlgSetParm(name,ele.value);
  1880. } else if (name.indexOf("m_sp_credential") > -1 && (!ele.value || ele.value != '')) {
  1881. need_cred = false;
  1882. }
  1883. }
  1884. }
  1885. if(need_cred){
  1886. dlgSetParm("h_CAM_action", "generateTC");
  1887. }
  1888. var spec = getConfigFrame().cfgGet('inlineSpec');
  1889. dlgSetParm("agentReportSpec",spec);
  1890. }
  1891. function showDataItem(action,nodeRef) {
  1892. if(action== 'add' || confirm(agentItemsChangeWarning)) {
  1893. dlgReset();
  1894. if (nodeRef && nodeRef != 'undefined' && nodeRef != '') {
  1895. dlgSetParm("nodeRef", nodeRef);
  1896. }
  1897. dlgSetParm("m", "/ags/defineDataItem.xts");
  1898. dlgSetParm("method", action);
  1899. //flag the dialog type
  1900. agsDialogTypes.setCurrentType(agsDialogTypes.DATAITEMS);
  1901. dlgSubmit();
  1902. }
  1903. }
  1904. function showParameters(action, nodeRef) {
  1905. if(action== 'add' || confirm(parameterChangeWarning)) {
  1906. commandStackHideDialogFrame()
  1907. dlgReset();
  1908. if (nodeRef && nodeRef != 'undefined' && nodeRef != '') {
  1909. dlgSetParm("nodeRef", nodeRef);
  1910. }
  1911. dlgSetParm("m", "/ags/defineParameter.xts");
  1912. dlgSetParm("method", action);
  1913. //flag the dialog type
  1914. agsDialogTypes.setCurrentType(agsDialogTypes.PARAMETERS);
  1915. dlgSubmit();
  1916. }
  1917. }
  1918. function insertDataItem(uiNodeTreeRef, tree) {
  1919. if (!uiNodeTreeRef || uiNodeTreeRef == 'undefined' || !tree || tree == 'undefined') {
  1920. return false;
  1921. }
  1922. var node = getTreeNode(tree, uiNodeTreeRef);
  1923. var selectedTreeObj = node.getTree();
  1924. // get all the selected nodes
  1925. var selectedNodes = selectedTreeObj.getSelectionOrder();
  1926. for (var i = 0; i < selectedNodes.length; i++) {
  1927. var nodeObj = selectedNodes[i];
  1928. addAgentItem(nodeObj.getValue());
  1929. }
  1930. //the agent has changed, so set the global configuration variable
  1931. cf.agentHasChanged(true);
  1932. }
  1933. function showContextMenu(event,isSourceMainDiv) {
  1934. // Menu Styles
  1935. var gMenuStyle = new CUIStyle('menuContainer', '', '', '', '');
  1936. var gMenuItemStyle = new CUIStyle('menuItem_normal', 'menuItem_hover', 'menuItem_pressed', '', 'menuItem_disabled');
  1937. var cf = getConfigFrame();
  1938. var uiNodeTreeRef = '';
  1939. if (!isSourceMainDiv || isSourceMainDiv == 'undefined') {
  1940. //get UI Node
  1941. var uiNode = getUINode(event);
  1942. uiNodeTreeRef = uiNode.getAttribute('treeRef').toString();
  1943. //get the tree object
  1944. var tree = uiNode.getAttribute('tree').toString();
  1945. //get tree Node
  1946. var node = getTreeNode(tree, uiNodeTreeRef);
  1947. if (node && !node.isSelected()) {
  1948. node.getTree().deSelectAll();
  1949. selectNode(event);
  1950. }
  1951. }
  1952. cf.gQsContextMenu = new CMenu('contextMenu',gMenuStyle);
  1953. var visibleTree = cfgGet("lastMenu");
  1954. var editAction = "";
  1955. var deleteAction = "";
  1956. var command = "getConfigFrame().getCommandStackManager().initiateCommandStack('checkCAF()',";
  1957. if ((visibleTree == TAB_MODEL || visibleTree == TAB_MEMBERS) && node && node.isSelected) {
  1958. var nodeType = node.getNodeType();
  1959. var nodeTypeObject = node.getNodeTypeObject();
  1960. var nodeTypeValue = node.getValue().type;
  1961. var menuItem = menuItemMap['asDataItem'];
  1962. if (nodeTypeObject.m_oProps.isAgentItemsInsertable()) {
  1963. menuItem.enable();
  1964. cfgSet("asDataItemState", true);
  1965. new CMenuItem(cf.gQsContextMenu, dialogContextMenuInsertDataItem_string, "DIALOG_CONTEXTMENU_INSERT_DATAITEM", 'getConfigFrame().insertDataItem("' + uiNodeTreeRef + '","' + tree + '");', '', gMenuItemStyle);
  1966. } else {
  1967. menuItem.disable();
  1968. cfgSet("asDataItemState", false);
  1969. }
  1970. // also want to add search capabilities too
  1971. if (nodeTypeValue == K_sHIERARCHY || nodeTypeValue == K_sLEVEL || nodeTypeValue == K_sMEMBER) {
  1972. var nodeValuePath = node.getValue().path;
  1973. var nodeValueType = node.getValue().type;
  1974. new CMenuItem(cf.gQsContextMenu, dialogContextMenuSearch_string, "DIALOG_CONTEXTMENU_SEARCH", 'getConfigFrame().selectMember("' + nodeValuePath + '","' + nodeValueType + '");', '../ags/images/tree/member_search.gif', gMenuItemStyle);
  1975. }
  1976. } else if (visibleTree == TAB_DATAITEMS) {
  1977. new CMenuItem(cf.gQsContextMenu, dialogContextMenuCalculation_string, "DIALOG_CONTEXTMENU_CALCULATION", command + "'showDataItem(\"add\")');", '../ags/images/menu/action_new_calculation.gif', gMenuItemStyle);
  1978. editAction = command + "'showDataItem(\"edit\",\"" + uiNodeTreeRef + "\")');";
  1979. deleteAction = command + "'deleteAgentItems()');";
  1980. } else if (visibleTree == TAB_PARAMETERS) {
  1981. new CMenuItem(gQsContextMenu, dialogContextMenuParameter_string, "DIALOG_CONTEXTMENU_PARAMETER", command + "'showParameters(\"add\")');", '../ags/images/menu/action_new_parameter.gif', gMenuItemStyle);
  1982. editAction = command + "'showParameters(\"edit\",\"" + uiNodeTreeRef + "\")');";
  1983. deleteAction = command + "'deleteParameters()');";
  1984. }
  1985. if (editAction && editAction.length > 0 && node && node.isSelected) {
  1986. new CMenuItem(gQsContextMenu, dialogContextMenuEditCalculation_string, "DIALOG_CONTEXTMENU_EDIT_DEFINITION", editAction, '', gMenuItemStyle);
  1987. new CMenuItem(gQsContextMenu, dialogContextMenuDeleteCalculation_string, "DIALOG_CONTEXTMENU_DELETE", deleteAction, '../ags/images/menu/action_delete.gif', gMenuItemStyle);
  1988. }
  1989. if (cf.gQsContextMenu.getNumItems() > 0) {
  1990. displayContextMenu(event);
  1991. }
  1992. }
  1993. function displayContextMenu(event) {
  1994. cf.gQsContextMenu.draw();
  1995. menu = cf.gQsContextMenu.getHTMLDiv();
  1996. menu.style.position="absolute";
  1997. var event_source = event.srcElement?event.srcElement:event.target;
  1998. var pos_x = 0;
  1999. var pos_y = 0;
  2000. if (event.pageX) {
  2001. pos_x = event.pageX;
  2002. pos_y = event.pageY;
  2003. } else if (event.clientX) {
  2004. pos_x = event.clientX;
  2005. pos_y = event.clientY;
  2006. }
  2007. cf.gQsContextMenu.setXCoord(pos_x);
  2008. cf.gQsContextMenu.setYCoord(pos_y);
  2009. cf.document.body.getWndObserver().addListener(cf.gQsContextMenu, removeContextMenu, "mouseup");
  2010. cf.document.body.getWndObserver().addListener(cf.gQsContextMenu, removeContextMenu, "resize");
  2011. //setRemoveMenu();
  2012. cf.gQsContextMenu.show();
  2013. }
  2014. function removeContextMenu() {
  2015. cf.gQsContextMenu.remove();
  2016. //Remove the listener
  2017. cf.document.body.getWndObserver().removeListener(cf.gQsContextMenu);
  2018. }
  2019. function resendResetEventList() {
  2020. getCommandStackManager().getCommandStack().push("resetEventList()");
  2021. getCommandStackManager().getCommandStack().push("doWait('resetEventList')");
  2022. }
  2023. function resetEventList() {
  2024. var msgFrame = getMessageIFrame();
  2025. var frameDoc = getFrameDocument(msgFrame);
  2026. var holder = new Object();
  2027. var blob = frameDoc.pform.agent_definition_blob.value;
  2028. holder['agent_definition_blob'] = blob;
  2029. holder['m'] = "/ags/reset_event_list.xts";
  2030. holder['forceSOAPFault']='false';
  2031. var dispatcher = new parent.cf.XHTTPDispatcher(resetEventListProcessResponse, holder);
  2032. applicationActionManager.httpStart();
  2033. try{
  2034. dispatcher.dispatch();
  2035. }catch(ex){
  2036. applicationActionManager.httpStop();
  2037. }
  2038. }
  2039. function resetEventListProcessResponse(responseArray)
  2040. {
  2041. var responseXML = responseArray[0];
  2042. var responseText = responseArray[1];
  2043. if(doClosePopUp){
  2044. //Now close the popup wait.
  2045. doClosePopUp();
  2046. }
  2047. applicationActionManager.httpStop();
  2048. var messageNode = responseXML.getElementsByTagName('message');
  2049. var parsedResponse = parseResponse(responseXML,responseText);
  2050. // decide what we're going to do
  2051. if (parsedResponse.isLogonFault()) {
  2052. // if the passport expired
  2053. doPassportExpire(responseXML,resendResetEventList,parsedResponse);
  2054. } else if (parsedResponse.isSoapFault()) {
  2055. // we have a fault which is a genuine fault fault
  2056. doSOAPFault(responseXML,null,parsedResponse);
  2057. } else if (messageNode.length == 1) {
  2058. var message = getTextNodeValue(messageNode[0]);
  2059. var command = "resetEventListDisplayResponse('" + message + "');";
  2060. setTimeout(command,100);
  2061. } else {
  2062. // check the text response to see if we got a html page back in the response
  2063. if (parsedResponse.isHTML() && !parsedResponse.isEmptyBody()) {
  2064. doHTMLResponse(responseText);
  2065. }
  2066. }
  2067. }
  2068. function resetEventListDisplayResponse(message) {
  2069. if (message) {
  2070. // none of the above
  2071. alert(message);
  2072. }
  2073. }
  2074. /*
  2075. * Highlight one of the items in the task list menu
  2076. */
  2077. function makeSelection(type){
  2078. if(applicationActionManager.isBlocked()){
  2079. return;
  2080. }
  2081. if(type != K_sCondition &&
  2082. type != K_sSchedule &&
  2083. type != K_sSuppression &&
  2084. type != K_sSetSubmit){
  2085. type = K_sAddAgentTask;
  2086. }
  2087. //reset the task list so that all the items are deselected
  2088. deSelectAll();
  2089. //set the style for the current item
  2090. setTaskState(type,K_cssTaskActive);
  2091. }
  2092. /*
  2093. * deselect all tasks
  2094. */
  2095. function deSelectAll(){
  2096. var taskList = new Array(5);
  2097. taskList[0] = K_sCondition;
  2098. taskList[1] = K_sSchedule;
  2099. taskList[2] = K_sAddAgentTask;
  2100. taskList[3] = K_sSuppression;
  2101. taskList[4] = K_sSetSubmit;
  2102. //set all tasks as inactive
  2103. for (i=0; i<5; i++)
  2104. {
  2105. setTaskState(taskList[i],K_cssTaskInactive);
  2106. }
  2107. }
  2108. /*
  2109. * common function to set a task type as active or inactive
  2110. * no action is taken if the task is already in the target state
  2111. */
  2112. function setTaskState(taskType,style) {
  2113. //get the task div
  2114. var selTask = agsFormUtils.getElementByIdOrName(taskType);
  2115. //set the active style if not already set
  2116. if(selTask!=null && selTask.className != style) {
  2117. //alert('setting state '+style+' for '+taskType);
  2118. selTask.className=style;
  2119. }
  2120. }
  2121. /*
  2122. general handler for the response generated by the select Object modal dialog
  2123. if more dialogs use the modal way (the way of the modal), this could be moddeded
  2124. */
  2125. function ccModalCallBack(cmd, response){
  2126. if(cmd != 'ok' || !response){
  2127. //perhaps a reason on cancel?
  2128. doClosePopUp();
  2129. parent.document.getElementById("messageIFrame").focus();
  2130. }else{
  2131. reloadAfterSelectObject(response);
  2132. }
  2133. }
  2134. // select the tab
  2135. function doSelectObject(mode, defaultObject)
  2136. {
  2137. if(applicationActionManager.isBlocked()){
  2138. return;
  2139. }
  2140. hideDialogFrame();
  2141. dlgReset();
  2142. //this is in cmd
  2143. initialiseDialog();
  2144. dlgSetParm("m_app", "AS");
  2145. dlgSetParm("m", '/portal/select/select.xts');
  2146. dlgSetParm("so.select", mode);
  2147. dlgSetParm("so.return_m", "/ags/dialogAdapter.xts");
  2148. dlgSetParm("md.callBack", "data");
  2149. if(defaultObject){
  2150. dlgSetParm("so.defaultObject", defaultObject);
  2151. dlgSetParm("so.defaultLocation", defaultObject + "/..");
  2152. } else {
  2153. var path = cfgGet("so.defaultLocation");
  2154. var selectedPath = getSelectedPath(mode);
  2155. if (path && selectedPath == false) {
  2156. dlgSetParm("so.defaultLocation", path);
  2157. }
  2158. }
  2159. dlgSubmit("popUpFrame");
  2160. }
  2161. /*Check to see if it is type of these tasks if so we don't want to set the
  2162. defaultLocation. Must be Administrator folder let the portal handle it.*/
  2163. function getSelectedPath(mode) {
  2164. if (mode == "importDeployment.es"
  2165. || mode == "exportDeployment.es"
  2166. || mode == "contentTask.es"
  2167. || mode == "indexUpdateTask.es"
  2168. || mode == "migrationTask.es"
  2169. || mode == "planningMacroTask.es") {
  2170. return true;
  2171. }
  2172. return false;
  2173. }
  2174. // check browser
  2175. function isIE()
  2176. {
  2177. return (navigator.userAgent.indexOf('MSIE') != -1);
  2178. }
  2179. //looking for return/object/value
  2180. function reloadAfterSelectObject(response){
  2181. if(!response){
  2182. doClosePopUp();
  2183. return
  2184. }
  2185. response = decode(response);
  2186. var xml = new XMLBuilderLoadXMLFromString(response);
  2187. if(!xml){
  2188. doClosePopUp();
  2189. return;
  2190. }
  2191. var items = xml.getElementsByTagName("item");
  2192. var searchPath = "";
  2193. for(var i = 0; i < items.length; i++){
  2194. var nameEl = items[i].firstChild;
  2195. if (window.clipboardData) {
  2196. if(typeof nameEl.text != "undefined" && nameEl.text == "storeID"){
  2197. searchPath = items[i].lastChild ? items[i].lastChild.text : "";
  2198. break;
  2199. }
  2200. //In IE11, the "text" attribute was removed from IXMLDOMElement.
  2201. else if(typeof nameEl.text == "undefined" && nameEl.textContent == "storeID"){
  2202. searchPath = items[i].lastChild ? items[i].lastChild.textContent : "";
  2203. break;
  2204. }
  2205. } else {
  2206. if(nameEl.textContent.toString() == "storeID"){
  2207. searchPath = items[i].lastChild ? items[i].lastChild.textContent.toString() : "";
  2208. break;
  2209. }
  2210. }
  2211. }
  2212. dlgReset();
  2213. //this is in cmd
  2214. initialiseDialog();
  2215. var use_case = getSelectUseCase();
  2216. if(use_case && use_case == "agents.es"){
  2217. dlgSetParm("m", "/ags/pre_load_agent.xts");
  2218. }else{
  2219. dlgSetParm("m", "/ags/dialogAdapter.xts");
  2220. }
  2221. dlgSetParm("selected_path", searchPath);
  2222. // set agent state
  2223. cf.agentHasChanged(true);
  2224. //flag the pop up for closure
  2225. doSetPopUpClosureFlag();
  2226. applicationActionManager.allowActions();
  2227. dlgSubmit("messageIFrame");
  2228. //the loading frame will unblock this
  2229. applicationActionManager.blockActions();
  2230. }
  2231. function getSelectUseCase(){
  2232. var selectUseCase = "";
  2233. var puf = getPopUpFrame();
  2234. var popUpForm;
  2235. if(puf && puf.document && puf.document.forms && puf.document.forms.length > 0 && puf.document.forms[0]){
  2236. //that was bordering on paranoia!
  2237. popUpForm = puf.document.forms[0];
  2238. }else{
  2239. return selectUseCase;
  2240. }
  2241. if(popUpForm["so.select"]){
  2242. selectUseCase = popUpForm["so.select"].value;
  2243. }
  2244. return selectUseCase;
  2245. }
  2246. /**
  2247. Go through the three sets of menus that we have.
  2248. for each one obtain its capabilty and make sure
  2249. it is valid. If it is the menu will be shown
  2250. otherwise it will be hidden.
  2251. This is called from init_model.xts where the
  2252. package capabilities are obtained and added into
  2253. and array and set using cfgSet. The 3 menu arrays
  2254. come from menu.xslt, toolbar.xslt, and menubar.xslt.
  2255. Only menus that have capabilities are added here.
  2256. The excpetion is menuItemMap where menus with keys
  2257. are added additionaly.
  2258. */
  2259. function resetMenus() {
  2260. var capabilities = cfgGet("userCapabilities");
  2261. for (var obj in menuItemMap) {
  2262. checkMenuCapability(menuItemMap[obj],capabilities);
  2263. }
  2264. for (var obj in tasksMenuMap) {
  2265. checkMenuCapability(tasksMenuMap[obj],capabilities);
  2266. }
  2267. // this contains menus and toolbar buttons. (both implement getCapability)
  2268. for (var obj in toolbarMenuMap) {
  2269. checkMenuCapability(toolbarMenuMap[obj],capabilities);
  2270. }
  2271. var topSpacer = document.getElementById("schedule_topSpacer");
  2272. var scheduleSpacer = document.getElementById("schedule_spacer");
  2273. var scheduleElement = document.getElementById("schedule");
  2274. //alert(topSpacer + ", " + scheduleSpacer + ", " + scheduleElement);
  2275. var canUseSchedule = new RegExp("canUseScheduling","i").test(capabilities);
  2276. if (topSpacer) {
  2277. topSpacer.style.display = canUseSchedule?"":"none";
  2278. }
  2279. if (scheduleSpacer) {
  2280. scheduleSpacer.style.display = canUseSchedule?"":"none";
  2281. }
  2282. if (scheduleElement) {
  2283. scheduleElement.style.display = canUseSchedule?"":"none";
  2284. }
  2285. }
  2286. function checkMenuCapability(menuItem,capabilities) {
  2287. if (menuItem) {
  2288. var capability = menuItem.getCapability();
  2289. if (capability && capability != "") {
  2290. var found = new RegExp(capability,"i").test(capabilities);
  2291. if (found) {
  2292. menuItem.show();
  2293. } else {
  2294. menuItem.hide();
  2295. }
  2296. }
  2297. }
  2298. }
  2299. //copied from rv
  2300. function processViewerMarkup(sId, sHTML)
  2301. {
  2302. var markup = sHTML;
  2303. var context = window[sId + "iContext"];
  2304. if (context != null && typeof context != "undefined")
  2305. {
  2306. markup = context.processMarkup(sHTML);
  2307. }
  2308. return markup;
  2309. }