viewer.pageActions.core.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2014
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or
  8. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *|
  10. *+------------------------------------------------------------------------+
  11. */
  12. function FindAction(){
  13. this.m_requestParams=null;
  14. this.m_sAction="find";
  15. this.findState=null;
  16. this.pageState=null;
  17. this.findConfig=null;
  18. };
  19. FindAction.prototype=new CognosViewerAction();
  20. FindAction.baseclass=CognosViewerAction.prototype;
  21. FindAction.prototype.setConfigAndState=function(_1){
  22. var cv=this.getCognosViewer();
  23. var _3=cv.getState();
  24. this.findConfig=cv.getConfig().getFindActionConfig();
  25. this.pageState=_3.getPageState();
  26. this.findState=_3.getFindState();
  27. };
  28. FindAction.prototype.setRequestParms=function(_4){
  29. this.setConfigAndState();
  30. var cv=this.getCognosViewer();
  31. var _6=cv.getState();
  32. if(_6.getFindState()){
  33. this.clearPreviousResult();
  34. }
  35. _6.clearFindState();
  36. if(_4){
  37. if(this.pageState==null){
  38. _6.setPageState({});
  39. this.pageState=_6.getPageState();
  40. }
  41. _6.setFindState(_4);
  42. this.findState=_6.getFindState();
  43. }
  44. };
  45. FindAction.prototype.execute=function(){
  46. if(!this.findState){
  47. return;
  48. }
  49. return this.findAndShow();
  50. };
  51. FindAction.prototype.findAndShow=function(){
  52. var cv=this.getCognosViewer();
  53. var _8=cv.hasNextPage();
  54. var _9=cv.hasPrevPage();
  55. var _a=this.pageState.getCurrentPage();
  56. var _b=this.findOnClient();
  57. this.findState.updatePageInfo(_b,_a,_8,_9);
  58. if(_b.length==0){
  59. if(this.findState.checkServerForNextMatch()){
  60. return cv.executeAction("FindNextOnServer");
  61. }else{
  62. var _c=this.findConfig.getNoMatchFoundCallback();
  63. _c();
  64. return false;
  65. }
  66. }else{
  67. var _d=this.findState.firstMatch();
  68. this.applyFocusStyle(_d);
  69. }
  70. return true;
  71. };
  72. FindAction.prototype.clearPreviousResult=function(_e){
  73. if(_e!==false){
  74. this.removeHighlights();
  75. }
  76. this.findState.resetPageInfo();
  77. };
  78. FindAction.prototype.findOnClient=function(){
  79. var _f=this.findState.getKeyword();
  80. this.removeHighlights();
  81. var _10=new Array();
  82. var cv=this.getCognosViewer();
  83. var _12=document.getElementById("CVReport"+cv.getId());
  84. this.findMatches(_12,_f,this.findState.isCaseSensitive(),_10,0,new FindPartialMatchHelper(),-1);
  85. this.applyMatchStyle(_10);
  86. return _10;
  87. };
  88. FindAction.prototype.applyMatchStyle=function(_13){
  89. var _14=_13.length;
  90. for(var idx=_14-1;idx>=0;idx--){
  91. var _16=_13[idx];
  92. for(var i=_16.length-1;i>=0;i--){
  93. var _18=_16[i];
  94. var _19=_18.element;
  95. var _1a=_19.childNodes[0];
  96. var _1b=_1a.data;
  97. var _1c=_1b.length;
  98. var _1d=_18.start;
  99. var _1e=_18.matchedStr.length;
  100. var _1f=(_1d>0)?_1b.substring(0,_1d):"";
  101. var _20=(_1d+_1e<_1c)?_1b.substring(_1d+_1e,_1c):"";
  102. var _21=document.createElement("span");
  103. _21.setAttribute("tabIndex",0);
  104. _21.setAttribute("style",this.findConfig.getMatchUIStyle());
  105. _21.style.background=this.findConfig.getMatchColor();
  106. _21.appendChild(document.createTextNode(_18.matchedStr));
  107. _1a.data=_20;
  108. _19.insertBefore(_21,_1a);
  109. if(_1f.length>0){
  110. var _22=document.createTextNode(_1f);
  111. _19.insertBefore(_22,_21);
  112. }
  113. if(_20.length==0){
  114. _19.removeChild(_1a);
  115. }
  116. _18.element=_21;
  117. }
  118. }
  119. };
  120. FindAction.prototype.removeHighlights=function(){
  121. var _23=this.findState.getMatches();
  122. var _24=this.findState.getFocusedMatch();
  123. if(_24){
  124. this.restoreMatchStyle(_24);
  125. }
  126. if(_23&&_23.length>0){
  127. var _25=_23.length;
  128. for(var i=0;i<_25;i++){
  129. var _27=_23[i];
  130. for(var j=0;j<_27.length;j++){
  131. var _29=_27[j];
  132. var _2a=_29.element;
  133. if(_2a){
  134. var _2b=_2a.parentNode;
  135. var _2c=null;
  136. var _2d=false;
  137. if(_2a.previousSibling&&_2a.previousSibling.nodeType==3){
  138. _2c=_2a.previousSibling;
  139. _2d=true;
  140. }else{
  141. if(_2a.nextSibling&&_2a.nextSibling.nodeType==3){
  142. _2c=_2a.nextSibling;
  143. }
  144. }
  145. if(_2c){
  146. _2c.data=_2d?(_2c.data+_29.matchedStr):(_29.matchedStr+_2c.data);
  147. _2b.removeChild(_2a);
  148. if(_2c.nextSibling&&_2c.nextSibling.nodeType==3){
  149. _2c.data=_2c.data+_2c.nextSibling.data;
  150. _2b.removeChild(_2c.nextSibling);
  151. }
  152. }else{
  153. var _2e=document.createTextNode(_29.matchedStr);
  154. _2b.insertBefore(_2e,_2a);
  155. _2b.removeChild(_2a);
  156. }
  157. }
  158. }
  159. }
  160. }
  161. };
  162. FindAction.prototype.manageFocusStyle=function(_2f,_30){
  163. if(!_2f){
  164. return;
  165. }
  166. for(var i=_2f.length-1;i>=0;i--){
  167. var _32=_2f[i];
  168. var _33=_32.element;
  169. if("restoreMatchStyle"===_30){
  170. _33.setAttribute("style",this.findConfig.getMatchUIStyle());
  171. _33.style.background=this.findConfig.getMatchColor();
  172. }else{
  173. _33.setAttribute("style",this.findConfig.getFocusUIStyle());
  174. _33.style.background=this.findConfig.getFocusColor();
  175. _33.focus();
  176. if(_33.blur){
  177. _33.blur();
  178. }
  179. }
  180. }
  181. };
  182. FindAction.prototype.applyFocusStyle=function(_34){
  183. this.manageFocusStyle(_34);
  184. };
  185. FindAction.prototype.restoreMatchStyle=function(_35){
  186. this.manageFocusStyle(_35,"restoreMatchStyle");
  187. };
  188. FindAction.prototype.isVisible=function(_36){
  189. var _37=this.checkDisplayStyle(_36);
  190. return (!_37.isVisibilityHidden&&!_37.isDisplayNone);
  191. };
  192. FindAction.prototype.checkDisplayStyle=function(_38){
  193. var _39=null;
  194. var _3a=null;
  195. if(window.getComputedStyle){
  196. var _3b=window.getComputedStyle(_38,"visibility");
  197. if(!_3b){
  198. _3b=window.getComputedStyle(_38,"display");
  199. }
  200. if(_3b){
  201. _39=_3b["visibility"];
  202. _3a=_3b["display"];
  203. }
  204. }else{
  205. if(_38.currentStyle){
  206. _39=_38.currentStyle.visibility;
  207. _3a=_38.currentStyle.display;
  208. }
  209. }
  210. var _3c=(_3a&&_3a.indexOf("block")==-1&&_3a.indexOf("inline")>=0);
  211. var obj={"isVisibilityHidden":("hidden"==_39),"isDisplayNone":("none"==_3a),"isDisplayInline":_3c,"display":_3a};
  212. return obj;
  213. };
  214. FindAction.prototype.findMatches=function(_3e,_3f,_40,_41,_42,_43,_44){
  215. if(_3e.nodeType===3){
  216. var _45=_3e.data;
  217. if(_45){
  218. var _46=_3e.parentNode.tagName.toUpperCase();
  219. if(_46!=="SCRIPT"&&_46!=="STYLE"){
  220. var _47=_40?_3f:_3f.toUpperCase();
  221. var _48=_40?_45:_45.toUpperCase();
  222. for(var _49=0;_49<_45.length;){
  223. _49=this.match(_49,_3e,_48,_47,_41,_42,_43,_44);
  224. }
  225. }
  226. }
  227. }else{
  228. if(_3e.nodeType===1){
  229. var _4a=this.checkDisplayStyle(_3e);
  230. if(!_4a.isDisplayInline){
  231. _44=_42;
  232. _43.reset();
  233. }
  234. if(_4a.isVisibilityHidden){
  235. _43.reset();
  236. return;
  237. }
  238. if(_4a.isDisplayNone){
  239. return;
  240. }
  241. for(var _4b=_3e.firstChild;_4b!=null;_4b=_4b.nextSibling){
  242. this.findMatches(_4b,_3f,_40,_41,++_42,_43,_44);
  243. }
  244. }
  245. }
  246. };
  247. FindAction.prototype.match=function(_4c,_4d,_4e,_4f,_50,_51,_52,_53){
  248. if(!_4e||_4c>=_4e.length){
  249. return (_4c+1);
  250. }
  251. var _54=_4d.data;
  252. var _55=_52.startIndexOfKeyword;
  253. var _56=this.matchByLetter(_4e,_4f,_54,_4c,_55);
  254. if(!_56){
  255. return _4c+1;
  256. }
  257. var _57=_56.matchedStr;
  258. if(_57.length==_4f.length){
  259. _56.update("full",_51,_4d.parentNode,_53);
  260. _50.push([_56]);
  261. _52.reset();
  262. return (_4c+_57.length);
  263. }
  264. if(_55==0){
  265. _56.update("head",_51,_4d.parentNode,_53);
  266. _52.add(_56);
  267. return (_4c+_57.length);
  268. }
  269. var _58=_52.partialMatches[_52.partialMatches.length-1];
  270. if(_58.blockDisplayParentIndex!=_53){
  271. _52.reset();
  272. return (_4e.lenght+1);
  273. }
  274. if((_55+_57.length)<_4f.length){
  275. _56.update("middle",_51,_4d.parentNode,_53);
  276. _52.add(_56);
  277. return (_4c+_57.length);
  278. }
  279. if((_55+_57.length)==_4f.length){
  280. _56.update("tail",_51,_4d.parentNode,_53);
  281. _52.add(_56);
  282. _50.push(_52.partialMatches.slice(0));
  283. _52.reset();
  284. }
  285. return (_4c+_57.length);
  286. };
  287. FindAction.prototype.matchByLetter=function(_59,_5a,_5b,_5c,_5d){
  288. var _5e=_5c;
  289. var _5f=true;
  290. var _60=0;
  291. for(;_5c<_59.length&&_5f;_5c++,_5d++){
  292. if(this.safeLetter(_59.charCodeAt(_5c))==this.safeLetter(_5a.charCodeAt(_5d))){
  293. _5f=true;
  294. if(++_60==_5a.length){
  295. break;
  296. }
  297. }else{
  298. _5f=false;
  299. }
  300. }
  301. if(!_5f){
  302. return null;
  303. }
  304. return new FindMatch(_5e,_5b.substr(_5e,_60));
  305. };
  306. FindAction.prototype.safeLetter=function(c){
  307. if(c==160){
  308. return 32;
  309. }else{
  310. return c;
  311. }
  312. };
  313. function FindMatch(_62,_63){
  314. this.start=_62;
  315. this.matchedStr=_63;
  316. this.index=null;
  317. this.element=null;
  318. this.type=null;
  319. this.blockDisplayParentIndex=null;
  320. this.orgStyle=null;
  321. };
  322. FindMatch.prototype={};
  323. FindMatch.prototype.update=function(_64,_65,_66,_67){
  324. this.index=_65;
  325. this.element=_66;
  326. this.type=_64;
  327. this.blockDisplayParentIndex=_67;
  328. this.orgStyle=this.element.getAttribute("style");
  329. };
  330. function FindPartialMatchHelper(){
  331. this.startIndexOfKeyword=0;
  332. this.partialMatches=null;
  333. };
  334. FindPartialMatchHelper.prototype={};
  335. FindPartialMatchHelper.prototype.reset=function(){
  336. this.startIndexOfKeyword=0;
  337. this.partialMatches=null;
  338. };
  339. FindPartialMatchHelper.prototype.add=function(_68){
  340. if(!this.partialMatches){
  341. this.partialMatches=[];
  342. }
  343. this.partialMatches.push(_68);
  344. this.startIndexOfKeyword+=_68.matchedStr.length;
  345. };
  346. function FindNextAction(){
  347. this.m_requestParams=null;
  348. this.m_sAction="findNext";
  349. };
  350. FindNextAction.prototype=new FindAction();
  351. FindNextAction.baseclass=FindAction.prototype;
  352. FindNextAction.prototype.setRequestParms=function(_69){
  353. this.setConfigAndState();
  354. };
  355. FindNextAction.prototype.execute=function(){
  356. if(this.findState){
  357. var _6a=this.findState.getFocusedMatch();
  358. if(this.findState.hasNext()){
  359. var _6b=this.findState.nextMatch();
  360. this.restoreMatchStyle(_6a);
  361. this.applyFocusStyle(_6b);
  362. }else{
  363. this.restoreMatchStyle(_6a);
  364. if(this.findState.checkServerForNextMatch()){
  365. var cv=this.getCognosViewer();
  366. return cv.executeAction("FindNextOnServer");
  367. }else{
  368. if(this.findState.isWrapAroundSearch()){
  369. _6a=this.findState.firstMatch();
  370. this.applyFocusStyle(_6a);
  371. if(this.findState.isRepeating()){
  372. var _6d=this.findConfig.getFindActionCompleteCallback();
  373. _6d();
  374. }
  375. }else{
  376. var _6d=this.findConfig.getFindActionCompleteCallback();
  377. _6d();
  378. }
  379. }
  380. }
  381. }
  382. return true;
  383. };
  384. function FindNextOnServerAction(){
  385. this.m_requestParams=null;
  386. this.m_sAction="findNextOnServer";
  387. };
  388. FindNextOnServerAction.prototype=new FindAction();
  389. FindNextOnServerAction.baseclass=FindAction.prototype;
  390. FindNextOnServerAction.prototype.setRequestParms=function(_6e){
  391. this.setConfigAndState();
  392. };
  393. FindNextOnServerAction.prototype.execute=function(){
  394. return this.sendRequest();
  395. };
  396. FindNextOnServerAction.prototype.sendRequest=function(){
  397. if(!this.findState){
  398. return -1;
  399. }
  400. var cv=this.getCognosViewer();
  401. var _70=new ViewerDispatcherEntry(cv);
  402. this.originalCompleteCallback=_70.getCallbacks()["complete"];
  403. _70.setCallbacks({"complete":{"object":this,"method":this.onRequestComplete}});
  404. _70.addFormField("ui.action","reportAction");
  405. _70.addFormField("generic.anyURI.http://developer.cognos.com/ceba/constants/runOptionEnum#pageNumber",this.findState.getPageNoForFindNext());
  406. _70.addFormField("generic.anyURI.http://developer.cognos.com/ceba/constants/runOptionEnum#search",this.findState.getKeyword());
  407. _70.addFormField("generic.boolean.http://developer.cognos.com/ceba/constants/runOptionEnum#caseSensitiveSearch",this.findState.isCaseSensitive());
  408. _70.addFormField("generic.boolean.http://developer.cognos.com/ceba/constants/runOptionEnum#wrapAroundSearch",this.findState.isWrapAroundSearch());
  409. this.findState.findOnServerStarted();
  410. return cv.dispatchRequest(_70);
  411. };
  412. FindNextOnServerAction.prototype.onRequestComplete=function(_71){
  413. var _72=_71.getAsynchStatus();
  414. var _73=GUtil.generateCallback(this.originalCompleteCallback.method,[_71],this.originalCompleteCallback.object);
  415. if(_72==="complete"){
  416. var _74=_71.getResult();
  417. if(_74&&_74.length>0){
  418. _73();
  419. setTimeout(GUtil.generateCallback(this.processResponse,[true],this),100);
  420. }else{
  421. setTimeout(GUtil.generateCallback(this.processResponse,[false],this),100);
  422. }
  423. }else{
  424. _73();
  425. }
  426. };
  427. FindNextOnServerAction.prototype.processResponse=function(_75){
  428. this.setConfigAndState();
  429. if(!this.findState){
  430. return false;
  431. }
  432. this.findState.findOnServerDone();
  433. if(_75){
  434. this.clearPreviousResult(false);
  435. if(this.findAndShow()){
  436. if(this.findState.isRepeating()){
  437. var _76=this.findConfig.getFindActionCompleteCallback();
  438. _76();
  439. }
  440. }
  441. }else{
  442. var _76=this.findState.foundMatchesInReport()?this.findConfig.getFindActionCompleteCallback():this.findConfig.getNoMatchFoundCallback();
  443. _76();
  444. }
  445. return true;
  446. };
  447. function GotoPageAction(){
  448. this.pageNumber=null;
  449. };
  450. GotoPageAction.prototype=new CognosViewerAction();
  451. GotoPageAction.ERROR_CODE_INVALID_INT="Goto-001";
  452. GotoPageAction.ERROR_CODE_REPORT_NOT_COMPLETE="Goto-002";
  453. GotoPageAction.ERROR_CODE_INVALID_PAGE_RANGE="Goto-003";
  454. GotoPageAction.prototype.setRequestParms=function(_77){
  455. if(_77){
  456. this.pageNumber=_77.pageNumber;
  457. this.anchorName=_77.anchorName;
  458. }
  459. };
  460. GotoPageAction.prototype.execute=function(){
  461. var oCV=this.getCognosViewer();
  462. var _79=oCV.getPageInfo();
  463. if(!this.isPositiveInt(this.pageNumber)){
  464. return this.buildActionResponseObject("error",GotoPageAction.ERROR_CODE_INVALID_INT,RV_RES.IDS_JS_ERROR_INVALID_INT);
  465. }else{
  466. if(oCV.getStatus()!="complete"){
  467. return this.buildActionResponseObject("error",GotoPageAction.ERROR_CODE_REPORT_NOT_COMPLETE,RV_RES.IDS_JS_ERROR_REPORT_NOT_COMPLETE);
  468. }else{
  469. if(_79&&_79.pageCount&&this.pageNumber>_79.pageCount){
  470. return this.buildActionResponseObject("error",GotoPageAction.ERROR_CODE_INVALID_PAGE_RANGE,RV_RES.IDS_JS_ERROR_INVALID_PAGE_RANGE);
  471. }
  472. }
  473. }
  474. if(_79.currentPage==this.pageNumber){
  475. this.scrollTo();
  476. return true;
  477. }
  478. var _7a=new ViewerDispatcherEntry(oCV);
  479. _7a.addFormField("ui.action","reportAction");
  480. _7a.addFormField("generic.anyURI.http://developer.cognos.com/ceba/constants/runOptionEnum#pageNumber",this.pageNumber);
  481. if(this.anchorName){
  482. _7a.setCallbacks({"postComplete":{"object":this,"method":this.scrollTo}});
  483. }
  484. oCV.dispatchRequest(_7a);
  485. };
  486. GotoPageAction.prototype.scrollTo=function(){
  487. if(this.anchorName){
  488. var _7b=document.getElementsByName(this.anchorName);
  489. if(_7b&&_7b.length>0&&_7b[0].scrollIntoView){
  490. _7b[0].scrollIntoView();
  491. }else{
  492. document.location="#"+this.anchorName;
  493. }
  494. }
  495. };
  496. HiddenIframeDispatcherEntry.IFRAME_ID_PREFIX="viewerHiddenRequest";
  497. HiddenIframeDispatcherEntry.FORM_NAME="viewerHiddenFormRequest";
  498. function HiddenIframeDispatcherEntry(oCV){
  499. HiddenIframeDispatcherEntry.baseConstructor.call(this,oCV);
  500. if(oCV){
  501. HiddenIframeDispatcherEntry.prototype.setDefaultFormFields.call(this);
  502. this.setRequestHandler(new RequestHandler(oCV));
  503. this.setWorkingDialog(oCV.getWorkingDialog());
  504. this.setRequestIndicator(oCV.getRequestIndicator());
  505. this.m_httpRequestConfig=oCV.getConfig()&&oCV.getConfig().getHttpRequestConfig()?oCV.getConfig().getHttpRequestConfig():null;
  506. this.setIframeId(HiddenIframeDispatcherEntry.IFRAME_ID_PREFIX+oCV.getId());
  507. this.originalGetViewerConfiguration=null;
  508. }
  509. };
  510. HiddenIframeDispatcherEntry.prototype=new DispatcherEntry();
  511. HiddenIframeDispatcherEntry.baseConstructor=DispatcherEntry;
  512. HiddenIframeDispatcherEntry.prototype.setDefaultFormFields=function(){
  513. var oCV=this.getViewer();
  514. var _7e=oCV.getCAFContext();
  515. this.addDefinedNonNullFormField("ui.cafcontextid",_7e);
  516. };
  517. HiddenIframeDispatcherEntry.prototype.sendRequest=function(){
  518. this._createHiddenIframe();
  519. var _7f=this._createForm();
  520. this._setupCallbacks();
  521. this.onPreHttpRequest(this.getRequest());
  522. _7f.submit();
  523. };
  524. HiddenIframeDispatcherEntry.prototype._iframeRequestComplete=function(){
  525. window.getViewerConfiguration=this.originalGetViewerConfiguration;
  526. this.onPostHttpRequest();
  527. this.onEntryComplete();
  528. };
  529. HiddenIframeDispatcherEntry.prototype._setupCallbacks=function(){
  530. this.originalGetViewerConfiguration=window.getViewerConfiguration;
  531. if(this.getFormField("cv.useAjax")!="false"){
  532. var _80=this;
  533. var _81=this.getRequestHandler().getRequestIndicator();
  534. var _82=this.getRequestHandler().getWorkingDialog();
  535. window.getViewerConfiguration=function(){
  536. var _83={"httpRequestCallbacks":{"reportStatus":{"complete":function(){
  537. _80.onComplete();
  538. },"working":function(){
  539. _80.onWorking();
  540. },"prompting":function(){
  541. _80.onPrompting();
  542. }}}};
  543. return _83;
  544. };
  545. }
  546. };
  547. HiddenIframeDispatcherEntry.prototype.setIframeId=function(id){
  548. this._iframeId=id;
  549. };
  550. HiddenIframeDispatcherEntry.prototype.getIframeId=function(){
  551. return this._iframeId;
  552. };
  553. HiddenIframeDispatcherEntry.prototype._createForm=function(_85){
  554. var oCV=this.getViewer();
  555. var _87=HiddenIframeDispatcherEntry.FORM_NAME+oCV.getId();
  556. var _88=document.getElementById(_87);
  557. if(_88){
  558. _88.parentNode.removeChild(_88);
  559. _88=null;
  560. }
  561. var _89=location.protocol+"//"+location.host+oCV.m_sGateway;
  562. _88=document.createElement("form");
  563. _88.setAttribute("method","post");
  564. _88.setAttribute("action",_89);
  565. _88.setAttribute("target",this.getIframeId());
  566. _88.setAttribute("id",_87);
  567. _88.style.display="none";
  568. var _8a=this.getRequest().getFormFields();
  569. var _8b=_8a.keys();
  570. for(var _8c=0;_8c<_8b.length;_8c++){
  571. _88.appendChild(createHiddenFormField(_8b[_8c],_8a.get(_8b[_8c])));
  572. }
  573. document.body.appendChild(_88);
  574. return _88;
  575. };
  576. HiddenIframeDispatcherEntry.prototype._createHiddenIframe=function(){
  577. var oCV=this.getViewer();
  578. var _8e=this.getIframeId();
  579. var _8f=document.getElementById(_8e);
  580. if(_8f){
  581. _8f.parentNode.parentNode.removeChild(_8f.parentNode);
  582. }
  583. var div=document.createElement("div");
  584. div.style.position="absolute";
  585. div.style.left="0px";
  586. div.style.top="0px";
  587. div.style.display="none";
  588. document.body.appendChild(div);
  589. div.innerHTML="<iframe frameborder=\"0\" id=\""+_8e+"\" name=\""+_8e+"\"></iframe>";
  590. _8f=document.getElementById(_8e);
  591. var _91=this;
  592. var _92=function(){
  593. HiddenIframeDispatcherEntry.handleIframeLoad(_91);
  594. };
  595. if(_8f.attachEvent){
  596. _8f.attachEvent("onload",_92);
  597. }else{
  598. _8f.addEventListener("load",_92,true);
  599. }
  600. };
  601. HiddenIframeDispatcherEntry.hideIframe=function(_93){
  602. var _94=document.getElementById(HiddenIframeDispatcherEntry.IFRAME_ID_PREFIX+_93);
  603. if(_94){
  604. _94.parentNode.style.display="none";
  605. }
  606. };
  607. HiddenIframeDispatcherEntry.showIframeContentsInWindow=function(_95){
  608. var _96=document.getElementById(HiddenIframeDispatcherEntry.IFRAME_ID_PREFIX+_95);
  609. if(!_96){
  610. return;
  611. }
  612. var _97=_96.contentWindow.document.getElementsByTagName("html")[0].innerHTML;
  613. var _98=window.open("","","height=400,width=500");
  614. if(_98){
  615. _98.document.write("<html>"+_97+"</html>");
  616. }
  617. };
  618. HiddenIframeDispatcherEntry.handleIframeLoad=function(_99){
  619. if(!_99){
  620. return;
  621. }
  622. var _9a=document.getElementById(_99.getIframeId());
  623. if(!_9a){
  624. return;
  625. }
  626. var oCV=_9a.contentWindow.window.gaRV_INSTANCES?_9a.contentWindow.window.gaRV_INSTANCES[0]:null;
  627. var _9c=oCV?oCV.getStatus():null;
  628. if(_9c=="complete"){
  629. _99.onComplete();
  630. }
  631. if(_9c=="working"){
  632. _99.onWorking();
  633. }
  634. if(_9c=="prompting"){
  635. _99.onPrompting();
  636. }
  637. if(!oCV||_9c=="fault"||_9c==""){
  638. _99.onFault();
  639. }
  640. };
  641. HiddenIframeDispatcherEntry.prototype.onFault=function(){
  642. this._iframeRequestComplete();
  643. HiddenIframeDispatcherEntry.showIframeContentsInWindow(this.getViewer().getId());
  644. };
  645. HiddenIframeDispatcherEntry.prototype.onPrompting=function(){
  646. this._iframeRequestComplete();
  647. if(this.m_httpRequestConfig){
  648. var _9d=this.m_httpRequestConfig.getReportStatusCallback("prompting");
  649. if(typeof _9d=="function"){
  650. _9d();
  651. }
  652. }
  653. HiddenIframeDispatcherEntry.showIframeContentsInWindow(this.getViewer().getId());
  654. };
  655. HiddenIframeDispatcherEntry.prototype.onComplete=function(){
  656. this._iframeRequestComplete();
  657. if(this.m_httpRequestConfig){
  658. var _9e=this.m_httpRequestConfig.getReportStatusCallback("complete");
  659. if(typeof _9e=="function"){
  660. _9e();
  661. }
  662. }
  663. var _9f=document.getElementById(this.getIframeId());
  664. if(typeof _9f.contentWindow.detachLeavingRV=="function"){
  665. _9f.contentWindow.detachLeavingRV();
  666. }
  667. var _a0=_9f.parentNode;
  668. _a0.style.display="none";
  669. if(this.getCallbacks()&&this.getCallbacks()["complete"]){
  670. HiddenIframeDispatcherEntry.executeCallback(this.getCallbacks()["complete"]);
  671. }
  672. };
  673. HiddenIframeDispatcherEntry.prototype.cancelRequest=function(_a1){
  674. this._iframeRequestComplete();
  675. if(!this.m_bCancelCalled){
  676. this.m_bCancelCalled=true;
  677. var _a2=document.getElementById(this.getIframeId());
  678. if(!_a2){
  679. return;
  680. }
  681. var oCV=_a2.contentWindow[getCognosViewerObjectString(this.getViewer().getId())];
  682. if(oCV){
  683. oCV.cancel();
  684. }
  685. }
  686. };
  687. HiddenIframeDispatcherEntry.executeCallback=function(_a4){
  688. if(_a4){
  689. var _a5=GUtil.generateCallback(_a4.method,_a4.params,_a4.object);
  690. _a5();
  691. }
  692. };
  693. HiddenIframeDispatcherEntry.getIframe=function(_a6){
  694. var _a7=document.getElementById(HiddenIframeDispatcherEntry.IFRAME_ID_PREFIX+_a6);
  695. return _a7;
  696. };
  697. function PrintAction(){
  698. this._pageNumber=null;
  699. this._pageCount=null;
  700. };
  701. PrintAction.prototype=new CognosViewerAction();
  702. PrintAction.ERROR_CODE_INVALID_INT="Print-001";
  703. PrintAction.ERROR_CODE_REPORT_NOT_COMPLETE="Print-002";
  704. PrintAction.ERROR_CODE_INVALID_PAGE_RANGE="Print-003";
  705. PrintAction.prototype.setRequestParms=function(_a8){
  706. if(_a8){
  707. if(_a8.pageNumber){
  708. this._pageNumber=_a8.pageNumber;
  709. }
  710. if(_a8.pageCount){
  711. this._pageCount=_a8.pageCount;
  712. }
  713. }
  714. };
  715. PrintAction.prototype.execute=function(){
  716. var oCV=this.getCognosViewer();
  717. var _aa=this.getCognosViewer().getPageInfo();
  718. if(this._pageNumber&&!this.isPositiveInt(this._pageNumber)){
  719. return this.buildActionResponseObject("error",PrintAction.ERROR_CODE_INVALID_INT,RV_RES.IDS_JS_ERROR_INVALID_INT);
  720. }else{
  721. if(this._pageCount&&!this.isPositiveInt(this._pageCount)){
  722. return this.buildActionResponseObject("error",PrintAction.ERROR_CODE_INVALID_INT,RV_RES.IDS_JS_ERROR_INVALID_INT);
  723. }else{
  724. if(oCV.getStatus()!="complete"){
  725. return this.buildActionResponseObject("error",PrintAction.ERROR_CODE_REPORT_NOT_COMPLETE,RV_RES.IDS_JS_ERROR_REPORT_NOT_COMPLETE);
  726. }else{
  727. if(_aa&&_aa.pageCount&&this._pageNumber>_aa.pageCount){
  728. return this.buildActionResponseObject("error",PrintAction.ERROR_CODE_INVALID_PAGE_RANGE,RV_RES.IDS_JS_ERROR_INVALID_PAGE_RANGE);
  729. }
  730. }
  731. }
  732. }
  733. var _ab=oCV.envParams;
  734. var _ac=this._pageNumber>0?this._pageNumber:"1";
  735. var _ad=this._pageCount?this._pageCount:"0";
  736. var _ae=new HiddenIframeDispatcherEntry(oCV);
  737. _ae.addFormField("ui.action","reportAction");
  738. _ae.addFormField("cv.responseFormat","print");
  739. _ae.addFormField("ui.conversation",oCV.getConversation());
  740. _ae.addFormField("m_tracking",oCV.getTracking());
  741. _ae.addFormField("cv.header","false");
  742. _ae.addFormField("cv.toolbar","false");
  743. _ae.addFormField("cv.id",oCV.getId());
  744. _ae.addFormField("cv.useAjax","false");
  745. _ae.addFormField("generic.anyURI.http://developer.cognos.com/ceba/constants/runOptionEnum#pageNumber",_ac);
  746. _ae.addFormField("generic.anyURI.http://developer.cognos.com/ceba/constants/runOptionEnum#pageCount",_ad);
  747. _ae.setCallbacks({"complete":{"object":this,"params":[],"method":this.printIframe}});
  748. oCV.dispatchRequest(_ae);
  749. };
  750. PrintAction.prototype.printIframe=function(){
  751. var _af=HiddenIframeDispatcherEntry.getIframe(this.getCognosViewer().getId());
  752. if(_af){
  753. if(isIE()){
  754. _af.contentWindow.document.execCommand("print",true,null);
  755. }else{
  756. _af.focus();
  757. _af.contentWindow.print();
  758. }
  759. }
  760. };
  761. function DownloadReportAction(){
  762. this._reportFormat=null;
  763. };
  764. DownloadReportAction.prototype=new CognosViewerAction();
  765. DownloadReportAction.prototype.setRequestParms=function(_b0){
  766. if(_b0){
  767. this._reportFormat=_b0.format;
  768. }
  769. };
  770. DownloadReportAction.prototype.execute=function(){
  771. if(!this._reportFormat){
  772. return false;
  773. }
  774. var oCV=this.getCognosViewer();
  775. var _b2=oCV.envParams;
  776. var _b3=new HiddenIframeDispatcherEntry(oCV);
  777. _b3.addFormField("ui.action","render");
  778. _b3.addFormField("cv.toolbar","false");
  779. _b3.addFormField("cv.header","false");
  780. _b3.addFormField("run.outputFormat",this._reportFormat);
  781. _b3.addFormField("ui.name",this.getObjectDisplayName());
  782. _b3.addFormField("cv.responseFormat","downloadObject");
  783. _b3.addFormField("ui.conversation",oCV.getConversation());
  784. _b3.addFormField("run.prompt","false");
  785. _b3.addFormField("asynch.attachmentEncoding","base64");
  786. _b3.addFormField("run.outputEncapsulation","URLQueryString");
  787. _b3.addFormField("cv.detachRelease","true");
  788. oCV.dispatchRequest(_b3);
  789. return true;
  790. };
  791. function ViewerFindActionConfig(){
  792. this.noMatchFoundCallback=null;
  793. this.findActionCompleteCallback=null;
  794. this.matchBackgroundColor="yellow";
  795. this.focusBackgroundColor="red";
  796. this.updateStyle();
  797. };
  798. ViewerFindActionConfig.BACKGROUND="background: ";
  799. ViewerFindActionConfig.prototype.configure=function(_b4){
  800. applyJSONProperties(this,_b4);
  801. this.updateStyle();
  802. };
  803. ViewerFindActionConfig.prototype.updateStyle=function(){
  804. this.matchBackgroundColor=this.matchBackgroundColor.toUpperCase();
  805. this.focusBackgroundColor=this.focusBackgroundColor.toUpperCase();
  806. this.matchUIStyle=ViewerFindActionConfig.BACKGROUND+this.matchBackgroundColor;
  807. this.focusUIStyle=ViewerFindActionConfig.BACKGROUND+this.focusBackgroundColor;
  808. };
  809. ViewerFindActionConfig.prototype.getNoMatchFoundCallback=function(){
  810. return typeof this.noMatchFoundCallback=="function"?this.noMatchFoundCallback:this._defaultNoMatchFoundCallback;
  811. };
  812. ViewerFindActionConfig.prototype._defaultNoMatchFoundCallback=function(){
  813. if(console&&console.log){
  814. console.log("invoked _defaultNoMatchFoundCallback!");
  815. }
  816. };
  817. ViewerFindActionConfig.prototype.getFindActionCompleteCallback=function(){
  818. return typeof this.findActionCompleteCallback=="function"?this.findActionCompleteCallback:this._defaultFindActionCompleteCallback;
  819. };
  820. ViewerFindActionConfig.prototype._defaultFindActionCompleteCallback=function(){
  821. if(console&&console.log){
  822. console.log("invoked _defaultFindActionCompleteCallback!");
  823. }
  824. };
  825. ViewerFindActionConfig.prototype.getMatchUIStyle=function(){
  826. return this.matchUIStyle;
  827. };
  828. ViewerFindActionConfig.prototype.getFocusUIStyle=function(){
  829. return this.focusUIStyle;
  830. };
  831. ViewerFindActionConfig.prototype.getMatchColor=function(){
  832. return this.matchBackgroundColor;
  833. };
  834. ViewerFindActionConfig.prototype.getFocusColor=function(){
  835. return this.focusBackgroundColor;
  836. };
  837. ViewerFindActionConfig.prototype.isFocusColorSameAsMatch=function(){
  838. return (this.focusBackgroundColor===this.matchBackgroundColor);
  839. };
  840. function ViewerFindState(){
  841. this.keyword=null;
  842. this.caseSensitive=false;
  843. this.wrapAroundSearch=true;
  844. this.matches=null;
  845. this.focus_index=-1;
  846. this.matchesFoundInReport=false;
  847. this.matchesFoundOnServer=false;
  848. this.pageFirstMatchFound=-1;
  849. this.matchesUpdateCount=0;
  850. this.currentPageNo=-1;
  851. this.currentPageHasNext=false;
  852. this.currentPageHasPrev=false;
  853. this.findingOnServerInProgress=false;
  854. this.searchedOnServer=false;
  855. };
  856. ViewerFindState.prototype.setState=function(_b5){
  857. applyJSONProperties(this,_b5);
  858. };
  859. ViewerFindState.prototype.getPageNoForFindNext=function(){
  860. if(!this.isSinglePageReport()){
  861. this.currentPageNo++;
  862. }
  863. return this.currentPageNo;
  864. };
  865. ViewerFindState.prototype.checkServerForNextMatch=function(){
  866. if(this.isSinglePageReport()){
  867. return false;
  868. }
  869. if(this.searchedOnServer&&(!this.matches||this.matches.length==0)){
  870. return false;
  871. }
  872. if(this.currentPageHasNext){
  873. return true;
  874. }
  875. if(this.currentPageHasPrev&&this.wrapAroundSearch){
  876. return true;
  877. }
  878. return false;
  879. };
  880. ViewerFindState.prototype.isSinglePageReport=function(){
  881. return (this.currentPageNo==1&&!this.currentPageHasNext&&!this.currentPageHasPrev);
  882. };
  883. ViewerFindState.prototype.findOnServerInProgress=function(){
  884. return this.findingOnServerInProgress;
  885. };
  886. ViewerFindState.prototype.findOnServerStarted=function(){
  887. this.findingOnServerInProgress=true;
  888. this.matchesFoundOnServer=false;
  889. this.searchedOnServer=true;
  890. };
  891. ViewerFindState.prototype.findOnServerDone=function(){
  892. this.findingOnServerInProgress=false;
  893. };
  894. ViewerFindState.prototype.foundMatchesInReport=function(){
  895. return this.matchesFoundInReport;
  896. };
  897. ViewerFindState.prototype.updatePageInfo=function(_b6,_b7,_b8,_b9){
  898. this.currentPageNo=_b7;
  899. this.currentPageHasPrev=_b9;
  900. this.currentPageHasNext=_b8;
  901. this.matches=_b6;
  902. this.focus_index=-1;
  903. if(_b6&&_b6.length>0){
  904. this.matchesFoundInReport=true;
  905. this.matchesUpdateCount++;
  906. if(this.pageFirstMatchFound==-1){
  907. this.pageFirstMatchFound=_b7;
  908. }
  909. }
  910. };
  911. ViewerFindState.prototype.resetPageInfo=function(){
  912. this.updatePageInfo(null,-1,false,false);
  913. };
  914. ViewerFindState.prototype.getMatches=function(){
  915. return this.matches;
  916. };
  917. ViewerFindState.prototype.firstMatch=function(){
  918. if(this.matches&&this.matches.length>0){
  919. this.focus_index=0;
  920. return this.matches[this.focus_index];
  921. }
  922. return null;
  923. };
  924. ViewerFindState.prototype.nextMatch=function(){
  925. if(this.matches&&this.matches.length>(this.focus_index+1)){
  926. return this.matches[++this.focus_index];
  927. }
  928. return null;
  929. };
  930. ViewerFindState.prototype.hasNext=function(){
  931. return (this.matches&&this.matches.length>(this.focus_index+1));
  932. };
  933. ViewerFindState.prototype.getFocusedMatch=function(){
  934. if(this.matches&&this.matches.length>0&&this.focus_index>=0){
  935. return this.matches[this.focus_index];
  936. }
  937. return null;
  938. };
  939. ViewerFindState.prototype.getKeyword=function(){
  940. return this.keyword;
  941. };
  942. ViewerFindState.prototype.isCaseSensitive=function(){
  943. return this.caseSensitive;
  944. };
  945. ViewerFindState.prototype.isWrapAroundSearch=function(){
  946. return this.wrapAroundSearch;
  947. };
  948. ViewerFindState.prototype.isRepeating=function(){
  949. if(this.isSinglePageReport()){
  950. return this.pageFirstMatchFound==this.currentPageNo;
  951. }else{
  952. return (this.pageFirstMatchFound==this.currentPageNo&&this.matchesUpdateCount>1);
  953. }
  954. };
  955. function ViewerPageState(){
  956. this.currentPage=1;
  957. this.pageCount=1;
  958. };
  959. ViewerPageState.prototype.setState=function(_ba){
  960. applyJSONProperties(this,_ba);
  961. };
  962. ViewerPageState.prototype.getCurrentPage=function(){
  963. return this.currentPage;
  964. };
  965. ViewerPageState.prototype.getPageCount=function(){
  966. return this.pageCount;
  967. };