config.js 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892
  1. /********************************************************************************************************************************
  2. * Licensed Materials - Property of IBM *
  3. * *
  4. * IBM Cognos Products: AGS *
  5. * *
  6. * (C) Copyright IBM Corp. 2005, 2010 *
  7. * *
  8. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *
  9. *********************************************************************************************************************************/
  10. //define the object that will check the keydown for hot keys
  11. var keyDownChecker = new Object();
  12. keyDownChecker.check = checkForHotKeyActions;
  13. keyDownChecker.update = function() {
  14. return true;
  15. }
  16. var browserCheck = new BrowserCheck();
  17. //define the hotkeys that are allowed to be processed
  18. var allowedHotkeys = new Array();
  19. //K,C,V,X,A
  20. allowedHotkeys[K_sKeyCode_K]=true;
  21. allowedHotkeys[K_sKeyCode_C]=true;
  22. allowedHotkeys[K_sKeyCode_V]=true;
  23. allowedHotkeys[K_sKeyCode_X]=true;
  24. allowedHotkeys[K_sKeyCode_A]=true;
  25. var saveChangesToDialogFrame=false;
  26. //
  27. // the variable "cfgValues" must have been defined in one the files including this script file.
  28. // It is done this way to ensure we have only one valid definition of "cfgValues"
  29. //
  30. var CURRENT_TIP = "infoItemTip";
  31. var CURRENT_TIP_SYNTAX = "infoItemSyntax";
  32. var CURRENT_ERROR_DIV_ID_KEY = "CURRENT_ERROR_DIV_ID_KEY";
  33. var DIALOG_FRAME_ID = "dialogIFrame";
  34. // var for event studio errors
  35. var pageErrors = new Array();
  36. // progressbar handle
  37. var g_divProgressBar;
  38. if ( window == window.top ) {
  39. try {
  40. // Sometimes causes "Access is denied" exception
  41. window.moveTo( 0,0 );
  42. window.resizeTo( screen.availWidth, screen.availHeight );
  43. }
  44. catch ( e ) { };
  45. };
  46. var dialogFormValues = new Array();
  47. var asyncFormValues = new Array();
  48. var cfgValues = new Array();
  49. var __preview_win = null;
  50. // These are the languages that are supported by Cognos Connection documentation
  51. var sSupportedLangs = " en fr ja de ";
  52. var sDefaultLang = "en";
  53. //
  54. // --- Configuration management functions ---
  55. //
  56. function cfgSet(n, v) { cfgValues[n] = v; }
  57. function cfgGet(n) { return cfgValues[n]; }
  58. function cfgRemove(n) { delete cfgValues[n]; }
  59. function cfgIsArray(a) {
  60. return isArray(cfgValues[a]);
  61. }
  62. function cfgPush(a, v) {
  63. if (!cfgIsArray(a)) cfgValues[a] = cfgMakeArray(a);
  64. addToArray(cfgValues[a], v);
  65. }
  66. function cfgAddParm(n, v) {
  67. if (!isArray(cfgValues[n]))
  68. cfgValues[n] = makeArray(cfgValues[n]);
  69. addToArray(cfgValues[n], v);
  70. }
  71. function cfgSetDefaultAt(i) {
  72. cfgSetAt("ColFormat", i, new Array("none"));
  73. cfgSetAt("IsHidden",i, false);
  74. cfgSetAt("OriginalLabels",i,"");
  75. cfgSetAt("calcOp",i,"");
  76. cfgSetAt("SummaryAgg",i,"none");
  77. cfgSetAt("DetailAgg",i,"none");
  78. cfgSetAt("RegularAgg",i,"none");
  79. cfgSetAt("sortOnRef",i,"none");
  80. cfgSetAt("promptCascadeOnRef",i,"none");
  81. cfgSetAt("PromptType",i,"0");
  82. cfgSetAt("ColFilterIdx",i,"");
  83. cfgSetAt("ColLabels",i,"");
  84. cfgSetAt("IsFakeMeasure",i,false);
  85. cfgSetAt("IsMeasure",i,false);
  86. cfgSetAt("IsCollapsed",i,false);
  87. cfgSetAt("ColRole",i,"Ungrouped");
  88. cfgSetAt("HasSummaries",i,false);
  89. cfgSetAt("displayType",i,"");
  90. }
  91. function cfgSetColAt(i, v1, v2, v3, v4, v5, v6, v7) {
  92. cfgSetAt("QueryIDs",i,v1);
  93. cfgSetAt("ColType",i,v2);
  94. cfgSetAt("ColUsage",i,v3);
  95. cfgSetAt("ColSort",i,v4);
  96. cfgSetAt("ColSortBy",i,v5);
  97. cfgSetAt("ColIDs",i,v6);
  98. cfgSetAt("ColOldType",i,v7);
  99. }
  100. function cfgSetAt(a, i, v) {
  101. if (!cfgIsArray(a)) cfgValues[a] = cfgMakeArray(a);
  102. insertInArrayAt(cfgValues[a], i, v);
  103. }
  104. function cfgGetAt(a, i) {
  105. if (!cfgIsArray(a)) return null;
  106. return cfgValues[a][i];
  107. }
  108. function cfgPop(a, v) {
  109. if (!cfgIsArray(a)) return;
  110. var bRemoved=false;
  111. var size=cfgValues[a].length;
  112. for (var i=0;i<size;i++) {
  113. if (!bRemoved && cfgValues[a][i]==v) bRemoved=true;
  114. if (bRemoved && i+1<size) cfgValues[a][i]=cfgValues[a][i+1];
  115. }
  116. if (bRemoved) cfgValues[a].length=size-1;
  117. }
  118. function cfgSize(a) {
  119. if (cfgIsArray(a)) return cfgValues[a].length;
  120. return 0;
  121. }
  122. function cfgIndexOf(a, v) {
  123. if (!cfgIsArray(a)) return -1;
  124. for (var i=0; i<cfgValues[a].length; i++)
  125. if (cfgValues[a][i]==v) return i;
  126. return -1;
  127. }
  128. function cfgMakeArray(a) {
  129. return makeArray(cfgValues[a]);
  130. }
  131. //
  132. // --- Array management functions ---
  133. //
  134. function addToArray(a, v) { if (!contains(a, v)) a[a.length] = v; }
  135. function insertInArrayAt(a, i, v) { a[i] = v; }
  136. function makeArray(a) {
  137. if (a == null || typeof a == "undefined")
  138. a = new Array();
  139. else if (typeof a != "object") {
  140. var tmp = a; a = new Array(); a[0] = tmp;
  141. }
  142. return a;
  143. }
  144. function contains(a, v) {
  145. for (var i in a)
  146. if (i == v) return true;
  147. return false;
  148. }
  149. function isArray(a) {
  150. if (a != null && typeof a == "object") return true;
  151. return false;
  152. }
  153. // -----------------------------------------------------------------------------
  154. //
  155. // --- Configuration utilities functions ---
  156. //
  157. // -----------------------------------------------------------------------------
  158. function reinitConfigValues() {
  159. cfgValues = new Array();
  160. cfgSet("productLocale", "en");
  161. cfgSet("contentLocale", "en-US");
  162. cfgSet("numRows", "20");
  163. cfgSet("NewReport", false);
  164. }
  165. function showMeTheValues(event, bShow) {
  166. if (event.shiftKey && event.ctrlKey) {
  167. switch (getKeyCode(event)) {
  168. //Crtl-Shift-F Show the agent studio form inputs
  169. case 70:
  170. showFormValues();
  171. break;
  172. case 67:
  173. showConfigValues();
  174. break;
  175. case 68:
  176. showDialogValues();
  177. break;
  178. case 65:
  179. getAgentItemsListener().displayState();
  180. break;
  181. }
  182. }else{
  183. switch (getKeyCode(event)) {
  184. case 46:
  185. deleteSelectedItem();
  186. break;
  187. case 27:
  188. doClosePopUp();
  189. break;
  190. }
  191. }
  192. }
  193. function getKeyCode(evt){
  194. var evt = (evt) ? evt : (window.event) ? event : null;
  195. if (evt) {
  196. var charCode = (evt.keyCode) ? evt.keyCode :((evt.which) ? evt.which : 0);
  197. }
  198. return charCode;
  199. }
  200. function showConfigValues() {
  201. var w = window.open("../qs/blank.html", "_trace_window_");
  202. w.document.writeln("<p>Config values ["+(new Date())+"]</p>");
  203. w.document.writeln("<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\"><th>name</th><th>value(s)</th>");
  204. //SEC_INFO: cfgValues[i] can contain the values set in the session parameters
  205. for (i in cfgValues) w.document.writeln("<tr><td style=\"color:blue\">"+i+"</td><td style=\"color:blue\">"+htmlEncode(printValue(cfgValues[i]))+"</td></tr>");
  206. w.document.writeln("</table>");
  207. }
  208. function showDialogValues() {
  209. var w = window.open("../qs/blank.html", "_trace_window_");
  210. w.document.writeln("<p>Dialog values ["+(new Date())+"]</p>");
  211. w.document.writeln("<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\"><th>name</th><th>value(s)</th>");
  212. for (i in dialogFormValues)
  213. w.document.writeln("<tr><td style=\"color:blue\">"+i+"</td><td style=\"color:blue\">"+htmlEncode(printValue(dialogFormValues[i]))+"</td></tr>");
  214. w.document.writeln("</table>");
  215. }
  216. /*
  217. * Display all the form controls in the message frame
  218. */
  219. function showFormValues() {
  220. var msgFrame = getMessageIFrame();
  221. var msgDoc = getFrameDocument(msgFrame);
  222. var forms = msgDoc.forms;
  223. var w = window.open("../ags/blank.html", "_trace_window_");
  224. w.document.write("<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN'><html><head><title>Agent Studio Message Frame Form Values</title></head><body>");
  225. w.document.write("<h1>Agent Studio Form Values ["+(new Date())+"]</h1>");
  226. w.document.write("<table border='1' summary='a list of form controls with id, name and value columns'>");
  227. //loop through the forms in the message frame
  228. for (var i=0;i<forms.length;i++) {
  229. var form = forms[i];
  230. w.document.write("<tr><td colspan='3'>Morphlet:"+form.m.value +". Found "+form.length+" input controls in "+form.name+"</td></tr>");
  231. w.document.write("<tr><th>id</th><th>name</th><th>value</th></tr>");
  232. //loop through the controls in the form
  233. for (var j=0;j<form.length;j++) {
  234. var control = form.elements[j];
  235. var type = form.elements[j].type;
  236. var outputElement = true;
  237. if ((type=='radio' || type=='checkbox') && !control.checked) {
  238. outputElement = false;
  239. }
  240. if (outputElement) {
  241. var styleGo = "style='color:green'";
  242. var styleStop = "style='color:red'";
  243. var blankCell="<td "+styleStop+">NONE</td>"
  244. w.document.write("<tr>");
  245. if (control.id != "") {
  246. // SEC_INFO: control property values are contants
  247. w.document.write("<td "+styleGo+">"+htmlEncode(control.id)+"</td>");
  248. }
  249. else {
  250. w.document.write(blankCell);
  251. }
  252. if (control.name != undefined) {
  253. // SEC_INFO: control property values are contants
  254. w.document.write("<td "+styleGo+">"+htmlEncode(control.name)+"</td>");
  255. }
  256. else {
  257. w.document.write(blankCell);
  258. }
  259. if (control.value != "") {
  260. // SEC_INFO: control property values are contants
  261. w.document.write("<td "+styleGo+">"+htmlEncode(control.value)+"</td>");
  262. }
  263. else {
  264. w.document.write(blankCell);
  265. }
  266. w.document.write("</tr>");
  267. }
  268. }
  269. }
  270. w.document.write("</table></body>");
  271. return;
  272. }
  273. function printValue(n) {
  274. if (n == null) return "null";
  275. if (typeof n == "object" && n.length>0) { var t = ""; for (var i in n) t+="<span style=\"color:black\">"+i+". </span>"+n[i]+"<br/>"; return t }
  276. return n;
  277. }
  278. function traceObject(obj) {
  279. var w = window.open("../qs/blank.html", "_trace_window_");
  280. w.document.writeln("<p>Output of an object. ["+(new Date())+"]</p>");
  281. w.document.writeln("<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\"><th>name</th><th>value(s)</th>");
  282. for (i in obj) w.document.writeln(htmlEncode("<tr><td>"+i+"</td><td>"+obj[i]+"</td></tr>"));
  283. w.document.writeln("</table>");
  284. }
  285. function getConnectionParametersSet(configKey){
  286. //get the connection parameters
  287. var connectionParamParser = getConnectionParameterValuesParser(configKey);
  288. //collect all name elements from the connection params
  289. var pv_elements = getElementsByLocalName(connectionParamParser, "item", true);
  290. var connection_name_set = new Object();
  291. for(var i = 0; i< pv_elements.length; i++){
  292. var name_string = getElementsByLocalName(pv_elements[i], "name", true);
  293. var value_string = pv_elements[i].getValue();
  294. connection_name_set[name_elements[i].getValue()] = value_string;
  295. }
  296. }
  297. //normalise parameter values using a parser
  298. //and strip out all but connection prompts
  299. function saveParameterValues(parameters, configKey){
  300. //get the connection parameters
  301. var connectionParamParser = getConnectionParameterValuesParser(configKey);
  302. //get the other parameters
  303. var otherParmItemParserArray = otherParmItemParserArray = new Array();
  304. //collect all name elements from the connection params
  305. var name_elements = getElementsByLocalName(connectionParamParser, "name", true);
  306. var connection_name_set = new Object();
  307. for(var i = 0; i< name_elements.length; i++){
  308. connection_name_set[name_elements[i].getValue()] = true;
  309. }
  310. for (var i = 0; i < parameters.length; i++)
  311. {
  312. if(!(parameters[i] instanceof XMLElement)){
  313. parameters[i] = new XMLParser(parameters[i]);
  314. }
  315. var param_name_element = findChildByLocalName(parameters[i], "name", false);
  316. var param_name = param_name_element ? param_name_element.getValue() : null;
  317. if(!param_name){
  318. continue;
  319. }
  320. if(param_name.indexOf("credential:") == 0){
  321. if(!connection_name_set[param_name]){
  322. //save it
  323. connectionParamParser.appendChild(parameters[i]);
  324. }
  325. }else{
  326. otherParmItemParserArray.push(parameters[i]);
  327. }
  328. }
  329. // set the connection parameter values so that we aren't prompted again
  330. cfgSet(configKey + "connectionParameterValues", connectionParamParser.toString());
  331. //also hang on to the other prompt values
  332. cfgSet(configKey + "otherParameterValues", otherParmItemParserArray);
  333. }
  334. function initConnectionParameterValues(configKey){
  335. var pvWrapper = "<bus:parameterValues xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xsi:type=\"SOAP-ENC:Array\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" SOAP-ENC:arrayType=\"bus:parameterValue[]\" xmlns:bus=\"http://developer.cognos.com/schemas/bibus/3/\"/>";
  336. cfgSet(configKey + "connectionParameterValues", pvWrapper);
  337. return pvWrapper;
  338. }
  339. function getConnectionParameterValuesParser(configKey){
  340. //get the connection parameters
  341. var connectionParams = cfgGet(configKey + "connectionParameterValues");
  342. if (!connectionParams) {
  343. connectionParams = initConnectionParameterValues(configKey);
  344. }
  345. return new XMLParser(connectionParams)
  346. }
  347. function getConnectionParameterValues(configKey){
  348. return getConnectionParameterValuesParser(configKey).toString();
  349. }
  350. //returns the pvs inthe form of a parameterValues prop
  351. function getAllParameterValuesParser(configKey){
  352. //get the connection parameters
  353. var paramParser = getConnectionParameterValuesParser(configKey);
  354. var otherParams = cfgGet(configKey + "otherParameterValues");
  355. if(otherParams){
  356. for(var i = 0; i < otherParams.length; i++){
  357. paramParser.appendChild(otherParams[i]);
  358. }
  359. }
  360. //these are a one hit wonder
  361. cfgRemove(configKey + "otherParameterValues");
  362. return paramParser;
  363. }
  364. //returns the pvs inthe form of a parameterValues prop
  365. function getAllParameterValues(configKey){
  366. return getAllParameterValuesParser(configKey).toString();
  367. }
  368. //returns the pvs in the form of a parameters prop
  369. function getAllParameters(configKey){
  370. var parameterValues = getAllParameterValuesParser(configKey);
  371. parameterValues.nodeName = "value";
  372. var paramWrapper = "<parameters xsi:type=\"bus:parameterValueArrayProp\" xmlns:bus=\"http://developer.cognos.com/schemas/bibus/3/\">";
  373. var paramParser = new XMLParser(paramWrapper);
  374. paramParser.appendChild(parameterValues);
  375. return paramParser.toString();
  376. }
  377. //returns the pvs in the form of a parameters prop
  378. function getConnectionParameters(configKey){
  379. var parameterValues = getConnectionParameterValuesParser(configKey);
  380. parameterValues.nodeName = "value";
  381. var paramWrapper = "<parameters xsi:type=\"bus:parameterValueArrayProp\" xmlns:bus=\"http://developer.cognos.com/schemas/bibus/3/\">";
  382. var paramParser = new XMLParser(paramWrapper);
  383. paramParser.appendChild(parameterValues);
  384. return paramParser.toString();
  385. }
  386. getElementsByLocalName = function (node, s, deep)
  387. {
  388. var a = new Array();
  389. for (var i = 0; i < node.childNodes.length; i++) {
  390. if (node.childNodes[i].getName().indexOf(s) != -1) {
  391. a[a.length] = node.childNodes[i];
  392. }
  393. }
  394. if (deep != false) {
  395. for (i = 0; i < node.childNodes.length; i++) {
  396. var aChild = getElementsByLocalName(node.childNodes[i], s, deep);
  397. for (var j = 0; j < aChild.length; j++) {
  398. a[a.length] = aChild[j];
  399. }
  400. }
  401. }
  402. return a;
  403. }
  404. findChildByLocalName = function (node, n, deepWalk)
  405. {
  406. if (node.getName() == n) {
  407. return(node);
  408. }
  409. for (var i = 0; i < node.childNodes.length; i++) {
  410. if (node.childNodes[i].getName().indexOf(n) != -1) {
  411. return node.childNodes[i];
  412. }
  413. }
  414. if (deepWalk != false) {
  415. for (i = 0; i < node.childNodes.length; i++) {
  416. var foundChild = node.childNodes[i].findChildByName(n, deepWalk);
  417. if (foundChild) {
  418. return foundChild;
  419. }
  420. }
  421. }
  422. return null;
  423. };
  424. // -----------------------------------------------------------------------------
  425. //
  426. // Form-related functions
  427. // We used those functions to update the form that update the dialogs.
  428. //
  429. // -----------------------------------------------------------------------------
  430. function dlgGetParm(n) {
  431. if (dlgContains(n))
  432. return dialogFormValues[n];
  433. else
  434. return null;
  435. }
  436. function dlgSetParm(n, v) { dialogFormValues[n] = v; }
  437. function dlgRemoveParm(n) { if (dlgContains(n)) delete dialogFormValues[n]; }
  438. function dlgReset() {
  439. dialogFormValues = new Array();
  440. dlgSetParm("b_action", "xts.run");
  441. var productLocale = cfgGet("productLocale");
  442. if (productLocale != null && productLocale != "")
  443. dlgSetParm("productLocale", productLocale);
  444. var contentLocale = cfgGet("contentLocale");
  445. if (contentLocale != null && contentLocale != "")
  446. dlgSetParm("contentLocale", contentLocale);
  447. // apparently we need to tell portal save us - that's it's us - le Agent Studio
  448. dlgSetParm("agsSave_m_app", "AS");
  449. //and just in case it colapses immediately....
  450. dlgSetParm("m_app", "AS");
  451. }
  452. function dlgAddParm(n, v) {
  453. if (!isArray(dialogFormValues[n]))
  454. dialogFormValues[n] = makeArray(dialogFormValues[n]);
  455. addToArray(dialogFormValues[n], v);
  456. }
  457. // n is the parameter with 2 values
  458. // add to the n array a value x,y (unique, generated)
  459. // add x (generated) with value v1 and y (generated) with value v2
  460. function dlgAddPairParm(n, v1, v2) {
  461. var first = "genX";
  462. var second = "genY";
  463. // get unique names for parameters
  464. var ii=0;
  465. while (dlgContains(first+ii))
  466. ii++;
  467. first = first + ii;
  468. ii=0;
  469. while (dlgContains(second+ii))
  470. ii++;
  471. second = second + ii;
  472. dlgAddParm(n, first + "," + second);
  473. dlgSetParm(first, v1);
  474. dlgSetParm(second, v2);
  475. }
  476. function dlgContains(n) {
  477. return contains(dialogFormValues, n);
  478. }
  479. function dlgShowMessage(p1, p2, p3) {
  480. dlgReset();
  481. dlgSetParm("m", "/qs/message.xts");
  482. if (p1 != null && p1 != "") dlgSetParm("xxParm1", p1);
  483. if (p2 != null && p2 != "") dlgSetParm("xxParm2", p2);
  484. if (p3 != null && p3 != "") dlgSetParm("xxParm3", p3);
  485. dlgSubmit();
  486. }
  487. //
  488. // --------------- ASYNC -----------------
  489. //
  490. function asyncGetParm(n) {
  491. if (asyncContains(n))
  492. return asyncFormValues[n];
  493. else
  494. return null;
  495. }
  496. function asyncSetParm(n, v) { asyncFormValues[n] = v; }
  497. function asyncRemoveParm(n) { if (asyncContains(n)) delete asyncFormValues[n]; }
  498. function asyncReset() {
  499. asyncFormValues = new Array();
  500. asyncSetParm("b_action", "xts.run");
  501. asyncSetParm("app", cfgGet("APPLICATION_NAME"));
  502. var productLocale = cfgGet("productLocale");
  503. if (productLocale != null && productLocale != "")
  504. asyncSetParm("productLocale", productLocale);
  505. var contentLocale = cfgGet("contentLocale");
  506. if (contentLocale != null && contentLocale != "")
  507. asyncSetParm("contentLocale", contentLocale);
  508. var dti = cfgGet("disp_trackingInfo");
  509. if (dti != null && dti != "")
  510. asyncSetParm("disp_trackingInfo", dti);
  511. var pv = getConnectionParameterValues();
  512. if (pv != null && pv != "")
  513. asyncSetParm("connectionParameterValues", pv);
  514. // -- debug stuff --
  515. // BIQ writes the generatedrequest.xml
  516. asyncSetParm("BIQ", cfgGet("BIQ"));
  517. if (cfgGet("__DBG__"))
  518. asyncSetParm("debug", true);
  519. }
  520. function asyncAddParm(n, v) {
  521. if (!isArray(asyncFormValues[n]))
  522. asyncFormValues[n] = makeArray(asyncFormValues[n]);
  523. addToArray(asyncFormValues[n], v);
  524. }
  525. function asyncContains(n) {
  526. return contains(asyncFormValues, n);
  527. }
  528. function displayForm(f) {
  529. var t = "Parameters for form [" + f.id + "] for window \"" + f.target + "\" using " + f.action;
  530. var parms = f.document.getElementsByTagName("INPUT");
  531. for (var i = parms.length-1; i >= 0; i--)
  532. t += "\n\t" + parms[i].name + " = " + parms[i].value;
  533. trace(t);
  534. }
  535. function qsDefaults() {
  536. cfgSet("RowsDesired", 20);
  537. cfgSet("StartRow", 1);
  538. cfgSet("ReportTitle", "");
  539. cfgSet("ReportShowTitle", 0); /* 0 = "title" 1 = text */
  540. cfgSet("ReportShowSubTitle", 1); /* 0 = No subtitle, 1 = filters, 2 = text */
  541. cfgSet("ReportSubTitle", "");
  542. cfgSet("PDFUsePortrait", true);
  543. cfgSet("PDFPaperSize", "Letter");
  544. cfgSet("bUsePortrait", true);
  545. cfgSet("PaperSize", "Letter");
  546. cfgRemove("QueryIDs");
  547. cfgRemove("SelColumns");
  548. cfgRemove("ColLabels");
  549. cfgRemove("ColType");
  550. cfgRemove("ColUsage");
  551. cfgRemove("IsFakeMeasure");
  552. cfgRemove("ColExp");
  553. cfgRemove("ColIDs");
  554. cfgRemove("CutColumns");
  555. cfgRemove("ColRole");
  556. cfgRemove("ColGroupIDs");
  557. cfgRemove("HasSummaries");
  558. cfgRemove("IsHidden");
  559. cfgRemove("IsMeasure");
  560. cfgRemove("OriginalLabels");
  561. cfgRemove("ReportType");
  562. cfgRemove("ContextMenuActive");
  563. cfgRemove("ActionRunning");
  564. cfgRemove("DialogSize");
  565. cfgRemove("DialogExecFunc");
  566. cfgRemove("DialogSelCols");
  567. cfgRemove("FormatType");
  568. cfgRemove("FormatDecimals");
  569. cfgRemove("FormatScale");
  570. cfgRemove("FormatThousandSep");
  571. cfgRemove("FormatNegSign");
  572. cfgRemove("FormatCurrencySymbol");
  573. cfgRemove("ColSort");
  574. cfgRemove("ColSortBy");
  575. cfgRemove("IsCollapsed");
  576. cfgRemove("DetailAgg");
  577. cfgRemove("RegularAgg");
  578. cfgRemove("SummaryAgg");
  579. cfgRemove("ExpFilter");
  580. cfgRemove("ColFilterIdx");
  581. cfgRemove("FilterStrings");
  582. cfgRemove("PromptType");
  583. }
  584. function rvDefaults(){
  585. cfgSet("RowsDesired", 20);
  586. cfgSet("StartRow", 1);
  587. cfgRemove("QueryIDs");
  588. cfgRemove("SelColumns");
  589. cfgRemove("ColLabels");
  590. cfgRemove("ColType");
  591. cfgRemove("ColExp");
  592. cfgRemove("ColIDs");
  593. cfgRemove("CutColumns");
  594. cfgRemove("ColRole");
  595. cfgRemove("ColGroupIDs");
  596. cfgRemove("HasSummaries");
  597. cfgRemove("IsMeasure");
  598. cfgRemove("ReportType");
  599. cfgRemove("ContextMenuActive");
  600. cfgRemove("ActionRunning");
  601. cfgRemove("DialogSize");
  602. cfgRemove("DialogExecFunc");
  603. cfgRemove("DialogSelCols");
  604. }
  605. function setScriptEngine() {
  606. cfgSet("APPLICATION_NAME", applicationName);
  607. cfgSet("SERVER_URL", serverURL);
  608. cfgSet("SCRIPT_ENGINE", scriptEngine);
  609. cfgSet("REQUEST_METHOD", methodName);
  610. //<xsl:if test="key('env-param','debug')='true'">cf.cfgSet("__DBG__", true);</xsl:if>
  611. cfgSet("BIQ", BIQ);
  612. cfgSet("queryLoaded",true);
  613. }
  614. function setWindowTitle() {
  615. var fileName = cfgGet("ReportName");
  616. if ( fileName != null )
  617. fileName = fileName.replace(/\.xml$/gi,"");
  618. if (fileName==null || fileName=="")
  619. top.document.title = windowTitle_string;
  620. else
  621. top.document.title = fileName + " - " + windowTitle_string ;
  622. var captionText = "";
  623. if (fileName!=null && fileName!="")
  624. captionText = " - " + fileName;
  625. else if (cfgGet("NewReport"))
  626. captionText = " - " + newFilename_string;
  627. var cp = document.getElementById("filenameCaption");
  628. if (cp)
  629. {
  630. while (cp.hasChildNodes())
  631. cp.removeChild(cp.firstChild);
  632. var newText = document.createTextNode(captionText);
  633. cp.appendChild(newText);
  634. }
  635. var returnLinkText = ( frameBackURL == null || frameBackURL == "") ? returnLink_string : exitLink_string;
  636. var cl = document.getElementById("returnLink");
  637. if (cl)
  638. {
  639. while (cl.hasChildNodes())
  640. cl.removeChild(cl.firstChild);
  641. var newText = document.createTextNode(returnLinkText);
  642. cl.appendChild(newText);
  643. }
  644. }
  645. function initQSUI() {
  646. reinitConfigValues();
  647. setScriptEngine();
  648. setWindowTitle();
  649. var size = parseInt(document.getElementById("menuFrame").style.width)
  650. if (size == null || isNaN(size))
  651. size = 200;
  652. cfgSet("MenuSize", size);
  653. redrawLayers();
  654. }
  655. function initRVUI() {
  656. reinitConfigValues();
  657. setScriptEngine();
  658. setWindowTitle();
  659. showDialogFrame(0);
  660. changeNavigationLinks(false,false,false,false);
  661. }
  662. function hideSplash(){
  663. window.defaultStatus='';
  664. var splashBT = document.getElementById("splashB");
  665. splashBT.style.display ="none";
  666. }
  667. function initASUI() {
  668. document.body.oWndObserver = new CWndObserver(window.id);//global observer
  669. document.body.getWndObserver = function() {return document.body.oWndObserver;}
  670. g_divProgressBar = new C_StartupBlocker();
  671. reinitConfigValues();
  672. setScriptEngine();
  673. setWindowTitle();
  674. // set up all the trees
  675. initDataItems();
  676. initParameterItems();
  677. initHistoryItems();
  678. initMemberSearch();
  679. var size = parseInt(document.getElementById("menuFrame").style.width)
  680. if (size == null || isNaN(size))
  681. size = 200;
  682. cfgSet("MenuSize", size);
  683. // set the new report to true in here - it's in async/conv for report studio
  684. // but cannot see why that's the case
  685. cfgSet("NewReport", true);
  686. // move progress info further
  687. showLoadingMsg('20');
  688. loadMenu();
  689. // move progress info further
  690. showLoadingMsg('30');
  691. setDispatcherErrorHandler(cDispatchErrorHandler);
  692. initEventNotification();
  693. var loadStack = new CommandStack(new Array());
  694. loadStack.failCommand = "parent.showLoadingMsg('100');setTimeout('parent.g_divProgressBar.F_Hide()', 300);parent.cfgSet('agsInit', false)";
  695. loadStack.push("setInsertableObjectsTabContainerHeight()");
  696. loadStack.push(new CommandStackObject("changeMenu(TAB_MODEL)"));
  697. loadStack.push("loadMessageFrame()");
  698. loadStack.push(new CommandStackObject("cfgSet('agsInit', true)"));
  699. loadStack.push(new CommandStackObject("cfgSet('AGS_initialized', true)"));
  700. loadStack.push(new CommandStackObject("showLoadingMsg('75')"));
  701. loadStack.push("reloadFunctionsTree()");
  702. loadStack.push(new CommandStackObject("showLoadingMsg('60')"));
  703. loadStack.push("reloadMetadataTree()");
  704. loadStack.push(new CommandStackObject("showLoadingMsg('40')"));
  705. loadStack.push("loadMetadataFrame()");
  706. getConfigFrame().getCommandStackManager().doCommandStack(loadStack);
  707. }
  708. function setInsertableObjectsTabContainerHeight(event) {
  709. /*
  710. lastMenu Model
  711. lastMenu DataItems
  712. lastMenu Functions
  713. lastMenu Parameters
  714. lastMenu History
  715. lastMenu MemberSearch
  716. */
  717. visibleTree = cfgGet("lastMenu");
  718. var oMenuContainer = document.getElementById("div_menu_"+visibleTree);
  719. var oInsertableObjectsHeader = document.getElementById("insertableObjectsHeader");
  720. var iBottomPadding = 0;
  721. if (oMenuContainer && oInsertableObjectsHeader) {
  722. var oMetadataTreeOuterPane = document.getElementById("div_menu_parent_"+visibleTree);
  723. //set the default size
  724. oMetadataTreeOuterPane.style.height = "100px";;
  725. iBottomPadding += oInsertableObjectsHeader.offsetHeight;
  726. var iMenuHeight = oMenuContainer.offsetHeight;
  727. var iBottomElementsHeight = iBottomPadding;
  728. var iNewMetadataTreeHeight = iMenuHeight - iBottomElementsHeight;
  729. if (iMenuHeight && iBottomElementsHeight && iNewMetadataTreeHeight > 0) {
  730. oMetadataTreeOuterPane.style.height = iNewMetadataTreeHeight + "px";
  731. }
  732. }
  733. }
  734. function showLoadingMsg(perc, msg){
  735. showDialogFrame(0);
  736. g_divProgressBar.F_SetPercent(perc);
  737. if(msg != null){
  738. g_divProgressBar.F_SetMessage(msg);
  739. } else {
  740. g_divProgressBar.F_SetMessage(perc + "%");
  741. }
  742. }
  743. //This code is copied from hal.js. Suggested by David Lilly
  744. //Since we can not use the hal.js I copied over the CSS and
  745. //the code below. Added the idHALStartupBlocker element to
  746. //ags.xts.
  747. function C_StartupBlocker( v_bHideProgressBar )
  748. {
  749. if ( document.getElementById( "idHALStartupBlocker" ) )
  750. {
  751. return;
  752. }
  753. }
  754. C_StartupBlocker.prototype.F_SetPercent = function(v_iPercent)
  755. {
  756. this.m_iPercent = v_iPercent;
  757. var div = document.getElementById( "idHALStartupBar" );
  758. if ( div )
  759. {
  760. div.style.width = Math.min( 100, v_iPercent ) + "%";
  761. }
  762. }
  763. C_StartupBlocker.prototype.F_Hide = function()
  764. {
  765. var el = document.getElementById( "idHALStartupBlocker" );
  766. if ( el )
  767. {
  768. el.parentNode.removeChild( el );
  769. }
  770. }
  771. C_StartupBlocker.prototype.F_SetMessage = function(s) {
  772. if ( this.m_iPercent >= 100 )
  773. {
  774. var div = document.getElementById( "idHALStartupBar" );
  775. if ( div )
  776. {
  777. div.innerText = s;
  778. }
  779. }
  780. }
  781. function initEventNotification() {
  782. //intercept hotkey combinations
  783. eventHandlerChainUtil.doEventHandlerChain(document, "keydown",keyDownChecker.check);
  784. //initialize any items
  785. for(var i = 0; i < toolbar.m_items.length; i++) {
  786. var tbItem = toolbar.m_items[i];
  787. if (tbItem.onmouseup) {
  788. tbItem.getObservers().attach(toolbar, toolbar.closeMenus, tbItem.onmouseup);
  789. }
  790. }
  791. toolbar.getObservers().attach(document.body.getWndObserver(),document.body.getWndObserver().mouseup,toolbar.onmouseup);
  792. m_menu.getObservers().attach(document.body.getWndObserver(),document.body.getWndObserver().mouseup,m_menu.onmouseup);
  793. document.body.getWndObserver().attachEvent(document.body, "mouseup");
  794. if (document.all) {
  795. document.body.getWndObserver().attachEvent(document.body, "resize");
  796. } else {
  797. document.body.getWndObserver().attachEvent(window, "resize");
  798. }
  799. document.body.getWndObserver().addListener(toolbar, toolbar.closeMenus, "mouseup");
  800. document.body.getWndObserver().addListener(m_menu, m_menu.closeMenus, "mouseup");
  801. document.body.getWndObserver().addListener(taskMenu, taskMenu.remove, "mouseup");
  802. var metadataFrame = document.getElementById("metadataIFrame");
  803. //for FF only, manage the resizing left hand data items panel. This needs to be revisited
  804. //and fixed for IE as well. The original code to resize for IE has been retained.
  805. if (!browserCheck.isIE5Up()) {
  806. var splitter = new Splitter();
  807. }
  808. }
  809. function handleBackSpace(evt) {
  810. var targ;
  811. if (!evt) var evt = window.event;
  812. if (evt.target) targ = evt.target;
  813. else if (evt.srcElement) targ = evt.srcElement;
  814. if (targ.nodeType == 3) // defeat Safari bug
  815. targ = targ.parentNode;
  816. if(targ.tagName != "TEXTAREA" && targ.tagName != "INPUT" && targ.tagName != "BODY"){
  817. stopEventPropagation(evt);
  818. }else if(targ.tagName == "BODY" && targ.id == ""){
  819. //this distinguishes between the whole page body and the body used in the div of the html edit page
  820. stopEventPropagation(evt);
  821. }
  822. }
  823. function stopEventPropagation(evt){
  824. //prevent the click from proceeding to other nodes
  825. if (typeof evt.cancelBubble != 'undefined'){
  826. evt.returnValue = false;
  827. evt.cancelBubble = true;
  828. }
  829. if (typeof evt.stopPropagation != 'undefined') {
  830. evt.stopPropagation();
  831. }
  832. }
  833. /*
  834. * check for, and discard the event for any CTRL-<numeric|character> hotkey combinations
  835. */
  836. function checkForHotKeyActions(evt) {
  837. if(evt.keyCode == 8){
  838. handleBackSpace(evt);
  839. return;
  840. }
  841. var ctrlPressed = false;
  842. var found = false;
  843. //the event could have occurred in any of the frames so we need
  844. //to check each one and grab the event object
  845. if (evt.ctrlKey==undefined) {
  846. var extractedEvent = window.event;
  847. for (var i=0;(i < document.frames.length && !found && extractedEvent == undefined);i++) {
  848. var frame = document.frames[i];
  849. if (frame.window.event != null) {
  850. found = true;
  851. extractedEvent = frame.window.event;
  852. }
  853. }
  854. evt = extractedEvent;
  855. }
  856. // fix for bug: COGCQ00224409 Belgian issue - unable to type chars pressing Altgr
  857. if (evt.altKey) {
  858. return true;
  859. }
  860. //IE
  861. if (browserCheck.isIE5dot5Up()) {
  862. ctrlPressed = evt.ctrlKey;
  863. }
  864. //Mozilla/firefox
  865. else {
  866. ctrlPressed & Event.CONTROL_MASK;
  867. }
  868. if (evt.keyCode!=K_sKeyCode_Ctrl) {
  869. var allowed = isHotKeyAllowed(evt.keyCode)
  870. if (ctrlPressed==true && !allowed) {
  871. //prevent the click from proceeding to other nodes
  872. stopEventPropagation(evt);
  873. }
  874. }
  875. }
  876. function isHotKeyAllowed(keyCode) {
  877. var allowed = allowedHotkeys[String(keyCode)];
  878. if (allowed == undefined) {
  879. allowed=false;
  880. }
  881. return allowed;
  882. }
  883. function loadMessageFrame()
  884. {
  885. //there is a problem with loading the message frame and the metadata pane
  886. //simultaneously, due to http connections, see bug 488327
  887. if(applicationActionManager.isBlocked()){
  888. setTimeout("loadMessageFrame()", 1000);
  889. return;
  890. }
  891. dlgReset();
  892. // we saved the Params for the message frame in the scripts -
  893. for (var param in messageFrame_Params) {
  894. //set the params
  895. dlgSetParm(param, messageFrame_Params[param]);
  896. }
  897. //submit the form using POST.
  898. dlgSubmit("messageIFrame", false);
  899. }
  900. function loadMetadataFrame()
  901. {
  902. dlgReset();
  903. // we saved the Params for the message frame in the scripts -
  904. for (var param in metadataFrame_Params) {
  905. //set the params
  906. dlgSetParm(param, metadataFrame_Params[param]);
  907. }
  908. //submit the form using POST.
  909. dlgSubmit("metadataIFrame", false);
  910. }
  911. function redrawSelf()
  912. {
  913. previewType = getPreviewType();
  914. var previewTitleTop = document.getElementById("previewTitleTop");
  915. if (previewTitleTop)
  916. {
  917. while (previewTitleTop.hasChildNodes())
  918. previewTitleTop.removeChild(previewTitleTop.firstChild);
  919. previewTitleTop.appendChild(document.createTextNode(previewType=="none" ? runnodata_string : runlimited_string));
  920. }
  921. var previewTitleBottom = document.getElementById("previewTitleBottom");
  922. if (previewTitleBottom)
  923. {
  924. var previewLink = document.getElementById("previewLink");
  925. while (previewTitleBottom.hasChildNodes())
  926. previewTitleBottom.removeChild(previewTitleBottom.firstChild);
  927. previewTitleBottom.appendChild(document.createTextNode(previewType=="none" ? runnodata_string : runlimited_string));
  928. while (previewLink.hasChildNodes())
  929. previewLink.removeChild(previewLink.firstChild);
  930. previewLink.appendChild(document.createTextNode(previewType=="none" ? runlimitedlink_string : runnodatalink_string));
  931. /*
  932. Here is the link to change the preview mode
  933. ( if in no data, you want to show the link to go to limited data, and vice-versa )
  934. */
  935. if(previewType=="none") {
  936. previewLink.onclick = function() { getConfigFrame().run("partial"); }
  937. }
  938. else {
  939. previewLink.onclick = function() { getConfigFrame().run("none"); }
  940. }
  941. }
  942. }
  943. /*
  944. * Submit the dialog using the GET method
  945. */
  946. function dlgSubmitGet() {
  947. var cf = getConfigFrame();
  948. var df = getFrame(DIALOG_FRAME_ID);
  949. if (!df) {
  950. df=this;
  951. }
  952. var url = cfgGet("SCRIPT_ENGINE");
  953. var sepChar="?";
  954. for (var n in dialogFormValues) {
  955. var values = makeArray(dialogFormValues[n]);
  956. for (var v in values) {
  957. url += sepChar+n+"="+values[v];
  958. sepChar="&";
  959. }
  960. }
  961. // Add in the cafcontextid
  962. url = cf.constructGETRequestParamsString(url);
  963. df.document.location.replace(url);
  964. }
  965. /*
  966. * Submit the dialog using the POST method
  967. */
  968. function dlgSubmitPost(tgt) {
  969. tgt = tgt ? tgt : DIALOG_FRAME_ID;
  970. checkLogin(undefined,"processSubmitPost('"+ tgt + "')");
  971. }
  972. //Do not call directly.
  973. function processSubmitPost(tgt) {
  974. var srcFrame = getFrame(tgt);
  975. if (!srcFrame) {
  976. srcFrame=this;
  977. }
  978. var srcForm = srcFrame.document.createElement("FORM");
  979. srcForm.target = tgt;
  980. srcForm.method = "POST";
  981. srcForm.action = cfgGet("SCRIPT_ENGINE");
  982. srcForm.style.margin="0px";
  983. //get the document body
  984. var srcBody = srcFrame.document.getElementsByTagName("BODY");
  985. if (srcBody!=null && srcBody[0]!=null) {
  986. srcBody=srcBody[0];
  987. }
  988. else {
  989. srcBody = srcFrame.document.documentElement;
  990. }
  991. // Remove all form objects from the srcBody
  992. while(srcBody.hasChildNodes())srcBody.removeChild(srcBody.childNodes.item(0));
  993. srcBody.appendChild(srcForm);
  994. // Put all parms in dialogFormValues in the form
  995. for (var n in dialogFormValues) {
  996. var values = makeArray(dialogFormValues[n]);
  997. for (var value in values) {
  998. var hiddenInput = srcFrame.document.createElement("textarea");
  999. hiddenInput.setAttribute("id", n);
  1000. hiddenInput.setAttribute("name", n);
  1001. //Firefox does not like setAttribute('value',n) but IE does
  1002. //both like this syntax :-)
  1003. hiddenInput.value=values[value];
  1004. // set the style to invisible
  1005. hiddenInput.style.display='none';
  1006. // add the control
  1007. srcForm.appendChild(hiddenInput);
  1008. }
  1009. }
  1010. addCAFContextIdToForm(srcFrame,srcForm);
  1011. // Remove onBeforeUnLoad for this submission but set it back after.
  1012. var oldUnload=window.onbeforeunload;
  1013. window.onbeforeunload=null;
  1014. // Submit the form
  1015. srcForm.submit();
  1016. window.onbeforeunload=oldUnload;
  1017. }
  1018. /*
  1019. * Check for unsaved changes to a dialog in the dialog frame. The user will be asked whether the changes
  1020. * should be saved. For the changes to be commited the dialog must implement the following functions :
  1021. *
  1022. * doApply() - validate the dialog and apply unsaved changes. Return false if the dialog could not be validated
  1023. * hasChanged() - if not implemented this will default to true
  1024. */
  1025. function commitDialogFrameChanges() {
  1026. //guard clause, the dialog frame is closed
  1027. if (isDialogFrameShowing()==false) {
  1028. return;
  1029. }
  1030. var currStack=getCommandStackManager().getCommandStack();
  1031. if (currStack.isEmpty()==false) {
  1032. var dialogFrame = getDialogFrame();
  1033. //determine whether the doApply() function is available for the current dialog
  1034. var canApply = typeof dialogFrame.doApply == "function";
  1035. //if the dialog does not support the hasChanged() function
  1036. //then always assume the dialog contents are dirty
  1037. var hasChanged=true;
  1038. if (typeof dialogFrame.hasChanged == "function") {
  1039. hasChanged = dialogFrame.hasChanged();
  1040. }
  1041. //unsaved dialog found
  1042. if (hasChanged && canApply) {
  1043. //show the popup if we haven't been here before, if the validation
  1044. //fails we don't want to keep showing the same message asking the
  1045. //user if they want to save the dialog when they have already made
  1046. //the decision
  1047. if (saveChangesToDialogFrame==false) {
  1048. saveChangesToDialogFrame = confirm(commitChangesWarning)
  1049. }
  1050. //if the user chose to save the dialog and the dialog validation
  1051. //failed then clear the command stack
  1052. if (saveChangesToDialogFrame && dialogFrame.doApply()==false) {
  1053. currStack.clear();
  1054. }
  1055. //Reset the flag when :
  1056. // 1. We don't care about dialog changes
  1057. // 2. The dialog changes were applied successfully
  1058. else {
  1059. saveChangesToDialogFrame=false;
  1060. }
  1061. }
  1062. }
  1063. }
  1064. /*
  1065. * This method will call doLoginProxy.xts to perform a pre-emptive
  1066. * session expiry check. This is to make sure we are always logged on.
  1067. * In some cases if a logon fault is encountered it will end up being
  1068. * redirected here from XMLHTTP calls, with the htmlFrgament, which is
  1069. * then redirected to the portal handleFault.xts.
  1070. */
  1071. function checkLogin(holder,callBackfunc) {
  1072. //Check if holder is there already.
  1073. if (holder == undefined) {
  1074. holder = new Object();
  1075. }
  1076. //If m already defined do not bother resetting.
  1077. if (holder['m'] == undefined) {
  1078. holder['m'] = "/ags/doLoginProxy.xts";
  1079. }
  1080. var callBack = function(responseArray) {
  1081. var isLoginOk = processLogin(responseArray);
  1082. if (callBackfunc != undefined) {
  1083. if (isLoginOk) {
  1084. eval(callBackfunc);
  1085. } else {
  1086. getCommandStackManager().getCommandStack().push(callBackfunc);
  1087. }
  1088. }
  1089. };
  1090. var dispatcher = new XHTTPDispatcher(callBack, holder);
  1091. applicationActionManager.httpStart();
  1092. try{
  1093. dispatcher.dispatch();
  1094. }catch(ex){
  1095. applicationActionManager.httpStop();
  1096. }
  1097. }
  1098. function processLogin(responseArray) {
  1099. var responseXML = responseArray[0];
  1100. var responseText = responseArray[1];
  1101. applicationActionManager.httpStop();
  1102. var parsedResponse = parseResponse(responseXML,responseText);
  1103. if (parsedResponse.isLogonFault()) {
  1104. // Get the HTML fault from the EMF rendered response.
  1105. var htmlFaultHtml = parsedResponse.getTextValueForXPath( "//fault//html" );
  1106. var popUpFrame = getPopUpFrame();
  1107. popUpFrame.document.open();
  1108. popUpFrame.document.write(htmlFaultHtml);
  1109. popUpFrame.document.close();
  1110. return false;
  1111. } else if (parsedResponse.isHTML() && !parsedResponse.isEmptyBody()) {
  1112. if (parsedResponse.contains('CAF_VALIDATION_FAILURE')) {
  1113. doHTMLResponse(responseText);
  1114. } else {
  1115. var popUpFrame = getPopUpFrame();
  1116. popUpFrame.document.open();
  1117. popUpFrame.document.write(responseText);
  1118. popUpFrame.document.close();
  1119. }
  1120. return false;
  1121. }
  1122. return true;
  1123. }
  1124. /*
  1125. * helper function to check for invalid strings in the message frame input form
  1126. * and optionally popup an alert
  1127. */
  1128. function checkCAF() {
  1129. var messageIFrame = getMessageIFrame();
  1130. var messageIFrame_doc = getFrameDocument(messageIFrame);
  1131. var failed = false;
  1132. var formsArray = messageIFrame_doc.forms;
  1133. //we cannot find a form, something is awry
  1134. if (formsArray.length==0) {
  1135. failed=true;
  1136. }
  1137. else {
  1138. failed = CAFValidateForm(formsArray[0]);
  1139. if (!failed) {
  1140. //commit the contents of the pending dialog frame is necessary
  1141. commitDialogFrameChanges();
  1142. var stackMgr = getCommandStackManager();
  1143. var currentStack = stackMgr.getCommandStack();
  1144. if (currentStack) {
  1145. //process the next command
  1146. if (currentStack.isEmpty()==false) {
  1147. stackMgr.processCommandStack();
  1148. }
  1149. }
  1150. }
  1151. }
  1152. return failed;
  1153. }
  1154. /*
  1155. * check the form type 'text' or 'textarea' inputs for invalid characters
  1156. * form - the form, must not be null or undefined
  1157. * popup - popup an alert when not valid, this is optional, the default is true
  1158. * returns true when validation has failed
  1159. */
  1160. function CAFValidateForm(form,popup) {
  1161. var items = new Array();
  1162. var failed=false;
  1163. for (var i = 0; i < form.elements.length && !failed; ++i) {
  1164. var control = form.elements[i];
  1165. // get the type of the control
  1166. var type = control.type;
  1167. //we only care about text controls
  1168. if (type == 'textarea' || type=='text' || control.tagName=='TEXTAREA') {
  1169. var ctrlName = form.elements[i].name;
  1170. var ctrlValue = control.value;
  1171. //check for a valid name
  1172. if (ctrlName!='') {
  1173. var res = CAFContainsInvalidString(ctrlValue);
  1174. //check the string
  1175. if (res) {
  1176. failed=true;
  1177. //check if the alert should be shown
  1178. if (popup == undefined || popup==true) {
  1179. window.alert(cafInvalidStringMsg + res);
  1180. }
  1181. //clear the command stack if commands exist
  1182. if (getCommandStackManager().getCommandStack().isEmpty()==false) {
  1183. getCommandStackManager().getCommandStack().clear();
  1184. }
  1185. //unblock
  1186. if(applicationActionManager.isBlocked()){
  1187. applicationActionManager.allowActions();
  1188. }
  1189. }
  1190. }
  1191. }
  1192. }
  1193. return failed;
  1194. }
  1195. /*
  1196. * A helper function to append the CAF context id to a form. The context id is added
  1197. * as a hidden input variable. If the context id is already present in the form no action is taken
  1198. * docFrame the current frame
  1199. * docForm the input form
  1200. */
  1201. function addCAFContextIdToForm(docFrame,docForm) {
  1202. // Add in the cafcontextid to the post request, this is accomplished by creating
  1203. //a hidden form variable and then setting the context id into it
  1204. var cf = getConfigFrame();
  1205. //check if a valid context id is present and the form does not already have it
  1206. if (cf.cafContextId != "" && docFrame.document.getElementById("cafcontextid")==null) {
  1207. //create the hidden caf context id input element
  1208. var i = docFrame.document.createElement("INPUT");
  1209. i.setAttribute("name", "cafcontextid");
  1210. i.setAttribute("value",cf.cafContextId);
  1211. i.setAttribute("id", "cafcontextid");
  1212. i.setAttribute("type", "hidden");
  1213. //add the caf context id to the form
  1214. docForm.appendChild(i);
  1215. }
  1216. }
  1217. /*
  1218. * Translates a string into javascript-encoded format according to the following rules:
  1219. * Double quote (") is converted to (\")
  1220. * Single quote (') is converted to (\')
  1221. * Backslash (\) is converted to (\\)
  1222. * Open angle bracket (<) is converted to (\<)
  1223. * Close angle bracket (>) is converted to (\>)
  1224. */
  1225. function jsStrEncode(str) {
  1226. if (typeof str != "string")
  1227. {
  1228. return str;
  1229. }
  1230. if (typeof str == "undefined" || str == "") {
  1231. str="";
  1232. }
  1233. else {
  1234. str = str.replace(/\\/g, '\\\\');
  1235. str = str.replace(/"/g, '\\"');
  1236. str = str.replace(/'/g, "\\'");
  1237. str = str.replace(/</g, '\\<');
  1238. str = str.replace(/>/g, '\\>');
  1239. }
  1240. return str;
  1241. }
  1242. /*
  1243. htmlEncode
  1244. translates a string into html encoded format according to the following rules:
  1245. * Double quote (") is converted to (\")
  1246. * ampersand (&) is converted to (\&amp;)
  1247. * Open angle bracket (<) is converted to (\<)
  1248. * Close angle bracket (>) is converted to (\>)
  1249. */
  1250. function htmlEncode(str)
  1251. {
  1252. if (typeof str != "string")
  1253. {
  1254. return str;
  1255. }
  1256. var tempString = str.replace(/&/g,"&amp;");
  1257. tempString = tempString.replace(/"/g,"&quot;");
  1258. tempString = tempString.replace(/</g,"&lt;");
  1259. tempString = tempString.replace(/>/g,"&gt;");
  1260. return tempString;
  1261. }
  1262. /*
  1263. * submit the dialog
  1264. */
  1265. function dlgSubmit(tgt, useGet) {
  1266. if(cf.applicationActionManager.isBlocked()){
  1267. return;
  1268. }
  1269. //block until page is reloaded
  1270. cf.applicationActionManager.blockActions();
  1271. if (useGet) {
  1272. dlgSubmitGet();
  1273. }
  1274. else {
  1275. dlgSubmitPost(tgt);
  1276. }
  1277. }
  1278. function asyncSubmit(tgt) {
  1279. // Create a new form object
  1280. var rf = getReportFrame();
  1281. if(!rf) rf=this;
  1282. var f = rf.document.createElement("FORM");
  1283. f.method = "POST";
  1284. f.action = cfgGet("SCRIPT_ENGINE");
  1285. if (tgt != null)
  1286. f.target = tgt;
  1287. else
  1288. f.target = rf.name;
  1289. f.style.margin="0px";
  1290. var b = rf.document.getElementsByTagName("BODY");
  1291. if (b!=null && b[0]!=null)
  1292. b=b[0];
  1293. else
  1294. b= rf.document.documentElement;
  1295. b.appendChild(f);
  1296. while (f.hasChildNodes())
  1297. f.removeChild(f.firstChild);
  1298. // Put all parms in asyncFormValues in the form
  1299. for (var n in asyncFormValues) {
  1300. var values = makeArray(asyncFormValues[n]);
  1301. for (var v in values) {
  1302. var i = rf.document.createElement("TEXTAREA");
  1303. i.setAttribute("name", n);
  1304. i.setAttribute("value", values[v]);
  1305. i.setAttribute("id", n);
  1306. // make this invisible
  1307. i.style.display='none';
  1308. // add the form control
  1309. f.appendChild(i);
  1310. }
  1311. }
  1312. addCAFContextIdToForm(rf,f);
  1313. hideDialogFrame();
  1314. // Remove onBeforeUnLoad for this submission but set it back after.
  1315. var oldUnload=window.onbeforeunload;
  1316. window.onbeforeunload=null;
  1317. // Submit the form
  1318. f.submit();
  1319. window.onbeforeunload=oldUnload;
  1320. }
  1321. /*
  1322. * Set the boolean configuration variable 'agentHasChanged'
  1323. */
  1324. function agentHasChanged(v_bChanged) {
  1325. if (v_bChanged == null) {
  1326. v_bChanged = false;
  1327. }
  1328. cfgSet("agentHasChanged", v_bChanged);
  1329. }
  1330. /*
  1331. * check if the agent has changed since the last save/load
  1332. */
  1333. function hasAgentChanged() {
  1334. var changed = cfgGet("agentHasChanged");
  1335. //need to track this for prompting to save
  1336. var last_known_condition = cfgGet("saved_agent_condition");
  1337. var current_condition = buildFilterCondition();
  1338. if(!last_known_condition || last_known_condition == ""){
  1339. //we have no saved condition
  1340. changed = changed || (current_condition && current_condition != "");
  1341. }else{
  1342. //we have a saved condition
  1343. changed = changed || new String(last_known_condition).localeCompare(current_condition) != 0;
  1344. }
  1345. return changed;
  1346. }
  1347. function setConditionError(errors, error_div_id){
  1348. if(!error_div_id){
  1349. //this may have been set by a calling page, to prevent passing it
  1350. error_div_id = cfgGet(CURRENT_ERROR_DIV_ID_KEY);
  1351. }
  1352. cfgSet(error_div_id, errors);
  1353. displayConditionError(errors);
  1354. }
  1355. function updateConditionError(error_div_id){
  1356. if (cfgGet(error_div_id)) {
  1357. displayConditionError(cfgGet(error_div_id));
  1358. }
  1359. }
  1360. var wait_interval = 500;
  1361. var wait_time = 10000;
  1362. function displayConditionError(errors, time_left){
  1363. var msgFrame = getMessageIFrame();
  1364. var msgDoc = getFrameDocument(msgFrame);
  1365. var error_div_id = cfgGet(CURRENT_ERROR_DIV_ID_KEY);
  1366. if(!errors){
  1367. errors = cfgGet(error_div_id);
  1368. }
  1369. if (!error_div_id) {
  1370. //Just incase so we do not lose the error
  1371. error_div_id = CURRENT_TIP;
  1372. }
  1373. var errorDiv=agsFormUtils.getElementByIdOrName(error_div_id);
  1374. if(!errorDiv){
  1375. time_left = time_left ? time_left - wait_interval : wait_time;
  1376. if(time_left > 0){
  1377. //get the error out of the cfg - the formatting is hard to handle through a setTimeout
  1378. // time_left is a number
  1379. setTimeout("displayConditionError(null, '" + time_left + "')", wait_interval);
  1380. }else{
  1381. //if its not there there has been a worse error....
  1382. //dont kick the user when theyre down
  1383. //alert(error);
  1384. }
  1385. }else{
  1386. setErrorDisplay(errorDiv,errorDiv.ownerDocument,errors);
  1387. }
  1388. }
  1389. /*
  1390. * This function retrieves any function tip information when available from the configuration
  1391. * and sets it into the tip frame
  1392. */
  1393. function updateInformationTip()
  1394. {
  1395. setInformationTip(cfgGet(CURRENT_TIP),cfgGet(CURRENT_TIP_SYNTAX));
  1396. }
  1397. /*
  1398. * Tell the info panel that a function has been selected. This causes
  1399. * a tip and function syntax to be rendered in the message frame
  1400. */
  1401. function displayInformationTip(node)
  1402. {
  1403. // save the current tip and syntax
  1404. cfgSet(CURRENT_TIP, node.tip);
  1405. cfgSet(CURRENT_TIP_SYNTAX,node.syntax);
  1406. // set the display
  1407. setInformationTip(node.tip, node.syntax);
  1408. }
  1409. /*
  1410. * Convenience method for setting the tip and syntax info the information panel
  1411. */
  1412. function setInformationTip(tipName,tipSyntax)
  1413. {
  1414. var msgFrame = getMessageIFrame();
  1415. var msgDoc = getFrameDocument(msgFrame);
  1416. var dialogFrame = getDialogFrame();
  1417. var dialogDoc = getFrameDocument(dialogFrame);
  1418. var infoItemTipDiv = msgDoc.getElementById(CURRENT_TIP);
  1419. var infoItemSyntaxDiv = msgDoc.getElementById(CURRENT_TIP_SYNTAX);
  1420. var infoItemTipDialogDiv = dialogDoc.getElementById(CURRENT_TIP);
  1421. var infoItemSyntaxDialogDiv = dialogDoc.getElementById(CURRENT_TIP_SYNTAX);
  1422. if (tipName != null && tipName.length > 0) {
  1423. setInfoItem(infoItemTipDiv,msgDoc,tipName);
  1424. setInfoItem(infoItemTipDialogDiv,dialogDoc,tipName);
  1425. } else {
  1426. resetDiv(infoItemTipDiv,false);
  1427. resetDiv(infoItemTipDialogDiv,false);
  1428. }
  1429. if (tipSyntax != null && tipSyntax.length > 0) {
  1430. setInfoItem(infoItemSyntaxDiv,msgDoc,tipSyntax);
  1431. setInfoItem(infoItemSyntaxDialogDiv,dialogDoc,tipSyntax);
  1432. } else {
  1433. resetDiv(infoItemSyntaxDiv,true);
  1434. resetDiv(infoItemSyntaxDialogDiv,true);
  1435. }
  1436. if ((!tipName || tipName.length < 0) && (!tipSyntax || tipSyntax.length < 0)) {
  1437. //Default Messages.
  1438. setInfoItem(infoItemTipDiv,msgDoc,agentConditionTipsMessage_string );
  1439. setInfoItem(infoItemTipDialogDiv,dialogDoc,dataItemTipsMessage_string );
  1440. setInfoItem(infoItemSyntaxDiv,msgDoc,agentConditionTipsSyntaxMessage_string);
  1441. setInfoItem(infoItemSyntaxDialogDiv,dialogDoc,dataItemTipsSyntaxMessage_string);
  1442. }
  1443. }
  1444. /*
  1445. * Empty the div that is passed. Set it to hidden if hide is true.
  1446. * This would be needed for functions where no tip but synatx is
  1447. * provided or vice versa.
  1448. */
  1449. function resetDiv(divNode,hide) {
  1450. if (divNode !=null) {
  1451. // remove the contents
  1452. while (divNode.hasChildNodes()) {
  1453. divNode.removeChild(divNode.firstChild);
  1454. }
  1455. if (hide) {
  1456. divNode.style.display = "none";
  1457. }
  1458. } else {
  1459. return false;
  1460. }
  1461. return true;
  1462. }
  1463. function setErrorsToDiv(divNode,msgDoc,errors){
  1464. if(!errors || errors.length == 0){
  1465. errors = new Array(new DefectMessage(validateNoErrors_string, "info", null));
  1466. }
  1467. var table = msgDoc.createElement("table");
  1468. var tbody = msgDoc.createElement("tbody");
  1469. table.appendChild(tbody);
  1470. for(var i = 0; i < errors.length; i++){
  1471. var row = msgDoc.createElement("tr");
  1472. var td1 = msgDoc.createElement("td");
  1473. var img = msgDoc.createElement("img");
  1474. img.setAttribute("src", errors[i].severity.img_src);
  1475. td1.appendChild(img);
  1476. row.appendChild(td1);
  1477. var td2 = msgDoc.createElement("td");
  1478. var p = msgDoc.createElement("p");
  1479. p.innerHTML=errors[i];
  1480. p.className = "infoErrorTabText";
  1481. td2.appendChild(p);
  1482. row.appendChild(td2);
  1483. tbody.appendChild(row);
  1484. }
  1485. divNode.appendChild(table);
  1486. }
  1487. /*
  1488. *Set some content into the function tip information area if it is available
  1489. */
  1490. function setErrorDisplay(divNode,msgDoc,errors)
  1491. {
  1492. if (resetDiv(divNode)) {
  1493. setErrorsToDiv(divNode,msgDoc,errors);
  1494. }
  1495. divNode.style.display = "";
  1496. var msgFrame = getMessageIFrame();
  1497. if(divNode.id && divNode.id.indexOf('DataItem') != -1){
  1498. msgFrame = getDialogFrame();
  1499. }
  1500. if (msgFrame.doInfoTabChange) {
  1501. msgFrame.doInfoTabChange(divNode.id ? divNode.id : divNode.name);
  1502. }
  1503. }
  1504. /*
  1505. *Set some content into the function tip information area if it is available
  1506. */
  1507. function setInfoItem(divNode,msgDoc,content)
  1508. {
  1509. if (resetDiv(divNode)) {
  1510. // split the content based on CR-LF's
  1511. var lines = content.split("\n");
  1512. // loop over the lines -converting all the preceding spaces into &nbsp;'s
  1513. for (var i = 0; i < lines.length; ++i) {
  1514. // split the line after the first non whitespace char
  1515. var re = /^(\s*)(.*)/;
  1516. var pre_space = lines[i].replace(re, "$1");
  1517. var after_space = lines[i].replace(re, "$2");
  1518. // convert all the prespace into &nbsp;s - use charcode instead though
  1519. pre_space = pre_space.replace(/\s/g, "\u00A0");
  1520. // add the two together
  1521. lines[i] = pre_space + after_space;
  1522. // make a textNode
  1523. var textNode = msgDoc.createTextNode(lines[i]);
  1524. divNode.appendChild(textNode);
  1525. // add a break
  1526. var br = msgDoc.createElement("BR");
  1527. divNode.appendChild(br);
  1528. }
  1529. divNode.style.display = "";
  1530. var msgFrame = getMessageIFrame();
  1531. if(divNode.id && divNode.id.indexOf('DataItem') != -1){
  1532. msgFrame = getDialogFrame();
  1533. }
  1534. if (msgFrame.doInfoTabChange) {
  1535. msgFrame.doInfoTabChange(divNode.id ? divNode.id : divNode.name);
  1536. }
  1537. }
  1538. }
  1539. function ParmValues(valueString){
  1540. this.properties = new Object();
  1541. if(valueString){
  1542. this.parseValueString(valueString);
  1543. }
  1544. }
  1545. ParmValues.prototype.parseValueString = function(valueString){
  1546. this.cleanProperties();
  1547. var nameValues = valueString.split("&");
  1548. for(var i = 0; nameValues && i < nameValues.length; i++){
  1549. nameValue = nameValues[i].split("=");
  1550. if(nameValue.length == 2){
  1551. var name = this.cleanString(nameValue[0]);
  1552. //set a property on this parser
  1553. this.properties[name] = this.cleanString(nameValue[1]);
  1554. }
  1555. //grab the first occurrence
  1556. else if (nameValue.length > 2){
  1557. var pos = nameValues[i].indexOf("=");
  1558. var name=this.cleanString(nameValues[i].substring(0,pos));
  1559. var value=this.cleanString(nameValues[i].substring(pos+1,nameValues[i].length));
  1560. this.properties[name] = value;
  1561. }
  1562. }
  1563. }
  1564. ParmValues.prototype.createValueString = function(){
  1565. var valueString = "";
  1566. for (var i in this.properties) {
  1567. valueString += "&" + i + "=" + this.properties[i];
  1568. }
  1569. return valueString;
  1570. }
  1571. ParmValues.prototype.setProperty = function(name, value){
  1572. this.properties[name] = value;
  1573. }
  1574. ParmValues.prototype.cleanProperties = function(){
  1575. this.properties = new Object();
  1576. }
  1577. ParmValues.prototype.cleanString = function(valueString){
  1578. var re = /^['"](.*)['"]$/;
  1579. return valueString.replace(re,"$1");
  1580. }