ppwbfind_gen.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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 Find pane of
  9. // 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 Results;
  16. var selectedControlIdx = -1;
  17. var displayLimit = 10;
  18. var currentPosition = 0;
  19. var rowsDisplayed = 0;
  20. var blockInvalidate = false;
  21. var nIndex=0; // initially we should ensure that we do infact begin from index 0 (vector search)
  22. var DisplayLimit = 10;
  23. var searchDirection = 1; //(1=up (next) 0=down (prev))
  24. var isError = 0;
  25. var isNextSearch = 0;
  26. var isPrevSearch = 0;
  27. var url = "";
  28. var restrict = "";
  29. var pattern = "";
  30. var cmd = "";
  31. var sellIndex = "";
  32. function findObj(n, d) {
  33. var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  34. d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  35. if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  36. for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  37. if(!x && document.getElementById) x=document.getElementById(n); return x;
  38. }
  39. function invalidateResults() {
  40. if (parent.isXtabStillLoading())
  41. {
  42. setTimeout("invalidateResults()", 50);
  43. return;
  44. }
  45. if (document.searchForm.FindIn.value == "R" && !blockInvalidate)
  46. {
  47. submitSearch(false);
  48. }
  49. }
  50. function initFind() {
  51. if (parent.isXtabStillLoading())
  52. {
  53. setTimeout("initFind()", 50);
  54. return;
  55. }
  56. document.searchForm.searchPattern.value = lastSearchPattern;
  57. if(lastSearchTarget >= 0)
  58. document.searchForm.searchTarget.selectedIndex = lastSearchTarget;
  59. if(lastSearchRestriction >= 0)
  60. document.searchForm.searchRestriction.selectedIndex= lastSearchRestriction;
  61. }
  62. function submitSearch(bChangeTarget) {
  63. if (!bChangeTarget && stateChanging)
  64. return;
  65. currentPosition = 0;
  66. rowsDisplayed = 0;
  67. var sellIndex = 0;
  68. buildURLSections();
  69. // a bit of logic to ensure
  70. if (isNextSearch | isPrevSearch )
  71. // use the previous search pattern
  72. pattern = lastSearchPattern;
  73. else{
  74. // new search, re-intialize indecies
  75. nBeginSearchAtIndex = 0;
  76. nEndSearchAtIndex = 0;
  77. }
  78. var findform = winFX.document.fhidden;
  79. var target = findform.target;
  80. findform.CNCT.value = 12;
  81. if (!findform.UI)
  82. findform.innerHTML += "<INPUT TYPE='hidden' NAME='UI'>";
  83. findform.UI.value = 0;
  84. var appendUrl = 'F' + cmd + ':"' + CEncodingUtil.EncodeStrOperand(pattern) + '"' + '\t' + restrict;
  85. if (!bChangeTarget)
  86. {
  87. var targetSellIndex = document.searchForm.searchTarget.selectedIndex;
  88. appendUrl += '\t' + document.searchForm.searchTarget.options[targetSellIndex].value;
  89. appendUrl += '\t' + nBeginSearchAtIndex + '\t' + nEndSearchAtIndex + '\t' + DisplayLimit + '\t' + searchDirection;
  90. }
  91. findform.CO.value = appendUrl;
  92. findform.target = window.name;
  93. findform.submit();
  94. findform.target = target;
  95. }
  96. function SetRadiobuttonIndex(){
  97. nIndex = 0;
  98. var flag = 0;
  99. while(flag==0){
  100. var result = document.result.ResultSet[nIndex];
  101. var checked = (typeof result != "undefined") ? result.checked : document.result.ResultSet.checked;
  102. if (checked){
  103. flag = 1;
  104. }
  105. nIndex++;
  106. }
  107. nIndex = nIndex-1;
  108. }
  109. function filterOnFindResult(){
  110. SetRadiobuttonIndex();
  111. var category = FindResults[nIndex];
  112. var command = '';
  113. if (document.searchForm.FindIn.value == "R")
  114. {
  115. if(category._tempInfo == "")
  116. command = 'DG' + ':' + category._axis + category._group + '\t' + category._id + "," + category._dim + ';' + category._code;
  117. }
  118. else
  119. {
  120. command = 'DC' + ':' + category._id + "," + category._dim + ';' + category._code;
  121. }
  122. if (command != '')
  123. {
  124. winFX.doit(command);
  125. }
  126. }
  127. function GoToCategory(){
  128. SetRadiobuttonIndex();
  129. var category = FindResults[nIndex];
  130. var rowPage = 0;
  131. var colPage = 0;
  132. var isOnCurrentPage = true;
  133. var hasPagination = typeof winFX.document.fhidden.J != "undefined" && typeof winFX.document.fhidden.K != "undefined";
  134. if (hasPagination) {
  135. rowPage = winFX.document.fhidden.J.value;
  136. colPage = winFX.document.fhidden.K.value;
  137. if(category._axis == 'R')
  138. isOnCurrentPage = rowPage == category._pageNo;
  139. else
  140. isOnCurrentPage = colPage == category._pageNo;
  141. }
  142. if (isOnCurrentPage) {
  143. writeErrorMessage(currSelection);
  144. return;
  145. }
  146. if(category._axis == 'R')
  147. command = 'PG' + ':' + category._pageNo + '\t' + colPage;
  148. else if(category._axis == 'C')
  149. command = 'PG' + ':' + rowPage + '\t' + category._pageNo;
  150. blockInvalidate = true;
  151. winFX.doit(command);
  152. blockInvalidate = false;
  153. }
  154. function writeErrorMessage(msg) {
  155. var err = findObj("errorMessage");
  156. if (err) {
  157. if (document.getElementById) { //IE 5.5+ , Netscape 6.0+
  158. err.innerHTML = '<table><tr><td valign="middle"><img src="../ppwb/Graphics/error.gif" height=18 width=18 alt=""></td><td class="CustomExceptionError" valign="middle">' + msg + '</td></tr></table><br><br>';
  159. } else if (isNSBrowser) { // Other Netscape browsers
  160. err.visibility = "visible";
  161. err.moveTo(11, document.layers["referenceLayer"].top + document.layers["referenceLayer"].clip.bottom);
  162. err.resizeTo(parent.FE.innerWidth - 25, 50);
  163. err.document.open();
  164. err.document.write('<html><body><table><tr><td><img src="../ppwb/Graphics/error.gif" height=18 width=18 alt=""></td><td class="CustomExceptionError" valign="middle">' + msg + '</td></tr></table></body></html>');
  165. err.document.close();
  166. } else
  167. alert (msg);
  168. }
  169. }
  170. function replaceRows(){
  171. SetRadiobuttonIndex();
  172. var category = FindResults[nIndex];
  173. var command = 'ER' + ':' + 'R-1' + '\t' + 'D' + category._dim + '\t' + category._id + "," + category._dim + ';' + category._code;
  174. winFX.doit(command);
  175. }
  176. function replaceColumns(){
  177. SetRadiobuttonIndex();
  178. var category = FindResults[nIndex];
  179. var command = 'ER' + ':' + 'C-1' + '\t' + 'D' + category._dim + '\t' + category._id + "," + category._dim + ';' + category._code;
  180. winFX.doit(command);
  181. }
  182. function changeTarget (value) {
  183. currentPosition = 0;
  184. rowsDisplayed = 0;
  185. buildURLSections();
  186. stateChanging = true;
  187. submitSearch(true);
  188. }
  189. //this of this as a class 'FindRecord' these are the member variables ... ".display" is a method (this needs to be changed to work with js1.3)
  190. function FindRecord (ppds_id, dim_index, code, label, path, axis, group, tempInfo, pageNo) {
  191. this._id = ppds_id;
  192. this._dim = dim_index;
  193. this._code = code;
  194. this._label = label;
  195. this._path = path;
  196. this._axis = axis;
  197. this._group = group;
  198. this._tempInfo = tempInfo;
  199. this._pageNo = pageNo;
  200. }
  201. function displayFindResults() {
  202. displayTitles(false);
  203. displayResults();
  204. displayActions();
  205. document.all.resultsDisplay.style.visibility = "visible";
  206. }
  207. function buildURLSections() {
  208. sellIndex = 0;
  209. pattern = document.searchForm.searchPattern.value;
  210. selIndex = document.searchForm.FindIn.selectedIndex;
  211. cmd = document.searchForm.FindIn.options[selIndex].value;
  212. selIndex = document.searchForm.searchRestriction.selectedIndex;
  213. restrict = document.searchForm.searchRestriction.options[selIndex].value;
  214. }
  215. function next() {
  216. isNextSearch = 1;
  217. searchDirection = 1;
  218. submitSearch(false);
  219. }
  220. function prev() {
  221. isPrevSearch = 1;
  222. searchDirection = 0;
  223. submitSearch(false);
  224. }