custexcept.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971
  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. // of the Custom Exceptions feature of PowerPlay Studio.
  9. // The functions are Internet Explorer specific.
  10. var gDefinedExceptionPane = "";
  11. var gCreateExceptionPane = "";
  12. var gSelectedException = 0;
  13. var gbEditPaneActive = 0;
  14. var customExceptComboBoxes = new Array();
  15. var customExceptComboBoxIds = new Array();
  16. var exceptionDefinitionPane = null;
  17. var exceptionCreationPane = null;
  18. function writeErrorMessage (msg) {
  19. displayCommonMessage(msg, MESSAGE_TYPE_INFO, [message_ok_button_text], [function() {removeMessage();}]);
  20. }
  21. function numberChange(control) {
  22. var v = control.value;
  23. var name = control.name;
  24. var strMin = localizedStrMinimum.toLowerCase();
  25. var strMax = localizedStrMaximum.toLowerCase();
  26. name = name.substr(0, name.length-1);
  27. if ( (v.toLowerCase() == strMin && name.toLowerCase() == "from") || (v.toLowerCase() == strMax && name.toLowerCase() == "to") ) {
  28. return;
  29. }
  30. var w = "";
  31. var negative = false;
  32. var len = v.length;
  33. for ( var i = 0; i < len; i++ ) {
  34. if ( ( i==0||i==(len-1) ) && v.charAt(i)=="-" ) {
  35. negative = true;
  36. }
  37. else {
  38. if ( v.charAt(i) != thousandsep )
  39. w = w + v.charAt(i);
  40. }
  41. }
  42. v = w;
  43. var reptchr = "/[^0-9" + decimalpt + "]/";
  44. var pos = v.search(eval(reptchr));
  45. if (pos != -1)
  46. v = v.substring(0,pos);
  47. if ( negative )
  48. control.value = "-" + v;
  49. else
  50. control.value = v;
  51. }
  52. function toHex (num) {
  53. hexChars = "0123456789ABCDEF";
  54. var result = "";
  55. while (num > 0) {
  56. var hexC = hexChars[num % 16];
  57. result = hexC + result;
  58. num = (num - (num % 16)) /16;
  59. }
  60. if (result.length != 6) {
  61. for (var i=result.length; i < 6; i++) result = "0" + result;
  62. }
  63. return result;
  64. }
  65. function rgbToHex(num) {
  66. var r = parseInt(num.substring(4));
  67. var remains = num.substring(num.indexOf(",") + 1);
  68. var g = parseInt(remains);
  69. remains = remains.substring(remains.indexOf(",") + 1);
  70. var b = parseInt(remains);
  71. var dec = 65536 * r + 256 * g + b;
  72. return toHex(dec);
  73. }
  74. function setMinField() {
  75. var obj = document.getElementById(minField);
  76. if (obj)
  77. {
  78. obj.value = localizedStrMinimum;
  79. localizedStrMinimum = obj.value;
  80. }
  81. }
  82. function setMaxField() {
  83. var obj = document.getElementById(maxField);
  84. if (obj)
  85. {
  86. obj.value = localizedStrMaximum;
  87. localizedStrMaximum = obj.value;
  88. }
  89. }
  90. function showHideLayers() { // ask jason no arguments
  91. var p,v,obj,args=showHideLayers.arguments;
  92. for (var i=0; i<(args.length-2); i+=3) // ask jason if he remembers
  93. if ((obj=document.getElementById(args[i]))!=null) {
  94. v=args[i+2];
  95. if (obj.style) {
  96. obj=obj.style;
  97. v=(v=='show')?'visible':(v='hide')?'hidden':v;
  98. }
  99. obj.visibility=v;
  100. }
  101. }
  102. function hideAllLayers() {
  103. for (var i = 1; i < 6; i++) {
  104. showHideLayers('LayerMin' + i,'','hide');
  105. showHideLayers('LayerMax' + i,'','hide');
  106. showHideLayers('LayerFGColor' + i,'','hide');
  107. showHideLayers('LayerBGColor' + i,'','hide');
  108. }
  109. }
  110. function showLayer (event, name) {
  111. var obj=document.getElementById(name);
  112. if (obj) {
  113. hideAllLayers();
  114. showHideLayers(name, '', 'show');
  115. }
  116. var mgr = new eventManager(event);
  117. mgr.cancelBubble();
  118. }
  119. function refreshDetails(currentX) {
  120. var range;
  121. var marker;
  122. var count = 1;
  123. var ranges;
  124. var fgColorVal, bgColorVal, fontSize, textAlign, bold, italic, underlined;
  125. marker = currentX.indexOf("\t");
  126. if (marker < 0 && currentX.length > 0) {
  127. ranges = currentX;
  128. } else {
  129. ranges = currentX.substr(0, marker);
  130. }
  131. marker = 0;
  132. while ( (marker = ranges.indexOf(";", marker+1)) > 0 ) {
  133. count++;
  134. }
  135. for ( var i = 1; i <= count; i++) {
  136. var currentRange;
  137. var minValue, maxValue;
  138. if ( (marker = ranges.indexOf(";", 0)) > 0 ) {
  139. currentRange = ranges.substr(0, marker);
  140. ranges = ranges.substr(marker+1, ranges.length);
  141. } else {
  142. currentRange = ranges;
  143. }
  144. //Minimum
  145. minValue = localizedStrMinimum;
  146. if (currentRange.charAt(0) != _rseparator) {
  147. minValue = currentRange.substr(0, currentRange.indexOf(_rseparator, 0));
  148. minValue = minValue.replace("\.", decimalpt);
  149. }
  150. currentRange = currentRange.substr((currentRange.indexOf(_rseparator, 0)+1), currentRange.length);
  151. //Maximum
  152. maxValue = localizedStrMaximum;
  153. if (currentRange.charAt(0) != _rseparator) {
  154. maxValue = currentRange.substr(0, currentRange.indexOf(_rseparator, 0));
  155. maxValue = maxValue.replace("\.", decimalpt);
  156. }
  157. currentRange = currentRange.substr((currentRange.indexOf(_rseparator, 0)+1), currentRange.length);
  158. //Font color
  159. fgColorVal = "#000000";
  160. if (currentRange.charAt(0) != _rseparator) {
  161. fgColorVal = currentRange.substr(0, currentRange.indexOf(_rseparator, 0));
  162. }
  163. currentRange = currentRange.substr((currentRange.indexOf(_rseparator, 0)+1), currentRange.length);
  164. //Background color
  165. bgColorVal = "#FFFFFF";
  166. if (currentRange.charAt(0) != _rseparator) {
  167. bgColorVal = currentRange.substr(0, currentRange.indexOf(_rseparator, 0));
  168. }
  169. currentRange = currentRange.substr((currentRange.indexOf(_rseparator, 0)+1), currentRange.length);
  170. fontSize = "0";
  171. if (currentRange.charAt(0) != _rseparator) {
  172. fontSize = currentRange.substr(0, currentRange.indexOf(_rseparator, 0));
  173. }
  174. currentRange = currentRange.substr((currentRange.indexOf(_rseparator, 0)+1), currentRange.length);
  175. textAlign = "0";
  176. if (currentRange.charAt(0) != _rseparator) {
  177. textAlign = currentRange.substr(0, currentRange.indexOf(_rseparator, 0));
  178. }
  179. currentRange = currentRange.substr((currentRange.indexOf(_rseparator, 0)+1), currentRange.length);
  180. bold = false;
  181. if (currentRange.charAt(0) != _rseparator) {
  182. bold = (currentRange.substr(0, currentRange.indexOf(_rseparator, 0)) == "1");
  183. }
  184. currentRange = currentRange.substr((currentRange.indexOf(_rseparator, 0)+1), currentRange.length);
  185. italic = false;
  186. if (currentRange.charAt(0) != _rseparator) {
  187. italic = (currentRange.substr(0, currentRange.indexOf(_rseparator, 0)) == "1");
  188. }
  189. currentRange = currentRange.substr((currentRange.indexOf(_rseparator, 0)+1), currentRange.length);
  190. underlined = false;
  191. if (currentRange.charAt(0) != _rseparator) {
  192. underlined = (currentRange == "1");
  193. }
  194. // set up the display
  195. document.getElementById("Min" + i).innerHTML = minValue;
  196. document.getElementById("Max" + i).innerHTML = maxValue;
  197. var exampleCell = document.getElementById("Example" + i);
  198. exampleCell.innerHTML = '12345';
  199. exampleCell.style.backgroundColor = bgColorVal;
  200. exampleCell.style.color = fgColorVal;
  201. if (!bold)
  202. exampleCell.style.fontWeight = "";
  203. if (italic)
  204. exampleCell.style.fontStyle = "italic";
  205. if (underlined)
  206. exampleCell.style.textDecoration = "underline";
  207. switch (textAlign) {
  208. case "0": exampleCell.style.textAlign = "right"; break;
  209. case "1": exampleCell.style.textAlign = "left"; break;
  210. case "2": exampleCell.style.textAlign = "center"; break;
  211. case "3": exampleCell.style.textAlign = "right"; break;
  212. }
  213. //Set attributes for easy retrieval
  214. exampleCell.setAttribute("fontSize",fontSize);
  215. exampleCell.setAttribute("textAlign",textAlign);
  216. if (!bold)
  217. exampleCell.setAttribute("bold","false");
  218. if (italic)
  219. exampleCell.setAttribute("italic","true");
  220. if (underlined)
  221. exampleCell.setAttribute("underline","true");
  222. }
  223. }
  224. function clearDetails() {
  225. for (var i = 1; i <= 5; i++) {
  226. document.getElementById("currentExceptionLabel").innerHTML = "&nbsp;&nbsp";
  227. document.getElementById("Min" + i).innerHTML = "";
  228. document.getElementById("Max" + i).innerHTML = "";
  229. var exampleCell = document.getElementById("Example" + i);
  230. exampleCell.innerHTML = "";
  231. exampleCell.style.backgroundColor = "#FFFFFF";
  232. exampleCell.style.color = "#000000";
  233. exampleCell.style.fontWeight = "bold";
  234. exampleCell.style.fontStyle = "";
  235. exampleCell.style.textDecoration = "";
  236. exampleCell.style.textAlign = "";
  237. exampleCell.setAttribute("fontSize",0);
  238. exampleCell.setAttribute("fontSize","0");
  239. exampleCell.setAttribute("textAlign","0");
  240. exampleCell.setAttribute("bold","true");
  241. exampleCell.setAttribute("italic","false");
  242. exampleCell.setAttribute("underline","false");
  243. }
  244. }
  245. function loadDetails(selectedOption) {
  246. // clear the existing exception from the display
  247. clearDetails();
  248. gSelectedException = selectedOption.selectedIndex;
  249. if(gSelectedException == 0) // the 'none' option is selected, there is nothing to load
  250. return;
  251. if (!topparent.getXtabFrame().document.fhidden.EX1) {
  252. clearDetails();
  253. return;
  254. }
  255. var customX = topparent.getXtabFrame().document.fhidden.EX1.value;
  256. var remainingX = customX;
  257. var currentX;
  258. var count = 0;
  259. for (var i = 1; i < gSelectedException*2; i++) {
  260. //trim off the name
  261. count = remainingX.indexOf("\t") + 1;
  262. if ( count == 1 ) {
  263. count = 0;
  264. break;
  265. }
  266. remainingX = remainingX.substring(count, customX.length);
  267. }
  268. var endcount = remainingX.indexOf("\t");
  269. if (endcount < 0) {
  270. currentX = remainingX;
  271. } else {
  272. currentX = remainingX.substr(0, endcount);
  273. }
  274. var sLabel = document.getElementById("DefinedExceptions")[gSelectedException].text;
  275. document.getElementById("currentExceptionLabel").innerHTML = CEncodingUtil.HtmlEncode(sLabel);
  276. refreshDetails(currentX);
  277. }
  278. function isDuplicateName (name, otherEx)
  279. {
  280. //nothing to check!
  281. if (otherEx.length <= 0) {
  282. return false;
  283. }
  284. var tabPos = otherEx.indexOf('\t\t', 0);
  285. if (tabPos > 0) {
  286. otherEx = otherEx.substr(0, tabPos);
  287. }
  288. while (otherEx.charAt(0) == '\t') {
  289. otherEx = otherEx.substr(1);
  290. }
  291. var fwdPtr = 0;
  292. var backPtr = -1;
  293. while (fwdPtr >= 0) {
  294. fwdPtr = otherEx.indexOf('\t', backPtr+1);
  295. if (name.toLowerCase() == otherEx.substr(backPtr+1, fwdPtr-(backPtr+1)).toLowerCase()) {
  296. return true; //duplicate...return TRUE
  297. }
  298. fwdPtr = otherEx.indexOf('\t', fwdPtr+1);
  299. backPtr = fwdPtr;
  300. }
  301. //unique name...return FALSE
  302. return false;
  303. }
  304. function getStartPosition() {
  305. var selectedVal = gSelectedException - 1;
  306. if (selectedVal < 0) {
  307. return -1;
  308. }
  309. var customX = topparent.getXtabFrame().document.fhidden.EX1.value;
  310. var count = 0;
  311. for (var i = 0; i < selectedVal*2; i++) {
  312. count = customX.indexOf('\t', count+1) ;
  313. }
  314. if (customX.charAt(count) == '\t') {
  315. return count+1;
  316. } else {
  317. return count;
  318. }
  319. }
  320. function getEndPosition(startCount) {
  321. var customX = topparent.getXtabFrame().document.fhidden.EX1.value;
  322. var endCount = customX.indexOf('\t', startCount);
  323. endCount = customX.indexOf('\t', endCount+1);
  324. if (endCount < 0) return customX.length;
  325. return endCount;
  326. }
  327. function buildException() {
  328. var def = document.getElementById("exception_name_edit_field").value;
  329. var strMin = localizedStrMinimum.toLowerCase();
  330. var strMax = localizedStrMaximum.toLowerCase();
  331. //Error: no exception name
  332. if (def.length <= 0) {
  333. writeErrorMessage(noNameErr);
  334. return (-1);
  335. }
  336. def += '\t';
  337. var ranges = "";
  338. var validChars = "/[^0-9" + decimalpt + "\-]/";
  339. var pos;
  340. for ( var i=1 ; i < 6 ; i++ ) {
  341. var from = document.getElementById("From" + i).value;
  342. var to = document.getElementById("To" + i).value;
  343. var decimalPtPattern = new RegExp('\\' + decimalpt);
  344. if (from != "" && to != "") {
  345. if (from.toLowerCase() != strMin && !CNumUtil.validateNumField(document.getElementById("From" + i), true, validChars)) {
  346. writeErrorMessage(invalidRangeValueErr);
  347. return (-1);
  348. }
  349. if (from.toLowerCase() != strMin){
  350. from = CNumUtil.normalizeDecimal(from);
  351. ranges += from;
  352. }
  353. ranges += _rseparator;
  354. if (to.toLowerCase() != strMax && !CNumUtil.validateNumField(document.getElementById("To" + i), true, validChars)) {
  355. writeErrorMessage(invalidRangeValueErr);
  356. return (-1);
  357. }
  358. if (to.toLowerCase() != strMax){
  359. to = CNumUtil.normalizeDecimal(to);
  360. ranges += to;
  361. }
  362. ranges += _rseparator;
  363. if (parseFloat(from) > parseFloat(to)) {
  364. writeErrorMessage(invalidRangeErr);
  365. return (-1);
  366. }
  367. var font = document.getElementById("FGColor" + i);
  368. var cell = document.getElementById("BGColor" + i);
  369. var strFont;
  370. var strCell;
  371. var strFont = font.getAttribute("color");
  372. var strCell = cell.getAttribute("color");
  373. var strBold = (document.getElementById("bold" + i).getAttribute("pressed") == "true")? "1" : "0" ;
  374. var strItalic = (document.getElementById("italic" + i).getAttribute("pressed") == "true")? "1" : "0" ;
  375. var strUnderline = (document.getElementById("underline" + i).getAttribute("pressed") == "true")? "1" : "0" ;
  376. var strTextAlign = "0";
  377. if (document.getElementById("textAlign" + i + "_left").getAttribute("pressed") == "true")
  378. strTextAlign = "1";
  379. else if (document.getElementById("textAlign" + i + "_center").getAttribute("pressed") == "true")
  380. strTextAlign = "2";
  381. else if (document.getElementById("textAlign" + i + "_right").getAttribute("pressed") == "true")
  382. strTextAlign = "3";
  383. var fontSizes = new Array(0,4,6,7,8,9,10,11,12,13,14,15,16,18,20);
  384. var strFontSize = "" + fontSizes[customExceptComboBoxes[("fontSize" + i)].getSelectedItem()];
  385. strFont = strFont.toUpperCase();
  386. ranges += strFont;
  387. ranges += _rseparator;
  388. strCell = strCell.toUpperCase();
  389. ranges += strCell;
  390. ranges += _rseparator;
  391. ranges += strFontSize;
  392. ranges += _rseparator;
  393. ranges += strTextAlign;
  394. ranges += _rseparator;
  395. ranges += strBold;
  396. ranges += _rseparator;
  397. ranges += strItalic;
  398. ranges += _rseparator;
  399. ranges += strUnderline;
  400. ranges += ';';
  401. } else if (from != "" || to != "") {
  402. writeErrorMessage(missingRangeValueErr);
  403. return (-1);
  404. }
  405. }
  406. //Error: no valid ranges
  407. if (ranges.length <= 0) {
  408. writeErrorMessage(noValidRangeErr);
  409. return (-1);
  410. }
  411. //trim off trailing ';'
  412. ranges = ranges.substr(0, ranges.length-1);
  413. def += ranges;
  414. return (def);
  415. }
  416. function addException() {
  417. clearAllPopups();
  418. var beforeX, afterX, currentX, customX;
  419. var hidEx = topparent.getXtabFrame().document.fhidden.EX1;
  420. if(!hidEx)
  421. customX = "";
  422. else
  423. customX = topparent.getXtabFrame().document.fhidden.EX1.value;
  424. var end;
  425. var start = getStartPosition();
  426. if (start < 0 || gbEditPaneActive == 0) {
  427. //must be a new one!! look for '\t\t'...
  428. var tabPos = customX.indexOf('\t\t', 0);
  429. if (tabPos < 0) {
  430. if (customX.length > 0) {
  431. beforeX = customX + '\t';
  432. } else {
  433. beforeX = ""
  434. }
  435. end = -1;
  436. } else {
  437. beforeX = customX.substr(0, tabPos);
  438. if( beforeX.length > 0 )
  439. beforeX += '\t';
  440. end = tabPos;
  441. }
  442. } else {
  443. beforeX = customX.substr(0, start);
  444. end = getEndPosition(start) ;
  445. }
  446. if (end < 0) {
  447. afterX = "";
  448. } else {
  449. afterX = customX.substr(end);
  450. }
  451. currentX = buildException();
  452. if (currentX == -1) {
  453. return;
  454. }
  455. //now, finally, check for duplicate names
  456. var tempBeforeX = beforeX;
  457. if (beforeX.charAt(beforeX.length-1) == '\t') {
  458. tempBeforeX = beforeX.substr(0, beforeX.length-1);
  459. }
  460. otherEx = tempBeforeX + afterX;
  461. if ( isDuplicateName(currentX.substr(0, currentX.indexOf('\t', 0)), otherEx) ) {
  462. writeErrorMessage(duplicateNameErr);
  463. return;
  464. }
  465. if(!hidEx) {
  466. var hiddenForm = topparent.getXtabFrame().document.getElementById("fhidden");
  467. // set the form's display style to "none" to avoid the xtab shifting downwards. For some unknown reason, IE adjusts the view for this new
  468. // input object even though it is hidden.
  469. hiddenForm.style.display = "none";
  470. if (!topparent.getGlobal("safari"))
  471. {
  472. var htmlToAppend = '<INPUT TYPE="HIDDEN" NAME="EX1" VALUE=""/>' + "\n";
  473. hiddenForm.innerHTML += htmlToAppend;
  474. }
  475. else
  476. {
  477. var vxPara = topparent.getXtabFrame().document.createElement('INPUT');
  478. vxPara.setAttribute('type', 'hidden');
  479. vxPara.setAttribute('NAME', 'EX1');
  480. vxPara.setAttribute('value', ' ');
  481. hiddenForm.appendChild(vxPara);
  482. }
  483. }
  484. topparent.getXtabFrame().document.fhidden.EX1.value = beforeX + currentX + afterX;
  485. var exceptName = document.getElementById("exception_name_edit_field").value;
  486. // reset the action pane the default size
  487. topparent.setActionPaneHeight("225");
  488. document.getElementById("exceptPaneContainer").removeChild(exceptionCreationPane);
  489. document.getElementById("exceptPaneContainer").appendChild(exceptionDefinitionPane);
  490. var exceptionList = document.getElementById("DefinedExceptions");
  491. var index = exceptionList.length;
  492. var command;
  493. if (gbEditPaneActive == 0) {
  494. command = 'A';
  495. }
  496. else {
  497. command = 'E';
  498. }
  499. topparent.getXtabFrame().doit('X' + command + ':' + '-1');
  500. if(command == 'A') {
  501. var newOption = new Option(exceptName,"");
  502. exceptionList[index] = newOption;
  503. exceptionList.selectedIndex = index;
  504. } else {
  505. exceptionList[gSelectedException].text = exceptName;
  506. }
  507. // refresh the details for the currently selected exception
  508. loadDetails(exceptionList);
  509. }
  510. function deleteException () {
  511. var exceptionList = document.getElementById("DefinedExceptions");
  512. var index = exceptionList.selectedIndex;
  513. if (index == 0) // if the none option is selected don't do anything
  514. return;
  515. topparent.getXtabFrame().doit('XD:' + index);
  516. exceptionList[index] = null;
  517. exceptionList.selectedIndex = 0;
  518. gSelectedException = 0;
  519. clearDetails();
  520. }
  521. function buildSelectionString () {
  522. var result = "";
  523. var rowSelections = topparent.getXtabFrame().getSelected("r");
  524. var colSelections = topparent.getXtabFrame().getSelected("c");
  525. for(var i = 0; i < rowSelections.length; ++i) {
  526. if( rowSelections[i].getAttribute("summary") )
  527. result += "S";
  528. result += rowSelections[i].getAttribute("ppdsId") + "\t";
  529. }
  530. for(var i = 0; i < colSelections.length; ++i) {
  531. if( colSelections[i].getAttribute("summary") )
  532. result += "S";
  533. result += colSelections[i].getAttribute("ppdsId") + "\t";
  534. }
  535. if (topparent.getXtabFrame().allSelected)
  536. result += "ALL" + "\t";
  537. return result;
  538. }
  539. function generateDefaultName() {
  540. var generatedName = "";
  541. var i = 1;
  542. if(!topparent.getXtabFrame().document.fhidden.EX1)
  543. return defaultExceptionNameLabel + i;
  544. var customX = topparent.getXtabFrame().document.fhidden.EX1.value;
  545. while(generatedName == "") {
  546. if(!customX) {
  547. generatedName = defaultExceptionNameLabel + i;
  548. }
  549. else if(!isDuplicateName(defaultExceptionNameLabel + i, customX)) {
  550. generatedName = defaultExceptionNameLabel + i;
  551. }
  552. ++i;
  553. }
  554. return generatedName;
  555. }
  556. function newException () {
  557. gbEditPaneActive = 0;
  558. // adjust the size of the action pane to accomodate the new exception pane.
  559. topparent.setActionPaneHeight("280");
  560. document.getElementById("exceptPaneContainer").removeChild(exceptionDefinitionPane);
  561. document.getElementById("exceptPaneContainer").appendChild(exceptionCreationPane);
  562. // load defaults values
  563. document.getElementById("exception_name_edit_field").value = generateDefaultName();
  564. for (var i = 1; i <= 5; i++) {
  565. document.getElementById("From" + i).value = "";
  566. document.getElementById("To" + i).value = "";
  567. setColorPicker(("BGColor" + i),"FFFFFF");
  568. setColorPicker(("FGColor" + i),"000000");
  569. setButtonState(document.getElementById("bold" + i),true);
  570. setButtonState(document.getElementById("italic" + i),false);
  571. setButtonState(document.getElementById("underline" + i),false);
  572. setButtonState(document.getElementById("textAlign" + i + "_left"),false);
  573. setButtonState(document.getElementById("textAlign" + i + "_center"),false);
  574. setButtonState(document.getElementById("textAlign" + i + "_right"),false);
  575. customExceptComboBoxes[("fontSize" + i)].setSelectedItem(0);
  576. }
  577. }
  578. function editException () {
  579. if(gSelectedException == 0) // none option is selected
  580. return newException();
  581. gbEditPaneActive = 1;
  582. // adjust the size of the action pane to accomodate the edit exception pane.
  583. topparent.setActionPaneHeight("294");
  584. var exceptionsSelect = document.getElementById("DefinedExceptions");
  585. var nameOfException = exceptionsSelect[exceptionsSelect.selectedIndex].text;
  586. var minSetting = new Array(5);
  587. var maxSetting = new Array(5);
  588. var bgColors = new Array(5);
  589. var fgColors = new Array(5);
  590. var fontSizes = new Array(5);
  591. var textAligns = new Array(5);
  592. var bolds = new Array(5);
  593. var italics = new Array(5);
  594. var underlines = new Array(5);
  595. for (var i = 1; i <= 5; ++i) {
  596. minSetting[i-1] = document.getElementById("Min" + i).innerHTML;
  597. maxSetting[i-1] = document.getElementById("Max" + i).innerHTML;
  598. var cellExample = document.getElementById("Example" + i);
  599. bgColors[i-1] = cellExample.style.backgroundColor;
  600. fgColors[i-1] = cellExample.style.color;
  601. fontSizes[i-1] = parseInt(cellExample.getAttribute("fontSize"));
  602. textAligns[i-1] = parseInt(cellExample.getAttribute("textAlign"));
  603. bolds[i-1] = (cellExample.getAttribute("bold") == "true");
  604. italics[i-1] = (cellExample.getAttribute("italic") == "true");
  605. underlines[i-1] = (cellExample.getAttribute("underline") == "true");
  606. }
  607. document.getElementById("exceptPaneContainer").removeChild(exceptionDefinitionPane);
  608. document.getElementById("exceptPaneContainer").appendChild(exceptionCreationPane);
  609. document.getElementById("exception_name_edit_field").value = nameOfException;
  610. for (var i = 1; i <= 5; ++i) {
  611. document.getElementById("From" + i).value = minSetting[i-1];
  612. document.getElementById("To" + i).value = maxSetting[i-1];
  613. var bgcolor = bgColors[i-1].toString();
  614. var fgcolor = fgColors[i-1].toString();
  615. if (bgcolor.substring(0,3) == "rgb") {
  616. bgcolor = rgbToHex(bgcolor);
  617. fgcolor = rgbToHex(fgcolor);
  618. } else {
  619. bgcolor = bgcolor.toUpperCase().substr(1);
  620. fgcolor = fgcolor.toUpperCase().substr(1);
  621. }
  622. setColorPicker(("BGColor" + i),bgcolor);
  623. setColorPicker(("FGColor" + i),fgcolor);
  624. setButtonState(document.getElementById("bold" + i), bolds[i-1]);
  625. setButtonState(document.getElementById("italic" + i), italics[i-1]);
  626. setButtonState(document.getElementById("underline" + i), underlines[i-1]);
  627. setButtonState(document.getElementById("textAlign" + i + "_left"), (textAligns[i-1] == "1"));
  628. setButtonState(document.getElementById("textAlign" + i + "_center"), (textAligns[i-1] == "2"));
  629. setButtonState(document.getElementById("textAlign" + i + "_right"), (textAligns[i-1] == "3"));
  630. var fontSizeItem = 0;
  631. switch (fontSizes[i-1]) {
  632. case 0: fontSizeItem = 0; break;
  633. case 4: fontSizeItem = 1; break;
  634. case 6: fontSizeItem = 2; break;
  635. case 7: fontSizeItem = 3; break;
  636. case 8: fontSizeItem = 4; break;
  637. case 9: fontSizeItem = 5; break;
  638. case 10: fontSizeItem = 6; break;
  639. case 11: fontSizeItem = 7; break;
  640. case 12: fontSizeItem = 8; break;
  641. case 13: fontSizeItem = 9; break;
  642. case 14: fontSizeItem = 10; break;
  643. case 15: fontSizeItem = 11; break;
  644. case 16: fontSizeItem = 12; break;
  645. case 18: fontSizeItem = 13; break;
  646. case 20: fontSizeItem = 14; break;
  647. }
  648. customExceptComboBoxes[("fontSize" + i)].setSelectedItem(fontSizeItem);
  649. }
  650. }
  651. function onCancel() {
  652. clearAllPopups();
  653. topparent.setActionPaneHeight("230");
  654. document.getElementById("exceptPaneContainer").removeChild(exceptionCreationPane);
  655. document.getElementById("exceptPaneContainer").appendChild(exceptionDefinitionPane);
  656. loadDetails(document.getElementById("DefinedExceptions"));
  657. }
  658. function onOk() {
  659. applyException();
  660. topparent.closeActionPane();
  661. }
  662. function applyException () {
  663. var selectionString = buildSelectionString();
  664. if (selectionString.length == 0) {
  665. return;
  666. }
  667. if (selectionString.indexOf("ALL") >= 0)
  668. selectionString = 0;
  669. var command;
  670. var index = document.getElementById("DefinedExceptions").selectedIndex;
  671. var value = '"' + selectionString + '"';
  672. if (index == 0) {
  673. index = "none";
  674. }
  675. command = 'XP:' + '"' + index +'"' + '\t' + value;
  676. topparent.getXtabFrame().doit(command);
  677. }
  678. function init () {
  679. topparent.openActionPane();
  680. topparent.setActionPaneHeight("230");
  681. initFontSizes();
  682. // cache the defined exceptions pane and clear it from the active pane
  683. exceptionDefinitionPane = document.getElementById("definedExceptPane");
  684. document.getElementById("exceptPaneContainer").removeChild(exceptionDefinitionPane);
  685. // cache the new/edit exception pane and clear it from active pane
  686. exceptionCreationPane = document.getElementById("createExceptPane");
  687. document.getElementById("exceptPaneContainer").removeChild(exceptionCreationPane);
  688. // set the active pane to the defined exception pane
  689. document.getElementById("exceptPaneContainer").appendChild(exceptionDefinitionPane);
  690. }
  691. function fontButtonClicked(event) {
  692. var eventM = new eventManager(event);
  693. eventM.cancelBubble();
  694. var button = eventM.getSrc();
  695. toggleButton(button);
  696. }
  697. function toggleButton(button) {
  698. if (button.getAttribute("isdisabled") == "true")
  699. return;
  700. if (button.getAttribute("pressed") == "true") {
  701. setButtonState(button,false);
  702. } else {
  703. setButtonState(button,true);
  704. }
  705. }
  706. function setButtonState(button,pressed) {
  707. if (pressed) {
  708. button.className = "chartOptionsFontButtonPressed";
  709. button.setAttribute("pressed","true");
  710. } else {
  711. button.className = "chartOptionsFontButton";
  712. button.setAttribute("pressed","false");
  713. }
  714. }
  715. function rolloverbutton(button) {
  716. if (button.getAttribute("isdisabled") == "true")
  717. return;
  718. if (button.getAttribute("pressed") == "true") {
  719. button.className = "chartOptionsFontButtonRolloverPressed";
  720. } else {
  721. button.className = "chartOptionsFontButtonRollover";
  722. }
  723. }
  724. function rolloutbutton(button) {
  725. if (button.getAttribute("isdisabled") == "true")
  726. return;
  727. if (button.getAttribute("pressed") == "true") {
  728. button.className = "chartOptionsFontButtonPressed";
  729. } else {
  730. button.className = "chartOptionsFontButton";
  731. }
  732. }
  733. function alignButtonClicked(event) {
  734. var eventM = new eventManager(event);
  735. eventM.cancelBubble();
  736. var button = eventM.getSrc();
  737. if (button.getAttribute("pressed") == "true") {
  738. setButtonState(button,false);
  739. } else {
  740. setButtonState(document.getElementById(button.id.substr(0,button.id.indexOf("_")) + "_left"),false);
  741. setButtonState(document.getElementById(button.id.substr(0,button.id.indexOf("_")) + "_center"),false);
  742. setButtonState(document.getElementById(button.id.substr(0,button.id.indexOf("_")) + "_right"),false);
  743. setButtonState(button,true);
  744. }
  745. }
  746. function initFontSizes() {
  747. //Because of the removal of the combo boxes from the dom, they have to be intialized each
  748. //time the edit exception pane is viewed.
  749. for (var i = 1; i <= 5; i++) {
  750. var id = "fontSize" + i;
  751. initializeFontSizeSelect(id);
  752. }
  753. }
  754. function initializeFontSizeSelect(comboBoxId,action) {
  755. var currentFontSizeSelect = document.getElementById(comboBoxId);
  756. if (currentFontSizeSelect) {
  757. var currentComboBox = initComboBox(currentFontSizeSelect);
  758. currentComboBox.addItem(new cbTextItem(strDefault, action, true));
  759. currentComboBox.addItem(new cbTextItem("4", action, false));
  760. currentComboBox.addItem(new cbTextItem("6", action, false));
  761. currentComboBox.addItem(new cbTextItem("7", action, false));
  762. currentComboBox.addItem(new cbTextItem("8", action, false));
  763. currentComboBox.addItem(new cbTextItem("9", action, false));
  764. currentComboBox.addItem(new cbTextItem("10", action, false));
  765. currentComboBox.addItem(new cbTextItem("11", action, false));
  766. currentComboBox.addItem(new cbTextItem("12", action, false));
  767. currentComboBox.addItem(new cbTextItem("13", action, false));
  768. currentComboBox.addItem(new cbTextItem("14", action, false));
  769. currentComboBox.addItem(new cbTextItem("15", action, false));
  770. currentComboBox.addItem(new cbTextItem("16", action, false));
  771. currentComboBox.addItem(new cbTextItem("18", action, false));
  772. currentComboBox.addItem(new cbTextItem("20", action, false));
  773. customExceptComboBoxes[comboBoxId] = currentComboBox;
  774. customExceptComboBoxIds[customExceptComboBoxIds.length] = comboBoxId;
  775. }
  776. }
  777. function clearAllPopups() {
  778. for (var i = 0; i < customExceptComboBoxIds.length; i++) {
  779. customExceptComboBoxes[customExceptComboBoxIds[i]].hideDropDown();
  780. }
  781. hideColorPicker();
  782. }