ppwbcustomex.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. // Licensed Materials - Property of IBM
  2. //
  3. // IBM Cognos Products: pps
  4. //
  5. // (C) Copyright IBM Corp. 2005, 2017
  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 the Main pane of the
  9. // Custom Exceptions feature of PowerPlay Studio.
  10. // The functions handle any minor browser differences.
  11. var isNSBrowser = navigator.appName.indexOf("Netscape")>=0;
  12. if( navigator.appVersion == "" )
  13. isNSBrowser = false;
  14. var isNSMac = isNSBrowser && navigator.platform.indexOf("Mac") >= 0;
  15. var isIE = false; // Microsoft Internet Explorer
  16. var isNS4 = false; // Netscape 4+
  17. var isW3C = false; // W3C compliant (inc NS6)
  18. var isUnknown = true; // in case something else comes along
  19. if (document.getElementById) {
  20. isW3C = true ; // NS6, MSIE 5, 6 and Opera 6.01 in Opera mode
  21. isUnknown = false;
  22. }
  23. if (document.all) {
  24. isIE = true ; // MSIE (all versions) and Opera 6.01 in MSIE 5 mode
  25. isUnknown = false;
  26. }
  27. if (document.layers) {
  28. isNS4 = true ; // NS 4
  29. isUnknown = false;
  30. }
  31. var isGecko = isNSBrowser && isW3C;
  32. function findObj(n, d) {
  33. if (!isGecko) {
  34. var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  35. d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  36. if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  37. for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  38. if(!x && document.getElementById) x=document.getElementById(n); return x;
  39. } else {
  40. var p,i,x;
  41. if(!d)
  42. d=document;
  43. if((p=n.indexOf("?"))>0 && parent.frames.length) {
  44. d=parent.frames[n.substring(p+1)].contentDocument;
  45. n=n.substring(0,p);
  46. }
  47. x = document.getElementById(n);
  48. if(!x&&d.childNodes)
  49. x=d.getElementById(n);
  50. for (i=0;!x&&i<d.forms.length;i++)
  51. x=d.forms[i][n];
  52. return x;
  53. }
  54. }
  55. function editException () {
  56. if (parent.isXtabStillLoading())
  57. {
  58. setTimeout("editException(" + index + ")", 50);
  59. return;
  60. }
  61. winFX.doit('XE:' + parent.getSelException() );
  62. }
  63. function addException () {
  64. if (parent.isXtabStillLoading())
  65. {
  66. setTimeout("addException()", 50);
  67. return;
  68. }
  69. winFX.doit('XA:' + parent.getSelException() );
  70. }
  71. function deleteException () {
  72. if (parent.isXtabStillLoading())
  73. {
  74. setTimeout("deleteException(" + value + ")", 50);
  75. return;
  76. }
  77. var index = parent.getSelException();
  78. if (index == 0)
  79. return;
  80. winFX.doit('XD:' + index);
  81. }
  82. function applyException () {
  83. if (parent.isXtabStillLoading())
  84. {
  85. setTimeout("applyException()", 50);
  86. return;
  87. }
  88. if (findObj("selInfo").value.indexOf("sel_info") > 0) {
  89. writeErrorMessage(errNoSelection);
  90. return;
  91. }
  92. var command;
  93. var index = findObj("DefinedExceptions").selectedIndex;
  94. var value = '"' + findObj("selInfo").value + '"';
  95. if (index == 0) {
  96. index = "none";
  97. }
  98. command = 'XP:' + '"' + index +'"' + '\t' + value;
  99. winFX.doit(command);
  100. }
  101. function writeLayerDocument (content) {
  102. var doc = document.layers["Details"].document;
  103. doc.open();
  104. doc.write(content);
  105. doc.close();
  106. }
  107. function clearDetails(startIdx, bDoNoneLabel) {
  108. if (isNSBrowser && !isGecko) {
  109. var content = '<table cellspacing="0" cellpadding="0" border="0" ><tr width="100%"><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="40%" class="CustomExceptionDescription">&nbsp;' + fromLabel + '</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="40%" class="CustomExceptionDescription">&nbsp;' + toLabel + '</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="20%" align="right" class="CustomExceptionDescription">&nbsp;' + colorLabel + '</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td></tr><tr bgcolor="#FFFFFF"><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="40%" height="20%" class="CustomExceptionDescription">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="40%" class="CustomExceptionDescription">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="20%" align="right" class="CustomExceptionDescription">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td></tr><tr bgcolor="#FFFFFF"><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="40%" height="20%" class="CustomExceptionDescription">&nbsp;</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="40%" class="CustomExceptionDescription">&nbsp;</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="20%" align="right" class="CustomExceptionDescription">&nbsp;</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td></tr><tr bgcolor="#FFFFFF"><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="40%" height="20%" class="CustomExceptionDescription">&nbsp;</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="40%" align="center" class="CustomExceptionDescription">' + noneLabel + '</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="20%" align="right"';
  110. content = content + 'class="CustomExceptionDescription">&nbsp;</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td></tr><tr bgcolor="#FFFFFF"><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="40%" height="20%" class="CustomExceptionDescription">&nbsp;</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="40%" class="CustomExceptionDescription">&nbsp;</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="20%" align="right" class="CustomExceptionDescription">&nbsp;</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td></tr><tr bgcolor="#FFFFFF"><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="40%" height="20%" class="CustomExceptionDescription">&nbsp;</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="40%" class="CustomExceptionDescription">&nbsp;</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="20%" align="right" class="CustomExceptionDescription">&nbsp;</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td></tr></table>';
  111. writeLayerDocument(content);
  112. } else if (!isGecko) {
  113. for (var i = startIdx; i < 6; i++) {
  114. eval("document.all.From" + i).innerHTML = "";
  115. eval("document.all.To" + i).innerHTML = "";
  116. eval("document.all.Color" + i).innerHTML = "";
  117. eval("document.all.Color" + i + ".style").color = "#000000";
  118. eval("document.all.Color" + i + ".style").backgroundColor = "#FFFFFF";
  119. eval("document.all.Color" + i + ".style").height = 12;
  120. }
  121. if (bDoNoneLabel) {
  122. document.all.To3.innerHTML = noneLabel;
  123. document.all.To3.style.textAlign = "center";
  124. }
  125. } else {
  126. for (var i = startIdx; i < 6; i++) {
  127. document.getElementById("From" + i).innerHTML = "";
  128. document.getElementById("From" + i).style.height = 12;
  129. document.getElementById("To" + i).innerHTML = "";
  130. document.getElementById("To" + i).style.height = 12;
  131. document.getElementById("Color" + i).innerHTML = "";
  132. document.getElementById("Color" + i).style.color = "#000000";
  133. document.getElementById("Color" + i).style.backgroundColor = "#FFFFFF";
  134. document.getElementById("Color" + i).style.height = 12;
  135. }
  136. if (bDoNoneLabel) {
  137. document.getElementById("To3").innerHTML = noneLabel;
  138. document.getElementById("To3").style.textAlign = "center";
  139. }
  140. }
  141. }
  142. function refreshDetails(currentX) {
  143. var range;
  144. var marker;
  145. var count = 1;
  146. var ranges;
  147. var i;
  148. var layerDoc = '<table cellspacing="0" cellpadding="0" border="0" ><tr width="100%"><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="40%" class="CustomExceptionDescription">&nbsp;' + fromLabel + '</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="40%" class="CustomExceptionDescription">&nbsp;' + toLabel + '</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="20%" align="right" class="CustomExceptionDescription">&nbsp;' + colorLabel + '</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td></tr>';
  149. var fgColorVal, bgColorVal;
  150. marker = currentX.indexOf("\t");
  151. if (marker < 0 && currentX.length > 0) {
  152. ranges = currentX;
  153. } else {
  154. ranges = currentX.substr(0, marker);
  155. }
  156. marker = 0;
  157. while ( (marker = ranges.indexOf(";", marker+1)) > 0 ) {
  158. count++;
  159. }
  160. for ( i = 1; i <= count; i++) {
  161. var currentRange;
  162. var minValue, maxValue;
  163. if ( (marker = ranges.indexOf(";", 0)) > 0 ) {
  164. currentRange = ranges.substr(0, marker);
  165. ranges = ranges.substr(marker+1, ranges.length);
  166. } else {
  167. currentRange = ranges;
  168. }
  169. //Minimum
  170. minValue = localizedStrMinimum;
  171. if (currentRange.charAt(0) != _rseparator) {
  172. minValue = currentRange.substr(0, currentRange.indexOf(_rseparator, 0));
  173. minValue = minValue.replace("\.", decimalpt);
  174. }
  175. currentRange = currentRange.substr((currentRange.indexOf(_rseparator, 0)+1), currentRange.length);
  176. //Maximum
  177. maxValue = localizedStrMaximum;
  178. if (currentRange.charAt(0) != _rseparator) {
  179. maxValue = currentRange.substr(0, currentRange.indexOf(_rseparator, 0));
  180. maxValue = maxValue.replace("\.", decimalpt);
  181. }
  182. currentRange = currentRange.substr((currentRange.indexOf(_rseparator, 0)+1), currentRange.length);
  183. //Font color
  184. fgColorVal = "#000000";
  185. if (currentRange.charAt(0) != _rseparator) {
  186. fgColorVal = '#' + currentRange.substr(0, currentRange.indexOf(_rseparator, 0));
  187. }
  188. currentRange = currentRange.substr((currentRange.indexOf(_rseparator, 0)+1), currentRange.length);
  189. //Background color
  190. bgColorVal = "#FFFFFF";
  191. if (currentRange.charAt(0) != _rseparator) {
  192. bgColorVal = '#' + currentRange.substr(0, currentRange.indexOf(_rseparator, 0));
  193. }
  194. if (isNSBrowser && !isGecko) {
  195. layerDoc += '<tr><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td height="20%" width="40%" bgcolor="#FFFFFF">&nbsp;' + minValue + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>';
  196. layerDoc += '<td width="1" bgcolor="#CCCCFF">&nbsp;</td><td height="20%" width="40%" bgcolor="#FFFFFF">&nbsp;' + maxValue + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>';
  197. layerDoc += '<td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="20%" height="20%" align="right" bgcolor=' + '"' + bgColorVal + '"' + '><font color=' + '"' + fgColorVal + '"' + '>123</font></td><td width="1" bgcolor="#CCCCFF">&nbsp;</td></tr>';
  198. } else if (!isGecko) {
  199. eval("document.all.From" + i).innerHTML = minValue;
  200. eval("document.all.To" + i).innerHTML = maxValue;
  201. eval("document.all.Color" + i).style.color = fgColorVal;
  202. eval("document.all.Color" + i).style.backgroundColor = bgColorVal;
  203. eval("document.all.Color" + i).innerHTML = "123";
  204. eval("document.all.Color" + i).style.height = 12;
  205. } else {
  206. document.getElementById("From" + i).innerHTML = minValue;
  207. document.getElementById("To" + i).innerHTML = maxValue;
  208. document.getElementById("Color" + i).style.color = fgColorVal;
  209. document.getElementById("Color" + i).style.backgroundColor = bgColorVal;
  210. document.getElementById("Color" + i).innerHTML = "123";
  211. document.getElementById("Color" + i).style.height = 15;
  212. }
  213. }
  214. if (isNSBrowser && !isGecko) {
  215. //clear the rest...
  216. for (; i < 6 ; i++ ) {
  217. layerDoc += '<tr bgcolor="#FFFFFF"><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="40%" height="20%" class="CustomExceptionDescription">&nbsp;</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="40%" class="CustomExceptionDescription">&nbsp;</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td><td width="20%" align="right" class="CustomExceptionDescription">&nbsp;</td><td width="1" bgcolor="#CCCCFF">&nbsp;</td></tr>';
  218. }
  219. layerDoc += '</table>';
  220. writeLayerDocument(layerDoc);
  221. } else if (!isGecko){
  222. clearDetails(i, false);
  223. //gets set to center for "none" exception
  224. document.all.To3.style.textAlign = "left";
  225. } else {
  226. clearDetails(i, false);
  227. //gets set to center for "none" exception
  228. document.getElementById("To3").style.textAlign = "left";
  229. }
  230. }
  231. function loadDetails(selectedVal) {
  232. if ( parent.isXtabStillLoading() ) {
  233. setTimeout("loadDetails(" + selectedVal + ")", 50);
  234. return;
  235. }
  236. parent.setSelException(selectedVal);
  237. if (selectedVal == 0 || typeof(findObj("EX1", winFX.document)) == "undefined") {
  238. clearDetails(1, true);
  239. return;
  240. }
  241. var customX = findObj("EX1", winFX.document).value;
  242. var remainingX = customX;
  243. var currentX;
  244. var count = 0;
  245. for (var i = 1; i < selectedVal*2; i++) {
  246. //trim off the name
  247. count = remainingX.indexOf("\t") + 1;
  248. if ( count == 1 ) {
  249. count = 0;
  250. break;
  251. }
  252. remainingX = remainingX.substring(count, customX.length);
  253. }
  254. var endcount = remainingX.indexOf("\t");
  255. if (endcount < 0) {
  256. currentX = remainingX;
  257. } else {
  258. currentX = remainingX.substr(0, endcount);
  259. }
  260. refreshDetails(currentX);
  261. }
  262. function writeErrorMessage (msg) {
  263. var err = findObj("ErrorMessage");
  264. if (err) {
  265. if (isNSBrowser && !isGecko) {
  266. err.visibility = "visible";
  267. err.moveTo(11, document.layers["Details"].top + document.layers["Details"].clip.bottom);
  268. err.resizeTo(parent.FE.innerWidth - 26, 50);
  269. err.document.open();
  270. err.document.write('<html><body><table><tr><td><img src="../ppwb/Graphics/error.gif" height=18 width=18 alt=""></td><td class="CustomException" valign="middle">' + msg + '</td></tr></table></body></html>');
  271. err.document.close();
  272. } else {
  273. err.innerHTML = '<table><tr><td valign="middle"><img src="../ppwb/Graphics/error.gif" height=18 width=18 alt=""></td><td class="CustomException" valign="middle">' + msg + '</td></tr></table><br><br>';
  274. }
  275. }
  276. }
  277. function computeClip (layer) {
  278. layer.clip.left = 1;
  279. layer.clip.top = -1;
  280. if (isNSMac) {
  281. layer.clip.bottom = 100;
  282. layer.clip.right = parent.FE.innerWidth - (0.1 * parent.FE.innerWidth);
  283. } else {
  284. layer.clip.bottom = 120;
  285. layer.clip.right = parent.FE.innerWidth - 25;
  286. }
  287. }