CCognosViewer.js 138 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2001, 2021
  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. /**
  13. @fileoverview
  14. This file implements all that is necessary to send requests to the server side of Cognos Viewer (using the URL Api),
  15. process the responses and to perform actions on a report like next page or email.
  16. It manages the report state (conversation, tracking, prompting), the report output and the features on the client for the viewer.
  17. */
  18. /**
  19. Initialize the CCognosViewer object.
  20. @constructor
  21. @param {string} sId Identifier used for this object. This identifier will be used to mark elements used by this class.
  22. @param {string} sGateway Path to "cognos.cgi". For example: "/cognos8/cgi-bin/cognos.cgi".
  23. */
  24. var CV_BACKGROUND_LAYER_ID = "CV_BACK";
  25. if (typeof window.gaRV_INSTANCES == "undefined")
  26. {
  27. window.gaRV_INSTANCES = [];
  28. }
  29. // Stubbed logger object, it will get augmented if/when logging is turned on
  30. if (!window.gViewerLogger) {
  31. window.gViewerLogger = {
  32. log : function(hint, content, type) {},
  33. addContextInfo : function(selectionController) {}
  34. };
  35. }
  36. function CognosViewerSession(oCV)
  37. {
  38. this.m_sConversation = oCV.getConversation();
  39. this.m_sParameters = oCV.getExecutionParameters();
  40. this.m_envParams = {};
  41. applyJSONProperties(this.m_envParams, oCV.envParams);
  42. this.m_bRefreshPage = false;
  43. }
  44. function CCognosViewer(sId, sGateway)
  45. {
  46. // Declare a global instance of CCognosViewer if none exists [for backward compatibility].
  47. // This global instance will be refered too by global prompt functions like setPromptControl() and promptButtonNext().
  48. if (typeof window.gCognosViewer == "undefined")
  49. {
  50. window.gCognosViewer = this;
  51. }
  52. if (typeof ViewerConfig == "function") {
  53. this.m_viewerConfig = new ViewerConfig();
  54. try {
  55. if (typeof window.getViewerConfiguration == "function") {
  56. this.m_viewerConfig.configure(window.getViewerConfiguration());
  57. }
  58. else if (window.parent && typeof window.parent.getViewerConfiguration == "function") {
  59. this.m_viewerConfig.configure(window.parent.getViewerConfiguration());
  60. }
  61. }
  62. catch(e) {
  63. // ignore errors for this block.
  64. }
  65. this.m_viewerUIConfig = this.m_viewerConfig.getUIConfig();
  66. }
  67. this.m_sActionState = "";
  68. this.m_bKeepSessionAlive = false;
  69. /**
  70. * @type array
  71. * @private
  72. */
  73. this.m_undoStack = [];
  74. /**
  75. @type array
  76. @private
  77. */
  78. this.m_aSecRequests = [];
  79. /**
  80. @type bool
  81. @private
  82. */
  83. this.m_bDebug = false;
  84. /**
  85. @type string
  86. @private
  87. */
  88. this.m_sCAFContext = "";
  89. /**
  90. @type string
  91. @private
  92. */
  93. this.m_sContextInfoXML = "";
  94. /**
  95. @type string
  96. @private
  97. */
  98. this.m_sConversation = "";
  99. /**
  100. * @type string
  101. * @private
  102. */
  103. this.m_sStatus = "";
  104. /**
  105. @type string
  106. @private
  107. */
  108. this.m_sGateway = sGateway;
  109. /**
  110. @type string
  111. @private
  112. */
  113. this.m_sId = sId;
  114. /**
  115. @type string
  116. @private
  117. */
  118. this.m_sMetadataInfoXML = "";
  119. /**
  120. @type string
  121. @private
  122. */
  123. this.m_sParameters = "";
  124. /**
  125. @type string
  126. @private
  127. */
  128. this.m_sReportState = "";
  129. this.envParams = {};
  130. /**
  131. @type string
  132. @private
  133. */
  134. this.m_sTracking = "";
  135. /**
  136. @type string
  137. @private
  138. */
  139. this.m_sSoapFault = "";
  140. /**
  141. @type string
  142. @private
  143. */
  144. this.m_sWaitHTML = "";
  145. /**
  146. @type CDrillManager
  147. @private
  148. */
  149. this.m_oDrillMgr = null;
  150. /**
  151. @type CDrillManager
  152. @private
  153. */
  154. this.goDrillManager = null;
  155. this.m_oWorkingDialog = null;
  156. this.m_oRequestExecutedIndicator = null;
  157. this.m_bUseWorkingDialog = true;
  158. /**
  159. @type CSubscriptionManager
  160. @private
  161. */
  162. this.m_oSubscriptionManager = null;
  163. /**
  164. @type CViewerManager
  165. @private
  166. */
  167. this.m_oCVMgr = null;
  168. /**
  169. @type boolean
  170. @private
  171. */
  172. this.m_bUseSafeMode = true;
  173. if (typeof CViewerManager == "function")
  174. {
  175. this.m_oCVMgr = new CViewerManager(this);
  176. }
  177. if (window.gaRV_INSTANCES)
  178. {
  179. // only add the cognos viewer object to the array if it isn't already in it
  180. var bFound = false;
  181. for (var iIndex=0; iIndex < window.gaRV_INSTANCES.length; iIndex++)
  182. {
  183. if (window.gaRV_INSTANCES[iIndex].m_sId == sId)
  184. {
  185. window.gaRV_INSTANCES[iIndex] = this;
  186. bFound = true;
  187. break;
  188. }
  189. }
  190. if (!bFound)
  191. {
  192. window.gaRV_INSTANCES = window.gaRV_INSTANCES.concat(this);
  193. }
  194. }
  195. this.m_bReportHasPrompts = false;
  196. this.m_viewerWidget = null;
  197. this.m_flashChartsObjectIds = [];
  198. this.m_raiseSharePromptEvent = true;
  199. this.m_actionFactory = null;
  200. this.m_calculationCache = {};
  201. this.m_drillTargets = [];
  202. this.m_reportRenderingDone = false;
  203. if (typeof PinFreezeManager !== "undefined") {
  204. this.m_pinFreezeManager = new PinFreezeManager(this);
  205. }
  206. if (typeof ViewerDispatcher !== "undefined") {
  207. this.m_viewerDispatcher = new ViewerDispatcher();
  208. }
  209. this.m_retryDispatcherEntry = null;
  210. this.m_RAPReportInfo=null;
  211. if (typeof ViewerState == "function") {
  212. this.m_viewerState = new ViewerState();
  213. }
  214. this.m_aInfoBar = null;
  215. }
  216. CCognosViewer.prototype.setScheduledMobileOutput = function(value) {
  217. this.m_mobileScheduledOutput = value;
  218. if (value) {
  219. this.m_sStatus = "complete";
  220. }
  221. };
  222. /**
  223. * Called from XSL and saved output, do not change this API
  224. */
  225. CCognosViewer.prototype.setTabInfo = function(tabsPaylaod) {
  226. this.m_tabsPayload = tabsPaylaod;
  227. // If we needed to keep the selected tab (going from live to saved output) then
  228. // update the tabs payload info with the correct tabId - if we can find it
  229. if (this.m_tabsPayload && this.m_tabsPayload.tabs && this._keepTabSelected) {
  230. var found = false;
  231. for (var i=0; i < this.m_tabsPayload.tabs.length; i++) {
  232. var tab = this.m_tabsPayload.tabs[i];
  233. if (tab.id == this._keepTabSelected) {
  234. this.m_tabsPayload.currentTabId = this._keepTabSelected;
  235. break;
  236. }
  237. }
  238. this._keepTabSelected = null;
  239. }
  240. };
  241. CCognosViewer.prototype.setKeepTabSelected = function(tabId) {
  242. this._keepTabSelected = tabId;
  243. };
  244. CCognosViewer.prototype.getTabController = function() {
  245. return this.m_tabControl;
  246. };
  247. CCognosViewer.prototype.getCurrentlySelectedTab = function() {
  248. return this.m_currentlySelectedTab ? this.m_currentlySelectedTab : null;
  249. };
  250. /**
  251. * Needed when going from saved output to a live report, or vice versa
  252. */
  253. CCognosViewer.prototype.deleteTabs = function() {
  254. if (this.m_tabControl) {
  255. this.m_tabControl.destroy();
  256. delete this.m_tabControl;
  257. this.m_tabControl = null;
  258. }
  259. this.m_tabsPayload = null;
  260. };
  261. CCognosViewer.prototype.renderTabs = function() {
  262. if (!this.m_tabsPayload) {
  263. return;
  264. }
  265. var viewingSavedOutput = this.isSavedOutput() && !this.m_mobileScheduledOutput;
  266. var navLinks = document.getElementById("CVNavLinks" + this.getId());
  267. if (navLinks || !this.shouldWriteNavLinks() || viewingSavedOutput) {
  268. var reportDiv = this.getReportDiv();
  269. this.m_bHasTabs = true;
  270. // If we've switched from saved output to live or vice versa we need to delete the
  271. // tab control so it gets re-created.
  272. if (this.m_tabControl && this.m_tabControl.isSavedOutput() != viewingSavedOutput) {
  273. this.deleteTabs();
  274. }
  275. if (!this.m_tabControl) {
  276. // No use in creating a tab control if the status isn't complete and we're not viewing saved output
  277. if (this.getStatus() != "complete" && !viewingSavedOutput) {
  278. return;
  279. }
  280. var tr = document.createElement("tr");
  281. var containerTD = document.createElement("td");
  282. tr.appendChild(containerTD);
  283. var mainTR = document.getElementById("mainViewerTR" + this.getId());
  284. if (!mainTR) {
  285. return;
  286. }
  287. if (this.m_tabsPayload.position == "topLeft") {
  288. mainTR.parentNode.insertBefore(tr, mainTR);
  289. }
  290. else {
  291. mainTR.parentNode.appendChild(tr);
  292. }
  293. var tabContainer = null;
  294. if (this.m_viewerWidget) {
  295. tabContainer = this.m_viewerWidget.findContainerDiv().firstChild;
  296. }
  297. else {
  298. tabContainer = containerTD;
  299. }
  300. var oCV = this;
  301. if (viewingSavedOutput) {
  302. this.m_tabControl = new CognosTabControl(tabContainer, function(tabId) { oCV.switchSavedOutputTab(tabId, true); });
  303. this.switchSavedOutputTab(this.m_tabsPayload.currentTabId, false);
  304. }
  305. else {
  306. this.m_tabControl = new CognosTabControl(tabContainer, function(tabId) { oCV.switchTabs(tabId); });
  307. }
  308. if (this.m_viewerWidget) {
  309. this.m_tabControl.setSpaceSaverContainer(containerTD);
  310. this.m_tabControl.setScrollAttachNode(this.m_viewerWidget.findContainerDiv());
  311. this.m_tabControl.useAbsolutePosition(true);
  312. }
  313. this.m_tabControl.setIsSavedOutput(viewingSavedOutput);
  314. // If we're dealing with the initial http response (not ajax) then we should mimic loading of the styles.
  315. // We need to move the links into the head using the gScriptLoader so it knows about them and also namespace and move
  316. // the styles into the head. This is all needed since with tabs we need to be able to remove/add styles for each tab
  317. if (!window.gScriptLoader.m_bScriptLoaderCalled) {
  318. var content = document.getElementById("RVContent" + this.getId());
  319. var links = this._getNodesWithViewerId(content, "link", null);
  320. for (var i=0; i < links.length; i++) {
  321. window.gScriptLoader.moveLinks(links[i]);
  322. }
  323. window.gScriptLoader.loadStyles(content, this.getId());
  324. this.repaintDiv(content);
  325. }
  326. }
  327. if (this.getStatus() == "prompting") {
  328. this.previouslySelectedTab = null; // In case the user hits Cancel on the prompt, we want to stay on the currently selected tab
  329. this.m_tabControl.hide();
  330. }
  331. else {
  332. if (this.isHighContrast()) {
  333. this.m_tabControl.setHighContrast(true);
  334. }
  335. this.m_tabControl.render(this.m_tabsPayload);
  336. this.m_currentlySelectedTab = this.m_tabControl.getSelectedTabId();
  337. // Special case where RSVP returned a different tab then the one that was asked for. Can happen with conditional rendering
  338. if (this.m_switchingToTabId && this.m_currentlySelectedTab != this.m_switchingToTabId) {
  339. this._removeTabContent(reportDiv.parentNode, this.m_switchingToTabId);
  340. this._removeTabContent(reportDiv.parentNode, this.m_currentlySelectedTab);
  341. if (navLinks) {
  342. this._removeTabContent(navLinks.parentNode, this.m_switchingToTabId);
  343. this._removeTabContent(navLinks.parentNode, this.m_currentlySelectedTab);
  344. }
  345. this.m_tabInfo = {};
  346. }
  347. this.m_switchingToTabId = null;
  348. reportDiv.setAttribute("tabId", this.m_currentlySelectedTab);
  349. if (navLinks) {
  350. navLinks.setAttribute("tabId", this.m_currentlySelectedTab);
  351. }
  352. if (isIE() && viewingSavedOutput && window.resizeIFrame && !this.m_viewerFragment && !this.m_viewerWidget) {
  353. window.resizeIFrame();
  354. }
  355. }
  356. this.setMaxContentSize();
  357. }
  358. else {
  359. var obj = this;
  360. setTimeout(function() { obj.renderTabs(); }, 100);
  361. }
  362. };
  363. CCognosViewer.prototype.cancelTabSwitch = function() {
  364. var reportDiv = this.getReportDiv();
  365. var tabCancelled = this.m_switchingToTabId;
  366. this.m_currentlySelectedTab = tabCancelled;
  367. this.m_tabControl.selectTab(this.previouslySelectedTab, false);
  368. this.switchTabs(this.previouslySelectedTab);
  369. if (reportDiv) {
  370. reportDiv.parentNode.removeChild(reportDiv);
  371. }
  372. if (this.m_tabInfo[this.m_currentlySelectedTab] && this.m_tabInfo[this.m_currentlySelectedTab].styles) {
  373. this._addTabStylesToHead(this.m_tabInfo[this.m_currentlySelectedTab].styles);
  374. }
  375. this.previouslySelectedTab = null;
  376. this.m_tabInfo[tabCancelled] = null;
  377. };
  378. CCognosViewer.prototype.switchSavedOutputTab = function(tabId, userInvoked) {
  379. // Clear the selection
  380. var selectionController = this.getSelectionController();
  381. if (selectionController) {
  382. selectionController.clearSelectedObjects();
  383. }
  384. this.m_currentlySelectedTab = this.m_tabControl.getSelectedTabId();
  385. if (userInvoked) {
  386. this.notifyTabChange(tabId);
  387. }
  388. if (this.m_viewerWidget) {
  389. this.m_viewerWidget.getSavedOutput().switchSavedOutputTab(tabId, userInvoked);
  390. this.getTabController().resetPosition();
  391. }
  392. else {
  393. if (!this.savedOutputTabNodes) {
  394. var iframe = document.getElementById("CVIFrame" + this.getId());
  395. this.savedOutputTabNodes = getElementsByAttribute(iframe.contentWindow.document.body, "*", "tabid");
  396. }
  397. if (!this.savedOutputTabNodes) {
  398. return;
  399. }
  400. // Loops through all the tabs and either show or hide them
  401. for (var i=0; i < this.savedOutputTabNodes.length; i++) {
  402. var table = this.savedOutputTabNodes[i];
  403. table.style.display = table.getAttribute("tabid") == tabId ? "" : "none";
  404. }
  405. this.setMaxContentSize();
  406. }
  407. };
  408. CCognosViewer.prototype.notifyTabChange = function(newTabId) {
  409. // Function will get overriden when we're in mobile
  410. };
  411. CCognosViewer.prototype._getNodesWithViewerId = function(parentNode, nodeName, id) {
  412. var result = [];
  413. var nodes = parentNode.getElementsByTagName(nodeName);
  414. // Loops through all the style elements to find those with the correct namespaceId
  415. for (var i=0; i < nodes.length; i++) {
  416. var node = nodes[i];
  417. if (!id || (node.getAttribute && node.getAttribute("namespaceId") == id)) {
  418. node.parentNode.removeChild(node);
  419. result.push(node);
  420. i--;
  421. }
  422. }
  423. return result;
  424. };
  425. /**
  426. * Used to remove the styles that were added by a report tab.
  427. */
  428. CCognosViewer.prototype._removeTabStylesFromHead = function() {
  429. var id = this.getId();
  430. return this._getNodesWithViewerId(document.getElementsByTagName("head").item(0), "style", id);
  431. };
  432. CCognosViewer.prototype._addTabStylesToHead = function(tabStyles) {
  433. if (!tabStyles) {
  434. return;
  435. }
  436. for (var i=0; i < tabStyles.length; i++) {
  437. document.getElementsByTagName("head").item(0).appendChild(tabStyles[i]);
  438. }
  439. };
  440. CCognosViewer.prototype.switchTabs = function(tabId) {
  441. //Defect 51503 - If already on tab that was clicked on then do nothing
  442. if (this.m_currentlySelectedTab == tabId) {
  443. return;
  444. }
  445. // Clear the selection
  446. var selectionController = this.getSelectionController();
  447. if (selectionController) {
  448. selectionController.clearSelectedObjects();
  449. }
  450. var reportDiv = this.getReportDiv();
  451. this.m_nReportDiv = null; // reset the member variable that keeps a link to the report div
  452. // Keep track of the current height. Needed if we're moving to a new tab to stop
  453. // the tab control from 'jumping' around.
  454. var oldDivHeight = reportDiv.clientHeight;
  455. // Hide the currently visible report div and nav links
  456. reportDiv.removeAttribute("id");
  457. reportDiv.style.display = "none";
  458. // We need to keep information about each tab in the case the user switches back to it.
  459. if (!this.m_tabInfo) {
  460. this.m_tabInfo = {};
  461. }
  462. var removedStyles = this._removeTabStylesFromHead();
  463. var dataManager = this.getSelectionController().getCCDManager();
  464. this.m_tabInfo[this.m_currentlySelectedTab] = {
  465. "conversation" : this.getConversation(),
  466. "metadata" : dataManager.getClonedMetadataArray(),
  467. "contextdata" : dataManager.getClonedContextdataArray(),
  468. "secondaryRequests" : this.getSecondaryRequests(),
  469. "styles" : removedStyles,
  470. "hasPromptControl" : this.getHasPrompts()
  471. };
  472. var tabContentDiv = this._findChildWithTabId(reportDiv.parentNode, tabId);
  473. this.previouslySelectedTab = this.m_currentlySelectedTab; // Needed in case the user hit Cancel on the new tab, we want to return to the previously selected tab
  474. // If we have a cached div that contains a prompt control then remove it from the DOM. We cannot simply flip between divs with tab controls
  475. // since we might get ID collisions
  476. if (tabContentDiv && this.m_tabInfo[tabId] && this.m_tabInfo[tabId].hasPromptControl) {
  477. if (tabContentDiv) {
  478. tabContentDiv.parentNode.removeChild(tabContentDiv);
  479. tabContentDiv = null;
  480. }
  481. delete this.m_tabInfo[tabId];
  482. this.m_tabInfo[tabId] = null;
  483. }
  484. // Do we already have a div for the tab we're switching to
  485. if (tabContentDiv) {
  486. this.m_currentlySelectedTab = tabId;
  487. tabContentDiv.style.display = "block";
  488. tabContentDiv.setAttribute("id", "CVReport" + this.getId());
  489. if (this.m_tabInfo && this.m_tabInfo[tabId]) {
  490. var tabInfo = this.m_tabInfo[tabId];
  491. if (tabInfo.conversation) {
  492. this.setConversation(tabInfo.conversation);
  493. }
  494. if (tabInfo.metadata) {
  495. dataManager.SetMetadata(tabInfo.metadata);
  496. }
  497. if (tabInfo.contextdata) {
  498. dataManager.SetContextData(tabInfo.contextdata);
  499. }
  500. if (tabInfo.secondaryRequests) {
  501. this.setSecondaryRequests(tabInfo.secondaryRequests);
  502. }
  503. if (tabInfo.styles) {
  504. this._addTabStylesToHead(tabInfo.styles);
  505. }
  506. this.setHasPrompts(tabInfo.hasPromptControl);
  507. }
  508. if (this.shouldWriteNavLinks()) {
  509. this.writeNavLinks(this.getSecondaryRequests().join(" "));
  510. }
  511. if (this.getPinFreezeManager() && this.getPinFreezeManager().hasFrozenContainers()) {
  512. this.getPinFreezeManager().rePaint();
  513. // force IE to repaint the div or the the RVContent div won't resize
  514. if (isIE()) {
  515. var oRVContent = document.getElementById("RVContent" + this.getId());
  516. this.repaintDiv(oRVContent);
  517. }
  518. }
  519. if (this.m_viewerWidget) {
  520. this.m_viewerWidget.placeTabControlInView();
  521. }
  522. // The tab that was clicked on is already in focus. Make sure we don't move the focus around.
  523. this._keepFocus = null;
  524. this.doneLoadingUpdateA11Y("complete");
  525. this.getTabController().resetPosition();
  526. this.setMaxContentSize();
  527. }
  528. else {
  529. this.m_switchingToTabId = tabId;
  530. var newReportDiv = reportDiv.cloneNode(false);
  531. newReportDiv.style.display = "block";
  532. newReportDiv.setAttribute("id", "CVReport" + this.getId());
  533. newReportDiv.removeAttribute("tabId"); // We don't want to clone the tabId
  534. reportDiv.parentNode.appendChild(newReportDiv);
  535. newReportDiv.innerHTML = "<table height='" + oldDivHeight + "px'><tr><td height='100%'></td></tr></table>";
  536. var request = new ViewerDispatcherEntry(this);
  537. request.addFormField("ui.action", "reportAction");
  538. request.addFormField("generic.anyURI.http://developer.cognos.com/ceba/constants/runOptionEnum#pageGroup", tabId);
  539. if (this.m_viewerWidget) {
  540. this.m_viewerWidget.placeTabControlInView();
  541. }
  542. this.dispatchRequest(request);
  543. }
  544. };
  545. /**
  546. * Removed the content div associated to a particular tab
  547. */
  548. CCognosViewer.prototype._removeTabContent = function(parentNode, tabId) {
  549. var tabContentDiv = this._findChildWithTabId(parentNode, tabId);
  550. while(tabContentDiv) {
  551. tabContentDiv.parentNode.removeChild(tabContentDiv);
  552. tabContentDiv = this._findChildWithTabId(parentNode, tabId);
  553. }
  554. };
  555. CCognosViewer.prototype._findChildWithTabId = function(parentNode, tabId) {
  556. var matchedNode = null;
  557. for (var i=0; i < parentNode.childNodes.length; i++) {
  558. var childNode = parentNode.childNodes[i];
  559. if (childNode.getAttribute("tabId") == tabId) {
  560. matchedNode = childNode;
  561. break;
  562. }
  563. }
  564. return matchedNode;
  565. };
  566. /**
  567. * Clears all the content divs associated to the tabs except the visible div
  568. */
  569. CCognosViewer.prototype.clearTabs = function() {
  570. if (!this.m_bHasTabs) {
  571. return;
  572. }
  573. this.m_tabInfo = {};
  574. var reportDiv = this.getReportDiv();
  575. var parentNode = reportDiv.parentNode;
  576. for (var i=0; i < parentNode.childNodes.length; i++) {
  577. var node = parentNode.childNodes[i];
  578. if (node.getAttribute("id") != "CVReport" + this.m_sId) {
  579. parentNode.removeChild(node);
  580. i--;
  581. }
  582. }
  583. };
  584. CCognosViewer.prototype.isSavedOutput = function() {
  585. var action = this.envParams["ui.action"];
  586. return action === 'view' || action === 'buxView';
  587. };
  588. CCognosViewer.prototype.renderSavedOutputIFrame = function(url, title, renderTabs) {
  589. var reportDiv = document.getElementById("CVReport" + this.getId());
  590. var iframe = document.createElement("iframe");
  591. iframe.style.width = "100%";
  592. iframe.style.height = "99%";
  593. iframe.id = "CVIFrame" + this.getId();
  594. iframe.title = title;
  595. iframe.setAttribute("frameBorder", "0");
  596. reportDiv.appendChild(iframe);
  597. var obj = this;
  598. var func = function() {
  599. obj.renderTabs();
  600. };
  601. setTimeout(function() {
  602. // If we're suppose to render tabs, set the onload of the iframe
  603. if (renderTabs) {
  604. if(iframe.attachEvent) {
  605. iframe.attachEvent("onload", func);
  606. }
  607. else {
  608. iframe.addEventListener("load", func, true);
  609. }
  610. }
  611. iframe.src = url;
  612. }, 1);
  613. };
  614. /**
  615. * This gets called from rv.xsl
  616. */
  617. CCognosViewer.prototype.updatePageState = function(pageState) {
  618. if (pageState && this.getState()) {
  619. this.getState().setPageState(pageState);
  620. }
  621. };
  622. /**
  623. * Public API used by customers, do not change!
  624. */
  625. CCognosViewer.prototype.getPageInfo = function() {
  626. if (this.m_viewerState && this.m_viewerState.getPageState()) {
  627. var pageState = this.m_viewerState.getPageState();
  628. return {
  629. "currentPage" : pageState.getCurrentPage(),
  630. "pageCount" : pageState.getPageCount()
  631. };
  632. }
  633. return {};
  634. };
  635. CCognosViewer.prototype.isIWidgetMobile = function() {
  636. return this.m_viewerWidget && this.m_viewerWidget.isMobile();
  637. };
  638. CCognosViewer.prototype.isInteractiveViewer = function() {
  639. return false;
  640. };
  641. /**
  642. * Returns true if we're in CW and inside the mobile app. If that's the case
  643. * the goto page will be launched via an iwidget event
  644. */
  645. CCognosViewer.prototype.launchGotoPageForIWidgetMobile = function(form) {
  646. if (this.isIWidgetMobile()) {
  647. this.m_viewerWidget.launchGotoPageForIWidgetMobile(form);
  648. return true;
  649. }
  650. return false;
  651. };
  652. CCognosViewer.prototype.executeDrillThroughForIWidgetMobile = function(form) {
  653. if (this.isIWidgetMobile()) {
  654. this.m_viewerWidget.executeDrillThroughForIWidgetMobile(form);
  655. return true;
  656. }
  657. return false;
  658. };
  659. CCognosViewer.prototype.getState = function() {
  660. return this.m_viewerState;
  661. };
  662. CCognosViewer.prototype.getConfig = function() {
  663. return this.m_viewerConfig;
  664. };
  665. CCognosViewer.prototype.getUIConfig = function() {
  666. return this.m_viewerUIConfig;
  667. };
  668. CCognosViewer.prototype.setCurrentNodeFocus = function(node) {
  669. this.m_currentNodeFocus = node;
  670. };
  671. CCognosViewer.prototype.getCurrentNodeFocus = function(node) {
  672. return this.m_currentNodeFocus;
  673. };
  674. CCognosViewer.prototype.setCurrentPromptControlFocus = function(node) {
  675. this.m_CurrentPromptControlFocus = node;
  676. };
  677. CCognosViewer.prototype.getCurrentPromptControlFocus = function(node) {
  678. return this.m_CurrentPromptControlFocus;
  679. };
  680. /**
  681. * Override this method if you need to load extra javascript files
  682. */
  683. CCognosViewer.prototype.loadExtra = function() {};
  684. CCognosViewer.prototype.setRetryDispatcherEntry = function(dispatcherEntry) {
  685. this.m_retryDispatcherEntry = dispatcherEntry;
  686. };
  687. CCognosViewer.prototype.getRetryDispatcherEntry = function() {
  688. return this.m_retryDispatcherEntry;
  689. };
  690. CCognosViewer.prototype.resetViewerDispatcher = function() {
  691. if (this.m_viewerDispatcher !== null) {
  692. delete this.m_viewerDispatcher;
  693. this.m_viewerDispatcher = new ViewerDispatcher();
  694. }
  695. };
  696. CCognosViewer.prototype.getViewerDispatcher = function() {
  697. return this.m_viewerDispatcher;
  698. };
  699. CCognosViewer.prototype.setFaultDispatcherEntry = function(dispatcherEntry) {
  700. this.m_faultDispatcherEntry = dispatcherEntry;
  701. };
  702. CCognosViewer.prototype.getFaultDispatcherEntry = function() {
  703. return this.m_faultDispatcherEntry;
  704. };
  705. CCognosViewer.prototype.dispatchRequest = function(dispatcherEntry) {
  706. this.setFaultDispatcherEntry(null);
  707. this.getViewerDispatcher().dispatchRequest(dispatcherEntry);
  708. };
  709. CCognosViewer.prototype.getActiveRequest = function() {
  710. return this.getViewerDispatcher().getActiveRequest();
  711. };
  712. CCognosViewer.prototype.getProductLocale = function() {
  713. if (this.sProductLocale) {
  714. return this.sProductLocale;
  715. }
  716. // default to english if the productLocale wasn't set
  717. return "en";
  718. };
  719. CCognosViewer.prototype.getDirection = function() {
  720. if (this.sDirection) {
  721. return this.sDirection;
  722. }
  723. return "ltr";
  724. };
  725. CCognosViewer.prototype.isBidiEnabled = function() {
  726. if (this.bIsBidiEnabled) {
  727. return true;
  728. }
  729. return false;
  730. };
  731. CCognosViewer.prototype.getBaseTextDirection = function() {
  732. if(this.isBidiEnabled()){
  733. if (this.sBaseTextDirection) {
  734. return this.sBaseTextDirection;
  735. }
  736. }
  737. return "";
  738. };
  739. CCognosViewer.prototype.getActionFactory = function(){
  740. if (!this.m_actionFactory) {
  741. this.m_actionFactory = new ActionFactory(this);
  742. }
  743. return this.m_actionFactory;
  744. };
  745. CCognosViewer.prototype.getAction = function(action) {
  746. var action = this.getActionFactory().load(action);
  747. action.setCognosViewer(this);
  748. return action;
  749. };
  750. CCognosViewer.prototype.getCalculationCache = function(){
  751. return this.m_calculationCache;
  752. };
  753. CCognosViewer.prototype.updateOutputForA11ySupport = function() {
  754. this.updateBorderCollapse();
  755. // Defect COGCQ00849044 - drill through links outside of data tables don't get
  756. // the correct labelledBy to let a JAWS use know there's a drill through link
  757. if (this.getA11YHelper()) {
  758. this.getA11YHelper().addLabelledByForItemsOutsideOfContainers();
  759. }
  760. var v_sAgent = navigator.userAgent.toLowerCase();
  761. var v_bIsIPhone = v_sAgent.indexOf( "iphone" ) != -1;
  762. var v_bIsIPod = v_sAgent.indexOf( "ipod" ) != -1;
  763. var v_bIsIPad = v_sAgent.indexOf( "ipad" ) != -1;
  764. var v_bIsIOS = v_bIsIPhone || v_bIsIPod || v_bIsIPad;
  765. var v_bIsAndroid = v_sAgent.indexOf( "android") != -1;
  766. if ( v_bIsIOS || v_bIsAndroid )
  767. {
  768. document.body.classList.add( "clsViewerMobile" );
  769. }
  770. };
  771. CCognosViewer.prototype.checkForHighContrast = function()
  772. {
  773. if (this.isBux) {
  774. this.m_bHighContrast = dojo.hasClass(document.body, "dijit_a11y") ? true : false;
  775. }
  776. else {
  777. var tempDiv = document.createElement("div");
  778. tempDiv.id = this.m_sId + "hc";
  779. tempDiv.style.border = "1px solid";
  780. tempDiv.style.borderColor = "red green";
  781. tempDiv.style.height = "10px";
  782. tempDiv.style.top = "-999px";
  783. tempDiv.style.position = "absolute";
  784. document.body.appendChild(tempDiv);
  785. var computedStyle = null;
  786. if (isIE())
  787. {
  788. computedStyle = tempDiv.currentStyle;
  789. }
  790. else
  791. {
  792. computedStyle = tempDiv.ownerDocument.defaultView.getComputedStyle(tempDiv, null);
  793. }
  794. if (!computedStyle) {
  795. return;
  796. }
  797. this.m_bHighContrast = computedStyle.borderTopColor == computedStyle.borderRightColor;
  798. document.body.removeChild(tempDiv);
  799. }
  800. };
  801. CCognosViewer.prototype.isHighContrast = function()
  802. {
  803. if (typeof this.m_bHighContrast === "undefined") {
  804. this.checkForHighContrast();
  805. }
  806. return this.m_bHighContrast;
  807. };
  808. CCognosViewer.prototype.isLimitedInteractiveMode = function() {
  809. return this.envParams && this.envParams.limitedInteractiveMode && this.envParams.limitedInteractiveMode === "true";
  810. };
  811. CCognosViewer.prototype.updateBorderCollapse = function()
  812. {
  813. if (this.isHighContrast() == true)
  814. {
  815. var reportDiv = null;
  816. if (this.envParams["ui.action"] == "view" && !this.isBux)
  817. {
  818. var iframe = document.getElementById("CVIFrame" + this.getId());
  819. reportDiv = iframe.contentWindow.document;
  820. }
  821. else
  822. {
  823. reportDiv = document.getElementById("CVReport" + this.getId());
  824. }
  825. var tables = reportDiv.getElementsByTagName("table");
  826. for (var i = 0; i < tables.length; i++)
  827. {
  828. if (tables[i].style.borderCollapse == "collapse")
  829. {
  830. tables[i].style.borderCollapse = "separate";
  831. }
  832. }
  833. }
  834. };
  835. CCognosViewer.prototype.isAccessibleMode = function()
  836. {
  837. if (this.m_bAccessibleMode == true)
  838. {
  839. return true;
  840. }
  841. return false;
  842. };
  843. /**
  844. * @return true if the current report is a single page report.
  845. */
  846. CCognosViewer.prototype.isSinglePageReport = function()
  847. {
  848. for (var request in this.m_aSecRequests) {
  849. if (this.m_aSecRequests[request] == 'nextPage' || this.m_aSecRequests[request] == 'previousPage')
  850. {
  851. return false;
  852. }
  853. }
  854. return true;
  855. };
  856. /**
  857. * @return true if the current report can sent nextPage request
  858. */
  859. CCognosViewer.prototype.hasNextPage = function()
  860. {
  861. for (var request in this.m_aSecRequests) {
  862. if (this.m_aSecRequests[request] == 'nextPage')
  863. {
  864. return true;
  865. }
  866. }
  867. return false;
  868. };
  869. /**
  870. * @return true if the current report can sent previousPage request
  871. */
  872. CCognosViewer.prototype.hasPrevPage = function()
  873. {
  874. for (var request in this.m_aSecRequests) {
  875. if (this.m_aSecRequests[request] == 'previousPage')
  876. {
  877. return true;
  878. }
  879. }
  880. return false;
  881. };
  882. /**
  883. * KeyDown events handler attached to the document, which disables hotkey page navigation within the viewer
  884. * @private
  885. */
  886. CCognosViewer.prototype.captureHotkeyPageNavigation = function(evt)
  887. {
  888. evt = (evt) ? evt : ((event) ? event : null);
  889. if(evt)
  890. {
  891. var node = getNodeFromEvent(evt);
  892. var nodeName = (node && node.nodeName) ? node.nodeName.toLowerCase() : null;
  893. if( (evt.keyCode == 8 && nodeName != "input" && nodeName != "textarea") || (evt.altKey == true && (evt.keyCode == 37 || evt.keyCode == 39)) )
  894. {
  895. evt.returnValue = false;
  896. evt.cancelBubble = true;
  897. if(typeof evt.stopPropagation != "undefined")
  898. {
  899. evt.stopPropagation();
  900. }
  901. if(typeof evt.preventDefault != "undefined")
  902. {
  903. evt.preventDefault();
  904. }
  905. return false;
  906. }
  907. }
  908. return true;
  909. };
  910. CCognosViewer.prototype.setUseWorkingDialog = function(bUseWorkingDialog) {
  911. this.m_bUseWorkingDialog = bUseWorkingDialog;
  912. };
  913. CCognosViewer.prototype.getWorkingDialog = function( ) {
  914. if (!this.m_oWorkingDialog && this.m_bUseWorkingDialog && typeof WorkingDialog !== "undefined") {
  915. if (this.getConfig() && this.getConfig().getHttpRequestConfig() && this.getConfig().getHttpRequestConfig().getWorkingDialog()) {
  916. this.m_oWorkingDialog = this.getConfig().getHttpRequestConfig().getWorkingDialog();
  917. }
  918. else {
  919. this.m_oWorkingDialog = new WorkingDialog(this);
  920. }
  921. }
  922. return this.m_oWorkingDialog;
  923. };
  924. CCognosViewer.prototype.getRequestIndicator = function() {
  925. if (this.m_bUseWorkingDialog && !this.m_oRequestExecutedIndicator && typeof RequestExecutedIndicator !== "undefined") {
  926. if (this.getConfig() && this.getConfig().getHttpRequestConfig() && this.getConfig().getHttpRequestConfig().getRequestIndicator()) {
  927. this.m_oRequestExecutedIndicator = this.getConfig().getHttpRequestConfig().getRequestIndicator();
  928. }
  929. else {
  930. this.m_oRequestExecutedIndicator = new RequestExecutedIndicator(this);
  931. }
  932. }
  933. return this.m_oRequestExecutedIndicator;
  934. };
  935. /**
  936. * Call this method to disable hot key page navigation within the viewer (back space, alt+left arrow, alt+right arrow)
  937. */
  938. CCognosViewer.prototype.disableBrowserHotkeyPageNavigation = function() {
  939. if (document.attachEvent)
  940. {
  941. document.attachEvent("onkeydown", this.captureHotkeyPageNavigation);
  942. }
  943. else if (document.addEventListener)
  944. {
  945. document.addEventListener("keydown", this.captureHotkeyPageNavigation, false);
  946. }
  947. };
  948. /**
  949. * Sets if the current HTML being displayed contains prompt controls
  950. * @param (boolean) hasPrompts
  951. */
  952. CCognosViewer.prototype.setHasPrompts = function(hasPrompts)
  953. {
  954. if (!hasPrompts) {
  955. this.preProcessControlArray = [];
  956. }
  957. this.m_bReportHasPrompts = hasPrompts;
  958. };
  959. /**
  960. * Checks to see if the HTML being displayed contains prompt controls
  961. * @return (boolean)
  962. */
  963. CCognosViewer.prototype.getHasPrompts = function() {
  964. return this.m_bReportHasPrompts;
  965. };
  966. /**
  967. * Sets the request mode (page/data)
  968. * @param (boolean) bPageRequest
  969. */
  970. CCognosViewer.prototype.setUsePageRequest = function(bPageRequest)
  971. {
  972. this.m_viewerDispatcher.setUsePageRequest(bPageRequest);
  973. };
  974. /**
  975. * Gets the request mode (page/data)
  976. * @return (boolean)
  977. */
  978. CCognosViewer.prototype.getUsePageRequest = function() {
  979. return this.m_viewerDispatcher.getUsePageRequest();
  980. };
  981. /**
  982. * If you don't want the viewer to release the current conversation on a page reload, use this method to keep the session alive
  983. * on page reloads
  984. * @param (boolean)
  985. */
  986. CCognosViewer.prototype.setKeepSessionAlive = function(bValue) {
  987. this.m_bKeepSessionAlive = bValue;
  988. };
  989. /**
  990. * Return the "Keep Session Alive" boolean value
  991. * @return (boolean)
  992. */
  993. CCognosViewer.prototype.getKeepSessionAlive = function() {
  994. return this.m_bKeepSessionAlive;
  995. };
  996. /**
  997. * Returns the web content root
  998. * @return (string)
  999. */
  1000. CCognosViewer.prototype.getWebContentRoot = function()
  1001. {
  1002. if (typeof this.sWebContentRoot != "undefined")
  1003. {
  1004. return this.sWebContentRoot;
  1005. }
  1006. else
  1007. {
  1008. return "..";
  1009. }
  1010. };
  1011. /**
  1012. * Returns the skin directory
  1013. * @return (string)
  1014. */
  1015. CCognosViewer.prototype.getSkin = function()
  1016. {
  1017. if (typeof this.sSkin != "undefined")
  1018. {
  1019. return this.sSkin;
  1020. }
  1021. else
  1022. {
  1023. return this.getWebContentRoot() + "/skins/corporate";
  1024. }
  1025. };
  1026. CCognosViewer.prototype.getSelectionController = function()
  1027. {
  1028. var selectionController;
  1029. try
  1030. {
  1031. selectionController = getCognosViewerSCObjectRef(this.m_sId);
  1032. }
  1033. catch(e)
  1034. {
  1035. selectionController = null;
  1036. }
  1037. return selectionController;
  1038. };
  1039. /**
  1040. Set up a function to call for events in CCognosViewer.
  1041. @param {string} sEventName Event names are:
  1042. <ul>
  1043. <li><code>done</code> (when a report page is returned)</li>
  1044. <li><code>error</code> (when an error code is returned)</li>
  1045. <li><code>prompt</code> (when an prompt page is returned)</li>
  1046. <li><code>wait</code> (when we get a ?working? and ?stillWorking? state)</li>
  1047. </ul>
  1048. @param {function} oFct Function to call when this even occurs.
  1049. @param {bool} bCaptureEvent If set to true, the normal behavior will not be used.
  1050. */
  1051. CCognosViewer.prototype.addCallback = function(sEventName, oFct, bCaptureEvent)
  1052. {
  1053. if (!this.m_aCallback)
  1054. {
  1055. this.m_aCallback = [];
  1056. }
  1057. this.m_aCallback = this.m_aCallback.concat({
  1058. m_sEvent: sEventName,
  1059. m_oCallback: oFct,
  1060. m_bCaptureEvent: (bCaptureEvent===true)
  1061. });
  1062. };
  1063. /**
  1064. Determines if the element supports drill down or not.
  1065. @param {string} sId Identifier or the HTML element with a ctxId attribute.
  1066. @return Default is <code>false</code>.
  1067. @type bool
  1068. */
  1069. CCognosViewer.prototype.canDrillDown = function(sId)
  1070. {
  1071. var sCtx = this.findCtx(sId).split("::")[0];
  1072. if (sCtx) {
  1073. var selectionController = this.getSelectionController();
  1074. if (selectionController) {
  1075. return (selectionController.canDrillDown(sCtx));
  1076. }
  1077. }
  1078. return false;
  1079. };
  1080. /**
  1081. Determines if the element supports drill up or not.
  1082. @param {string} sId Identifier or the HTML element with a ctxId attribute.
  1083. @return Default is <code>false</code>.
  1084. @type bool
  1085. */
  1086. CCognosViewer.prototype.canDrillUp = function(sId)
  1087. {
  1088. var sCtx = this.findCtx(sId).split("::")[0];
  1089. if (sCtx) {
  1090. var selectionController = this.getSelectionController();
  1091. if (selectionController) {
  1092. return (selectionController.canDrillUp(sCtx));
  1093. }
  1094. }
  1095. return false;
  1096. };
  1097. /**
  1098. Call this function to know if all required prompts have valid inputs.
  1099. */
  1100. CCognosViewer.prototype.canSubmitPrompt = function()
  1101. {
  1102. var oPromptElement = null;
  1103. if (this.preProcessControlArray && this.preProcessControlArray instanceof Array)
  1104. {
  1105. var kCount = this.preProcessControlArray.length;
  1106. for ( var k=0; k < kCount; k++ )
  1107. {
  1108. oPromptElement = eval( this.preProcessControlArray[k] );
  1109. if ( oPromptElement.isValid() === false )
  1110. {
  1111. // RTC 123130 : cascade children cannot block submit/refresh if m_reportRenderingDone.
  1112. if (!this.m_reportRenderingDone || !oPromptElement.getCascadeOnParameter || !oPromptElement.getCascadeOnParameter()) {
  1113. return false;
  1114. }
  1115. }
  1116. }
  1117. }
  1118. return true;
  1119. };
  1120. CCognosViewer.prototype.closeContextMenuAndToolbarMenus = function() {
  1121. if (this.rvMainWnd) {
  1122. this.rvMainWnd.closeContextMenuAndToolbarMenus();
  1123. }
  1124. };
  1125. /**
  1126. Context Menu Handler in Report Viewer.
  1127. dcm == Display Context Menu
  1128. @private
  1129. */
  1130. CCognosViewer.prototype.dcm = function(event, selectNode)
  1131. {
  1132. if (this.canDisplayContextMenu())
  1133. {
  1134. if (this.preSelectNode == true) {
  1135. selectNode = false;
  1136. this.preSelectNode = false;
  1137. }
  1138. if (this.rvMainWnd.displayContextMenu(event, selectNode) != false)
  1139. {
  1140. return stopEventBubble(event);
  1141. }
  1142. }
  1143. };
  1144. /**
  1145. * Determines if the viewer should show a context menu
  1146. * @private
  1147. */
  1148. CCognosViewer.prototype.canDisplayContextMenu = function()
  1149. {
  1150. if (!this.getUIConfig() || this.getUIConfig().getShowContextMenu()) {
  1151. return ( !this.isWorkingOrPrompting() && this.rvMainWnd != null && typeof this.bCanUseCognosViewerContextMenu != "undefined" && this.bCanUseCognosViewerContextMenu);
  1152. }
  1153. return false;
  1154. };
  1155. /**
  1156. Handler for drill actions in Report Viewer.
  1157. de == Drill Event
  1158. @private
  1159. */
  1160. CCognosViewer.prototype.de = function(event)
  1161. {
  1162. var oDrillMgr = this.getDrillMgr();
  1163. if (oDrillMgr)
  1164. {
  1165. oDrillMgr.singleClickDrillEvent(event, 'RV');
  1166. }
  1167. };
  1168. /**
  1169. @param {string} Message
  1170. @private
  1171. */
  1172. CCognosViewer.prototype.debug = function(sMsg)
  1173. {
  1174. if (this.m_bDebug)
  1175. {
  1176. var sCallee = "";
  1177. var oCaller = this.debug.caller;
  1178. if (typeof oCaller == "object" && oCaller !== null)
  1179. {
  1180. sCallee = oCaller.toString().match(/function (\w*)/)[1];
  1181. }
  1182. if (!sCallee)
  1183. {
  1184. sCallee = '?';
  1185. }
  1186. alert(sCallee + ": " + sMsg);
  1187. }
  1188. };
  1189. CCognosViewer.prototype.callbackExists = function(sEvent) {
  1190. var bEventWasCaptured = false;
  1191. if (this.m_aCallback && this.m_aCallback.length) {
  1192. for (var idxCallback = 0; idxCallback < this.m_aCallback.length; ++idxCallback) {
  1193. var oCB = this.m_aCallback[idxCallback];
  1194. if (oCB.m_sEvent == sEvent) {
  1195. return true;
  1196. }
  1197. }
  1198. }
  1199. return false;
  1200. };
  1201. /**
  1202. @param {string} sEvent Event name to call the callback functions for.
  1203. @type boolean
  1204. @return <i>true</i> if there was a callback associated with the event and that it's capture event was set to true. <i>false</i> otherwise.
  1205. @private
  1206. */
  1207. CCognosViewer.prototype.executeCallback = function(sEvent)
  1208. {
  1209. var bEventWasCaptured = false;
  1210. if (this.m_aCallback && this.m_aCallback.length)
  1211. {
  1212. for (var idxCallback = 0; idxCallback < this.m_aCallback.length; ++idxCallback)
  1213. {
  1214. var oCB = this.m_aCallback[idxCallback];
  1215. if (oCB.m_sEvent == sEvent)
  1216. {
  1217. if (typeof oCB.m_oCallback == "function")
  1218. {
  1219. oCB.m_oCallback();
  1220. }
  1221. if (oCB.m_bCaptureEvent)
  1222. {
  1223. bEventWasCaptured = true;
  1224. }
  1225. }
  1226. }
  1227. }
  1228. return bEventWasCaptured;
  1229. };
  1230. /**
  1231. CAF context information.
  1232. @return CAF encoded string.
  1233. @type string
  1234. */
  1235. CCognosViewer.prototype.getCAFContext = function()
  1236. {
  1237. return this.m_sCAFContext;
  1238. };
  1239. /**
  1240. Get the fault
  1241. @return string
  1242. */
  1243. CCognosViewer.prototype.getSoapFault = function()
  1244. {
  1245. return this.m_sSoapFault;
  1246. };
  1247. /**
  1248. Returns the identifiers of the columns related to an element.
  1249. @param {string} sId Identifier or the HTML element with a ctxId attribute.
  1250. @return array of identifiers of the columns making up this element.
  1251. @type string[]
  1252. */
  1253. CCognosViewer.prototype.getColumnContextIds = function(sId)
  1254. {
  1255. return this.getContextIds(sId, 2);
  1256. };
  1257. /**
  1258. Conversation info (encoded string).
  1259. @return CAF encoded string.
  1260. @type string
  1261. */
  1262. CCognosViewer.prototype.getConversation = function()
  1263. {
  1264. return this.m_sConversation;
  1265. };
  1266. /**
  1267. * Status of the ongoing report server conversation
  1268. * @return conversation status
  1269. * @type string
  1270. */
  1271. CCognosViewer.prototype.getStatus = function()
  1272. {
  1273. return (this.m_sStatus ? this.m_sStatus : "");
  1274. };
  1275. /**
  1276. * Checks if current status is a working state
  1277. * @param {string} sState? Optional parameter. If not a string, the current state of CCognosViewer will be used.
  1278. * @return true/false
  1279. * @type boolean
  1280. */
  1281. CCognosViewer.prototype.isWorking = function(sState)
  1282. {
  1283. if (typeof sState != "string") {
  1284. sState = this.getStatus();
  1285. }
  1286. return ((""+sState).match(/^(working|stillWorking)$/) ? true : false);
  1287. };
  1288. /**
  1289. * Checks if current status is a working or prompting state
  1290. * @return true/false
  1291. * @type boolean
  1292. */
  1293. CCognosViewer.prototype.isWorkingOrPrompting = function()
  1294. {
  1295. return (this.getStatus().match(/^(working|stillWorking|prompting)$/) ? true : false);
  1296. };
  1297. /**
  1298. * Returns the action state. This value will only be set if the action is in a interupted state (wait/prompting)
  1299. * @return action state
  1300. * @type string
  1301. */
  1302. CCognosViewer.prototype.getActionState = function()
  1303. {
  1304. return this.m_sActionState;
  1305. };
  1306. /**
  1307. Get the name of the ref data item associated with the element.
  1308. @param {string} sId Identifier or the HTML element with a ctxId attribute.
  1309. @return Name of the ref data item associated with the element. Returns <code>null</code> if there is not any.
  1310. @type string
  1311. @deprecated Use CCognosViewer.getReportContextHelper().getDataItemName() instead
  1312. */
  1313. CCognosViewer.prototype.getDataItemName = function(sId)
  1314. {
  1315. var sName = null;
  1316. var sCtx = this.findCtx(sId).split("::")[0];
  1317. if (sCtx) {
  1318. var selectionController = this.getSelectionController();
  1319. if (selectionController) {
  1320. var aName = selectionController.getRefDataItem(sCtx);
  1321. if (aName) {
  1322. sName = aName;
  1323. }
  1324. }
  1325. }
  1326. return sName;
  1327. };
  1328. /**
  1329. Get the Name of the data type associated with the element.
  1330. @param {string} sId Identifier or the HTML element with a ctxId attribute.
  1331. @return Name of the data type associated with the element. Returns <code>null</code> if there is not any.
  1332. @type int
  1333. */
  1334. CCognosViewer.prototype.getDataType = function(sId)
  1335. {
  1336. var sType = null;
  1337. var sCtx = this.findCtx(sId).split("::")[0];
  1338. if (sCtx) {
  1339. var selectionController = this.getSelectionController();
  1340. if (selectionController) {
  1341. var aType = selectionController.getDataType(sCtx);
  1342. if (aType) {
  1343. sType = aType;
  1344. }
  1345. }
  1346. }
  1347. return sType;
  1348. };
  1349. /**
  1350. Returns the level associated with the element.
  1351. @param {string} sId Identifier or the HTML element with a ctxId attribute.
  1352. @return Depth (relative to the hierarchy) of the element. Returns <code>null</code> if there is not any.
  1353. @type integer
  1354. */
  1355. CCognosViewer.prototype.getDepth = function(sId)
  1356. {
  1357. var sLevel = null;
  1358. var sCtx = this.findCtx(sId).split("::")[0];
  1359. if (sCtx) {
  1360. var selectionController = this.getSelectionController();
  1361. if (selectionController) {
  1362. var aLevel = selectionController.getDepth(sCtx);
  1363. if (aLevel) {
  1364. sLevel = aLevel;
  1365. }
  1366. }
  1367. }
  1368. return sLevel;
  1369. };
  1370. /**
  1371. @return CAF encoded string.
  1372. @type string
  1373. @private
  1374. */
  1375. CCognosViewer.prototype.getDrillMgr = function()
  1376. {
  1377. if (!this.m_oDrillMgr) {
  1378. this.loadExtra();
  1379. if (typeof CDrillManager == "function") {
  1380. this.m_oDrillMgr = new CDrillManager(this);
  1381. this.goDrillManager = this.m_oDrillMgr;
  1382. }
  1383. }
  1384. return this.m_oDrillMgr;
  1385. };
  1386. /**
  1387. @return the subscription handler.
  1388. @type object
  1389. @private
  1390. */
  1391. CCognosViewer.prototype.getSubscriptionManager = function()
  1392. {
  1393. if (!this.m_oSubscriptionManager) {
  1394. this.loadExtra();
  1395. if (typeof CSubscriptionManager == "function") {
  1396. this.m_oSubscriptionManager = new CSubscriptionManager(this);
  1397. }
  1398. }
  1399. return this.m_oSubscriptionManager;
  1400. };
  1401. /**
  1402. Do a reprompt with the updated global parameters.
  1403. The UI should not be updated if the forward request does not return any output pages.
  1404. @return CAF encoded string.
  1405. @type string
  1406. */
  1407. CCognosViewer.prototype.updateGlobalParameters = function (globalParametersDelta) {
  1408. var oReq = new ViewerDispatcherEntry(this);
  1409. oReq.addFormField("ui.action", "forward");
  1410. oReq.addFormField("generic.anyURI.runOptionEnum#globalParameters", globalParametersDelta);
  1411. oReq.addFormField("run.prompt", true);
  1412. oReq.addFormField("_promptControl", "reprompt");
  1413. this.submitPromptValues(oReq);
  1414. //TODO what if forward returns nothing
  1415. };
  1416. /**
  1417. Execution Parameters (encoded string).
  1418. @return CAF encoded string.
  1419. @type string
  1420. */
  1421. CCognosViewer.prototype.getExecutionParameters = function()
  1422. {
  1423. return this.m_sParameters;
  1424. };
  1425. /**
  1426. @private
  1427. @return Gateway path.
  1428. @type string
  1429. */
  1430. CCognosViewer.prototype.getGateway = function()
  1431. {
  1432. return this.m_sGateway;
  1433. };
  1434. /**
  1435. @public
  1436. @return current specification
  1437. @type string
  1438. */
  1439. CCognosViewer.prototype.getSpecification = function()
  1440. {
  1441. return this.envParams["ui.spec"];
  1442. };
  1443. /**
  1444. Returns the Hierarchy Unique Name (HUN) associated to an element.
  1445. @param {string} sId Identifier or the HTML element with a ctxId attribute.
  1446. @return Name (HUN) of the hierarchy associated with the element. Returns <code>null</code> if there is not any.
  1447. @type string
  1448. */
  1449. CCognosViewer.prototype.getHierarchyUniqueName = function(sId)
  1450. {
  1451. var sHun = null;
  1452. var sCtx = this.findCtx(sId).split("::")[0];
  1453. if (sCtx) {
  1454. var selectionController = this.getSelectionController();
  1455. if (selectionController) {
  1456. var aHUN = selectionController.getHun(sCtx);
  1457. if (aHUN) {
  1458. sHun = aHUN;
  1459. }
  1460. }
  1461. }
  1462. return sHun;
  1463. };
  1464. /**
  1465. Returns the Dimension Unique Name (DUN) associated to an element.
  1466. @param {string} sId Identifier or the HTML element with a ctxId attribute.
  1467. @return Name (DUN) of the dimension associated with the element. Returns <code>null</code> if there is not any.
  1468. @type string
  1469. */
  1470. CCognosViewer.prototype.getDimensionUniqueName = function(sId)
  1471. {
  1472. var sCtx = this.findCtx(sId).split("::")[0];
  1473. if (sCtx) {
  1474. var selectionController = this.getSelectionController();
  1475. if (selectionController) {
  1476. var aDUN = selectionController.getDun(sCtx);
  1477. if (aDUN) {
  1478. return aDUN;
  1479. }
  1480. }
  1481. }
  1482. return null;
  1483. };
  1484. /**
  1485. @private
  1486. @return Id Identifier for this instance of CCognosViewer.
  1487. @type string
  1488. */
  1489. CCognosViewer.prototype.getId = function()
  1490. {
  1491. return this.m_sId;
  1492. };
  1493. /**
  1494. Returns the Level Id (LUN) associated to an element.
  1495. @param {string} sId Identifier or the HTML element with a ctxId attribute.
  1496. @return Identifier for the level associated with the element. Returns <code>null</code> if there is not any.
  1497. @type string
  1498. */
  1499. CCognosViewer.prototype.getLevelId = function(sId)
  1500. {
  1501. var sLevel = null;
  1502. var sCtx = this.findCtx(sId).split("::")[0];
  1503. if (sCtx) {
  1504. var selectionController = this.getSelectionController();
  1505. if (selectionController) {
  1506. var aLUN = selectionController.getLun(sCtx);
  1507. if (aLUN) {
  1508. sLevel = aLUN;
  1509. }
  1510. }
  1511. }
  1512. return sLevel;
  1513. };
  1514. /**
  1515. Returns the Member Unique Name (MUN) associated to an element.
  1516. @param {string} sId Identifier or the HTML element with a ctxId attribute.
  1517. @return Name (MUN) of the member associated with the element. Returns <code>null</code> if there is not any.
  1518. @type string
  1519. @deprecated Use CCognosViewer.getReportContextHelper().getMun() instead
  1520. */
  1521. CCognosViewer.prototype.getMemberUniqueName = function(sId)
  1522. {
  1523. var sMUN = null;
  1524. var sCtx = this.findCtx(sId).split("::")[0];
  1525. if (sCtx) {
  1526. var selectionController = this.getSelectionController();
  1527. if (selectionController) {
  1528. var aMUN = selectionController.getMun(sCtx);
  1529. if (aMUN) {
  1530. sMUN = aMUN;
  1531. }
  1532. }
  1533. }
  1534. return sMUN;
  1535. };
  1536. /**
  1537. This function return the name of the javascript reference (variable) to this object. The default is "window" if the id is invalid.
  1538. @private
  1539. @return Id Identifier for this instance of CCognosViewer.
  1540. @type string
  1541. */
  1542. CCognosViewer.prototype.getObjectId = function()
  1543. {
  1544. var sObjId = "window";
  1545. if (typeof this.getId() == "string") {
  1546. sObjId = getCognosViewerObjectRefAsString(this.getId());
  1547. }
  1548. return sObjId;
  1549. };
  1550. /**
  1551. Returns the Query Id associated to an element.
  1552. @param {string} sId Identifier or the HTML element with a ctxId attribute.
  1553. @return Model id associated with the element. Returns <code>null</code> if there is not any.
  1554. @type string
  1555. */
  1556. CCognosViewer.prototype.getQueryModelId = function(sId)
  1557. {
  1558. var sQuery = null;
  1559. var sCtx = this.findCtx(sId).split("::")[0];
  1560. if (sCtx) {
  1561. var selectionController = this.getSelectionController();
  1562. if (selectionController) {
  1563. var aQMID = selectionController.getQueryModelId(sCtx);
  1564. if (aQMID) {
  1565. sQuery = aQMID;
  1566. }
  1567. }
  1568. }
  1569. return sQuery;
  1570. };
  1571. /**
  1572. Returns the Query name associated to an element.
  1573. @param {string} sId Identifier or the HTML element with a ctxId attribute.
  1574. @return Query name associated with the element. Returns <code>null</code> if there is not any.
  1575. @type string
  1576. */
  1577. CCognosViewer.prototype.getQueryName = function(sId)
  1578. {
  1579. var sQuery = null;
  1580. var sCtx = this.findCtx(sId).split("::")[0];
  1581. if (sCtx) {
  1582. var selectionController = this.getSelectionController();
  1583. if (selectionController) {
  1584. var aQuery = selectionController.getRefQuery(sCtx);
  1585. if (aQuery) {
  1586. sQuery = aQuery;
  1587. }
  1588. }
  1589. }
  1590. return sQuery;
  1591. };
  1592. CCognosViewer.prototype.getContextIds = function(sId, index)
  1593. {
  1594. var aIds = [];
  1595. var sCtx = this.findCtx(sId);
  1596. if (sCtx)
  1597. {
  1598. var aIDparts = sCtx.split("::");
  1599. if (aIDparts && aIDparts.length > 1 && index < aIDparts.length)
  1600. {
  1601. aIds = aIDparts[index].split(":");
  1602. }
  1603. }
  1604. return aIds;
  1605. };
  1606. /**
  1607. Returns the identifiers of the rows related to an element.
  1608. @param {string} sId Identifier or the HTML element with a ctxId attribute.
  1609. @return array of identifiers of the rows making up this element.
  1610. @type string[]
  1611. */
  1612. CCognosViewer.prototype.getRowContextIds = function(sId)
  1613. {
  1614. return this.getContextIds(sId, 1);
  1615. };
  1616. /**
  1617. Returns the identifiers of the page related to an element.
  1618. @param {string} sId Identifier or the HTML element with a ctxId attribute.
  1619. @return array of identifiers of the rows making up this element.
  1620. @type string[]
  1621. */
  1622. CCognosViewer.prototype.getPageContextIds = function(sId)
  1623. {
  1624. return this.getContextIds(sId, 3);
  1625. };
  1626. /**
  1627. @private
  1628. @param {string} sKey the key of the string
  1629. @type string
  1630. @return The localized string matching the key. Returns the key if it there is not string associated.
  1631. */
  1632. CCognosViewer.prototype.getString = function(sKey)
  1633. {
  1634. if (RV_RES && RV_RES[sKey]) {
  1635. return RV_RES[sKey];
  1636. }
  1637. return sKey;
  1638. };
  1639. /**
  1640. @private
  1641. @type CViewerManager
  1642. @return A CViewerManager instance or a "window" object if the former do not exists.
  1643. */
  1644. CCognosViewer.prototype.getRV = function()
  1645. {
  1646. if (typeof this.m_oCVMgr == "object")
  1647. {
  1648. return this.m_oCVMgr;
  1649. }
  1650. return window;
  1651. };
  1652. /**
  1653. @private
  1654. @type array
  1655. @return available secondary requests
  1656. */
  1657. CCognosViewer.prototype.getSecondaryRequests = function()
  1658. {
  1659. return this.m_aSecRequests;
  1660. };
  1661. /**
  1662. Tracking info (encoded string).
  1663. @type string
  1664. @return CAF encoded string.
  1665. */
  1666. CCognosViewer.prototype.getTracking = function()
  1667. {
  1668. return this.m_sTracking;
  1669. };
  1670. /**
  1671. @private
  1672. @type string
  1673. @param {string} sId Identifier or a HTML element
  1674. @return Returns an empty string if not found.
  1675. */
  1676. CCognosViewer.prototype.findCtx = function(sId)
  1677. {
  1678. var sCtx = "";
  1679. if (typeof sId == "string")
  1680. {
  1681. // return sId if it matches something in the context data
  1682. var aCtx = this.getReportContextHelper().processCtx(sId);
  1683. var sRefDataItem = aCtx[0][0];
  1684. var selectionController = this.getSelectionController();
  1685. if (selectionController) {
  1686. if (selectionController.isContextId(sRefDataItem))
  1687. {
  1688. sCtx = sId;
  1689. }
  1690. }
  1691. }
  1692. if (!sCtx)
  1693. {
  1694. var oHTMLElement = this.findElementWithCtx(sId);
  1695. if (oHTMLElement)
  1696. {
  1697. sCtx = oHTMLElement.getAttribute("ctx");
  1698. }
  1699. }
  1700. return sCtx;
  1701. };
  1702. /**
  1703. @private
  1704. @type HTMLelement
  1705. @param {string} sId Identifier or a HTML element
  1706. @return Returns a HTML element with a <i>ctx</i> attribute. Processed recursively on the children. Returns <code>null</node> if there is not any.
  1707. */
  1708. CCognosViewer.prototype.findElementWithCtx = function(sId)
  1709. {
  1710. var oElement = sId;
  1711. if (typeof sId == "string") {
  1712. oElement = this.findElementWithCtx(document.getElementById(sId));
  1713. }
  1714. if (oElement)
  1715. {
  1716. if (oElement.getAttribute && oElement.getAttribute("ctx"))
  1717. {
  1718. return oElement;
  1719. }
  1720. for (var idxChild = 0; idxChild < oElement.childNodes.length; idxChild++)
  1721. {
  1722. var oChild = this.findElementWithCtx(oElement.childNodes[idxChild]);
  1723. if (oChild) {
  1724. return oChild;
  1725. }
  1726. }
  1727. }
  1728. return null;
  1729. };
  1730. /**
  1731. Returns the use value associated to an element.
  1732. @type string
  1733. @param {string} sId Identifier or the HTML element with a ctxId attribute.
  1734. @return Use value associated with the element. Returns <code>null</code> if there is not any.
  1735. */
  1736. CCognosViewer.prototype.getUseValue = function(sId)
  1737. {
  1738. var sVal = null;
  1739. var sCtx = this.findCtx(sId).split("::")[0];
  1740. if (sCtx) {
  1741. var selectionController = this.getSelectionController();
  1742. if (selectionController) {
  1743. sVal = selectionController.getUseValue(sCtx);
  1744. }
  1745. }
  1746. return sVal;
  1747. };
  1748. /**
  1749. @private
  1750. @param {object} oProp Properties to add to this instance of CCognosViewer, like flags and strings.
  1751. */
  1752. CCognosViewer.prototype.init = function(oProperties)
  1753. {
  1754. if (oProperties && typeof oProperties == "object")
  1755. {
  1756. for (var sProp in oProperties)
  1757. {
  1758. this[sProp] = oProperties[sProp];
  1759. }
  1760. }
  1761. };
  1762. /**
  1763. * @private
  1764. * Method that should only be called when the user hits the back button in the browser
  1765. */
  1766. CCognosViewer.prototype.initViewer = function(originalState) {
  1767. var requestHandler = new RequestHandler(this);
  1768. var backJaxForm = document.getElementById('formBackJax' + this.getId());
  1769. if (backJaxForm && typeof backJaxForm.state != "undefined" && backJaxForm.state.value.length > 0) {
  1770. requestHandler.loadReportHTML(backJaxForm.result.value);
  1771. var oState = eval("(" + backJaxForm.state.value + ")");
  1772. requestHandler.updateViewerState(oState);
  1773. requestHandler.postComplete();
  1774. }
  1775. else {
  1776. // If ajax is off and the status is working, save the fact that we've visited
  1777. // this page so we know we've done the wait request. If we get called again
  1778. // (browser back button) then simply keep going back in the browser history
  1779. // since we don't want to execute the wait again or it'll cause an asynch error.
  1780. if (this.getUsePageRequest()) {
  1781. var status = originalState ? originalState.m_sStatus : null;
  1782. // For some reason the form field trick does not work in IE, instead
  1783. // we can use the hash to know if the user hit the back button. Note the
  1784. // hash trick doesn't work in Chrome, so the other browsers
  1785. // will use the form field trick
  1786. if (isIE()) {
  1787. if (window.location.hash == '#working') {
  1788. window.history.go(-2);
  1789. return;
  1790. }
  1791. else if (status === "working" || status === "stillWorking") {
  1792. window.location.hash = "#working";
  1793. }
  1794. }
  1795. else if (backJaxForm && backJaxForm.working){
  1796. if (backJaxForm.working.value == "true") {
  1797. window.history.go(-1);
  1798. return;
  1799. }
  1800. else if (status === "working" || status === "stillWorking") {
  1801. backJaxForm.working.value = "true";
  1802. }
  1803. }
  1804. }
  1805. requestHandler.processInitialResponse(originalState);
  1806. }
  1807. };
  1808. /**
  1809. * @private
  1810. * @Saves the responseXML for a completed request
  1811. */
  1812. CCognosViewer.prototype.saveBackJaxInformation = function(dataResponse) {
  1813. var backJaxForm = document.getElementById('formBackJax' + this.getId());
  1814. if (backJaxForm) {
  1815. if (typeof backJaxForm.state != "undefined") {
  1816. backJaxForm.state.value = dataResponse.getResponseStateText();
  1817. }
  1818. if (typeof backJaxForm.result != "undefined") {
  1819. backJaxForm.result.value = dataResponse.getResult();
  1820. }
  1821. }
  1822. };
  1823. /**
  1824. Pre-selects a node prior handling of the context menu.
  1825. pcc == Page Context Clicked
  1826. @private
  1827. */
  1828. CCognosViewer.prototype.pcc = function(evt)
  1829. {
  1830. // we only want to preselect the node if the right mouse button was clicked.
  1831. if (evt && typeof evt.button != "undefined" && evt.button != "1")
  1832. {
  1833. this.preSelectNode = true;
  1834. var selectionController = this.getSelectionController();
  1835. if(selectionController) {
  1836. selectionController.pageContextClicked(evt);
  1837. }
  1838. }
  1839. };
  1840. /**
  1841. * @private
  1842. * @param {XMLHTTP response} oResponse
  1843. */
  1844. CCognosViewer.prototype.isValidAjaxResponse = function(responseXML)
  1845. {
  1846. return (responseXML && responseXML.childNodes && responseXML.childNodes.length > 0 && responseXML.childNodes[0].nodeName != "parsererror" ? true : false);
  1847. };
  1848. /**
  1849. * @private
  1850. */
  1851. CCognosViewer.prototype.resubmitInSafeMode = function(dispatcherEntry)
  1852. {
  1853. //re-submit the request in "page" mode. We'll need to inform the user we're doing this (Post beta)
  1854. if (this.m_bUseSafeMode) {
  1855. this.resetViewerDispatcher();
  1856. this.setUsePageRequest(true);
  1857. this.envParams["cv.useAjax"] = "false";
  1858. if (dispatcherEntry) {
  1859. dispatcherEntry.retryRequest();
  1860. }
  1861. }
  1862. };
  1863. /**
  1864. *
  1865. */
  1866. CCognosViewer.prototype.showLoadedContent = function(oRVContent)
  1867. {
  1868. if (oRVContent !== null && typeof oRVContent != "undefined") {
  1869. oRVContent.style.display = "block";
  1870. }
  1871. this.m_resizeReady = true;
  1872. this.doneLoading();
  1873. var obj = this;
  1874. setTimeout(function() { obj.renderTabs(); }, 1);
  1875. };
  1876. /**
  1877. * Called once the HTML and scripts have been loaded and processResponseState is finished.
  1878. * Will resize the widget and take care of any accessibility stuff needed (focus, JAWS, ...)
  1879. */
  1880. CCognosViewer.prototype.doneLoading = function()
  1881. {
  1882. var viewerIWidget = this.getViewerWidget();
  1883. if (viewerIWidget) {
  1884. if (window.IBM&&window.IBM.perf){window.IBM.perf.log("viewer_doneLoading", this);}
  1885. var status = this.getStatus();
  1886. if (!this.m_reportRenderingDone && this.m_resizeReady && this.m_stateSet) {
  1887. var noAutoResize = status == "working" || status == "stillWorking" || status == "fault";
  1888. viewerIWidget.fireEvent("com.ibm.bux.widget.render.done", null, {noAutoResize:noAutoResize});
  1889. if (status == "complete") {
  1890. if (window.IBM&&window.IBM.perf){window.IBM.perf.log("viewer_doneLoading", this);}
  1891. if (typeof viewerIWidget.postLoadContent == 'function') {
  1892. viewerIWidget.postLoadContent();
  1893. }
  1894. this.m_reportRenderingDone = true;
  1895. if (!noAutoResize) {
  1896. var thisObj = this;
  1897. //need a delay because bux widget delays the resize operation.
  1898. setTimeout(function() { thisObj.m_readyToRespondToResizeEvent = true; }, 20);
  1899. }
  1900. }
  1901. }
  1902. if (status != "fault") {
  1903. viewerIWidget.clearErrorDlg();
  1904. }
  1905. this.doneLoadingUpdateA11Y(status);
  1906. }
  1907. else {
  1908. var status = this.getStatus();
  1909. if (status == "complete") {
  1910. this.m_reportRenderingDone = true;
  1911. this.JAWSTalk(RV_RES.IDS_JS_READY);
  1912. }
  1913. else if (status == "working") {
  1914. this.JAWSTalk(RV_RES.IDS_JS_WAIT_PAGE_LOADING);
  1915. }
  1916. }
  1917. };
  1918. CCognosViewer.prototype.doneLoadingUpdateA11Y = function(status) {
  1919. // if we're refreshing the report because of a modify report request, set the focus
  1920. // to the first table in the report
  1921. if (this.getKeepFocus() !== false && this.getKeepFocus() != null) {
  1922. var keepFocus = this.getKeepFocus();
  1923. if (status == "complete") {
  1924. this.setKeepFocus(false);
  1925. }
  1926. var focusOn = null;
  1927. if (this.getVisibleDialog() !== null) {
  1928. focusOn = this.getVisibleDialog().getDialogDiv();
  1929. } else if (keepFocus === true) {
  1930. focusOn = document.getElementById("CVReport" + this.getId());
  1931. } else if (typeof keepFocus == "string") {
  1932. focusOn = document.getElementById(keepFocus);
  1933. } else if (keepFocus !== null) {
  1934. focusOn = keepFocus;
  1935. if (this.isBux) {
  1936. dojo.window.scrollIntoView(focusOn);
  1937. }
  1938. }
  1939. if (focusOn) {
  1940. setFocusToFirstTabItem(focusOn);
  1941. }
  1942. if (status == "complete") {
  1943. this.JAWSTalk(RV_RES.IDS_JS_READY);
  1944. } else if (status == "working" || status == "stillWorking") {
  1945. this.JAWSTalk(RV_RES.IDS_JS_WAIT_PAGE_LOADING);
  1946. }
  1947. }
  1948. };
  1949. /**
  1950. * Creates a div with a role of alert so that JAWS speaks the content of the div
  1951. * @param {Object} sString
  1952. */
  1953. CCognosViewer.prototype.JAWSTalk = function(sString) {
  1954. // This doesn't work with voice over
  1955. if (this.isMobile() || this.isIWidgetMobile()) {
  1956. return;
  1957. }
  1958. var id = this.getId();
  1959. var div = document.getElementById("JAWS_Alert_" + id);
  1960. if (div) {
  1961. div.parentNode.removeChild(div);
  1962. }
  1963. div = document.createElement("div");
  1964. div.id = "JAWS_Alert_" + id;
  1965. div.style.position = "absolute";
  1966. div.style.top = "-9000px";
  1967. div.style.display = "none";
  1968. div.setAttribute("role", "alert");
  1969. div.appendChild(document.createTextNode(sString));
  1970. var content = document.getElementById("RVContent" + id);
  1971. if (content) {
  1972. content.appendChild(div);
  1973. } else if (typeof console != "undefined" && console && console.log) {
  1974. console.log("CCognosViewer: Could not find the Viewer div to append the JAWS alert.");
  1975. }
  1976. };
  1977. /**
  1978. * insert icons if
  1979. * a. server is set to true, and widget is set to true
  1980. * b. server is set to true, and widget is undefined.
  1981. * c. server is set to false, and widget is set to true
  1982. */
  1983. CCognosViewer.prototype.canInsertExpandIconsForAllCrosstabs = function()
  1984. {
  1985. if( this.isLimitedInteractiveMode() || this.isBlacklisted("ExpandMember") || this.isIWidgetMobile() ) {
  1986. return false;
  1987. }
  1988. var bServerSetting = this.getAdvancedServerProperty("VIEWER_JS_EXPAND_COLLAPSE_CONTROLS_DEFAULT");
  1989. if( bServerSetting === null ){
  1990. return false;
  1991. }
  1992. var bWidgetSetting = this.getViewerWidget().getProperties().getShowExpandCollapseIconFlag();
  1993. return ( bServerSetting.toLowerCase() === 'on' && bWidgetSetting !== false )
  1994. || ( bServerSetting.toLowerCase() === 'off' && bWidgetSetting === true );
  1995. };
  1996. /**
  1997. * Needed for IE10 to make sure we don't have any extra scrollbars
  1998. */
  1999. CCognosViewer.prototype.setMaxContentSize = function() {
  2000. if ("10" != window.getIEVersion()) {
  2001. return;
  2002. }
  2003. if (document.body.className === "viewer") {
  2004. var height = document.body.offsetHeight;
  2005. var nonReportHeight = this.getNonReportHeight(document.getElementById("CVReport" + this.getId()));
  2006. var viewerTable = document.getElementById("mainViewerTable" + this.getId());
  2007. viewerTable.style.maxHeight = height - nonReportHeight - 2 + "px";
  2008. var callback = GUtil.generateCallback(this.setMaxContentSize,[true], this);
  2009. if (!this.attachedOnResize) {
  2010. this.attachedOnResize = true;
  2011. if (window.attachEvent) {
  2012. window.attachEvent("onresize", callback);
  2013. }
  2014. else if (window.addEventListener) {
  2015. window.addEventListener("resize", callback, false);
  2016. }
  2017. }
  2018. }
  2019. };
  2020. CCognosViewer.prototype.getNonReportHeight = function(node) {
  2021. var restOfPageHeight = 0;
  2022. var parentNode = node.parentNode;
  2023. if (!parentNode) {
  2024. return restOfPageHeight;
  2025. }
  2026. if (parentNode.childNodes.length > 1) {
  2027. for (var i=0; i < parentNode.childNodes.length; i++) {
  2028. var childNode = parentNode.childNodes[i];
  2029. if (childNode != node && !isNaN(childNode.clientHeight) && childNode.style.display != "none") {
  2030. restOfPageHeight += childNode.clientHeight;
  2031. }
  2032. }
  2033. }
  2034. // Keep going until we reach the main Viewer table
  2035. if (node.getAttribute("id") != ("mainViewerTable" + this.m_viewerId)) {
  2036. restOfPageHeight += this.getNonReportHeight(parentNode);
  2037. }
  2038. return restOfPageHeight;
  2039. };
  2040. CCognosViewer.prototype.addPageAdornments = function()
  2041. {
  2042. this.m_layoutElements = null;
  2043. this.m_lidToElement = null;
  2044. this.initFlashCharts();
  2045. this.insertSortIconsForAllLists();
  2046. var widgetProperties = this.getViewerWidget().getProperties();
  2047. if(this.canInsertExpandIconsForAllCrosstabs() ) {
  2048. this.insertExpandIconsForAllCrosstabs();
  2049. }
  2050. var oReportDiv = document.getElementById("CVReport" + this.getId());
  2051. if (oReportDiv) {
  2052. var oCV = this;
  2053. // We need to pin the containers in a setTimeout to get around a timing issue in IE where
  2054. // the UI wasn't rendered and we were trying to freeze. We also have the addInfoBar in the setTimeout
  2055. // since it needs to be done AFTER the pin is applied
  2056. setTimeout(function() {
  2057. if (oCV.getPinFreezeManager() && oCV.getPinFreezeManager().hasFrozenContainers()) {
  2058. oCV.getPinFreezeManager().renderReportWithFrozenContainers(oReportDiv);
  2059. }
  2060. oCV.addInfoBar();
  2061. }, 1);
  2062. }
  2063. this.getViewerWidget().reselectSelectionFilterObjects();
  2064. this.getViewerWidget().addChromeWhitespaceHandler(this.getId());
  2065. };
  2066. CCognosViewer.prototype.addFlashChart = function(refId)
  2067. {
  2068. this.m_flashChartsObjectIds.push(refId);
  2069. };
  2070. CCognosViewer.prototype.flashChartError = function(parameters) {
  2071. // turn off animations, and refresh the report
  2072. var cvWidget = this.getViewerWidget();
  2073. var properties = cvWidget.getProperties();
  2074. properties.setProperty("flashCharts", false);
  2075. var redrawAction = this.getAction("Redraw");
  2076. redrawAction.isUndoable = function() { return false; };
  2077. redrawAction.execute();
  2078. };
  2079. CCognosViewer.prototype.initFlashCharts = function()
  2080. {
  2081. var viewerIWidget = this.getViewerWidget();
  2082. if(this.m_flashChartsObjectIds.length > 0)
  2083. {
  2084. var reportTable = document.getElementById("rt" + this.getId());
  2085. if (window.addEventListener) {
  2086. reportTable.addEventListener("mousedown", onFlashChartRightClick, true);
  2087. }
  2088. else {
  2089. var objectIds = {};
  2090. var onmouseup = function() {
  2091. this.releaseCapture();
  2092. };
  2093. var onmousedown = function() {
  2094. onFlashChartRightClick(event);
  2095. this.setCapture();
  2096. };
  2097. for (var i = 0; i < this.m_flashChartsObjectIds.length; ++i) {
  2098. var objectId = this.m_flashChartsObjectIds[i];
  2099. var flashObject = document.getElementById(objectId);
  2100. objectIds[objectId] = 1;
  2101. flashObject.parentNode.onmouseup = onmouseup;
  2102. flashObject.parentNode.onmousedown = onmousedown;
  2103. }
  2104. if (this.m_flashChartsObjectIds.length > 0) {
  2105. reportTable.attachEvent("oncontextmenu", function(){
  2106. if (objectIds[window.event.srcElement.id]) {
  2107. return false;
  2108. }
  2109. });
  2110. }
  2111. }
  2112. if (viewerIWidget) {
  2113. viewerIWidget.fireEvent("com.ibm.bux.widget.setShowBordersWhenInnactive", null, true);
  2114. }
  2115. } else {
  2116. if (viewerIWidget) {
  2117. viewerIWidget.fireEvent("com.ibm.bux.widget.setShowBordersWhenInnactive", null, false);
  2118. }
  2119. }
  2120. };
  2121. CCognosViewer.prototype.initializeLayoutElements = function() {
  2122. var reportTable = document.getElementById("rt" + this.getId());
  2123. var layoutElements = getElementsByAttribute(reportTable, "*", "lid");
  2124. this.m_lidToElement = {};
  2125. this.m_layoutElements=[];
  2126. var elementIdx = 0;
  2127. var pfManager = this.getPinFreezeManager();
  2128. for(var i = 0; i < layoutElements.length; i++) {
  2129. var e = layoutElements[i];
  2130. if (!pfManager || !pfManager.getContainerElement(e) || pfManager.isElementInMainOutput(e)) {
  2131. this.m_layoutElements[elementIdx]=e;
  2132. this.m_lidToElement[e.getAttribute("lid")] = e;
  2133. elementIdx++;
  2134. }
  2135. }
  2136. };
  2137. CCognosViewer.prototype.getLayoutElement = function(iLayoutIndex) {
  2138. if (!this.m_layoutElements) {
  2139. this.initializeLayoutElements();
  2140. }
  2141. if (this.m_layoutElements) {
  2142. return this.m_layoutElements[iLayoutIndex];
  2143. }
  2144. return null;
  2145. };
  2146. CCognosViewer.prototype.getLayoutElementFromLid = function(lid) {
  2147. if(!this.m_lidToElement) {
  2148. this.initializeLayoutElements();
  2149. }
  2150. return this.m_lidToElement[lid];
  2151. };
  2152. CCognosViewer.prototype.getInfoBars = function() {
  2153. return this.m_aInfoBar ? this.m_aInfoBar : null;
  2154. };
  2155. CCognosViewer.prototype.addInfoBar = function()
  2156. {
  2157. if (this.getAdvancedServerProperty("VIEWER_JS_HIDE_INFO_BAR") === "true") {
  2158. return;
  2159. }
  2160. var oRAPReportInfo = this.getRAPReportInfo();
  2161. if(oRAPReportInfo)
  2162. {
  2163. var reportTable = document.getElementById("rt" + this.getId());
  2164. this.initializeLayoutElements();
  2165. var aInfoBarIDs = [];
  2166. this.m_aInfoBar = [];
  2167. for(var layoutElementIdx = 0; layoutElementIdx < this.m_layoutElements.length; ++layoutElementIdx)
  2168. {
  2169. var layoutElement = this.m_layoutElements[layoutElementIdx];
  2170. var lid = layoutElement.getAttribute("lid");
  2171. if (lid) {
  2172. //the layout element with its lid attribute having RAP_ prefix is added by RAP for no data handler.
  2173. if (lid.indexOf("RAP_NDH_") > -1) {
  2174. lid = lid.substring(8);
  2175. }
  2176. // need to strip off the Viewer's id
  2177. lid = lid.substring(0, lid.indexOf(this.getId()));
  2178. }
  2179. var container = oRAPReportInfo.getContainer(lid);
  2180. if (container && typeof container.parentContainer == "undefined") {
  2181. var childContainers = this.collectChildContainers(container.container);
  2182. if (this.getPinFreezeManager()) {
  2183. oPinFreezeContainerElement=this.getPinFreezeManager().getContainerElement(layoutElement);
  2184. layoutElement=(oPinFreezeContainerElement) ? oPinFreezeContainerElement : layoutElement;
  2185. }
  2186. var infoBar = new InfoBar(this, layoutElement, container, childContainers, layoutElementIdx);
  2187. infoBar.setTimingDetails(oRAPReportInfo._getEventTimings());
  2188. infoBar.render();
  2189. if (infoBar.hasSomethingRendered() ) {
  2190. aInfoBarIDs.push(infoBar.getId());
  2191. }
  2192. this.m_aInfoBar.push(infoBar);
  2193. }
  2194. }
  2195. var oWidget = this.getViewerWidget();
  2196. if (oWidget) {
  2197. oWidget.refreshInfoBarRenderedState(aInfoBarIDs);
  2198. }
  2199. }
  2200. };
  2201. CCognosViewer.prototype.collectChildContainers = function(parentContainerId)
  2202. {
  2203. var childContainers = [];
  2204. var oRAPReportInfo = this.getRAPReportInfo();
  2205. if (oRAPReportInfo) {
  2206. var containerCount = oRAPReportInfo.getContainerCount();
  2207. for (var cidx = 0; cidx < containerCount; ++cidx) {
  2208. var container = oRAPReportInfo.getContainerFromPos(cidx);
  2209. if (typeof container.parentContainer != "undefined" && container.parentContainer == parentContainerId) {
  2210. childContainers.push(container);
  2211. }
  2212. }
  2213. }
  2214. return childContainers;
  2215. };
  2216. CCognosViewer.prototype.addReportInfo = function()
  2217. {
  2218. var widget = this.getViewerWidget();
  2219. if( typeof widget === "undefined" || widget === null) {
  2220. return;
  2221. }
  2222. // If there's no original report then don't show the reset info. This happens on a publish
  2223. // Also, if we're in mobile don't show the reset
  2224. if (!widget.getAttributeValue("originalReport") || this.isIWidgetMobile()) {
  2225. return;
  2226. }
  2227. var baseReportModificationTime = this.envParams["baseReportModificationTime"];
  2228. var savedBaseReportModificationTime = widget.getAttributeValue( "baseReportModificationTime" );
  2229. if( typeof baseReportModificationTime !== "undefined" &&
  2230. typeof savedBaseReportModificationTime !== "undefined" &&
  2231. savedBaseReportModificationTime &&
  2232. savedBaseReportModificationTime != '<empty>' &&
  2233. baseReportModificationTime !== savedBaseReportModificationTime )
  2234. {
  2235. var cvid = this.getId();
  2236. var rvContent = document.getElementById("CVReport" + cvid);
  2237. var rvContentParent = rvContent.parentNode;
  2238. var id = "ReportInfo" + cvid;
  2239. var divElement = document.createElement("div");
  2240. divElement.setAttribute("id", id + "_container");
  2241. divElement.setAttribute("cvid", cvid);
  2242. divElement.className = "new-info-indicator BUXNoPrint";
  2243. //Create icon
  2244. var imgElement = document.createElement( "img");
  2245. var img = null;
  2246. if(this.getDirection() === "rtl") {
  2247. img = "/rv/images/action_show_info_rtl.png";
  2248. } else {
  2249. img = "/rv/images/action_show_info.png";
  2250. }
  2251. imgElement.src = this.getWebContentRoot() + img ;
  2252. imgElement.className = 'reportInfoIcon';
  2253. imgElement.setAttribute("tabIndex", "0");
  2254. imgElement.setAttribute("alt", "");
  2255. imgElement.setAttribute("title", "");
  2256. imgElement.setAttribute("role", "presentation");
  2257. var reportInfoTitle = RV_RES.IDS_JS_REPORT_INFO_TITLE;
  2258. var reportInfoText = RV_RES.IDS_JS_REPORT_INFO_TEXT;
  2259. var reportInfoLinkText = RV_RES.IDS_JS_REPORT_INFO_LINK_TEXT;
  2260. divElement.appendChild( imgElement );
  2261. rvContentParent.insertBefore( divElement, rvContent );
  2262. this.m_reportInfoTooltip = new bux.reportViewer.ReportInfo({
  2263. connectId: [id + "_container"],
  2264. focusElement: imgElement,
  2265. position: ["above","below"],
  2266. title: reportInfoTitle,
  2267. text: reportInfoText,
  2268. linkText: reportInfoLinkText,
  2269. linkScript: getCognosViewerObjectRefAsString(cvid) + ".reportInfoResetReport();",
  2270. allowMouseOverToolTip: true
  2271. });
  2272. }
  2273. };
  2274. /*
  2275. * This method is invoked by the markup produced by addReportInfo
  2276. */
  2277. CCognosViewer.prototype.reportInfoResetReport = function()
  2278. {
  2279. this.executeAction( "ResetToOriginal" );
  2280. };
  2281. /*
  2282. * This method hides ReportInfo (if it exist) when 'Reset to Original' option is invoked
  2283. * Currently, only invoked by ResetToOriginalAction
  2284. */
  2285. CCognosViewer.prototype.hideReportInfo = function()
  2286. {
  2287. var reportInfoContainerDiv = document.getElementById( "ReportInfo" + this.getId() + "_container" );
  2288. if( typeof reportInfoContainerDiv !== "undefined" && reportInfoContainerDiv !== null )
  2289. {
  2290. reportInfoContainerDiv.style.visibility = "hidden";
  2291. }
  2292. };
  2293. /**
  2294. * Currently only called when adding sort icons to the CC Viewer
  2295. */
  2296. CCognosViewer.prototype.insertSortIcons = function()
  2297. {
  2298. var limitedInteractiveMode = this.envParams ? this.envParams.limitedInteractiveMode : true;
  2299. if (typeof limitedInteractiveMode === "undefined" || limitedInteractiveMode === true) {
  2300. return;
  2301. }
  2302. // For now we only want to show the sort icons for a run. This means that it will not show up
  2303. // in studios or when run from a studio
  2304. if (this.envParams["ui.action"] === "run" || this.envParams["ui.primaryAction"] === "run") {
  2305. this.insertSortIconsForAllLists();
  2306. }
  2307. };
  2308. CCognosViewer.prototype._getContainers = function(sContainerType) {
  2309. var aNodes = [];
  2310. var sLayoutType = "", sClassName = "";
  2311. if(sContainerType === "list") {
  2312. sLayoutType = "list";
  2313. sClassName = "ls";
  2314. } else if(sContainerType === "crosstab") {
  2315. sLayoutType = "crosstab";
  2316. sClassName = "xt";
  2317. }
  2318. var nReportDiv = document.getElementById("CVReport" + this.getId());
  2319. // If we have reportInfo then use it to find all the containers, it's a lot more
  2320. // reliable then using the css class on the table which can be changed in report studio
  2321. if (this.getRAPReportInfo()) {
  2322. var aContainerIds = this.getRAPReportInfo().getContainerIds(sLayoutType);
  2323. for(var i = 0; i < aContainerIds.length; ++i) {
  2324. var aContainerTables = getElementsByAttribute(nReportDiv, "table", "lid", aContainerIds[i] + this.getId(), 1);
  2325. if (aContainerTables && aContainerTables.length > 0) {
  2326. aNodes.push(aContainerTables[0]);
  2327. }
  2328. }
  2329. } else {
  2330. aNodes = getElementsByClassName(nReportDiv, "table", sClassName);
  2331. }
  2332. return aNodes;
  2333. };
  2334. CCognosViewer.prototype.insertSortIconsForAllLists = function()
  2335. {
  2336. var aListTableElements = this._getContainers("list");
  2337. for (var i = 0; i < aListTableElements.length; ++i) {
  2338. this.insertSortIconsToList(aListTableElements[i]);
  2339. }
  2340. };
  2341. CCognosViewer.prototype.insertSortIconsToList = function(listTableElement)
  2342. {
  2343. var columnHeaderElements = getElementsByAttribute(listTableElement, '*', "type", 'columnTitle');
  2344. for (var i = 0; i < columnHeaderElements.length; ++i) {
  2345. var columnHeader = columnHeaderElements[i];
  2346. // we need to create a selection object for the column header so any missing context information
  2347. // can be calculated
  2348. this.getSelectionController().getSelectionObjectFactory().getSelectionObject(columnHeader);
  2349. // double check to ensure we're not adding the sort icon to a crosstab node memeber or a crosstab corner
  2350. if (columnHeader.getAttribute("canSort") != "false" && columnHeader.getAttribute("CTNM") === null && columnHeader.getAttribute("CC") === null) {
  2351. var sortImgAlreadyInserted = false;
  2352. for (var iChild=0; iChild < columnHeader.childNodes.length; iChild++) {
  2353. var child = columnHeader.childNodes[iChild];
  2354. if (child.nodeName.toLowerCase() == "img" )
  2355. {
  2356. // make sure we didn't already add a sort icon. Happens when we have lists inside of lists
  2357. if( child.id && child.id.indexOf("sortimg") === 0)
  2358. {
  2359. sortImgAlreadyInserted = true;
  2360. break;
  2361. }
  2362. //remove the sort icon from QS report
  2363. var sLid = child.getAttribute( "lid");
  2364. if(sLid && sLid.indexOf("SortIcon") !== -1)
  2365. {
  2366. columnHeader.removeChild( child );
  2367. break;
  2368. }
  2369. }
  2370. }
  2371. if (!sortImgAlreadyInserted && this.canInsertSortIcon(columnHeader) ) {
  2372. this.insertSortIconToColumnHeader(columnHeader);
  2373. }
  2374. }
  2375. }
  2376. };
  2377. CCognosViewer.prototype.isDrillBlackListed = function() {
  2378. if (typeof this.m_bDrillBlacklisted == "undefined") {
  2379. this.m_bDrillBlacklisted = this.isBlacklisted("DrillDown") || this.isBlacklisted("DrillUp");
  2380. }
  2381. return this.m_bDrillBlacklisted;
  2382. };
  2383. CCognosViewer.prototype.isBlacklisted = function(item) {
  2384. return this.UIBlacklist && this.UIBlacklist.indexOf(" " + item + " ") > 0;
  2385. };
  2386. CCognosViewer.prototype.canInsertSortIcon = function(oColumnHeaderElement) {
  2387. var sortValue = oColumnHeaderElement.getAttribute('rp_sort');
  2388. return ( (!this.isLimitedInteractiveMode() && !this.isBlacklisted("Sort")) || ( sortValue !== undefined && sortValue !== null && sortValue.length > 0 ) );
  2389. };
  2390. CCognosViewer.prototype.insertSortIconToColumnHeader = function(oColumnHeaderElement) {
  2391. if (!oColumnHeaderElement.style.whiteSpace) {
  2392. oColumnHeaderElement.style.whiteSpace='nowrap'; //note: TD nowrap= attribute is deprecated and ocassionally wraps in IE!
  2393. }
  2394. var imgElement = document.createElement("img");
  2395. imgElement.setAttribute("id", 'sortimg' + Math.random());
  2396. if( (!this.isLimitedInteractiveMode() && !this.isBlacklisted("Sort")) )
  2397. {
  2398. imgElement.onmouseover = function() {this.setAttribute("oldClassName", this.className); this.className += " sortIconOver";};
  2399. imgElement.onmouseout = function() {this.className = this.getAttribute("oldClassName"); this.removeAttribute("oldClassName");};
  2400. }
  2401. imgElement.src = this.getImgSrc(oColumnHeaderElement );
  2402. var sortInfo = this.getSortInfo(oColumnHeaderElement);
  2403. var sSort = this.getSortOrder(sortInfo);
  2404. imgElement.setAttribute( 'alt', this.getSortAltText( sSort ));
  2405. imgElement.setAttribute( 'title', this.getSortAltText( sSort ));
  2406. imgElement.className = this.getSortClass( sortInfo );
  2407. imgElement.setAttribute('sortOrder', sSort);
  2408. oColumnHeaderElement.appendChild( imgElement );
  2409. };
  2410. CCognosViewer.prototype.canInsertShowExpandCollapseIconForNode = function( oItemInfo, contextId )
  2411. {
  2412. var selectionController = this.getSelectionController();
  2413. var bHasCalculationMetadata = selectionController.hasCalculationMetadata( contextId, [contextId], "crosstab" );
  2414. return( ( selectionController.canDrillDown( contextId ) || oItemInfo.alwaysCanExpandCollapse )
  2415. && !selectionController.isCalculationOrMeasure( contextId, bHasCalculationMetadata ));
  2416. };
  2417. CCognosViewer.prototype.insertExpandIconsForAllCrosstabs = function() {
  2418. var aCrosstabTableElements = this._getContainers("crosstab");
  2419. var _this = this;
  2420. var oRAPReportInfo = this.getRAPReportInfo();
  2421. var oContextHelper = this.getReportContextHelper();
  2422. for(var i = 0; i < aCrosstabTableElements.length; i++) {
  2423. var nCrosstabTable = aCrosstabTableElements[i];
  2424. var sContainerLID = nCrosstabTable.getAttribute("lid");
  2425. //Remove viewer namespace from lid
  2426. sContainerLID = sContainerLID.substring(0, sContainerLID.length - this.getId().length);
  2427. var aHeaderNodes = getElementsByAttribute(nCrosstabTable, ["td","th"], "ctnm", "true");
  2428. for(var j = 0; j < aHeaderNodes.length; j++) {
  2429. var nHeaderNode = aHeaderNodes[j];
  2430. var sCtx = this.findCtx(nHeaderNode);
  2431. var sDataItemName = oContextHelper.getDataItemName(sCtx);
  2432. if(sDataItemName) {
  2433. var oItemInfo = oRAPReportInfo.getItemInfo(sContainerLID, sDataItemName);
  2434. var aContextIds = oContextHelper.processCtx( sCtx );
  2435. if( this.canInsertShowExpandCollapseIconForNode( oItemInfo, aContextIds[0][0] ) ) {
  2436. var sMun = oContextHelper.getMun(sCtx);
  2437. var bIsExpanded = sMun && oItemInfo.expandedMembers && oItemInfo.expandedMembers[sMun] === true;
  2438. var nIcon = document.createElement("div");
  2439. nIcon.setAttribute("skipSelection", "true");
  2440. nIcon.className = "expandButton " + (bIsExpanded ? "collapse" : "expand");
  2441. nHeaderNode.insertBefore(nIcon, nHeaderNode.firstChild);
  2442. var nCaption = document.createElement("span");
  2443. nCaption.className = "expandButtonCaption";
  2444. nCaption.innerHTML = (bIsExpanded ? "[-]" : "[+]");
  2445. nIcon.appendChild(nCaption);
  2446. }
  2447. }
  2448. }
  2449. }
  2450. };
  2451. CCognosViewer.prototype.removeExpandIconsForAllCrosstabs = function() {
  2452. var aCrosstabTableElements = this._getContainers("crosstab");
  2453. for(var i = 0; i < aCrosstabTableElements.length; i++) {
  2454. var nCrosstabTable = aCrosstabTableElements[i];
  2455. var sContainerLID = nCrosstabTable.getAttribute("lid");
  2456. //Remove viewer namespace from lid
  2457. sContainerLID = sContainerLID.substring(0, sContainerLID.length - this.getId().length);
  2458. var aHeaderNodes = getElementsByAttribute(nCrosstabTable, "td", "ctnm", "true");
  2459. for(var j = 0; j < aHeaderNodes.length; j++) {
  2460. var nHeaderNode = aHeaderNodes[j];
  2461. if( nHeaderNode.firstChild.className === 'expandButton collapse'
  2462. || nHeaderNode.firstChild.className === 'expandButton expand' )
  2463. {
  2464. nHeaderNode.removeChild( nHeaderNode.firstChild );
  2465. }
  2466. }
  2467. }
  2468. };
  2469. CCognosViewer.prototype.fillInContextData = function() {
  2470. if (!this.isLimitedInteractiveMode()) {
  2471. var reportDiv = document.getElementById("CVReport" + this.getId());
  2472. var listTableElements = getElementsByClassName(reportDiv, "table", 'ls');
  2473. for (var i = 0; i < listTableElements.length; ++i) {
  2474. var columnHeaderElements = getElementsByAttribute(listTableElements[i], '*', "type", 'columnTitle');
  2475. for (var j = 0; j < columnHeaderElements.length; ++j) {
  2476. this.getSelectionController().getSelectionObjectFactory().getSelectionObject(columnHeaderElements[j]);
  2477. }
  2478. }
  2479. }
  2480. };
  2481. CCognosViewer.prototype.getSortAltText = function (sSort)
  2482. {
  2483. if( sSort === "ascending" )
  2484. {
  2485. return RV_RES.IDS_JS_SORT_ASCENDING;
  2486. }
  2487. else if( sSort === "descending")
  2488. {
  2489. return RV_RES.IDS_JS_SORT_DESCENDING;
  2490. } else if (sSort === "nosort")
  2491. {
  2492. return RV_RES.IDS_JS_NOT_SORTED;
  2493. }
  2494. };
  2495. CCognosViewer.prototype.getSortInfo = function (oColumnHeaderElement)
  2496. {
  2497. var sortInfo = oColumnHeaderElement.getAttribute('rp_sort');
  2498. if (sortInfo)
  2499. {
  2500. sortInfo = sortInfo.split('.');
  2501. }
  2502. return sortInfo;
  2503. };
  2504. CCognosViewer.prototype.getSortClass = function( sortInfo )
  2505. {
  2506. var classname = 'sortIconHidden';
  2507. if (sortInfo)
  2508. {
  2509. if( sortInfo[0] === 'd'|| sortInfo[0] === 'a')
  2510. {
  2511. classname = 'sortIconVisible';
  2512. }
  2513. }
  2514. return classname;
  2515. };
  2516. CCognosViewer.prototype.getSortOrder = function( sortInfo )
  2517. {
  2518. var sortOrder = 'nosort';
  2519. if( sortInfo )
  2520. {
  2521. if( sortInfo[0] === 'd')
  2522. {
  2523. sortOrder = 'descending';
  2524. }
  2525. else if( sortInfo[0] === 'a')
  2526. {
  2527. sortOrder = 'ascending';
  2528. }
  2529. }
  2530. return sortOrder;
  2531. };
  2532. CCognosViewer.prototype.getImgSrc = function( oColumnHeaderElement )
  2533. {
  2534. var sortOrder = oColumnHeaderElement.getAttribute('rp_sort');
  2535. var src = this.getWebContentRoot() + "/rv/images/" + this.getSortIconName( sortOrder );
  2536. return src;
  2537. };
  2538. CCognosViewer.prototype.getSortIconName = function( sortOrder )
  2539. {
  2540. var iconName = 'sort_no.gif';
  2541. if (sortOrder) {
  2542. sortOrder = sortOrder.split('.');
  2543. if( sortOrder[0] === 'd')
  2544. {
  2545. iconName = 'sort_descending.gif';
  2546. }
  2547. else if( sortOrder[0] === 'a')
  2548. {
  2549. iconName = 'sort_ascending.gif';
  2550. }
  2551. }
  2552. return iconName;
  2553. };
  2554. CCognosViewer.prototype.shouldWriteNavLinks = function() {
  2555. if (this.envParams["cv.navlinks"] == "false") {
  2556. return false;
  2557. }
  2558. else if (!this.getUIConfig() || this.getUIConfig().getShowPageNavigation()) {
  2559. if (this.rvMainWnd || (this.isBux && !this.isActiveReport()) ) {
  2560. return true;
  2561. }
  2562. }
  2563. return false;
  2564. };
  2565. CCognosViewer.prototype.isActiveReport = function() {
  2566. if (this.envParams["cv.responseFormat"] === "activeReport" ) {
  2567. return true;
  2568. }
  2569. return false;
  2570. };
  2571. CCognosViewer.prototype.resetRaiseSharePromptEventFlag = function()
  2572. {
  2573. this.m_raiseSharePromptEvent = true;
  2574. };
  2575. CCognosViewer.prototype.resetbHasPromptFlag = function()
  2576. {
  2577. this.m_bHasPrompt = null;
  2578. };
  2579. CCognosViewer.prototype.disableRaiseSharePromptEvent = function()
  2580. {
  2581. this.m_raiseSharePromptEvent = false;
  2582. };
  2583. CCognosViewer.prototype.widgetHasPromptParameters = function()
  2584. {
  2585. var cvWidget = this.getViewerWidget();
  2586. return (cvWidget && cvWidget.promptParametersRetrieved == true && this.envParams && typeof this.envParams["reportPrompts"] != "undefined" && this.envParams["reportPrompts"] != null && this.envParams["reportPrompts"].length > 0);
  2587. };
  2588. // ***
  2589. /**
  2590. * Returns the pompt parameters info
  2591. * @return { transientSpec: TransientSpec,value:parameter values}
  2592. */
  2593. CCognosViewer.prototype.getPromptParametersInfo = function()
  2594. {
  2595. var result = null;
  2596. if (this.widgetHasPromptParameters()) {
  2597. result = "<widget><parameterValues>" + sXmlEncode(this.getExecutionParameters()) + "</parameterValues>" + this.envParams["reportPrompts"] + "</widget>" ;
  2598. }
  2599. return result;
  2600. };
  2601. CCognosViewer.prototype.raisePromptEvent = function(sharedPrompts, formFields,clearCascadePromptParams)
  2602. {
  2603. try
  2604. {
  2605. var cvWidget = this.getViewerWidget();
  2606. cvWidget.getWidgetContextManager().raisePromptEvent(sharedPrompts, formFields, formFields.get("ui.action"), this.getModelPath(),clearCascadePromptParams);
  2607. } catch ( e )
  2608. {
  2609. }
  2610. };
  2611. /**
  2612. * Returns the model path using the selection if available or
  2613. * the 'main' model path if no cells are selected.
  2614. */
  2615. CCognosViewer.prototype.getModelPath = function() {
  2616. var modelPath = this.getSelectionController().getModelPathForCurrentSelection();
  2617. if (modelPath) {
  2618. return modelPath;
  2619. }
  2620. else if (this.envParams.modelPath) {
  2621. return this.envParams.modelPath;
  2622. }
  2623. else if(typeof document.forms["formWarpRequest" + this.getId()].modelPath !== "undefined") {
  2624. return document.forms["formWarpRequest" + this.getId()].modelPath.value;
  2625. }
  2626. return "";
  2627. };
  2628. CCognosViewer.prototype.setKeepFocus = function(value) {
  2629. this._keepFocus = value;
  2630. };
  2631. CCognosViewer.prototype.getKeepFocus = function() {
  2632. if (typeof this._keepFocus != "undefined") {
  2633. return this._keepFocus;
  2634. }
  2635. return false;
  2636. };
  2637. CCognosViewer.prototype.onFocus = function(evt) {
  2638. var a11yHelper = this.getA11YHelper();
  2639. if (a11yHelper) {
  2640. a11yHelper.onFocus(evt);
  2641. }
  2642. };
  2643. CCognosViewer.prototype.getA11YHelper = function() {
  2644. if (!this.a11yHelper) {
  2645. this.loadExtra();
  2646. if (typeof ViewerA11YHelper == "function") {
  2647. this.a11yHelper = new ViewerA11YHelper(this);
  2648. }
  2649. else {
  2650. if (typeof console !== "undefined" && console.log) {
  2651. console.log("CCognosViewer: Could not create ViewerA11YHelper object.");
  2652. }
  2653. return null;
  2654. }
  2655. }
  2656. return this.a11yHelper;
  2657. };
  2658. CCognosViewer.prototype.onKeyDown = function(evt) {
  2659. if (this.getA11YHelper()) {
  2660. this.getA11YHelper().onKeyDown(evt);
  2661. }
  2662. };
  2663. /**
  2664. * Function that will hide/show the jump to report link
  2665. */
  2666. CCognosViewer.prototype.updateSkipToReportLink = function()
  2667. {
  2668. var status = this.getStatus();
  2669. var oSkipToReport = document.getElementById("cvSkipToReport" + this.getId());
  2670. if (oSkipToReport) {
  2671. oSkipToReport.style.display = status == "prompting" ? "none" : "";
  2672. }
  2673. };
  2674. /**
  2675. * Function that will hide/show the jump to navigation link
  2676. */
  2677. CCognosViewer.prototype.updateSkipToNavigationLink = function(bHide)
  2678. {
  2679. var oSkipToNavigation = document.getElementById("cvSkipToNavigation" + this.getId());
  2680. if (oSkipToNavigation)
  2681. {
  2682. oSkipToNavigation.style.display = bHide ? "none" : "";
  2683. }
  2684. };
  2685. CCognosViewer.prototype.pageAction = function(pageAction) {
  2686. this.setKeepFocus("CVNavLinks" + this.getId());
  2687. var request = new ViewerDispatcherEntry(this);
  2688. request.addFormField("ui.action", pageAction);
  2689. if (this.getCurrentlySelectedTab()) {
  2690. request.addFormField("generic.anyURI.http://developer.cognos.com/ceba/constants/runOptionEnum#pageGroup", this.getCurrentlySelectedTab());
  2691. }
  2692. this.dispatchRequest(request);
  2693. };
  2694. /**
  2695. Helper function to generate one link for the page navigation.
  2696. @private
  2697. @param {object} oLink A object that contains the link info. oLink.text is the string to show to the user. oLink.sImg is the name of the icon to show for the normal (active) state. oLink.sImgDisabled is the name of the icon for the disabled state.
  2698. @param {string} sRequest The request to send when the link is clicked. Possible values are <code>firstPage</code>, <code>nextPage</code>, <code>previousPage</code> and <code>lastPage</code>.
  2699. @param {string} bActive True if the link should be active (normal state). False to disabled the link.
  2700. @type string
  2701. @return The HTML string that makes up the navigation links.
  2702. */
  2703. CCognosViewer.prototype.writeNavLink = function(oLink, sRequest, bActive, bSavedOutput)
  2704. {
  2705. var sPattern = "";
  2706. if (bActive)
  2707. {
  2708. sPattern =
  2709. '<td nowrap="nowrap">' +
  2710. '<img src="LINK_IMG" width="15" height="15" alt="" style="vertical-align:middle;">' +
  2711. '</td>' +
  2712. '<td nowrap="nowrap">';
  2713. if (bSavedOutput)
  2714. {
  2715. sPattern += '<a href="#" tabindex="0" onclick="' + getCognosViewerObjectRefAsString(this.getId()) + '.getViewerWidget().getSavedOutput().pageAction(\'LINK_REQUEST\');return false;"';
  2716. }
  2717. else
  2718. {
  2719. sPattern += '<a href="#" tabindex="0" onclick="' + getCognosViewerObjectRefAsString(this.getId()) + '.pageAction(\'LINK_REQUEST\');return false;"';
  2720. }
  2721. sPattern += '>LINK_TEXT</a>&#160;' +
  2722. '</td>';
  2723. }
  2724. else
  2725. {
  2726. sPattern =
  2727. '<td nowrap="nowrap">' +
  2728. '<img src="LINK_IMG" width="15" height="15" alt="" style="vertical-align:middle;">' +
  2729. '</td>' +
  2730. '<td nowrap="nowrap">LINK_TEXT&#160;</td>';
  2731. }
  2732. var sImg = this.sSkin + (!bActive && oLink.sImgDisabled ? oLink.sImgDisabled : oLink.sImg);
  2733. return sPattern.replace(/LINK_REQUEST/g, sRequest).replace(/LINK_TEXT/g, oLink.sText).replace(/LINK_IMG/g, sImg);
  2734. };
  2735. /**
  2736. Loads up the necessary info for the navigation links (localized strings, icon names, skin to use).
  2737. @private
  2738. */
  2739. CCognosViewer.prototype.loadNavLinks = function()
  2740. {
  2741. // load navlinks string and image path dynamically, synchronously.
  2742. var sText = window.gScriptLoader.loadFile(this.getGateway(), "b_action=xts.run&m=portal/report-viewer-navlinks.xts");
  2743. if (sText)
  2744. {
  2745. this.init(eval("(" + sText + ")"));
  2746. }
  2747. };
  2748. /**
  2749. Build the HTML code for the navigation links and update them in the UI.
  2750. @param {string} sSR space separated secondary requests
  2751. @private
  2752. */
  2753. CCognosViewer.prototype.writeNavLinks = function(sSR, bSavedOutput)
  2754. {
  2755. var oNavLinksDiv = document.getElementById("CVNavLinks" + this.getId());
  2756. if (oNavLinksDiv)
  2757. {
  2758. var nNavLinksDivContainer = document.getElementById("CVNavLinks_Container" + this.getId());
  2759. if (typeof this.oNavLinks != "object" || typeof sSR != "string" || !sSR.match(/\bfirstPage\b|\bpreviousPage\b|\bnextPage\b|\blastPage\b|\bplayback\b/i))
  2760. {
  2761. oNavLinksDiv.style.display = "none";
  2762. if (nNavLinksDivContainer) {
  2763. nNavLinksDivContainer.style.display = "none";
  2764. }
  2765. this.updateSkipToNavigationLink(true);
  2766. return;
  2767. }
  2768. this.updateSkipToNavigationLink(false);
  2769. if (nNavLinksDivContainer) {
  2770. nNavLinksDivContainer.style.display = "";
  2771. }
  2772. oNavLinksDiv.style.display = (isIE() ? "block" : "table-cell");
  2773. var sHTML = "";
  2774. sHTML += '<table border="0" cellpadding="0" cellspacing="0" class="pageControls BUXNoPrint" role="presentation"><tbody><tr>';
  2775. sHTML += this.writeNavLink(this.oNavLinks.oFirst, 'firstPage', sSR.match(/\bfirstPage\b/gi), bSavedOutput);
  2776. sHTML += this.writeNavLink(this.oNavLinks.oPrevious, 'previousPage', sSR.match(/\bpreviousPage\b/gi), bSavedOutput);
  2777. sHTML += this.writeNavLink(this.oNavLinks.oNext, 'nextPage', sSR.match(/\bnextPage\b/gi), bSavedOutput);
  2778. sHTML += this.writeNavLink(this.oNavLinks.oLast, 'lastPage', sSR.match(/\blastPage\b/gi), bSavedOutput);
  2779. sHTML += '</tr></tbody></table>';
  2780. // if there was a hidden span for JAWS, keep it around.
  2781. var oNavLinksLabel = document.getElementById("CVNavLinks_label" + this.getId());
  2782. var navLinkLabel = "";
  2783. if (oNavLinksLabel) {
  2784. navLinkLabel += "<span id=\"CVNavLinks_label" + this.getId() + "\" style=\"visibilty:hidden; display:none;\">" + oNavLinksLabel.innerHTML + "</span>";
  2785. }
  2786. oNavLinksDiv.innerHTML = navLinkLabel + sHTML;
  2787. }
  2788. else if (this.shouldWriteNavLinks())
  2789. {
  2790. setTimeout(getCognosViewerObjectRefAsString(this.getId()) + '.writeNavLinks("' + sSR + '","' + bSavedOutput + '");', 100);
  2791. }
  2792. };
  2793. /**
  2794. * Ignores mouse clicks in the background layer when request is running
  2795. */
  2796. function CVBackgroundLayer_ignoreMouseClick( e )
  2797. {
  2798. if (e.returnValue) { e.returnValue = false; }
  2799. else if (e.preventDefault) { e.preventDefault(); }
  2800. else { return false; }
  2801. }
  2802. /**
  2803. * Creates a transparent background to be displayed when request is running so that mouse clicks can be ignored
  2804. */
  2805. CCognosViewer.prototype.createTransparentBackgroundLayer = function()
  2806. {
  2807. this.removeTransparentBackgroundLayer();
  2808. var oBL = document.createElement( "div" );
  2809. oBL.id = CV_BACKGROUND_LAYER_ID;
  2810. oBL.style.display = "none";
  2811. oBL.style.position = "absolute";
  2812. oBL.setAttribute("role", "region");
  2813. oBL.setAttribute("aria-label", RV_RES.IDS_JS_A11Y_BACKGROUND_TINT);
  2814. oBL.style.top = "0px";
  2815. oBL.style.left = "0px";
  2816. oBL.style.zIndex = 98;
  2817. oBL.style.width = "100%";
  2818. oBL.style.height = "100%";
  2819. oBL.style.backgroundColor = 'rgb(238, 238, 238)'; //arbitrary colour
  2820. oBL.style.opacity = '0';
  2821. oBL.style.filter = 'alpha(opacity:0)';
  2822. oBL.innerHTML = '<table tabindex="1" width="100%" height="100%"><tr><td role="presentation" onclick="CVBackgroundLayer_ignoreMouseClick(event)"></td></tr></table>';
  2823. oBL.style.display = 'inline';
  2824. document.body.appendChild( oBL );
  2825. };
  2826. /**
  2827. * Removes the transparent background layer
  2828. */
  2829. CCognosViewer.prototype.removeTransparentBackgroundLayer = function()
  2830. {
  2831. var oBL = document.getElementById( CV_BACKGROUND_LAYER_ID );
  2832. if( oBL )
  2833. {
  2834. oBL.parentNode.removeChild( oBL );
  2835. }
  2836. };
  2837. /**
  2838. * Closes active http connections. Note this method will not issue a cancel. If you need to cancel an RSVP request, use the cancel method
  2839. * @return (boolean)
  2840. */
  2841. CCognosViewer.prototype.closeActiveHTTPConnection = function()
  2842. {
  2843. var dispatcherEntry = this.getActiveRequest();
  2844. if (dispatcherEntry) {
  2845. dispatcherEntry.abortHttpRequest();
  2846. }
  2847. };
  2848. /**
  2849. * Returns true if the viewer is in asynch mode, and the request is cancellable
  2850. * @return (boolean)
  2851. */
  2852. CCognosViewer.prototype.canCancel = function()
  2853. {
  2854. var sTracking = this.getTracking();
  2855. var sStatus = this.getStatus();
  2856. return sTracking != "" && sStatus != "complete";
  2857. };
  2858. /**
  2859. * Cancels the current request, and restores the viewer back to the previous state.
  2860. */
  2861. CCognosViewer.prototype.cancel = function(cancelLink)
  2862. {
  2863. if (this.getWorkingDialog() && this.getWorkingDialog().disableCancelButton) {
  2864. // Disable the button so the user knows we've done a cancel and won't hit it multiple times
  2865. this.getWorkingDialog().disableCancelButton(cancelLink);
  2866. }
  2867. this.removeTransparentBackgroundLayer();
  2868. this.clearPrompts();
  2869. if (this.m_viewerFragment && this.envParams["fragment.fireEventWhenComplete"]) {
  2870. this.envParams["fragment.fireEventWhenComplete"] = "";
  2871. }
  2872. var cognosViewerUndo = null;
  2873. if(this.m_undoStack.length > 0) {
  2874. cognosViewerUndo = this.m_undoStack.pop();
  2875. }
  2876. var dispatcherEntry = this.getActiveRequest();
  2877. if(this.canCancel() === true || dispatcherEntry) {
  2878. if (dispatcherEntry) {
  2879. dispatcherEntry.cancelRequest(true);
  2880. }
  2881. else {
  2882. // if we don't have an active request the cancel
  2883. // came from a prompt page, the working dialog when ajax is off or fragments
  2884. var request = null;
  2885. var refreshPage = cognosViewerUndo != null && cognosViewerUndo.m_bRefreshPage;
  2886. if (typeof this.getCancelDispatcherEntry == "function") {
  2887. request = this.getCancelDispatcherEntry();
  2888. }
  2889. // for fragments, when we cancel we want to replace the report
  2890. // with the run button. Also when we're cancelling from a prompt page
  2891. // and we have an earlier 'complete' conversation
  2892. else if (refreshPage || this.m_viewerFragment) {
  2893. request = new ViewerDispatcherEntry(this);
  2894. }
  2895. else {
  2896. if (this.getId() == 'RS') {
  2897. request = new ViewerDispatcherEntry(this);
  2898. request.addFormField("cv.responseFormat", "rs");
  2899. }
  2900. else {
  2901. request = new DispatcherEntry(this);
  2902. request.addFormField("cv.responseFormat", "successfulRequest");
  2903. }
  2904. }
  2905. request.forceSynchronous();
  2906. request.addFormField("ui.action", "cancel");
  2907. request.addFormField("m_tracking", this.getTracking());
  2908. // Blank out the tracking so that if the cancel function gets called again we won't send multiple cancel requests.
  2909. // This can happen if we're leaving the Viewer after the cancel
  2910. this.setTracking("");
  2911. // If we have an old conversation, send the 'cv.previousSession'
  2912. // form field which will cause the server to do a currentPage after the
  2913. // cancel so the user will see the report he had before the reprompt
  2914. if (refreshPage) {
  2915. var undoSpec = "<CognosViewerUndo><conversation>";
  2916. undoSpec += cognosViewerUndo.m_sConversation;
  2917. undoSpec += "</conversation></CognosViewerUndo>";
  2918. request.addFormField("cv.previousSession", undoSpec);
  2919. }
  2920. this.dispatchRequest(request);
  2921. if (!this.isBux && !this.m_viewerFragment && (this.getUsePageRequest() || !this.isReportRenderingDone())) {
  2922. this.executeCallback("cancel");
  2923. }
  2924. }
  2925. this.setStatus("complete");
  2926. var action = this.envParams["ui.action"];
  2927. var oriPageRequest = this.getUsePageRequest();
  2928. var oriStackSize = this.m_undoStack.length;
  2929. if(cognosViewerUndo != null) {
  2930. this.m_sConversation = cognosViewerUndo.m_sConversation;
  2931. this.m_sParameters = cognosViewerUndo.m_sParameters;
  2932. this.envParams = {};
  2933. applyJSONProperties(this.envParams, cognosViewerUndo.m_envParams);
  2934. this.m_undoStack.push(cognosViewerUndo);
  2935. }
  2936. this.setTracking("");
  2937. if (this.previouslySelectedTab) {
  2938. this.cancelTabSwitch();
  2939. }
  2940. else if (action != "view" && oriStackSize <= 0 && this.rvMainWnd) {
  2941. // If the stack size was 0, then the user hit cancel from the wait dialog or from the initial prompt page. Try and go
  2942. // back to the previous report if there was one.
  2943. this.rvMainWnd.executePreviousReport(-1);
  2944. }
  2945. return true;
  2946. }
  2947. else if (this.rvMainWnd && typeof this.envParams != "undefined" && (this.envParams["ui.primaryAction"] == "authoredDrillThrough" || this.envParams["ui.primaryAction"] == "authoredDrillThrough2")) {
  2948. this.rvMainWnd.executePreviousReport(-1);
  2949. return true;
  2950. }
  2951. else {
  2952. if (!this.isBux) {
  2953. executeBackURL(this.getId());
  2954. }
  2955. return true;
  2956. }
  2957. return false;
  2958. };
  2959. CCognosViewer.prototype.clearPrompts = function()
  2960. {
  2961. if (this.preProcessControlArray)
  2962. {
  2963. var kCount = this.preProcessControlArray.length;
  2964. var k = 0;
  2965. for (k=0; k<kCount; k++)
  2966. {
  2967. var oPrmtCtrl = eval(this.preProcessControlArray[k]);
  2968. if (oPrmtCtrl)
  2969. {
  2970. if (oPrmtCtrl.clearSubmit) {
  2971. oPrmtCtrl.clearSubmit();
  2972. }
  2973. }
  2974. }
  2975. }
  2976. };
  2977. /**
  2978. * Sends a wait request to the report server. If the current status is not "working" or "stillWorking", the request will not be sent
  2979. * @return (boolean)
  2980. */
  2981. CCognosViewer.prototype.wait = function()
  2982. {
  2983. if(this.isWorking())
  2984. {
  2985. this.JAWSTalk(RV_RES.IDS_JS_WAIT_PAGE_LOADING);
  2986. var request = new ViewerDispatcherEntry(this);
  2987. request.addFormField("ui.action", "wait");
  2988. request.addFormField("ui.primaryAction", this.envParams["ui.primaryAction"]);
  2989. request.addFormField("cv.actionState", this.envParams["cv.actionState"]);
  2990. request.addNonEmptyStringFormField("bux", this.envParams["bux"]);
  2991. request.addNonEmptyStringFormField("ui.preserveRapTags", this.envParams["ui.preserveRapTags"]);
  2992. this.dispatchRequest(request);
  2993. return true;
  2994. }
  2995. return false;
  2996. };
  2997. /**
  2998. @param {string} sValue CAF encoded string.
  2999. */
  3000. CCognosViewer.prototype.setCAFContext = function(sValue)
  3001. {
  3002. this.m_sCAFContext = sValue;
  3003. };
  3004. /**
  3005. @param {string} sXML XML for the context.
  3006. */
  3007. CCognosViewer.prototype.setContextInfo = function(sXML)
  3008. {
  3009. this.m_sContextInfoXML = sXML;
  3010. };
  3011. /**
  3012. @param {string} sValue CAF encoded string.
  3013. */
  3014. CCognosViewer.prototype.setConversation = function(sValue)
  3015. {
  3016. this.m_sConversation = sValue;
  3017. };
  3018. /**
  3019. @param {string} sValue CAF encoded string.
  3020. */
  3021. CCognosViewer.prototype.setActionState = function(sValue)
  3022. {
  3023. this.m_sActionState = sValue;
  3024. };
  3025. /**
  3026. * Sets the conversation status
  3027. * @param string (conversation status)
  3028. */
  3029. CCognosViewer.prototype.setStatus = function(sStatus)
  3030. {
  3031. this.m_sStatus = sStatus;
  3032. };
  3033. /**
  3034. @param {bool} bDebug Enable/disable debugging in {@link CCognosViewer}.
  3035. @private
  3036. */
  3037. CCognosViewer.prototype.setDebug = function(bDebug)
  3038. {
  3039. this.m_bDebug = bDebug;
  3040. };
  3041. /**
  3042. @param {string} sValue CAF encoded string.
  3043. */
  3044. CCognosViewer.prototype.setExecutionParameters = function(sValue)
  3045. {
  3046. this.m_sParameters = sValue;
  3047. };
  3048. /**
  3049. @param {string} sXML XML for the metadata.
  3050. */
  3051. CCognosViewer.prototype.setMetadataInfo = function(sXML)
  3052. {
  3053. this.m_sMetadataInfoXML = sXML;
  3054. };
  3055. /**
  3056. @param {array} aValue
  3057. */
  3058. CCognosViewer.prototype.setSecondaryRequests = function(aValue)
  3059. {
  3060. if (aValue) {
  3061. this.m_aSecRequests = aValue;
  3062. }
  3063. else {
  3064. this.m_aSecRequests = [];
  3065. }
  3066. };
  3067. /**
  3068. @param {string} sValue CAF encoded string.
  3069. */
  3070. CCognosViewer.prototype.setTracking = function(sValue)
  3071. {
  3072. this.m_sTracking = sValue;
  3073. };
  3074. /**
  3075. @param (string) sValue fault code
  3076. */
  3077. CCognosViewer.prototype.setSoapFault = function(sValue)
  3078. {
  3079. this.m_sSoapFault = sValue;
  3080. };
  3081. CCognosViewer.prototype.showOutputInNewWindow = function(sURL)
  3082. {
  3083. var formWarpRequest = document.getElementById("formWarpRequest" + this.getId());
  3084. var doPostBack = formWarpRequest.elements["ui.postBack"];
  3085. var backURL = formWarpRequest.elements["ui.backURL"];
  3086. // For accessible PDF we always show the PDF in it's own browser. Make sure we detach
  3087. // our windowUnload events so that we don't release the conversation which causes the PDF to get removed from the repository service
  3088. if (this.isAccessibleMode() && this.envParams["run.outputFormat"] == "PDF" && window.detachLeavingRV) {
  3089. window.detachLeavingRV();
  3090. }
  3091. // Only open a new window if we can do something (close, backURL) with the current window.
  3092. if (window.opener || doPostBack || (backURL && backURL.value !== 'javascript:window.close();')) {
  3093. window.open(sURL, "", "");
  3094. this.updateNewBrowserWindow();
  3095. }
  3096. // The current window wasn't created by javascript, so simply replace the
  3097. // current window with the new URL
  3098. else {
  3099. window.location = sURL;
  3100. }
  3101. };
  3102. CCognosViewer.prototype.hideToolbar = function(bHide) {
  3103. this.m_bHideToolbar = bHide;
  3104. };
  3105. CCognosViewer.prototype.showExcel = function(sURL)
  3106. {
  3107. var currentWindowClosing = true;
  3108. var formWarpRequest = document.getElementById("formWarpRequest" + this.getId());
  3109. var backURL = formWarpRequest.elements["ui.backURL"];
  3110. if (backURL && backURL.value.indexOf('javascript:window.close()') !== 0 && backURL.value.indexOf("close.html") === -1) {
  3111. currentWindowClosing = false;
  3112. }
  3113. // Make sure we detach our windowUnload events so that we don't release the conversation
  3114. // which causes the Excel output to get removed from the repository service
  3115. if (window.detachLeavingRV) {
  3116. window.detachLeavingRV();
  3117. }
  3118. var windowObj = window;
  3119. // For IE and Firefox get the parent window (if available) to call
  3120. // window.open. This is to fix
  3121. // issues where the open/save dialog would go away
  3122. if (window.opener && (isIE() || isFF()) && currentWindowClosing) {
  3123. windowObj = window.opener ? window.opener : window;
  3124. }
  3125. // We won't be able to close the current window if it wasn't open using javascript. So if
  3126. // the window.opener is null and we're going to close the current window, simply replace the URL with the new one
  3127. else if (!window.opener && currentWindowClosing) {
  3128. window.location = sURL;
  3129. return;
  3130. }
  3131. var popupDialog = null;
  3132. var properties = "";
  3133. try {
  3134. if (this.envParams["cv.excelWindowOpenProperties"]) {
  3135. properties=this.envParams["cv.excelWindowOpenProperties"];
  3136. }
  3137. popupDialog = windowObj.open(sURL, "",properties);
  3138. } catch (e) {
  3139. // permission denied to access property open for window.opener.open
  3140. // APAR COGCQ00839573
  3141. windowObj = window;
  3142. popupDialog = windowObj.open(sURL, "",properties);
  3143. }
  3144. // check to see if the dialog have
  3145. if (!popupDialog || popupDialog.closed || typeof popupDialog.closed == 'undefined') {
  3146. // if Browser pop up blocker is enabled dialog will not open
  3147. alert(RV_RES.RV_BROWSER_POPUP_IS_ENABLED);
  3148. }
  3149. this.updateNewBrowserWindow();
  3150. };
  3151. CCognosViewer.prototype.updateNewBrowserWindow = function()
  3152. {
  3153. var id = this.getId();
  3154. var doPostBack = document.forms["formWarpRequest" + id].elements["ui.postBack"];
  3155. var backURL = document.forms["formWarpRequest" + id].elements["ui.backURL"];
  3156. if (doPostBack && doPostBack.value)
  3157. {
  3158. setTimeout(getCognosViewerObjectRefAsString(id) + '.getRV().doPostBack();', 100);
  3159. }
  3160. else if (backURL && backURL.value)
  3161. {
  3162. if (backURL.value.length < 2048)
  3163. {
  3164. setTimeout('location.replace("' + backURL.value + '");', 100);
  3165. }
  3166. else
  3167. {
  3168. backURL = decodeURIComponent(backURL.value);
  3169. var URLandParameters = backURL.split("?");
  3170. var backURLForm = document.createElement("form");
  3171. backURLForm.style.display = "none";
  3172. backURLForm.setAttribute("target", "_self");
  3173. backURLForm.setAttribute("method", "post");
  3174. backURLForm.setAttribute("action", URLandParameters[0]);
  3175. var parameterList = URLandParameters[1].split("&"); // must be ampersand symbol
  3176. for(var nextParameter = 0; nextParameter < parameterList.length; nextParameter++)
  3177. {
  3178. // We cannot use "split" here using "=" because there are "=" within the parameters
  3179. // that must be kept.
  3180. var equalsIndexPos = parameterList[nextParameter].indexOf("=");
  3181. var parameterName = parameterList[nextParameter].substr(0, equalsIndexPos);
  3182. var parameterValue = parameterList[nextParameter].substr(equalsIndexPos + 1);
  3183. var urlFormField = document.createElement("img");
  3184. urlFormField.setAttribute("type", "hidden");
  3185. urlFormField.setAttribute("name", decodeURIComponent(parameterName));
  3186. urlFormField.setAttribute("value", decodeURIComponent(parameterValue));
  3187. backURLForm.appendChild(urlFormField);
  3188. }
  3189. document.body.appendChild(backURLForm);
  3190. backURLForm.submit();
  3191. }
  3192. }
  3193. else
  3194. {
  3195. window.close();
  3196. }
  3197. };
  3198. /**
  3199. * ****** Legacy method for QS only. *******
  3200. */
  3201. CCognosViewer.prototype.showWaitPage = function() {};
  3202. /**
  3203. * ****** Legacy method for QS only. *******
  3204. * @param {Object} oCCognosViewerRequest
  3205. */
  3206. CCognosViewer.prototype.sendRequest = function(oCCognosViewerRequest) {
  3207. var oDispEntry = new ViewerDispatcherEntry(this);
  3208. oDispEntry.addFormField("ui.action", oCCognosViewerRequest.getAction());
  3209. if (oCCognosViewerRequest.getCallback() != null) {
  3210. oDispEntry.setCallbacks( { "complete" : {"object" : null, "method" : oCCognosViewerRequest.getCallback()}});
  3211. }
  3212. var aFormFields = oCCognosViewerRequest.getFormFields().keys();
  3213. for (var idxFormField = 0; idxFormField < aFormFields.length; idxFormField++) {
  3214. oDispEntry.addFormField(aFormFields[idxFormField], oCCognosViewerRequest.getFormFields().get(aFormFields[idxFormField]));
  3215. }
  3216. var aOptions = oCCognosViewerRequest.m_oOptions.keys();
  3217. for (var idxOption = 0; idxOption < aOptions.length; idxOption++) {
  3218. oDispEntry.addFormField(aOptions[idxOption], oCCognosViewerRequest.getOption(aOptions[idxOption]));
  3219. }
  3220. var aParameters = oCCognosViewerRequest.m_oParams.keys();
  3221. for (var idxParameter = 0; idxParameter < aParameters.length; idxParameter++) {
  3222. oDispEntry.addFormField(aParameters[idxParameter], oCCognosViewerRequest.getParameter(aParameters[idxParameter]));
  3223. }
  3224. this.dispatchRequest(oDispEntry);
  3225. };
  3226. /**
  3227. Used by prompt controls to submit (forward) requests.
  3228. @private
  3229. @param {string} sAction <code>cancel</code>, <code>back</code>, <code>next</code> or <code>finish</code>.
  3230. @param {string} sUrl "Back url" to use after the prompt has been cancelled.
  3231. */
  3232. CCognosViewer.prototype.promptAction = function(sAction, sUrl)
  3233. {
  3234. // make sure the widget retains focus once the page is loaded
  3235. this.setKeepFocus(true);
  3236. if ( typeof datePickerObserverNotify == "function" )
  3237. {
  3238. datePickerObserverNotify();
  3239. }
  3240. var widget = this.getViewerWidget();
  3241. if (sAction == "cancel")
  3242. {
  3243. this.cancelPrompt(sUrl);
  3244. if (widget)
  3245. {
  3246. if (!this.isReportRenderingDone())
  3247. {
  3248. var payload = { action: 'deleteWidget' };
  3249. widget.fireEvent("com.ibm.bux.widget.action", null, payload);
  3250. }
  3251. }
  3252. }
  3253. else
  3254. {
  3255. var oReq = new ViewerDispatcherEntry(this);
  3256. oReq.addFormField("ui.action", sAction == "back" ? "back" : "forward");
  3257. if (sAction == "finish") {
  3258. oReq.addFormField("run.prompt", false);
  3259. }
  3260. else if (sAction == "back" || sAction == "next") {
  3261. oReq.addFormField("run.prompt", true);
  3262. }
  3263. if (sAction == "reprompt") {
  3264. if ( typeof repromptObserverNotify == "function" )
  3265. {
  3266. repromptObserverNotify(this);
  3267. }
  3268. oReq.addFormField("_promptControl", sAction);
  3269. }
  3270. else {
  3271. oReq.addFormField("_promptControl", "prompt");
  3272. }
  3273. if (widget) {
  3274. widget.fireEvent("com.ibm.bux.widget.modified", null, {'modified':true});
  3275. if (widget.isSelectionFilterEnabled) {
  3276. widget.clearSelectionFilter();
  3277. }
  3278. }
  3279. this.submitPromptValues(oReq);
  3280. }
  3281. };
  3282. /**
  3283. @private
  3284. @param {string} sUrl "Back url" to use after the prompt has been cancelled.
  3285. */
  3286. CCognosViewer.prototype.cancelPrompt = function(sUrl)
  3287. {
  3288. this.cancel();
  3289. };
  3290. /**
  3291. Notifies other controls when a prompt control is updated
  3292. @private
  3293. @param {integer} iState
  3294. @param {object} oNotifier
  3295. */
  3296. CCognosViewer.prototype.notify = function(iState, oNotifier)
  3297. {
  3298. var kCount = 0, k = 0;
  3299. var oPromptElement = null;
  3300. if (this.rangeObserverArray && this.rangeObserverArray instanceof Array)
  3301. {
  3302. kCount = this.rangeObserverArray.length;
  3303. for (k=0; k<kCount; k++)
  3304. {
  3305. oPromptElement = eval(this.rangeObserverArray[k]);
  3306. if (oPromptElement && typeof oPromptElement == "object" && typeof oPromptElement.update == "function")
  3307. {
  3308. oPromptElement.update();
  3309. }
  3310. }
  3311. }
  3312. var bPageEnabled = true;
  3313. if (this.preProcessControlArray && this.preProcessControlArray instanceof Array)
  3314. {
  3315. kCount = this.preProcessControlArray.length;
  3316. for (k=0; k<kCount; k++)
  3317. {
  3318. oPromptElement = eval(this.preProcessControlArray[k]);
  3319. if ((typeof oPromptElement.getValid == "function") && !oPromptElement.getValid())
  3320. {
  3321. bPageEnabled = false;
  3322. break;
  3323. }
  3324. }
  3325. }
  3326. this.notifyPageNavEnabled(bPageEnabled);
  3327. if (this.multipleObserverArray && this.multipleObserverArray instanceof Array)
  3328. {
  3329. kCount = this.multipleObserverArray.length;
  3330. for (k=0; k<kCount; k++)
  3331. {
  3332. oPromptElement = eval(this.multipleObserverArray[k]);
  3333. if (oPromptElement && typeof oPromptElement == "object" && typeof oPromptElement.checkInsertRemove == "function")
  3334. {
  3335. oPromptElement.checkInsertRemove();
  3336. }
  3337. }
  3338. }
  3339. for (var idxNotif = 0; idxNotif < gaNotifyTargets.length; idxNotif++)
  3340. {
  3341. var oTarget = gaNotifyTargets[idxNotif];
  3342. if (typeof oTarget != "undefined" && typeof oTarget.notify == "function")
  3343. {
  3344. oTarget.notify(iState, oNotifier);
  3345. }
  3346. }
  3347. };
  3348. /**
  3349. @private
  3350. @param {bool} bEnabled
  3351. */
  3352. CCognosViewer.prototype.notifyPageNavEnabled = function(bEnabled)
  3353. {
  3354. if (this.pageNavigationObserverArray && this.pageNavigationObserverArray instanceof Array)
  3355. {
  3356. var kCount = this.pageNavigationObserverArray.length;
  3357. //determine if there is a finish button on the page, if so we'll disable the next.
  3358. var bFinishPresent = false;
  3359. var oPromptElement = null;
  3360. var iPromptElementType = null;
  3361. var k = 0;
  3362. for (k=0; k<kCount; k++)
  3363. {
  3364. try
  3365. {
  3366. oPromptElement = eval(this.pageNavigationObserverArray[k]);
  3367. iPromptElementType = oPromptElement.getType();
  3368. if (iPromptElementType == PROMPTBUTTON_FINISH)
  3369. {
  3370. bFinishPresent = true;
  3371. break;
  3372. }
  3373. }
  3374. catch(e)
  3375. {
  3376. }
  3377. }
  3378. for (k=0; k<kCount; k++)
  3379. {
  3380. try
  3381. {
  3382. oPromptElement = eval(this.pageNavigationObserverArray[k]);
  3383. iPromptElementType = oPromptElement.getType();
  3384. if (!bEnabled)
  3385. {
  3386. if ((iPromptElementType == PROMPTBUTTON_NEXT) || (iPromptElementType == PROMPTBUTTON_OK) || (iPromptElementType == PROMPTBUTTON_FINISH))
  3387. {
  3388. oPromptElement.setEnabled(false);
  3389. }
  3390. }
  3391. else
  3392. {
  3393. if (iPromptElementType == PROMPTBUTTON_FINISH)
  3394. {
  3395. oPromptElement.setEnabled(this.bCanFinish);
  3396. }
  3397. else if (iPromptElementType == PROMPTBUTTON_NEXT)
  3398. {
  3399. oPromptElement.setEnabled(this.bNextPage || !bFinishPresent);
  3400. }
  3401. else if (iPromptElementType == PROMPTBUTTON_OK)
  3402. {
  3403. oPromptElement.setEnabled(true);
  3404. }
  3405. }
  3406. }
  3407. catch(e2)
  3408. {
  3409. }
  3410. }
  3411. }
  3412. };
  3413. /**
  3414. * If the drilled-on HUN matches the prompt parameter values, the drill needs to be reset.
  3415. * This function returns the drilled-on HUN that matches the prompt parameter value.
  3416. */
  3417. CCognosViewer.prototype.getDrillResetHUNs = function(sharePromptEventPayload)
  3418. {
  3419. var drilledOnHUNs = null;
  3420. if (this.getRAPReportInfo()) {
  3421. drilledOnHUNs = this.getRAPReportInfo().getDrilledOnHUNs();
  3422. }
  3423. if( !drilledOnHUNs ){ return null; }
  3424. var executionParameters = this.getExecutionParameters();
  3425. if( !executionParameters ) { return null; }
  3426. var changedPromptParamsList = this._getListOfChangedPromptParameters(sharePromptEventPayload);
  3427. if (!changedPromptParamsList || changedPromptParamsList.length === 0) {
  3428. return null;
  3429. }
  3430. var aDrillResetHUNs = [];
  3431. for( var i = 0; i < drilledOnHUNs.length; i++ ){
  3432. for (var j =0; j < changedPromptParamsList.length; j++) {
  3433. if( changedPromptParamsList[j].indexOf( drilledOnHUNs[i] ) !== -1 ) {
  3434. aDrillResetHUNs.push( drilledOnHUNs[i] );
  3435. }
  3436. }
  3437. }
  3438. return aDrillResetHUNs;
  3439. };
  3440. CCognosViewer.prototype.getOldParameters = function(){
  3441. var oldParmValues = new CParameterValues();
  3442. var documentNode = XMLBuilderLoadXMLFromString(this.getExecutionParameters());
  3443. if (documentNode.childNodes.length == 1) {
  3444. oldParmValues.loadWithOptions(documentNode.childNodes[0], /*credentials*/false);
  3445. }
  3446. if( !oldParmValues || !oldParmValues.m_parameterValues || !oldParmValues.m_parameterValues.m_aValues){
  3447. return null;
  3448. }
  3449. return oldParmValues.m_parameterValues.m_aValues;
  3450. };
  3451. CCognosViewer.prototype._createDummyRequest = function() {
  3452. var dummyReq = new ViewerDispatcherEntry( this );
  3453. return this.preparePromptValues(dummyReq);
  3454. };
  3455. /**
  3456. * Prompt parameter values are of the format:
  3457. * <selectChoices>
  3458. * <selectBoundRange>...</selectBoundRange>
  3459. * <selectUnboundedEndRange>...</selectUnboundedEndRange>
  3460. * <selectOption>...</selectOption>
  3461. * <selectChoices>
  3462. * However, this function only checks and returns the changed values for <selectOption> (since this function is used to determine if drill reset is necessary)
  3463. *
  3464. */
  3465. CCognosViewer.prototype._getChangedPromptParametersValues = function( oldParmValueItems, newParmValue, changedPromptParamsList ) {
  3466. var documentNode = XMLBuilderLoadXMLFromString( newParmValue );
  3467. if( !documentNode) {
  3468. //Just in case parameter value is non-XML string - not very likely
  3469. for( var j=0; j < oldParmValueItems.length; j++ )
  3470. {
  3471. var oldParmValue = oldParmValueItems[j].m_useValue;
  3472. if( newParmValue.indexOf( sXmlEncode( oldParmValue ) ) < 0 ){
  3473. changedPromptParamsList.push(oldParmValue);
  3474. }
  3475. }
  3476. return;
  3477. }
  3478. var newParameters = documentNode.getElementsByTagName( "selectOption");
  3479. if( !newParameters )
  3480. {
  3481. return;
  3482. }
  3483. var noOfOldParameterValues = oldParmValueItems.length;
  3484. var noOfNewParameterValues = newParameters.length;
  3485. for( var i=0; i < noOfNewParameterValues; i++ )
  3486. {
  3487. var newParmValue = newParameters[i].attributes.getNamedItem("useValue").nodeValue;
  3488. bMatchOldParam = false;
  3489. for( var j=0; j < noOfOldParameterValues; j++ )
  3490. {
  3491. var oldParmValue = oldParmValueItems[j].m_useValue;
  3492. if( newParmValue.indexOf( oldParmValue ) === 0 ){
  3493. bMatchOldParam = true;
  3494. break; // no need to continue
  3495. }
  3496. }
  3497. if( !bMatchOldParam )
  3498. {
  3499. changedPromptParamsList.push( newParmValue )
  3500. }
  3501. }
  3502. };
  3503. CCognosViewer.prototype._getListOfChangedPromptParameters = function(sharePromptEventPayload)
  3504. {
  3505. var oldParameters = this.getOldParameters();
  3506. if( !oldParameters ) { return null; }
  3507. var changedPromptParamsList = [];
  3508. if( !sharePromptEventPayload ){
  3509. var oRequest = this._createDummyRequest();
  3510. for (var oldParm in oldParameters){
  3511. var oldParmValueItems = oldParameters[oldParm].m_parmValueItems;
  3512. var newParmValue = oRequest.getRequest().getFormFields().get('p_' + oldParm);
  3513. if (!newParmValue) { continue; }
  3514. this._getChangedPromptParametersValues(oldParmValueItems, newParmValue, changedPromptParamsList);
  3515. }
  3516. } else {
  3517. if( !sharePromptEventPayload.parameters ){ return null; }
  3518. var newParameters = sharePromptEventPayload.parameters;
  3519. for( var i = 0; i < newParameters.length; i++ ){
  3520. var newParmName = newParameters[i].parmName;
  3521. if( !newParmName || !oldParameters[newParmName] ){ continue; }
  3522. var oldParmValueItems = oldParameters[newParmName].m_parmValueItems;
  3523. if( !oldParmValueItems || oldParmValueItems.length == 0 ){ continue; }
  3524. this._getChangedPromptParametersValues( oldParmValueItems, newParameters[i].parmValue, changedPromptParamsList );
  3525. }
  3526. }
  3527. return changedPromptParamsList;
  3528. };
  3529. /**
  3530. @private
  3531. @param {object} oReq
  3532. */
  3533. CCognosViewer.prototype.submitPromptValues = function(oReq)
  3534. {
  3535. if ( this.gbPromptRequestSubmitted === true )
  3536. {
  3537. return false;
  3538. }
  3539. this.gbPromptRequestSubmitted = true;
  3540. if( this.isBux ) {
  3541. var aDrillResetHUNs = this.getDrillResetHUNs(null/*share prompt event payload*/);
  3542. if(aDrillResetHUNs && aDrillResetHUNs.length !== 0 ){
  3543. var parms = { 'drilledResetHUNs' : aDrillResetHUNs };
  3544. this.executeAction( "DrillReset", parms );
  3545. return;
  3546. }
  3547. }
  3548. oReq = this.preparePromptValues(oReq);
  3549. if (window.portletSharePrompt) {
  3550. var portletPromptParams = this.portletPromptParams(oReq);
  3551. if (portletPromptParams.length > 0) {
  3552. portletSharePrompt(portletPromptParams);
  3553. }
  3554. }
  3555. this.dispatchRequest(oReq);
  3556. };
  3557. /**
  3558. * Prepare parameters to be shared with other portlets
  3559. *
  3560. @private
  3561. @param {object} oReq
  3562. @return (array)
  3563. */
  3564. CCognosViewer.prototype.portletPromptParams = function(oReq) {
  3565. var result = [];
  3566. var requestParam = null;
  3567. var validSharePrompt = true; // false for search or credentials requests
  3568. var aParameters = oReq.getFormFields().keys();
  3569. for (var idxParameter = 0; idxParameter < aParameters.length; idxParameter++) {
  3570. requestParam = aParameters[idxParameter];
  3571. // don't share credential parameters or search request
  3572. if (requestParam == "_promptControl" && oReq.getFormField(requestParam) == "search") {
  3573. validSharePrompt = false;
  3574. break;
  3575. }
  3576. else
  3577. if (requestParam.indexOf("p_") === 0) {
  3578. if (requestParam.indexOf("p_credential") === 0) {
  3579. validSharePrompt = false;
  3580. break;
  3581. }
  3582. else {
  3583. result.push([requestParam, oReq.getFormField(requestParam)]);
  3584. }
  3585. }
  3586. }
  3587. if (result && !validSharePrompt) {
  3588. result = [];
  3589. }
  3590. return result;
  3591. };
  3592. CCognosViewer.prototype.preparePromptValues = function(oReq)
  3593. {
  3594. // Use aInputs to keep track of input fields submitted.
  3595. var aInputSubmitted = [];
  3596. if (this.preProcessControlArray)
  3597. {
  3598. var kCount = this.preProcessControlArray.length;
  3599. var k = 0;
  3600. for (k=0; k<kCount; k++)
  3601. {
  3602. var oPrmtCtrl = eval(this.preProcessControlArray[k]);
  3603. var bPrmtEnabled = (typeof oPrmtCtrl.isEnabled == "function" ? oPrmtCtrl.isEnabled() : true);
  3604. if (oPrmtCtrl && typeof oPrmtCtrl.preProcess == "function" && bPrmtEnabled)
  3605. {
  3606. oPrmtCtrl.preProcess();
  3607. if (oPrmtCtrl.m_oSubmit)
  3608. {
  3609. // Query Studio still passes us the old CCognosViewerRequest object
  3610. if (oReq.addParameter) {
  3611. oReq.addParameter(oPrmtCtrl.m_oSubmit.name, oPrmtCtrl.m_oSubmit.value);
  3612. }
  3613. else {
  3614. oReq.addFormField(oPrmtCtrl.m_oSubmit.name, oPrmtCtrl.m_oSubmit.value);
  3615. }
  3616. aInputSubmitted.push(oPrmtCtrl.m_oSubmit);
  3617. if (oPrmtCtrl.m_sPromptId && oPrmtCtrl.m_oForm && oPrmtCtrl.m_oForm.elements && typeof oPrmtCtrl.m_oForm.elements['p_' + oPrmtCtrl.m_sRef] == "object")
  3618. {
  3619. // we have a promptID based control, add its value separately (ie multiple search controls on the same parameter on the same page).
  3620. if (oReq.addParameter) {
  3621. oReq.addParameter('p_' + oPrmtCtrl.m_sPromptId, oPrmtCtrl.m_oForm.elements['p_' + oPrmtCtrl.m_sRef].value);
  3622. }
  3623. else {
  3624. oReq.addFormField('p_' + oPrmtCtrl.m_sPromptId, oPrmtCtrl.m_oForm.elements['p_' + oPrmtCtrl.m_sRef].value);
  3625. }
  3626. }
  3627. }
  3628. }
  3629. }
  3630. }
  3631. var elFWR = document.getElementById("formWarpRequest" + this.getId());
  3632. if (elFWR)
  3633. {
  3634. var aInputs = elFWR.elements;
  3635. for (var idxInput = 0; idxInput < aInputs.length; idxInput++)
  3636. {
  3637. var elInput = aInputs[idxInput];
  3638. if ( !elInput.name || !elInput.name.match(/^p_/) )
  3639. {
  3640. continue;
  3641. }
  3642. var bToAdd = true;
  3643. for (var idxSubmitted = 0; idxSubmitted < aInputSubmitted.length; idxSubmitted++)
  3644. {
  3645. if (aInputSubmitted[idxSubmitted] == elInput)
  3646. {
  3647. bToAdd = false; break;
  3648. }
  3649. }
  3650. if (bToAdd)
  3651. {
  3652. oReq.addFormField(elInput.name, elInput.value);
  3653. aInputSubmitted.push(elInput);
  3654. }
  3655. }
  3656. }
  3657. var oRM = this['CognosReport'];
  3658. if (oRM)
  3659. {
  3660. var aParams = oRM.prompt.getParameters();
  3661. for (var i = 0; i < aParams.length; i++)
  3662. {
  3663. var sName = "p_" + aParams[i].getName();
  3664. if ( !oReq.getFormField(sName) )
  3665. {
  3666. oReq.addFormField(sName, aParams[i].getXML());
  3667. }
  3668. }
  3669. }
  3670. return oReq;
  3671. };
  3672. CCognosViewer.prototype.setViewerWidget = function( cvWidget )
  3673. {
  3674. this.m_viewerWidget = cvWidget;
  3675. };
  3676. CCognosViewer.prototype.getViewerWidget = function()
  3677. {
  3678. return this.m_viewerWidget;
  3679. };
  3680. CCognosViewer.prototype.getFlashChartOption = function()
  3681. {
  3682. var cvWidget = this.getViewerWidget();
  3683. var flashCharts = null;
  3684. if (cvWidget) {
  3685. var props = cvWidget.getProperties();
  3686. if (props) {
  3687. flashCharts = props.getFlashCharts();
  3688. }
  3689. }
  3690. return flashCharts;
  3691. };
  3692. CCognosViewer.prototype.fireWidgetEvent = function( evt, payload )
  3693. {
  3694. var viewerIWidget = this.getViewerWidget();
  3695. if (viewerIWidget != null) {
  3696. viewerIWidget.fireEvent(evt, null, payload);
  3697. }
  3698. };
  3699. CCognosViewer.prototype.isMobile = function() { return false; };
  3700. /**
  3701. * Set the currently visible modal dialog
  3702. * @param {Object} dialog
  3703. */
  3704. CCognosViewer.prototype.setVisibleDialog = function(dialog) {
  3705. this.m_visibleDialog = dialog;
  3706. };
  3707. /**
  3708. * Get the visible modal dialog (if any)
  3709. */
  3710. CCognosViewer.prototype.getVisibleDialog = function() {
  3711. if (typeof this.m_visibleDialog != "undefined") {
  3712. return this.m_visibleDialog;
  3713. }
  3714. return null;
  3715. };
  3716. CCognosViewer.prototype.getContentLocale = function() {
  3717. var formWarpRequest = document.getElementById("formWarpRequest" + this.getId());
  3718. if (formWarpRequest && formWarpRequest["ui.contentLocale"] && formWarpRequest["reRunObj"] && formWarpRequest["reRunObj"].value.length > 0)
  3719. {
  3720. return formWarpRequest["ui.contentLocale"].value;
  3721. }
  3722. return null;
  3723. };
  3724. /**
  3725. Show/hide header, toolbar based on the current state.
  3726. @private
  3727. @param {string} sState Conversation's state
  3728. */
  3729. CCognosViewer.prototype.updateLayout = function(sState)
  3730. {
  3731. var cvid = this.getId();
  3732. var oHeader = document.getElementById('CVHeader' + cvid);
  3733. var oToolbar = document.getElementById('CVToolbar' + cvid);
  3734. if (!oHeader && !oToolbar)
  3735. {
  3736. setTimeout(getCognosViewerObjectRefAsString(cvid) + '.updateLayout("' + sState + '");', 100);
  3737. return;
  3738. }
  3739. if (oHeader) {
  3740. var hideBannerConfig = this.getUIConfig() && !this.getUIConfig().getShowBanner();
  3741. if ((sState == "prompting" && !this.bShowHeaderWithPrompts) || hideBannerConfig) {
  3742. oHeader.parentNode.style.display = "none";
  3743. }
  3744. else {
  3745. oHeader.parentNode.style.display = "";
  3746. }
  3747. }
  3748. if (oToolbar) {
  3749. if (sState == "prompting" || this.m_bHideToolbar == true) {
  3750. oToolbar.parentNode.style.display = "none";
  3751. }
  3752. else {
  3753. oToolbar.parentNode.style.display = "";
  3754. }
  3755. }
  3756. };
  3757. /**
  3758. Update the state of the response specification.
  3759. @private
  3760. @param {string} sResponseSpecification specification state
  3761. */
  3762. CCognosViewer.prototype.updateResponseSpecification = function(sResponseSpecification)
  3763. {
  3764. this.sResponseSpecification = sResponseSpecification;
  3765. };
  3766. /**
  3767. Returns the response specification if available.
  3768. @private
  3769. @param
  3770. */
  3771. CCognosViewer.prototype.getResponseSpecification = function()
  3772. {
  3773. return this.sResponseSpecification;
  3774. };
  3775. /**
  3776. * Releases the currect conversation. Returns true if release was called, otherwise false
  3777. * @param {Object} callback
  3778. */
  3779. CCognosViewer.prototype.release = function(asynchronous)
  3780. {
  3781. if( this.getStatus() != 'fault' )
  3782. {
  3783. this._release(asynchronous);
  3784. }
  3785. };
  3786. /**
  3787. * Releases the currect conversation. Returns true if release was called, otherwise false
  3788. * @param {Object} callback
  3789. */
  3790. CCognosViewer.prototype._release = function(asynchronous)
  3791. {
  3792. var form = document.getElementById("formWarpRequest" + this.getId());
  3793. var tracking = this.getTracking();
  3794. if(!tracking && form && form["m_tracking"] && form["m_tracking"].value) {
  3795. tracking = form["m_tracking"].value;
  3796. form["m_tracking"].value = "";
  3797. }
  3798. // blank out the tracking so we never do multiple releases for the same tracking
  3799. this.setTracking("");
  3800. if(tracking)
  3801. {
  3802. var request = new DispatcherEntry(this);
  3803. if( this.isWorkingOrPrompting() ) {
  3804. request.addFormField("ui.action", "cancel");
  3805. }
  3806. else {
  3807. request.addFormField("ui.action", "release");
  3808. }
  3809. request.addFormField("cv.responseFormat", "successfulRequest");
  3810. request.addNonEmptyStringFormField("ui.primaryAction", this.envParams["ui.primaryAction"]);
  3811. request.addNonEmptyStringFormField("ui.objectClass", this.envParams["ui.objectClass"]);
  3812. request.addFormField("m_tracking", tracking);
  3813. if (asynchronous != true) {
  3814. request.forceSynchronous();
  3815. }
  3816. // If the current request is using a cv.outputKey then the release
  3817. // request should get load balanced to the same Viewer
  3818. var activeRequest = this.getActiveRequest() ? this.getActiveRequest() : this.getFaultDispatcherEntry();
  3819. if (activeRequest && activeRequest.getFormField("cv.outputKey")) {
  3820. request.addFormField("b_action", "cvx.high");
  3821. request.addFormField("cv.outputKey", activeRequest.getFormField("cv.outputKey"));
  3822. request.addFormField("cv.waitForResponse", "false");
  3823. request.setHeaders(activeRequest.getHeaders());
  3824. }
  3825. // Use a sendBeacon call instead of XMLHttpRequest to avoid timming issues when window is closing.
  3826. var formFields = request.getRequest().getFormFields();
  3827. var formFieldNames = formFields.keys();
  3828. // Use URLSearchParams to force sendBeacon to set the correct content-type header i.e. application/x-www-form-urlencoded
  3829. var data = new URLSearchParams();
  3830. for (var index = 0; index < formFieldNames.length; index++) {
  3831. data.append(formFieldNames[index], formFields.get(formFieldNames[index]));
  3832. }
  3833. if (!navigator.sendBeacon(this.getGateway(), data)) {
  3834. if (typeof console !== "undefined" && console.log) {
  3835. console.log("CCognosViewer: release sendBeacon failed.");
  3836. }
  3837. }
  3838. return true;
  3839. }
  3840. return false;
  3841. };
  3842. CCognosViewer.prototype.cleanupStyles = function() {
  3843. if (this.getViewerWidget()) {
  3844. this.getViewerWidget().cleanupStyles();
  3845. }
  3846. };
  3847. /**
  3848. * Will release the conversation and clean up the Viewer object
  3849. * @param {Object} callback
  3850. */
  3851. CCognosViewer.prototype.destroy = function(asynchronous) {
  3852. this.release(asynchronous);
  3853. if (!this.m_destroyed)
  3854. {
  3855. //cleanup action
  3856. if( typeof window.gaRV_INSTANCES != "undefined") {
  3857. for (var iIndex=0; iIndex < window.gaRV_INSTANCES.length; iIndex++)
  3858. {
  3859. if (window.gaRV_INSTANCES[iIndex].m_sId == this.getId())
  3860. {
  3861. window.gaRV_INSTANCES.splice(iIndex, 1);
  3862. this.m_destroyed = true;
  3863. break;
  3864. }
  3865. }
  3866. }
  3867. if (this.m_layoutElements) {
  3868. for (var i=0; i<this.m_layoutElements.length; i++) {
  3869. var e = this.m_layoutElements[i];
  3870. var j = e.getAttribute("lid");
  3871. this.m_layoutElements.splice(i, 1);
  3872. delete this.m_lidToElement[j];
  3873. var parentNode = e.parentNode;
  3874. if (parentNode) {
  3875. parentNode.removeChild(e);
  3876. }
  3877. }
  3878. delete this.m_layoutElements;
  3879. delete this.m_lidToElement;
  3880. }
  3881. if (this.m_oDrillMgr) {
  3882. this.m_oDrillMgr.setCV(null);
  3883. }
  3884. var selectionController = this.getSelectionController();
  3885. if (selectionController) {
  3886. GUtil.destroyProperties(selectionController);
  3887. }
  3888. var cvId = this.getId();
  3889. this.m_viewerDispatcher = null;
  3890. GUtil.destroyProperties(this, true);
  3891. cleanupGlobalObjects(cvId);
  3892. }
  3893. };
  3894. /**
  3895. * Releases the conversation
  3896. * @param {Object} callback
  3897. */
  3898. CCognosViewer.prototype.exit = function()
  3899. {
  3900. this.release();
  3901. };
  3902. /**
  3903. * Executes a viewer action
  3904. * @param (string) The action to execute (ie. run)
  3905. */
  3906. CCognosViewer.prototype.executeAction = function(sAction, parms )
  3907. {
  3908. var action = this.getAction(sAction);
  3909. action.setRequestParms( parms );
  3910. return action.execute();
  3911. };
  3912. /**
  3913. * Gets a calculation object
  3914. */
  3915. CCognosViewer.prototype.getCalculation = function(sCalculation){
  3916. var calc = null;
  3917. var calcCache = this.getCalculationCache();
  3918. if (calcCache[sCalculation]) {
  3919. calc = calcCache[sCalculation];
  3920. } else {
  3921. if (window[sCalculation] && typeof window[sCalculation] == "function") {
  3922. calc = new window[sCalculation]();
  3923. calc.setCognosViewer(this);
  3924. }
  3925. calcCache[sCalculation] = calc;
  3926. }
  3927. return calc;
  3928. };
  3929. CCognosViewer.prototype.findBlueDotMenu = function(aMenuItems)
  3930. {
  3931. var root = null;
  3932. var items = (aMenuItems) ? aMenuItems : this.getToolbar();
  3933. for(var idx = 0; idx < items.length; ++idx) {
  3934. if (typeof items[idx]._root != "undefined") {
  3935. root = items[idx]._root;
  3936. break;
  3937. }
  3938. }
  3939. return root;
  3940. };
  3941. /**
  3942. * Finds an item in the toolbar. If toolbarSpec is null, it'll search through
  3943. * the top level buttons (i.e. Not the blue dot menu)
  3944. */
  3945. CCognosViewer.prototype.findToolbarItem = function(itemName, toolbarSpec)
  3946. {
  3947. var spec = typeof toolbarSpec == "undefined" || toolbarSpec == null ? this.getToolbar() : toolbarSpec;
  3948. var buttonSpec = null;
  3949. for(var iIndex = 0; iIndex < spec.length; ++iIndex) {
  3950. var name = spec[iIndex]["name"];
  3951. if (typeof name != "undefined" && name == itemName) {
  3952. buttonSpec = spec[iIndex];
  3953. break;
  3954. }
  3955. }
  3956. return buttonSpec;
  3957. };
  3958. /**
  3959. * Finds the index of an item in the toolbar. If toolbarSpec is null, it'll search through
  3960. * the top level buttons (i.e. Not the blue dot menu)
  3961. */
  3962. CCognosViewer.prototype.findToolbarItemIndex = function(itemName, toolbarSpec)
  3963. {
  3964. var spec = typeof toolbarSpec == "undefined" || toolbarSpec == null ? this.getToolbar() : toolbarSpec;
  3965. var buttonIndex = null;
  3966. for(var iIndex = 0; iIndex < spec.length; ++iIndex) {
  3967. var name = spec[iIndex]["name"];
  3968. if (typeof name != "undefined" && name == itemName) {
  3969. buttonIndex = iIndex;
  3970. break;
  3971. }
  3972. }
  3973. return buttonIndex;
  3974. };
  3975. /**
  3976. * Attempt to re-add a button to the toolbar where it originally was.
  3977. * First choice is to place it after the precedingButton if available,
  3978. * otherwise fall back on using the provided buttonLocation.
  3979. * @param A toolbar spec
  3980. * @param The button to add
  3981. * @param (string) The button name that should precede the added button (optional)
  3982. * @param (string) The index to place the button (optional)
  3983. */
  3984. CCognosViewer.prototype.addedButtonToToolbar = function(toolBarSpec, buttonToAdd, precedingButton, buttonLocation)
  3985. {
  3986. if (typeof buttonToAdd != "undefined" && buttonToAdd != null) {
  3987. if (this.findToolbarItem(buttonToAdd.name, toolBarSpec) == null) {
  3988. // first try adding the button after a specific one
  3989. precedingButton = this.findToolbarItemIndex(precedingButton, toolBarSpec);
  3990. if (typeof precedingButton != "undefined" && precedingButton != null) {
  3991. toolBarSpec.splice(++precedingButton, 0, buttonToAdd);
  3992. return true;
  3993. }
  3994. // fallback using an index, hoping it's the correct place to put it
  3995. else if (typeof buttonLocation != "undefined" && buttonLocation != null) {
  3996. toolBarSpec.splice(buttonLocation, 0, buttonToAdd);
  3997. return true;
  3998. }
  3999. }
  4000. }
  4001. return false;
  4002. };
  4003. CCognosViewer.prototype.addDrillTargets = function(drillTargets)
  4004. {
  4005. this.m_drillTargets = drillTargets;
  4006. };
  4007. CCognosViewer.prototype.getDrillTargets = function()
  4008. {
  4009. if (this.m_drillTargets.length == 0 && this.envParams["ui.action"] == "view")
  4010. {
  4011. var iframe = document.getElementById("CVIFrame" + this.getId());
  4012. if (typeof iframe != "undefined" && iframe != null)
  4013. {
  4014. if (iframe.contentWindow.drillTargets)
  4015. {
  4016. return iframe.contentWindow.drillTargets;
  4017. }
  4018. }
  4019. }
  4020. return this.m_drillTargets;
  4021. };
  4022. CCognosViewer.prototype.getDrillTarget = function(idx)
  4023. {
  4024. if(idx >= this.m_drillTargets.length)
  4025. {
  4026. return null;
  4027. }
  4028. return this.m_drillTargets[idx];
  4029. };
  4030. CCognosViewer.prototype.getNumberOfDrillTargets = function()
  4031. {
  4032. return this.m_drillTargets.length;
  4033. };
  4034. CCognosViewer.prototype.isReportRenderingDone = function()
  4035. {
  4036. return this.m_reportRenderingDone;
  4037. };
  4038. CCognosViewer.prototype.setReportRenderingDone = function(flag)
  4039. {
  4040. this.m_reportRenderingDone = flag;
  4041. };
  4042. CCognosViewer.prototype.hasAVSChart = function()
  4043. {
  4044. var oRAPReportInfo = this.getRAPReportInfo();
  4045. if (oRAPReportInfo) {
  4046. var sDisplayTypes = oRAPReportInfo.getDisplayTypes();
  4047. return sDisplayTypes.match("_v2") != null || sDisplayTypes.match("v2_") != null;
  4048. }
  4049. return false;
  4050. };
  4051. /**
  4052. * Accessor for the PinFreezeManager used by this Viewer
  4053. */
  4054. CCognosViewer.prototype.getPinFreezeManager = function() {
  4055. return this.m_pinFreezeManager;
  4056. };
  4057. CCognosViewer.prototype.getReportContextHelper = function() {
  4058. if(!this.m_reportContextHelper) {
  4059. this.m_reportContextHelper = new ReportContextHelper(this.getSelectionController().getCCDManager());
  4060. }
  4061. return this.m_reportContextHelper;
  4062. };
  4063. CCognosViewer.prototype.getRAPReportInfo = function() {
  4064. return this.m_RAPReportInfo;
  4065. };
  4066. CCognosViewer.prototype.setRAPReportInfo = function(oRapReportInfo) {
  4067. this.m_RAPReportInfo = oRapReportInfo;
  4068. };
  4069. /**
  4070. * Return true iff the DOM node is currently available to the user to see.
  4071. */
  4072. CCognosViewer.prototype.isNodeVisible = function(node) {
  4073. if(this.m_pinFreezeManager) {
  4074. return this.m_pinFreezeManager.isNodeVisible(node);
  4075. }
  4076. return true;
  4077. };
  4078. /**
  4079. * Returns the warp request form used by this viewer.
  4080. */
  4081. CCognosViewer.prototype.getWarpRequestForm = function() {
  4082. return document.getElementById("formWarpRequest" + this.getId());
  4083. };
  4084. CCognosViewer.prototype.getBrowser = function() {
  4085. return this.sBrowser;
  4086. };
  4087. /**
  4088. * In IE you sometimes need to 'repaint' a div to make it update. Simple helper function to do that
  4089. */
  4090. CCognosViewer.prototype.repaintDiv = function(oDiv) {
  4091. var display = oDiv.style.display;
  4092. oDiv.style.display = "none";
  4093. oDiv.style.display = display;
  4094. };
  4095. CCognosViewer.prototype.isMetadataEmpty = function () {
  4096. var oSC = this.getSelectionController();
  4097. if (oSC) {
  4098. var oCCDM = oSC.getCCDManager();
  4099. if (oCCDM) {
  4100. return oCCDM.isMetadataEmpty();
  4101. }
  4102. }
  4103. return true;
  4104. };
  4105. CCognosViewer.prototype.setContextMenu = function(contextMenu) {
  4106. this.m_contextMenu = contextMenu;
  4107. };
  4108. CCognosViewer.prototype.getContextMenu = function() {
  4109. return this.m_contextMenu;
  4110. };
  4111. CCognosViewer.prototype.setToolbar = function(toolbar) {
  4112. this.m_toolbar = toolbar;
  4113. };
  4114. CCognosViewer.prototype.getToolbar = function() {
  4115. return this.m_toolbar;
  4116. };
  4117. CCognosViewer.prototype.getAdvancedServerProperty = function(property) {
  4118. if(this.m_advancedProperties && this.m_advancedProperties[property] !== undefined &&
  4119. this.m_advancedProperties[property] !== null) {
  4120. return this.m_advancedProperties[property];
  4121. } else {
  4122. return null;
  4123. }
  4124. };
  4125. /**
  4126. * Returns true if current report has prompts or ambiguous connection info.
  4127. * Checking is done once and the result is saved and reused.
  4128. * The resetbHasPromptFlag function can be called to reset the saved result.
  4129. *
  4130. * If VIEWER_JS_PROMPT_AGAIN_SHOW_ALWAYS advanced server property is set to true, then return true.
  4131. * This is backup switch to go back to old behavior.
  4132. *
  4133. * When a prompt (Required, optional or model based prompts) is applied, evnParams['reportPrompts'] has the information.
  4134. * If 'reportPrompt' in envParams is not empty, then return true.
  4135. * Note that prompt information appears also in execution parameters but this check is more effient.
  4136. *
  4137. * When user selects one from ambiguous commections, the infromation is stored in execution parameters.
  4138. * Note that Slider/Checkbox filter is also saved in execution parameters.
  4139. * Check if execution parameters include ambiguous connection info which parameter name has prefix 'credential:', then return true.
  4140. *
  4141. */
  4142. CCognosViewer.prototype.hasPrompt = function() {
  4143. if (typeof this.m_bHasPrompt === "undefined" || this.m_bHasPrompt === null) {
  4144. var foundPrompt = false;
  4145. if (this.getAdvancedServerProperty("VIEWER_JS_PROMPT_AGAIN_SHOW_ALWAYS") === "true" ||
  4146. (this.envParams.reportPrompts && this.envParams.reportPrompts.length>0 )) {
  4147. foundPrompt = true;
  4148. } else {
  4149. //Check if selection of ambiguous connections is in execution parameter
  4150. var paramValues = new CParameterValues();
  4151. var documentNode = XMLBuilderLoadXMLFromString(this.getExecutionParameters());
  4152. if (documentNode.childNodes.length == 1) {
  4153. paramValues.loadWithOptions(documentNode.childNodes[0], /*credentials*/true);
  4154. var numberOfParameters = paramValues.length();
  4155. for (var index = 0; index < numberOfParameters; ++index) {
  4156. var parameter = paramValues.getAt(index);
  4157. if (parameter !== null && parameter.length() > 0 &&
  4158. parameter.name().indexOf("credential:") != -1) {
  4159. foundPrompt = true;
  4160. break;
  4161. }
  4162. }
  4163. }
  4164. }
  4165. this.m_bHasPrompt = foundPrompt;
  4166. }
  4167. return this.m_bHasPrompt;
  4168. };
  4169. /**
  4170. * PUBLIC API, do not change!
  4171. * Used by ADP to get the stateData from the RSVP response
  4172. */
  4173. CCognosViewer.prototype.getDrillState = function() {
  4174. //PUBLIC API, do not change!
  4175. return this.m_sStateData ? this.m_sStateData : "";
  4176. };
  4177. CCognosViewer.prototype.isSelectionFilterEnabled = function() {
  4178. if (typeof this.m_bSelectionFilterSwitch == "undefined") {
  4179. this.m_bSelectionFilterSwitch = false;
  4180. }
  4181. return this.m_bSelectionFilterSwitch;
  4182. };
  4183. /**
  4184. * PUBLIC API, do not change
  4185. * Used to send a contextChange event
  4186. */
  4187. CCognosViewer.prototype.broadcastContextChange = function(evt, payload) {
  4188. if (this.getViewerWidget()) {
  4189. this.getViewerWidget().broadcastContextChange(payload);
  4190. }
  4191. stopEventBubble(evt);
  4192. };
  4193. /**
  4194. * PUBLIC API, do not change
  4195. * Used to send a contextChanged.prompt event
  4196. */
  4197. CCognosViewer.prototype.broadcastParameterChange = function(evt, payload) {
  4198. if (this.getViewerWidget()) {
  4199. this.getViewerWidget().broadcastParameterChange(payload);
  4200. }
  4201. stopEventBubble(evt);
  4202. };
  4203. /*
  4204. * returns the DIV element that has rendered report
  4205. */
  4206. CCognosViewer.prototype.getReportDiv = function() {
  4207. if (!this.m_nReportDiv) {
  4208. this.m_nReportDiv = document.getElementById("CVReport" + this.m_sId);
  4209. }
  4210. return this.m_nReportDiv;
  4211. };
  4212. /**
  4213. Initialize the CDocumentWriter object.
  4214. @constructor
  4215. @param {string} sId The unqiue id of the anchor tag which is a placholder for the script to execute
  4216. @param {string} sScript The script to be executed
  4217. */
  4218. function CDocumentWriter(sId, sScript)
  4219. {
  4220. this.m_sId = sId;
  4221. this.m_sText = "";
  4222. this.m_sScript = sScript;
  4223. }
  4224. /**
  4225. * Determines if the document writer can handle the embedded script successfully.
  4226. * @return (boolean)
  4227. */
  4228. CDocumentWriter.prototype.isValid = function()
  4229. {
  4230. if(typeof this.m_sScript != "undefined" && this.m_sScript && window.gScriptLoader)
  4231. {
  4232. //Previously, there was a check that m_sScript contained <script> and </script>
  4233. //tags, but now that the code is extracted directly from the DOM, tags are not
  4234. //included in the script string.
  4235. return true;
  4236. }
  4237. return false;
  4238. };
  4239. /**
  4240. * Executes the inline script. This method will return false if an error occurs
  4241. * @return (boolean)
  4242. */
  4243. CDocumentWriter.prototype.execute = function()
  4244. {
  4245. if(this.isValid() && window.gScriptLoader)
  4246. {
  4247. var reDocumentWrite = /document\.write(ln)?\s*\(/gi;
  4248. var sScript = this.m_sScript.replace(reDocumentWrite, "this.write(").replace(window.gScriptLoader.m_reScriptTagOpen, "").replace(window.gScriptLoader.m_reScriptTagClose, "");
  4249. try
  4250. {
  4251. eval(sScript);
  4252. var placeHolderNode = document.getElementById(this.m_sId);
  4253. if(placeHolderNode)
  4254. {
  4255. placeHolderNode.innerHTML = this.m_sText;
  4256. return true;
  4257. }
  4258. }
  4259. catch(e){}
  4260. }
  4261. return false;
  4262. };
  4263. /**
  4264. * Builds a string and caches it locally to be inserted later on during execution
  4265. */
  4266. CDocumentWriter.prototype.write = function(oArgument)
  4267. {
  4268. var sResult = "";
  4269. if(typeof oArgument == "function")
  4270. {
  4271. sResult = eval(oArgument);
  4272. }
  4273. else if(typeof oArgument == "string")
  4274. {
  4275. sResult = oArgument;
  4276. }
  4277. this.m_sText += sResult;
  4278. };
  4279. /**
  4280. * Finds the first node under the container with a tabIndex of 0 and sets the focus to it. Note, we can't use dijit._getTabNavigable here
  4281. * since it's pretty expensive for large reports since it'll loop through ALL the elements. All we need to do is find the first one
  4282. * which is usually within the first 10 elements we try.
  4283. * @param {Object} container
  4284. */
  4285. function setFocusToFirstTabItem(container) {
  4286. if (!window.dojo) {
  4287. return;
  4288. }
  4289. var arrNodes = dojo.query("*", container);
  4290. var nodesLen = arrNodes.length;
  4291. for (var i = 0; i < nodesLen; i++) {
  4292. var node = arrNodes[i];
  4293. // skip any hidden nodes
  4294. if (!node.style || (node.style.display != "none" && node.style.visibility != "hidden")) {
  4295. if (node.getAttribute("tabIndex") == 0) {
  4296. try {
  4297. node.focus();
  4298. }
  4299. catch (e) {
  4300. // IE 8 sometimes throws an exception if the node isn't fully initialized.
  4301. }
  4302. break;
  4303. }
  4304. }
  4305. }
  4306. }
  4307. function ReportContextHelper(oCDManager) {
  4308. this.m_oCDManager = oCDManager;
  4309. }
  4310. ReportContextHelper.prototype.destroy = function() {
  4311. if (this.m_oCDManager && this.m_oCDManager.destroy) {
  4312. this.m_oCDManager.destroy();
  4313. }
  4314. delete this.m_oCDManager;
  4315. };
  4316. /**
  4317. * Splits a context string into arrays of individual context values.
  4318. * For example:
  4319. * * "9" returns [["9"]]
  4320. * * "9::8::7" returns [["9"],["8"],["7"]]
  4321. * * "9::8:7::3:2" returns [["9"],["8","7"],["3","2"]]
  4322. * sCtx must be a string.
  4323. */
  4324. ReportContextHelper.prototype.processCtx = function(sCtx) {
  4325. var aContextIds0 = sCtx.split("::");
  4326. var aContextIds1 = [];
  4327. for(var i = 0; i < aContextIds0.length; ++i) {
  4328. aContextIds1[i] = aContextIds0[i].split(":");
  4329. }
  4330. if(aContextIds1 && aContextIds1.length && aContextIds1[0].length) {
  4331. return aContextIds1;
  4332. } else {
  4333. return null;
  4334. }
  4335. };
  4336. /**
  4337. * Retrieves the data item from the context.
  4338. * sCtx must be a string with a context value or id.
  4339. */
  4340. ReportContextHelper.prototype.getDataItemName = function(sCtx) {
  4341. var aRefDataItem = this.processCtx(sCtx);
  4342. if (aRefDataItem) {
  4343. return this.getRefDataItem(aRefDataItem[0][0]);
  4344. }
  4345. return null;
  4346. };
  4347. ReportContextHelper.prototype.getRefDataItem = function(sCtxId) {
  4348. var sRefDataItem = this.m_oCDManager.GetRDIValue(sCtxId);
  4349. return (sRefDataItem == null) ? "" : sRefDataItem;
  4350. };
  4351. /**
  4352. * Gets the Member Unique Name from a context string or id.
  4353. * oParam can be:
  4354. * * a string - either a :: delimited ctx string, such as "9::8:7::3:2",
  4355. * or a single context id, such as "9"
  4356. * * a number - a single context id, such as 9
  4357. * * an already-processed string in an array, such as [["9"],["8","7"],["3","2"]]
  4358. * Returns "" if no MUN is found.
  4359. */
  4360. ReportContextHelper.prototype.getMun = function(oParam)
  4361. {
  4362. var aCtx = null;
  4363. if(typeof oParam === "string") {
  4364. aCtx = this.processCtx(oParam);
  4365. } else if(typeof oParam === "number") {
  4366. aCtx = this.processCtx(oParam.toString());
  4367. } else {
  4368. aCtx = oParam;
  4369. }
  4370. if (aCtx) {
  4371. var sMun = this.m_oCDManager.GetMUN(aCtx[0][0]);
  4372. return (sMun == null) ? "" : sMun;
  4373. }
  4374. return "";
  4375. };