base.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. // Licensed Materials - Property of IBM
  2. //
  3. // IBM Cognos Products: pps
  4. //
  5. // (C) Copyright IBM Corp. 2005, 2022
  6. //
  7. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  8. // This forms the javascript functions used for PowerPlay Studio
  9. // except for those functions involved with HTML4
  10. // The functions handle any minor browser differences.
  11. var fh, gImgArray, iconHelp;
  12. var imgNm;
  13. var FTok = false;
  14. var _fhchanged = false;
  15. var _fhtarget;
  16. var _fhaction;
  17. var _fhRA;
  18. var gparent = getGrandParentofFXWindow();
  19. var hasFinishedLoading = 0;
  20. function winFocus(w) {
  21. if(w!=null&&w.focus!=null)
  22. w.focus();
  23. }
  24. function sync( ){
  25. gImgArray=gparent.FT.gToolbarImg;
  26. iconHelp=gparent.FT.iconHelp1;
  27. FTok = true;
  28. }
  29. function initVars(){
  30. fh=document.fhidden;
  31. if (fh) {
  32. fh.CO.value = "";
  33. fh.RA.value = "999";
  34. captureScreenRes(fh);
  35. if(gparent.FXloaded!=null){
  36. gparent.FXloaded=1;
  37. gparent.sync();
  38. }
  39. }
  40. }
  41. function captureScreenRes(fh){
  42. setCookie("BRes",screen.availWidth + "*" + screen.availHeight,(10*365),topparent.getGlobal('cookieSecure'));
  43. }
  44. function initXtab(){
  45. initVars();
  46. reloadActionPane();
  47. reloadToolbar();
  48. }
  49. function crosstab()
  50. {
  51. var ACT_PANE_NONE = 0;
  52. var ACT_PANE_FIND = 1;
  53. var ACT_PANE_HIDESHOW = 2;
  54. var ACT_PANE_EXPLAIN = 4;
  55. var ACT_PANE_PDFOPTIONS = 5;
  56. var ACT_PANE_DISPLAYOPTIONS = 6;
  57. var ACT_PANE_CALCULATION = 7;
  58. var ACT_PANE_CUSTOMEXCEPTIONS = 8;
  59. var ACT_PANE_EDITTITLE = 9;
  60. var ACT_PANE_CUSTOM_SUBSETS_INIT = 10;
  61. var ACT_PANE_RANK = 11;
  62. var ACT_PANE_SUPPRESS_OPTIONS = 12;
  63. var ACT_PANE_CHART_OPTIONS = 13;
  64. var ACT_PANE_XTAB_OPTIONS = 14;
  65. var ACT_PANE_ABOUT = 15;
  66. var actionFrame = ACT_PANE_NONE;
  67. switch (fh.CO.value) {
  68. case "MF": actionFrame = ACT_PANE_FIND; break;
  69. case "ME": actionFrame = ACT_PANE_EXPLAIN; break;
  70. case "MQ": actionFrame = ACT_PANE_HIDESHOW; break;
  71. case "MT": actionFrame = ACT_PANE_DISPLAYOPTIONS; break;
  72. case "MC": actionFrame = ACT_PANE_CALCULATION; break;
  73. case "MX": actionFrame = ACT_PANE_CUSTOMEXCEPTIONS; break;
  74. case "MP": actionFrame = ACT_PANE_PDFOPTIONS; break;
  75. case "MI": actionFrame = ACT_PANE_EDITTITLE; break;
  76. case "MO": actionFrame = ACT_PANE_RANK; break;
  77. case "MD": actionFrame = ACT_PANE_SUPPRESS_OPTIONS; break;
  78. case "MY": actionFrame = ACT_PANE_CHART_OPTIONS; break;
  79. case "MB": actionFrame = ACT_PANE_XTAB_OPTIONS; break;
  80. case "MA": actionFrame = ACT_PANE_ABOUT; break;
  81. default:
  82. if (fh.CO.value.indexOf("MZ") == 0) {
  83. actionFrame = ACT_PANE_CUSTOM_SUBSETS_INIT;
  84. }
  85. }
  86. if (actionFrame != ACT_PANE_NONE)
  87. {
  88. if(actionFrame == ACT_PANE_EXPLAIN)
  89. setSelections();
  90. if (fh.ACTPANE.value == actionFrame &&
  91. (actionFrame != ACT_PANE_CUSTOM_SUBSETS_INIT || fh.CO.value == "MZI") &&
  92. (topparent.document.getElementById("rightFrameset").rows.indexOf("*,0")))
  93. {//Close Action frame and set to none.
  94. topparent.closeActionPane();
  95. return;
  96. }
  97. else
  98. {//Set to correct action pane and render
  99. fh.ACTPANE.value = actionFrame;
  100. fh.CNCT.value = 19;
  101. fh.target = "ActionPane";
  102. }
  103. parseAndSubmit(fh);
  104. }
  105. else
  106. {
  107. var xtabFrame = topparent.getXtabFrame();
  108. var chartFrame = topparent.getChartFrame();
  109. if ( topparent.isChartPaneOpen() )
  110. {
  111. topparent.chartHeight = chartFrame.document.body.offsetHeight;
  112. topparent.xtabHeight = xtabFrame.document.body.offsetHeight;
  113. }
  114. if((fh.CO.value).substring(0,2)!='GE') //export to PDF
  115. fh.target = topparent.Data.name;
  116. else
  117. fh.target = "_blank";
  118. if ((fh.CO.value).substring(0,4) == 'RA:1') {
  119. fh.target = "_blank";
  120. }
  121. fh.CNCT.value = 14;
  122. parseAndSubmit(fh);
  123. }
  124. FTok=false;
  125. }
  126. function doit(action){
  127. //preventative parsing
  128. if ( action.charAt((action.length - 1)) == '\t' && action.charAt((action.length - 2)) == '\t' )
  129. action = action.substr(0, action.length - 2);
  130. initVars(); // required for NS3 as it does not trap the resize event
  131. if (action.charAt(0) == "!") {
  132. eval(action.substring(1));
  133. } else {
  134. if(fh) {
  135. if(fh.RA.value != 12)
  136. fh.RA.value = 999;
  137. if( action.substring(0,2) == "LM" ){
  138. fh.LM.value=action;
  139. } else {
  140. fh.CO.value=action;
  141. }
  142. if (fh.CNCT.value == 5) {
  143. fh.CNCT.value = 1;
  144. fh.target = "_self";
  145. }
  146. crosstab();
  147. }
  148. }
  149. }
  150. function doParent(action, target){
  151. fh.CO.value=action;
  152. if (!topparent.name)
  153. topparent.name = "temp";
  154. if (target)
  155. fh.target = target;
  156. else
  157. fh.target = topparent.name;
  158. FTok=false;
  159. parseAndSubmit(fh);
  160. }
  161. function doOver(a,n,r){
  162. if(FTok) {
  163. document.images[a].src=gImgArray[n][r].src;
  164. window.status=what(iconHelp[n]);
  165. }
  166. return true;
  167. }
  168. function doClick(a,n,it){
  169. doOver(a,n,2);
  170. eval("doit('" + it + "')");
  171. }
  172. function what(t){
  173. status = t;
  174. return true;
  175. }
  176. function getGrandParentofFXWindow()
  177. {
  178. var retVal = window.parent;
  179. // If we are in split-view, the parent
  180. // frame will be the "Data" frame. If so,
  181. // we want the parent of "Data".
  182. if (retVal.name == "Data")
  183. retVal = window.parent.parent;
  184. return retVal;
  185. }
  186. function setSelections() {
  187. var rowSelections = getSelected("r");
  188. var colSelections = getSelected("c");
  189. var action = fh.CO.value;
  190. if(fh.CO.value == "ME")
  191. fh.EXPL.value = '1';
  192. if (rowSelections.length == 1 && rowSelections[0].getAttribute("nodeId")){
  193. if (colSelections.length == 1 || !colSelections.length){
  194. action += ":" + "r" + rowSelections[0].getAttribute("nodeId");
  195. }
  196. }
  197. if (colSelections.length == 1 && colSelections[0].getAttribute("nodeId")){
  198. if (!rowSelections.length)
  199. action += ":" + "c" + colSelections[0].getAttribute("nodeId");
  200. if(rowSelections.length == 1)
  201. {
  202. if(fh.CO.value == "ME")
  203. fh.EXPL.value = '1\tc' + colSelections[0].getAttribute("nodeId");
  204. }
  205. }
  206. fh.CO.value=action;
  207. }
  208. function parseAndSubmit(fh)
  209. {
  210. //************WARNING*************
  211. //** Do not do this with any other hidden form parameter
  212. //** The ACTPANE parameter is special since we know that
  213. //** it's value is correct, and won't corrupt the LKGS
  214. //********************************
  215. //We need to add the active action pane to the LKGS
  216. if (fh.LKGS)
  217. fh.LKGS.value += "&ACTPANE=" + fh.ACTPANE.value;
  218. if (fh.DSHSP && !topparent.getGlobal('is_save')) {
  219. fh.removeChild(fh.DSHSP);
  220. }
  221. if ((document.charset && document.charset.toLowerCase() == "shift_jis") ||
  222. (document.characterSet && document.characterSet.toLowerCase() == "shift_jis"))
  223. {
  224. var children = fh.childNodes;
  225. var length = children.length;
  226. var i=0;
  227. for (; i < length; i++)
  228. {
  229. var child = children[i];
  230. if (child.value)
  231. {
  232. child.value = escape(child.value);
  233. var str = child.value;
  234. str = str.replace(/%u2016/g, "%u2225");
  235. str = str.replace(/%u2014/g, "%u2015");
  236. str = str.replace(/%u301C/g, "%uff5e");
  237. str = str.replace(/%u2212/g, "%uff0d");
  238. child.value = unescape(str);
  239. }
  240. }
  241. }
  242. // XSRF-TOKEN cookie is null when disableXSRFCheck=true in bootstrap.properties.
  243. var xsrfTokenCookie = getCookie("XSRF-TOKEN");
  244. if (xsrfTokenCookie && (fh.CO.value).substring(0,3) == 'IP:')
  245. {
  246. // CAPSIRTS-412 / CAPP-171 and CAPP-332
  247. // 1. In PowerPlay Studio, right click in blank area of right pane or click "Display Options" in toolbar.
  248. // 2. Select "Edit Title...", enter or change title, and click "OK".
  249. var input = document.createElement("input");
  250. input.setAttribute("name", "pp_client_caf");
  251. input.setAttribute("type", "hidden");
  252. fh.appendChild(input);
  253. fh.ppClientCAF = input;
  254. fh.ppClientCAF.setAttribute("value", "");
  255. var existingForm = document.getElementById(fh.id);
  256. var xhr = new XMLHttpRequest();
  257. xhr.onreadystatechange = function()
  258. {
  259. if (xhr.readyState === 4)
  260. {
  261. parent.Data.document.write(xhr.responseText);
  262. parent.Data.document.close();
  263. }
  264. }
  265. xhr.open(existingForm.method, existingForm.action, false);
  266. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  267. xhr.setRequestHeader("X-XSRF-TOKEN", xsrfTokenCookie);
  268. xhr.send(getFormDataQueryString(existingForm));
  269. }
  270. else
  271. {
  272. fh.submit();
  273. }
  274. }
  275. function getFormDataQueryString(form)
  276. {
  277. var keyValuePairs = [];
  278. for (var i = 0; i < form.elements.length; i++)
  279. {
  280. var element = form.elements[i];
  281. keyValuePairs.push(encodeURIComponent(element.name) + "=" + encodeURIComponent(element.value));
  282. }
  283. return queryString = keyValuePairs.join("&");
  284. }