calculation.js 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257
  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 Calculation pane of
  9. // PowerPlay Studio.
  10. // The functions handle any minor browser differences.
  11. var rightPane;
  12. var addrightPane;
  13. var subrightPane;
  14. var forrightPane;
  15. var forExplain;
  16. var accrightPane;
  17. var rollrightPane;
  18. var addSelect;
  19. var subSelect1;
  20. var subSelect2;
  21. var accSelect;
  22. var rollSelect;
  23. var operationSelect;
  24. var calcOpTypesSelect;
  25. var rc;
  26. var dim;
  27. var selecteddim;
  28. var selections;
  29. var catarr;
  30. var calcID;
  31. var editCode; //calculation being editing
  32. var errorMsg = "";
  33. var calcTypeIndex; //remember the calc type
  34. var calcOpTypesIndex; //remember the calc operation type
  35. var calcTypesArray = new Array();
  36. var calcOpTypesArray= new Array();
  37. var categories = new Array();
  38. categories["R"] = new Array();
  39. categories["C"] = new Array();
  40. var lowestDimInAxis = new Array();
  41. function addToArray(rc, dim, name, code, calc, rankBased, top_of_dim, POB_nonbaseable) {
  42. if (!categories[rc][dim]) {
  43. categories[rc][dim] = new Array();
  44. }
  45. //Use the fact that the lowest level categories are added last to the array
  46. lowestDimInAxis[rc] = dim;
  47. categories[rc][dim][categories[rc][dim].length] = new categoryRecord(name, code, calc, rankBased, top_of_dim, POB_nonbaseable);
  48. }
  49. function categoryRecord(name, code, calc, rankBased, top_of_dim, POB_nonbaseable) {
  50. this._name = name;
  51. this._calc = calc;
  52. this._code = code;
  53. this._rankBased = rankBased;
  54. this._top_of_dim = top_of_dim;
  55. this._POB_nonbaseable = POB_nonbaseable;
  56. if (!calc)
  57. {
  58. var comma = code.search(',');
  59. if (comma > -1)
  60. {
  61. var dimIdx = parseInt(code.substr(comma+1));
  62. this._isMeasure = topparent.getGlobal("gDimensionInfo")[dimIdx].isMeasureDimension;
  63. }
  64. }
  65. }
  66. function initVars() {
  67. rightPane = document.getElementById("details");
  68. //Store Each calculation type's sub-dom tree.
  69. addrightPane = document.getElementById("addDetails");
  70. subrightPane = document.getElementById("subDetails");
  71. forrightPane = document.getElementById("forDetails");
  72. accrightPane = document.getElementById("accDetails");
  73. rollrightPane = document.getElementById("rollDetails");
  74. pctbaserightPane = document.getElementById("PctBaseDetails");
  75. addSelect = document.getElementById("addCatSel");
  76. subSelect1 = document.getElementById("subCatSel1");
  77. subSelect2 = document.getElementById("subCatSel2");
  78. accSelect = document.getElementById("accCatSel");
  79. pctBaseSelect = document.getElementById("pctBaseSel");
  80. pctBaseBaseSelect = document.getElementById("pctBaseBase");
  81. rollSelect = document.getElementById("rollCatSel");
  82. forExplain = document.getElementById("forecastExplanation");
  83. operationSelect = document.getElementById("calcType");
  84. calcOpTypesSelect = document.getElementById("calcOpType");
  85. //Remove each calculations sub-dom tree.
  86. rightPane.removeChild(addrightPane);
  87. rightPane.removeChild(subrightPane);
  88. rightPane.removeChild(forrightPane);
  89. rightPane.removeChild(accrightPane);
  90. rightPane.removeChild(rollrightPane);
  91. rightPane.removeChild(pctbaserightPane);
  92. calcOpTypesIndex = -1;
  93. calcTypeIndex = -1;
  94. }
  95. function init() {
  96. topparent.openActionPane();
  97. ContextMenu.initialize(true,false);
  98. document.getElementById("calcOpType").selectedIndex = 0;
  99. document.getElementById("calcType").selectedIndex = 0;
  100. initVars();
  101. initErrorVars();
  102. createCategoryRecords();
  103. resetDialog();
  104. }
  105. function refresh() {
  106. resetDialog();
  107. }
  108. function resetDialog() {
  109. removeMessage();
  110. displayContent();
  111. if (document.getElementById("applyButton"))
  112. document.getElementById("applyButton").disabled = true;
  113. if (calcOpTypesSelect)
  114. calcOpTypesSelect.disabled = true;
  115. if (operationSelect)
  116. operationSelect.disabled = true;
  117. if (document.preCalculation) {
  118. document.preCalculation.delete_calc.checked=true;
  119. document.preCalculation.edit.checked=false;
  120. document.preCalculation.rename.checked=false;
  121. document.preCalculation.insert.checked=false;
  122. }
  123. popSelections();
  124. var rowcolswitch = false;
  125. var rowSelections = getSelected("r");
  126. var colSelections = getSelected("c");
  127. if (rowSelections.length && colSelections.length) { //Both rows and columns selected
  128. handleError(strNoSelectionsMsg , true);
  129. return;
  130. } else if (!rowSelections.length && !colSelections.length) {//No rows or columns selected
  131. if( !isLevelSelected("r") && !isLevelSelected("c") ) {
  132. handleError(strNoSelectionsMsg, true);
  133. return;
  134. }
  135. else {
  136. if( isLevelSelected("r") ) {
  137. rc = "R";
  138. }
  139. else {
  140. rc = "C";
  141. }
  142. }
  143. }
  144. if (rowSelections.length || isLevelSelected("r")) {
  145. if (rc != "R")
  146. rowcolswitch = true;
  147. rc = "R";
  148. if (isLevelSelected("r"))
  149. dim = getSelectedLevel().getAttribute("dimIdx");
  150. else if (!resetRowColArray(rowSelections))
  151. return;
  152. } else {
  153. if (rc != "C")
  154. rowcolswitch = true;
  155. rc = "C";
  156. if (isLevelSelected("c"))
  157. dim = getSelectedLevel().getAttribute("dimIdx");
  158. else if (!resetRowColArray(colSelections))
  159. return;
  160. }
  161. catarr = categories[rc][dim];
  162. if (!catarr || !catarr.length) {
  163. handleError(strNoSelectionsMsg, true);
  164. return;
  165. }
  166. //if the editingCalc is true, then user is editting a calculation (value of 2 is for renaming calculation only).
  167. var editCalc = topparent.getGlobal("editingCalc");
  168. //the only selection is a non-isolated calculation, so render the preContent to ask user to
  169. //choose it is going to be an insert or edit.
  170. if(catarr != null){
  171. if(catarr.length > 1 && (rowSelections.length == 1 ^ colSelections.length == 1)){
  172. if(editCalc == -1) {
  173. var theSel = rowSelections.length > 0 ? rowSelections[0] : colSelections[0];
  174. if(theSel.getAttribute("calculation") == 'true' && theSel.getAttribute("rank") != 'true'){
  175. selecteddim = null;
  176. clearDialogs();
  177. displayPreContent();
  178. return;
  179. }
  180. }
  181. }
  182. }
  183. calcID = "0";
  184. editCode = "";
  185. if(editCalc == 1 || editCalc == 2 || editCalc == 3){
  186. editCode = rowSelections.length == 1 ? rowSelections[0].getAttribute("ppdsId") : colSelections[0].getAttribute("ppdsId");
  187. if(editCode.charAt(0) == 'T')
  188. calcID = editCode.substring(1, editCode.length);//will be used in the command sent to server when apply changes.
  189. }
  190. // While editing calculations, we need to preserve this variable so as to not allow replacement of any calculation by forecast.
  191. if(editCalc != 1)
  192. topparent.setGlobal("editingCalc", -1);
  193. if (rowSelections.length && resetforCalc(rowSelections, editCalc))
  194. return;
  195. else if (resetforCalc(colSelections, editCalc))
  196. return;
  197. document.getElementById("calcOpType").disabled = false;
  198. document.getElementById("calcType").disabled = false;
  199. document.getElementById("applyButton").disabled = false;
  200. if (((dim == selecteddim) && (!rowcolswitch)) && (calcID == "0")) {
  201. if (getCurrentCalc()._type == 0) {//refresh add or roll selections
  202. preSelectOptions(document.getElementById("addCatSel"));
  203. } else if (getCurrentCalc()._type == 3) {
  204. preSelectOptions(document.getElementById("rollCatSel"));
  205. }
  206. return;
  207. } else {
  208. selecteddim = dim;
  209. }
  210. clearDialogs();
  211. var sCmd = "gDimensionInfo[" + dim + "].isTimeDimension";
  212. popCalcOpTypes();
  213. popCalcTypes(topparent.getGlobal(sCmd),isOnlyRanks());
  214. setCalcType(true);
  215. }
  216. function resetforCalc(categ, editCalc) {
  217. if(calcID == "0")
  218. return false;
  219. if ((categ.length != 1) || (categ[0].getAttribute("ppdsId").charAt(0) != 'T')) //not a calculation edit
  220. return false;
  221. //set the calcId to new calculation;
  222. dim = categ[0].getAttribute("dimIdx");
  223. catarr = categories[rc][dim];
  224. if(editCalc == 1) {
  225. popDialogWithCalcInfo(categ[0].getAttribute("ppdsId")); //We have to populate for the calculation.
  226. displayContent();
  227. }
  228. else if (editCalc == 2) {
  229. displayRenameContent(); //change label only
  230. popRenameInfo(categ[0].getAttribute("ppdsId"));
  231. document.getElementById("labelRenameField").select()
  232. }
  233. else if( editCalc == 3 )
  234. {
  235. //close the dialog and delete the calc!!
  236. if (categ[0].getAttribute("dependent_cats") != null) {
  237. displayDeleteContent();
  238. popDeleteInfo(categ[0].getAttribute("dependent_cats"));
  239. } else {
  240. topparent.closeActionPane();
  241. var del = 'MK:' + categ[0].getAttribute("ppdsId");
  242. topparent.getXtabFrame().doit(del);
  243. }
  244. return true;
  245. }
  246. if (document.getElementById("calcOpType"))
  247. document.getElementById("calcOpType").disabled = false;
  248. if (document.getElementById("calcType"))
  249. document.getElementById("calcType").disabled = false;
  250. if (document.getElementById("applyButton"))
  251. document.getElementById("applyButton").disabled = false;
  252. return true;
  253. }
  254. function popDeleteInfo(dependents) {
  255. var div = document.getElementById("referencedCalcs");
  256. var deps = dependents.split("\t");
  257. for (var i = 0; i < deps.length; i++) {
  258. div.appendChild(document.createTextNode(deps[i]));
  259. div.appendChild(document.createElement("BR"));
  260. }
  261. }
  262. function resetRowColArray(array) {
  263. dim = array[0].getAttribute("dimIdx");
  264. for (var i = 1;i < array.length;i++) {
  265. var tempdim = array[i].getAttribute("dimIdx");
  266. if (tempdim != dim) {
  267. handleError(strIncorrectSelectionsMsg, true);
  268. return false;
  269. }
  270. }
  271. return true;
  272. }
  273. function clearDialogs() {
  274. if (document.getElementById("labelField"))
  275. document.getElementById("labelField").value = "";
  276. }
  277. function getCurrentCalcOpType() {
  278. return operationsTypesArray[document.getElementById("calcOpType").options[document.getElementById("calcOpType").selectedIndex].value];
  279. }
  280. function setCalcOpType(preselect) {
  281. //we pop only calculations that belong to selected operation type
  282. //and we preselect the very first calculation type
  283. var sCmd = "gDimensionInfo[" + dim + "].isTimeDimension";
  284. popCalcTypes(topparent.getGlobal(sCmd),isOnlyRanks());
  285. operationSelect.selectedIndex = 0;
  286. setCalcType(true);
  287. }
  288. function getCurrentCalc() {
  289. return operationsArray[document.getElementById("calcType").options[document.getElementById("calcType").selectedIndex].value];
  290. }
  291. function setCalcType(preselect) {
  292. calcTypeIndex = operationSelect.selectedIndex;
  293. var calc = getCurrentCalc();
  294. if (rightPane.childNodes.length > 0)
  295. rightPane.removeChild(rightPane.childNodes[0]);
  296. switch (calc._type) {
  297. case 0:
  298. rightPane.appendChild(addrightPane);
  299. document.getElementById("labelDiv").style.visibility = "visible";
  300. break;
  301. case 2:
  302. rightPane.appendChild(subrightPane);
  303. document.getElementById("subtagSpot").innerHTML = "<br>" + CEncodingUtil.HtmlEncode(calc._tag);
  304. document.getElementById("labelDiv").style.visibility = "visible";
  305. break;
  306. case 1:
  307. rightPane.appendChild(accrightPane);
  308. document.getElementById("labelDiv").style.visibility = "visible";
  309. break;
  310. case 3:
  311. rightPane.appendChild(rollrightPane);
  312. document.getElementById("labelDiv").style.visibility = "visible";
  313. break;
  314. case 4:
  315. rightPane.appendChild(forrightPane);
  316. document.getElementById("labelDiv").style.visibility = "hidden";
  317. document.getElementById("forecastExplanation").style.visibility = "visible";
  318. break;
  319. case 5:
  320. rightPane.appendChild(pctbaserightPane);
  321. document.getElementById("labelDiv").style.visibility = "visible";
  322. break;
  323. }
  324. popCategories(calc, preselect, editCode.length); //If editing then remove dependents of current calc
  325. }
  326. function operRec(tag, type, opType, rankApplicable) {
  327. this._tag = tag;
  328. this._type = type;
  329. this._opType = opType;
  330. if (rankApplicable != '')
  331. this._rankApplicable = true;
  332. else
  333. this._rankApplicable = false;
  334. }
  335. function calcOpTypeRec(name, opType) {
  336. this._name = name;
  337. this._opType = opType;
  338. }
  339. function calcTypeRec(name, value, opType, isOnlyTime,isRankApplicable) {
  340. this._name = name;
  341. this._value = value;
  342. this._opType = opType;
  343. if (isOnlyTime != '')
  344. this._isOnlyTime = true;
  345. else
  346. this._isOnlyTime = false;
  347. if (isRankApplicable != '')
  348. this._isRankApplicable = true;
  349. else
  350. this._isRankApplicable = false;
  351. }
  352. function addToOpTypeOptionArray(name, opType) {
  353. calcOpTypesArray[calcOpTypesArray.length] = new calcOpTypeRec(name,opType);
  354. }
  355. function addToOptionArray(name, value, opType, isOnlyTime, isRankApplicable) {
  356. calcTypesArray[calcTypesArray.length] = new calcTypeRec(name,value,opType, isOnlyTime,isRankApplicable);
  357. }
  358. function isOnlyRanks() {
  359. var onlyRanks = true;
  360. if (catarr != null) {
  361. for (var i = 0; i < catarr.length && onlyRanks; i++)
  362. if (!catarr[i]._rankBased)
  363. onlyRanks = false;
  364. }
  365. return onlyRanks;
  366. }
  367. function popOptions(select, incCalcs, incRanks, restrictCurrentCalc) {
  368. var idx = select.options.length;
  369. while (idx > 0) {
  370. select.options[--idx] = null;
  371. }
  372. var selIdx = 0;
  373. var showCat;
  374. if (catarr != null) {
  375. for (var i = 0; i < catarr.length; i++){
  376. showCat = true;
  377. if (catarr[i]._top_of_dim == true)
  378. showCat = false;
  379. if (catarr[i]._code == editCode)
  380. showCat = false;
  381. if (catarr[i]._calc && (!incCalcs || isForcastCalc(catarr[i]._code)))
  382. showCat = false;
  383. if (catarr[i]._rankBased && !incRanks)
  384. showCat = false;
  385. if (restrictCurrentCalc && catarr[i]._calc && isBasedOnCalc(catarr[i]._code,"T" + calcID))
  386. showCat = false;
  387. if (showCat) {
  388. select.options[selIdx] = new Option(catarr[i]._name,i);
  389. select.options[selIdx++].label = catarr[i]._name;
  390. }
  391. }
  392. }
  393. return selIdx;
  394. }
  395. function popOtherAxisOptions(select) {
  396. var dimArray = categories[ ((rc == "R")? "C" : "R") ][lowestDimInAxis[ ((rc == "R")? "C" : "R")] ];
  397. var selIdx = 0;
  398. var idx = select.options.length;
  399. while (idx > 0) {
  400. select.options[--idx] = null;
  401. }
  402. if (dimArray) {
  403. for (var i = 0; i < dimArray.length; i++) {
  404. if (!dimArray[i]._POB_nonbaseable) {
  405. select.options[selIdx] = new Option(dimArray[i]._name,i);
  406. select.options[selIdx++].label = CEncodingUtil.HtmlEncode(dimArray[i]._name);
  407. }
  408. }
  409. }
  410. }
  411. function clearOtherAxisOptions(select) {
  412. var idx = select.options.length;
  413. while (idx > 0) {
  414. select.options[--idx] = null;
  415. }
  416. }
  417. function isForcastCalc(id) {
  418. var calcInfo = getcalcInfo(id);
  419. if (calcInfo && (calcInfo._oper == "f")) {
  420. return true;
  421. }
  422. return false;
  423. }
  424. function popCalcOpTypes() {
  425. var select = document.getElementById("calcOpType");
  426. var idx = select.options.length;
  427. while (idx > 0) {
  428. select.options[--idx] = null;
  429. }
  430. var nIdx = 0;
  431. for (var i = 0; i < calcOpTypesArray.length; i++)
  432. {
  433. select.options[nIdx] = new Option(calcOpTypesArray[i]._name,calcOpTypesArray[i]._opType);
  434. select.options[nIdx].label = CEncodingUtil.HtmlEncode(calcOpTypesArray[i]._name);
  435. nIdx++;
  436. }
  437. if(calcOpTypesIndex != -1)
  438. select.selectedIndex = calcOpTypesIndex;
  439. else
  440. select.selectedIndex = 0;
  441. }
  442. function popCalcTypes(isTimeDim, isOnlyRanks) {
  443. var select = document.getElementById("calcType");
  444. var idx = select.options.length;
  445. while (idx > 0) {
  446. select.options[--idx] = null;
  447. }
  448. var selectedOpTypesIndex = 1; //initialize to one just in case
  449. //we'll pop only calculations that belong to selected operation type
  450. var selectedOpType = getCurrentCalcOpType();
  451. if(typeof selectedOpType != "undefined")
  452. selectedOpTypesIndex = selectedOpType._opType;
  453. //when poping calculation, first check if we are currently editing existing calc
  454. //in that case we do not want to pop forecast
  455. var excludeForecast = false;
  456. if(catarr != null){
  457. var editCalc = topparent.getGlobal("editingCalc");
  458. if(editCalc == 1){
  459. var rowSelections = getSelected("r");
  460. var colSelections = getSelected("c");
  461. if(catarr.length > 0 && (rowSelections.length == 1 ^ colSelections.length == 1))
  462. {
  463. var id = rowSelections.length == 1 ? rowSelections[0].getAttribute("ppdsId") : colSelections[0].getAttribute("ppdsId");
  464. if(id.charAt(0) == 'T')
  465. {
  466. var calcInfo = getcalcInfo(id);
  467. excludeForecast = operationsArray[calcInfo._oper]._type != 4;
  468. }
  469. }
  470. }
  471. }
  472. var nIdx = 0;
  473. for (var i = 0; i < calcTypesArray.length; i++) {
  474. if ((!calcTypesArray[i]._isOnlyTime || isTimeDim) &&
  475. (calcTypesArray[i]._isRankApplicable || !isOnlyRanks) &&
  476. (calcTypesArray[i]._value != 'f' || !excludeForecast) &&
  477. (calcTypesArray[i]._opType == selectedOpTypesIndex)) { //No forecast option for edits
  478. select.options[nIdx] = new Option(calcTypesArray[i]._name,calcTypesArray[i]._value);
  479. select.options[nIdx].label = CEncodingUtil.HtmlEncode(calcTypesArray[i]._name);
  480. nIdx++;
  481. }
  482. }
  483. if(calcTypeIndex != -1 && calcTypeIndex < select.childNodes.length) {
  484. select.selectedIndex = calcTypeIndex;
  485. }
  486. }
  487. function popCategories(calc, preselect, restrictCurrentCalc) {
  488. var currentSelectionIndex = 0;
  489. switch (calc._type) {
  490. case 0:
  491. currentSelectionIndex = popOptions(addSelect,true,calc._rankApplicable,restrictCurrentCalc);
  492. if (preselect && currentSelectionIndex)
  493. preSelectOptions(addSelect);
  494. break;
  495. case 2:
  496. currentSelectionIndex = popOptions(subSelect1,true,calc._rankApplicable,restrictCurrentCalc);
  497. if( currentSelectionIndex )
  498. currentSelectionIndex = popOptions(subSelect2,true,calc._rankApplicable,restrictCurrentCalc);
  499. break;
  500. case 1:
  501. currentSelectionIndex = popOptions(accSelect,true,calc._rankApplicable,restrictCurrentCalc);
  502. if (preselect && currentSelectionIndex)
  503. preSelectOptions(accSelect);
  504. break;
  505. case 3:
  506. currentSelectionIndex = popOptions(rollSelect,false,calc._rankApplicable,restrictCurrentCalc);
  507. if (preselect && currentSelectionIndex)
  508. preSelectOptions(rollSelect);
  509. break;
  510. case 5:
  511. currentSelectionIndex = popOptions(pctBaseSelect, true, calc._rankApplicable, restrictCurrentCalc);
  512. if (preselect && currentSelectionIndex)
  513. preSelectOptions(pctBaseSelect);
  514. clearOtherAxisOptions(pctBaseBaseSelect);
  515. break;
  516. }
  517. if( !currentSelectionIndex && calc._type != 4) {
  518. handleError(strNoSelectionsMsg, true);
  519. return;
  520. }
  521. }
  522. function preSelectOptions(select) {
  523. for (var i = 0; i < select.length; i++) {
  524. var val = select[i].value;
  525. if (catarr[val])
  526. {
  527. var catCode = catarr[val]._code;
  528. if(catCode.charAt(0) == 'T')
  529. select[i].selected = selections[catCode];
  530. else
  531. select[i].selected = selections[parseInt(catarr[val]._code)];
  532. }
  533. }
  534. }
  535. function popSelections() {
  536. var selects = getSelected("r");
  537. if (selects.length == 0)
  538. selects = getSelected("c");
  539. selections = new Array();
  540. for (var i = 0; i < selects.length; i++)
  541. selections[selects[i].getAttribute("ppdsId")] = true;
  542. }
  543. function onRenameCalculation() {
  544. if (document.getElementById("labelRenameField").value == "") {
  545. topparent.closeActionPane();
  546. return;
  547. }
  548. var label = document.getElementById("labelRenameField").value;
  549. var cmd = 'MN:' + editCode;
  550. cmd += "\t";
  551. cmd += '"' + CEncodingUtil.EncodeStrOperand(label) + '"';
  552. topparent.closeActionPane();
  553. topparent.getXtabFrame().doit(cmd);
  554. }
  555. function onDeleteCalculation() {
  556. if (document.getElementById("delCalc").checked) {
  557. topparent.closeActionPane();
  558. var cmd = 'MK:' + editCode;
  559. topparent.getXtabFrame().doit(cmd);
  560. } else {
  561. topparent.closeActionPane();
  562. var cmd = 'MH:0\t' + editCode;
  563. topparent.getXtabFrame().doit(cmd);
  564. }
  565. }
  566. function applyChanges() {
  567. if (!validateInput()) {
  568. if(errorMsg != ""){
  569. calcOpTypesIndex = calcOpTypesSelect.selectedIndex;
  570. calcTypeIndex = operationSelect.selectedIndex;
  571. handleError(errorMsg, false);
  572. }
  573. return;
  574. }
  575. var cmd = "C" + operationSelect.options[operationSelect.selectedIndex].value + ":";
  576. var label = document.getElementById("labelField").value;
  577. cmd += (label && getCurrentCalc()._type != 4) ? ('"' + CEncodingUtil.EncodeStrOperand(label) + '"') : "";
  578. cmd += "\t" + calcID;
  579. cmd += "\t" + "-1\t";
  580. cmd += (document.getElementById("customPosition").checked)? ("2\t" + ((rc == 'R')? "1" : "0")) : "0\t0";
  581. topparent.getXtabFrame().fh.ACTPANE.value = 0;
  582. switch(getCurrentCalc()._type)
  583. {
  584. case 0:
  585. cmd = getAddCmd(cmd);break;
  586. case 1:
  587. cmd = getAccCmd(cmd); break;
  588. case 2:
  589. cmd = getSubCmd(cmd);break;
  590. case 3:
  591. cmd = getRollCmd(cmd);break;
  592. case 4:
  593. cmd = getForCmd(cmd);break;
  594. case 5:
  595. cmd = getPctBaseCmd(cmd);break;
  596. }
  597. if (cmd.charAt(0) == '!') {
  598. return;
  599. } else {
  600. topparent.getXtabFrame().doit(cmd);
  601. }
  602. topparent.closeActionPane();
  603. }
  604. function getCatFromDimIdxPair(catNo) {
  605. var dimArray = categories[ ((rc == "R")? "C" : "R") ][ lowestDimInAxis[ ((rc == "R")? "C" : "R")] ];
  606. return dimArray[catNo];
  607. }
  608. function getAccCmd(cmd) {
  609. cmd += "\t" + catarr[document.getElementById("accCatSel").options[document.getElementById("accCatSel").selectedIndex].value]._code;
  610. return cmd;
  611. }
  612. function getPctBaseCmd(cmd) {
  613. cmd += "\t" + catarr[document.getElementById("pctBaseSel").options[document.getElementById("pctBaseSel").selectedIndex].value]._code;
  614. if (document.getElementById("pctBaseTypeBase").checked) {
  615. var cat = getCatFromDimIdxPair(document.getElementById("pctBaseBase").options[document.getElementById("pctBaseBase").selectedIndex].value);
  616. cmd += "\t" + cat._code;
  617. }
  618. return cmd;
  619. }
  620. function getSubCmd(cmd) {
  621. var error = false;
  622. if (document.getElementById("rcat1").checked)
  623. cmd += "\t" + catarr[document.getElementById("subCatSel1").options[document.getElementById("subCatSel1").selectedIndex].value]._code;
  624. else {
  625. if (document.getElementById("subNum1").value)
  626. cmd += "\t" + CNumUtil.normalizeDecimal(document.getElementById("subNum1").value);
  627. else
  628. error = true;
  629. }
  630. if (document.getElementById("rcat2").checked)
  631. cmd += "\t" + catarr[document.getElementById("subCatSel2").options[document.getElementById("subCatSel2").selectedIndex].value]._code;
  632. else {
  633. if (document.getElementById("subNum2").value)
  634. cmd += "\t" + CNumUtil.normalizeDecimal(document.getElementById("subNum2").value);
  635. else
  636. error = true;
  637. }
  638. if (error)
  639. cmd = "!:" + strProvideNumbersMsg;
  640. return cmd;
  641. }
  642. function getAddCmd(cmd) {
  643. var ctr = numSelected(document.getElementById("addCatSel"));
  644. cmd += getListCmd(document.getElementById("addCatSel"));
  645. if (document.getElementById("userNumberCB").checked)
  646. {
  647. ctr++;
  648. cmd += "\t" + CNumUtil.normalizeDecimal(document.getElementById("addNum1").value);
  649. }
  650. if (ctr < 2)
  651. cmd = "!:" + strSelectMoreCatMsg;
  652. return cmd;
  653. }
  654. function getRollCmd(cmd) {
  655. var ctr = numSelected(document.getElementById("rollCatSel"));
  656. if (ctr == 0)
  657. cmd = "!:" + strSelectCatMsg;
  658. else
  659. cmd += getListCmd(document.getElementById("rollCatSel"));
  660. return cmd;
  661. }
  662. function getForCmd(cmd) {
  663. var i = 0;
  664. while (catarr[i]._top_of_dim)
  665. i++;
  666. cmd += "\t" + catarr[i]._code + "\t";
  667. cmd += document.getElementById("ForMethod").value + "\t";
  668. cmd += document.getElementById("ForNum").value;
  669. return cmd;
  670. }
  671. function numSelected(list) {
  672. var ctr = 0;
  673. for (var i = 0; i < list.options.length; i++) {
  674. if (list.options[i].selected)
  675. ctr++;
  676. }
  677. return ctr;
  678. }
  679. function getListCmd(list) {
  680. var cmd = "";
  681. for (var i = 0; i < list.options.length; i++) {
  682. if (list.options[i].selected)
  683. cmd += "\t" + catarr[list.options[i].value]._code;
  684. }
  685. return cmd;
  686. }
  687. function dialogOperand(type, code) {
  688. this._type = type;
  689. this._code = code;
  690. }
  691. function dialogInfo(oper, label, operands) {
  692. this._oper = oper;
  693. this._label = label;
  694. this._operands = operands;
  695. this._defaultPosition = true;
  696. }
  697. function getcalcInfo(id) {
  698. var idx = parseInt(id.substring(1));
  699. if (topparent.getXtabFrame().fh && topparent.getXtabFrame().fh.PT) {
  700. var calcs = topparent.getXtabFrame().fh.PT.value.split("\t\t");
  701. var dim;
  702. for (var i = 0; i < calcs.length; i++) {
  703. var x = calcs[i].split("\t");
  704. var j = 0;
  705. if (x[j].charAt(0) == 'D') dim = x[j++].substring(1);
  706. if (i == idx - 1) {
  707. var rIdx = 0;
  708. var op = x[j++];
  709. var opt = op.substring(2).split(",");
  710. var pos = opt[0];
  711. var label = opt[1];
  712. var operands = new Array;
  713. for (;j < x.length; j++) {
  714. if (x[j].charAt(0) == 'D') {
  715. x[j] = x[j].substr(x[j].indexOf(',') + 1);
  716. }
  717. if (x[j].charAt(0) == 'T') {
  718. operands[operands.length] = new dialogOperand('T',x[j]);
  719. } else {
  720. var p = x[j].split(",");
  721. if (p.length == 1)
  722. operands[operands.length] = new dialogOperand('N', x[j]);
  723. else
  724. operands[operands.length] = new dialogOperand('C', p[0] + "," + dim + "," + p[1]);
  725. }
  726. }
  727. var result = new dialogInfo(op.charAt(0),label,operands);
  728. if (pos.length > 1 && (pos.charAt(pos.indexOf(';') + 1) == '1' || pos.charAt(pos.indexOf(';') + 1) == '2'))
  729. result._defaultPosition = false;
  730. return(result);
  731. }
  732. }
  733. }
  734. return null;
  735. }
  736. function isBasedOnCalc(calc,ancestorCalc) {
  737. //Get the Info for this calc.
  738. var calcInfo = getcalcInfo(calc);
  739. //Loop through each of its operands and for each calc, if it's the ancestor or is based
  740. //on the ancestor return true;
  741. for (var i = 0; i < calcInfo._operands.length; i++) {
  742. if (calcInfo._operands[i]._type == "T")
  743. if (calcInfo._operands[i]._code == ancestorCalc ||
  744. isBasedOnCalc(calcInfo._operands[i]._code,ancestorCalc))
  745. return true;
  746. }
  747. return false;
  748. }
  749. function popRenameInfo(id) {
  750. // adjust the size of the action pane for the rename calculation pane.
  751. topparent.setActionPaneHeight("180");
  752. var calcInfo = getcalcInfo(id);
  753. if(calcInfo._label != "") {
  754. document.getElementById("labelRenameField").value = calcInfo._label;
  755. }
  756. else {
  757. for (var i = 0; i < catarr.length; i++) {
  758. var temp = catarr[i]._code.split(",");
  759. if(temp[0] == id)
  760. document.getElementById("labelRenameField").value = catarr[i]._name;
  761. }
  762. }
  763. }
  764. function popPctBaseOtherAxisDropDown() {
  765. if (pctBaseBaseSelect.options.length == 0) {
  766. popOtherAxisOptions(pctBaseBaseSelect);
  767. }
  768. }
  769. function popDialogWithCalcInfo(id) {
  770. var sCmd = "gDimensionInfo[" + dim + "].isTimeDimension";
  771. var calcInfo = getcalcInfo(id);
  772. popCalcOpTypes();
  773. //find and select proper operation type
  774. for (var i = 0; i < calcOpTypesSelect.options.length; i++) {
  775. if (calcOpTypesSelect.options[i].value == operationsArray[calcInfo._oper]._opType) {
  776. calcOpTypesSelect.selectedIndex = i;
  777. break;
  778. }
  779. }
  780. popCalcTypes(topparent.getGlobal(sCmd),isOnlyRanks());
  781. //find and select proper calculation type;
  782. for (var i = 0; i < operationSelect.options.length; i++) {
  783. if (operationSelect.options[i].value == calcInfo._oper) {
  784. operationSelect.selectedIndex = i;
  785. break;
  786. }
  787. }
  788. //fill in label field if not a forcast
  789. if (operationsArray[calcInfo._oper]._type != 4)
  790. document.getElementById("labelField").value = calcInfo._label;
  791. if (!calcInfo._defaultPosition)
  792. document.getElementById("customPosition").checked = true;
  793. //populate menus
  794. setCalcType(false);
  795. // fill in operands based on calculation type;
  796. switch (operationsArray[calcInfo._oper]._type) {
  797. case 0: //Add type
  798. var allFound = true;
  799. for (var i = 0; i < calcInfo._operands.length;i++) {
  800. var found = false;
  801. if (calcInfo._operands[i]._type == 'N') {
  802. document.getElementById("userNumberCB").checked = true;
  803. document.getElementById("addNum1").value = CNumUtil.localizeDecimal(calcInfo._operands[i]._code);
  804. found = true;
  805. } else {
  806. for (var j = 0; j < document.getElementById("addCatSel").options.length; j++) {
  807. if (compareCategory(catarr[document.getElementById("addCatSel").options[j].value]._code, calcInfo._operands[i]._code)) {
  808. found = true;
  809. document.getElementById("addCatSel").options[j].selected = true;
  810. j = addSelect.options.length;
  811. }
  812. }
  813. }
  814. if (!found)
  815. allFound = false;
  816. }
  817. if (!allFound) {
  818. displayCommonMessage(strCalcCatsNotExist, MESSAGE_TYPE_INFO, [message_ok_button_text, message_cancel_button_text], [function() {removeMessage();}, function() {topparent.closeActionPane();}]);
  819. }
  820. break;
  821. case 2: //Subtract type
  822. var oper1 = calcInfo._operands[0];
  823. var oper2 = calcInfo._operands[1];
  824. var found1 = false;
  825. var found2 = false;
  826. if (calcInfo._oper == "g") {
  827. // Special case: For percent growth, the operands are in reverse order.
  828. // Like what was done in the javascript for dynamic mode, switch them around.
  829. oper1 = calcInfo._operands[1];
  830. oper2 = calcInfo._operands[0];
  831. }
  832. if (oper1._type == 'N') {
  833. document.getElementById("subNum1").value = CNumUtil.localizeDecimal(oper1._code);
  834. document.getElementById("rcat1").checked = false;
  835. document.getElementById("rnum1").checked = true;
  836. found1 = true;
  837. } else {
  838. for (var j = 0; j < document.getElementById("subCatSel1").options.length; j++) {
  839. if (compareCategory(catarr[document.getElementById("subCatSel1").options[j].value]._code, oper1._code)) {
  840. found1 = true;
  841. document.getElementById("subCatSel1").options[j].selected = true;
  842. j = document.getElementById("subCatSel1").options.length; //break out
  843. }
  844. }
  845. }
  846. if (oper2._type == 'N') {
  847. document.getElementById("subNum2").value = CNumUtil.localizeDecimal(oper2._code);
  848. document.getElementById("rcat2").checked = false;
  849. document.getElementById("rnum2").checked = true;
  850. found2 = true;
  851. } else {
  852. for (var j = 0; j < document.getElementById("subCatSel2").options.length; j++) {
  853. if (compareCategory(catarr[document.getElementById("subCatSel2").options[j].value]._code, oper2._code)) {
  854. found2 = true;
  855. document.getElementById("subCatSel2").options[j].selected = true;
  856. j = document.getElementById("subCatSel2").options.length;
  857. }
  858. }
  859. }
  860. if (!found1 || !found2) {
  861. displayCommonMessage(strCalcCatsNotExist, MESSAGE_TYPE_INFO, [message_ok_button_text, message_cancel_button_text], [function() {removeMessage();}, function() {topparent.closeActionPane();}]);
  862. }
  863. break;
  864. case 1: //Accumulate type
  865. var found = false;
  866. for (var j = 0; j < document.getElementById("accCatSel").options.length; j++) {
  867. if (compareCategory(catarr[document.getElementById("accCatSel").options[j].value]._code, calcInfo._operands[0]._code)) {
  868. found = true;
  869. document.getElementById("accCatSel").options[j].selected = true;
  870. j = document.getElementById("accCatSel").options.length;
  871. }
  872. }
  873. if (!found) {
  874. displayCommonMessage(strCalcCatsNotExist, MESSAGE_TYPE_INFO, [message_ok_button_text, message_cancel_button_text], [function() {removeMessage();}, function() {topparent.closeActionPane();}]);
  875. }
  876. break;
  877. case 3: //rollup style
  878. var allFound = true;
  879. for (var i = 0; i < calcInfo._operands.length;i++) {
  880. var found = false;
  881. for (var j = 0; j < document.getElementById("rollCatSel").options.length; j++) {
  882. if (compareCategory(catarr[document.getElementById("rollCatSel").options[j].value]._code,calcInfo._operands[i]._code)) {
  883. found = true;
  884. document.getElementById("rollCatSel").options[j].selected = true;
  885. j = document.getElementById("rollCatSel").options.length;
  886. }
  887. }
  888. if (!found)
  889. allFound = false;
  890. }
  891. if (!allFound) {
  892. displayCommonMessage(strCalcCatsNotExist, MESSAGE_TYPE_INFO, [message_ok_button_text, message_cancel_button_text], [function() {removeMessage();}, function() {topparent.closeActionPane();}]);
  893. }
  894. break;
  895. case 4: //Forcast
  896. document.getElementById("labelDiv").style.visibility = "hidden";
  897. document.getElementById("ForMethod").value = calcInfo._operands[1]._code;
  898. document.getElementById("ForNum").value = CNumUtil.localizeDecimal(calcInfo._operands[2]._code);
  899. break;
  900. case 5: //Percent Base type
  901. popOtherAxisOptions(pctBaseBaseSelect);
  902. var foundOper = false;
  903. for (var j = 0; j < document.getElementById("pctBaseSel").options.length; j++) {
  904. if (compareCategory(catarr[document.getElementById("pctBaseSel").options[j].value]._code, calcInfo._operands[0]._code)) {
  905. foundOper = true;
  906. document.getElementById("pctBaseSel").options[j].selected = true;
  907. j = document.getElementById("pctBaseSel").options.length;
  908. }
  909. }
  910. if (calcInfo._operands.length > 1) {
  911. document.getElementById("pctBaseTypeBase").checked = true;
  912. var found = !foundOper;
  913. for (var j = 0; j < document.getElementById("pctBaseBase").options.length; j++) {
  914. var cat = getCatFromDimIdxPair(document.getElementById("pctBaseBase").options[j].value);
  915. if (compareCategory(cat._code, calcInfo._operands[1]._code)) {
  916. found = true;
  917. document.getElementById("pctBaseBase").options[j].selected = true;
  918. j = document.getElementById("pctBaseBase").options.length;
  919. }
  920. }
  921. if (!foundOper) {
  922. displayCommonMessage(strCalcCatsNotExist, MESSAGE_TYPE_INFO, [message_ok_button_text, message_cancel_button_text], [function() {removeMessage();}, function() {topparent.closeActionPane();}]);
  923. }
  924. if (!found) {
  925. displayCommonMessage(strPrcntBaseBaseNotExist, MESSAGE_TYPE_INFO, [message_ok_button_text, message_cancel_button_text], [function() {removeMessage();}, function() {topparent.closeActionPane();}]);
  926. }
  927. }
  928. break;
  929. }
  930. }
  931. function validateInput() {
  932. var validChars = "/[^0-9" + decimalpt + "\-]/";
  933. switch(getCurrentCalc()._type) {
  934. case 0: //validate Add
  935. if(document.getElementById("userNumberCB").checked && document.getElementById("addNum1").value == ""){
  936. errorMsg = strProvideNumbersMsg;
  937. return false;
  938. }
  939. if (!CNumUtil.validateNumField(document.getElementById("addNum1"),true, validChars )) {
  940. errorMsg = strInvalidNumbersMsg;
  941. return false;
  942. }
  943. document.getElementById("addNum1").value = CNumUtil.normalizeDecimal(document.getElementById("addNum1").value);
  944. var ctr = numSelected(document.getElementById("addCatSel"));
  945. var num = document.getElementById("userNumberCB").checked ? 1 : 0;
  946. if( ctr + num < 2){
  947. errorMsg = strSelectMoreCatMsg;
  948. return false;
  949. }
  950. break;
  951. case 2: //Validate Subtract
  952. if(document.getElementById("rnum1").checked && document.getElementById("subNum1").value == ""){
  953. errorMsg = strProvideNumbersMsg;
  954. return false;
  955. }
  956. if(document.getElementById("rnum2").checked && document.getElementById("subNum2").value == ""){
  957. errorMsg = strProvideNumbersMsg;
  958. return false;
  959. }
  960. if (!CNumUtil.validateNumField(document.getElementById("subNum1"),true, validChars) || !CNumUtil.validateNumField(document.getElementById("subNum2"),true, validChars)) {
  961. errorMsg = strInvalidNumbersMsg;
  962. return false;
  963. }
  964. if((document.getElementById("rnum1").checked && CNumUtil.validateNumField(document.getElementById("subNum1"),true, validChars)) &&
  965. (document.getElementById("rnum2").checked && CNumUtil.validateNumField(document.getElementById("subNum2"),true, validChars)) ){
  966. errorMsg = strInvalidCalcMsg;
  967. return false;
  968. }
  969. document.getElementById("subNum1").value = CNumUtil.normalizeDecimal(document.getElementById("subNum1").value);
  970. document.getElementById("subNum2").value = CNumUtil.normalizeDecimal(document.getElementById("subNum2").value);
  971. document.getElementById("rnum1").value = CNumUtil.normalizeDecimal(document.getElementById("rnum1").value);
  972. document.getElementById("rnum2").value = CNumUtil.normalizeDecimal(document.getElementById("rnum2").value);
  973. break;
  974. case 3: //rollup style
  975. if (!numSelected(document.getElementById("rollCatSel"))) {
  976. errorMsg = strSelectMoreCatMsg;
  977. return false;
  978. }
  979. break;
  980. case 4: //Validate Forcast
  981. if (!CNumUtil.validateNumField(document.getElementById("ForNum"),false, validChars) || document.getElementById("ForNum").value <= 0) {
  982. errorMsg = strInvalidNumbersMsg;
  983. return false;
  984. }
  985. break;
  986. }
  987. return true;
  988. }
  989. function ableFormField(event, owner,field) {
  990. if (!owner.checked)
  991. field.value = "";
  992. }
  993. function selectAll(event, box) {
  994. var box = document.getElementById(box);
  995. for (var i = 0; i < box.options.length; i++) {
  996. box.options[i].selected = true;
  997. }
  998. var mgr = new eventManager(event);
  999. mgr.cancelBubble();
  1000. }
  1001. function unselectAll(event, box) {
  1002. var box = document.getElementById(box);
  1003. for (var i = 0; i < box.options.length; i++) {
  1004. box.options[i].selected = false;
  1005. }
  1006. var mgr = new eventManager(event);
  1007. mgr.cancelBubble();
  1008. }
  1009. function submitPreCalcDialog() {
  1010. topparent.setGlobal("editingCalc", 0);
  1011. if(document.preCalculation.edit.checked)
  1012. topparent.setGlobal("editingCalc", 1);
  1013. else if(document.preCalculation.insert.checked)
  1014. topparent.setGlobal("editingCalc", 0);
  1015. else if(document.preCalculation.rename.checked)
  1016. topparent.setGlobal("editingCalc", 2);
  1017. else if(document.preCalculation.delete_calc.checked)
  1018. topparent.setGlobal("editingCalc", 3);
  1019. resetDialog();
  1020. }
  1021. function handleError(sError, closeActionPane){
  1022. selecteddim = null;
  1023. if (closeActionPane)
  1024. displayCommonMessage(sError, MESSAGE_TYPE_INFO, [], []);
  1025. else
  1026. displayCommonMessage(sError, MESSAGE_TYPE_INFO, [message_ok_button_text], [function() {removeMessage();}]);
  1027. }
  1028. function explainForecast(selectedOption) {
  1029. var selectedVal = selectedOption.selectedIndex;
  1030. document.getElementById("forecastExplanation").style.visibility = "visible";
  1031. switch (selectedVal) {
  1032. case 0:
  1033. document.getElementById("forecastExplanation").innerHTML = "<table><tr><td><img name=\"Trend\" alt=\"" + CEncodingUtil.HtmlEncode(strForcastTrend) + "\" border=\"0\" height=\"28\" src=\"../ppwb/Icon/trend.gif\"></img></td><td class=\"ForecastMethodExplanation\">" + CEncodingUtil.HtmlEncode(strForcastExplTrend)+"</td></tr></table>";
  1034. break;
  1035. case 1:
  1036. document.getElementById("forecastExplanation").innerHTML = "<table><tr><td><img name=\"Growth\" alt=\"" + CEncodingUtil.HtmlEncode(strForcastGrowth) + "\" border=\"0\" height=\"28\" src=\"../ppwb/Icon/growth.gif\"></img></img></td><td class=\"ForecastMethodExplanation\">" + CEncodingUtil.HtmlEncode(strForcastExplGrowth)+"</td></tr></table>";
  1037. break;
  1038. case 2:
  1039. document.getElementById("forecastExplanation").innerHTML = "<table><tr><td><img name=\"AR\" alt=\"" + CEncodingUtil.HtmlEncode(strForcastAutoreg) + "\" border=\"0\" height=\"28\" src=\"../ppwb/Icon/autoregression.gif\"></img></img></td><td class=\"ForecastMethodExplanation\">" + CEncodingUtil.HtmlEncode(strForcastExplAutoreg)+"</td></tr></table>";
  1040. break;
  1041. default:
  1042. //alert("explain trend");
  1043. break;
  1044. }
  1045. return;
  1046. }
  1047. function compareCategory(code1, code2) {
  1048. if(code1.charAt(0) == 'T')
  1049. return code1 == code2;
  1050. else
  1051. return parseInt(code1) == parseInt(code2);
  1052. }