promptengine_prompts2.js 76 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375
  1. /* Copyright (c) Business Objects 2006. All rights reserved. */
  2. var PE_VALUE_DESC_SEPARATOR = ' - ';
  3. if(typeof(_pe) == 'undefined') {
  4. _pe = new function()
  5. {
  6. var o=this
  7. o._ie=(document.all!=null)?true:false
  8. o._dom=(document.getElementById!=null)?true:false
  9. o._isQuirksMode = (document.compatMode != 'CSS1Compat');
  10. o._moz=o._dom&&!o._ie
  11. o._appVer=navigator.appVersion.toLowerCase();
  12. o._mac=(o._appVer.indexOf('macintosh')>=0)||(o._appVer.indexOf('macos')>=0);
  13. o._userAgent=navigator.userAgent?navigator.userAgent.toLowerCase():null
  14. o._saf=o._moz&&(o._userAgent.indexOf("safari")>=0)
  15. o._ie6=o._ie&&(o._appVer.indexOf("msie 6")>=0)
  16. o._root = ''
  17. o._images= o._root + '/images/'
  18. // prompt section
  19. o._prompts=new Array
  20. o._lovBS=1000
  21. o._st='s'
  22. o._nm='n'
  23. o._cy='c'
  24. o._bo='b'
  25. o._da='d'
  26. o._tm='t'
  27. o._dt='dt'
  28. _BlockWaitWidgetID = "PEBlockWidgetID"
  29. // dialog secion
  30. o._theLYR=null
  31. o._dlgResize=null
  32. o._widgets=new Array
  33. o.DlgBox_modals=new Array;
  34. o.DlgBox_instances=new Array
  35. o.DlgBox_current=null
  36. o._show='visible'
  37. o._hide='hidden'
  38. o._hand=o._ie?"hand":"pointer"
  39. // functions
  40. o.init=PE_init
  41. o.canSubmit=PE_canSubmit
  42. o.beginBlocking=PE_beginBlocking
  43. o.endBlocking=PE_endBlocking
  44. // commands
  45. o.setLOVMsg=PE_setLOVMsg
  46. }
  47. }
  48. function PE_init(root,lovBS)
  49. {
  50. var o=this
  51. if (root && root.length > 0)
  52. {
  53. if (root.charAt(root.length - 1)!='/') root += '/'
  54. o._root = root
  55. o._images = root + 'images/'
  56. }
  57. else
  58. {
  59. o._root = null
  60. o._images = null
  61. }
  62. if(lovBS>0) o._lovBS=lovBS
  63. }
  64. function PE_canSubmit()
  65. {
  66. return (this.DlgBox_current) ? false : true
  67. }
  68. /*
  69. Commands:
  70. cmd=lov (get values from the active prompt)
  71. ap(active prompt id)
  72. */
  73. function PE_setLOVMsg(form,vid,pid)
  74. {
  75. var fl=document.getElementById(vid);
  76. var fv=fl.value;
  77. if (fv.length > 0) fv += "&";
  78. fv += "cmd=1&ap" + "=" + pid;
  79. fl.value=fv
  80. }
  81. var DateTimeFormatSetting = {
  82. "datePattern":"Y-M-D",
  83. "isTwoDigitMonth":true,
  84. "isTwoDigitDay":true,
  85. "dateRegex":null,
  86. "dateTimeRegex":null
  87. };
  88. ///////////////////////////////
  89. // functions for DateTimeFormatSetting
  90. function promptengine_getDatePattern()
  91. {
  92. return DateTimeFormatSetting.datePattern;
  93. }
  94. function promptengine_setDatePattern(pattern)
  95. {
  96. DateTimeFormatSetting.datePattern = pattern;
  97. }
  98. function promptengine_getIsTwoDigitMonth()
  99. {
  100. return DateTimeFormatSetting.isTwoDigitMonth;
  101. }
  102. function promptengine_setIsTwoDigitMonth(isTwoDigitMonth)
  103. {
  104. DateTimeFormatSetting.isTwoDigitMonth = isTwoDigitMonth;
  105. }
  106. function promptengine_getIsTwoDigitDay()
  107. {
  108. return DateTimeFormatSetting.isTwoDigitDay;
  109. }
  110. function promptengine_setIsTwoDigitDay(isTwoDigitDay)
  111. {
  112. DateTimeFormatSetting.isTwoDigitDay = isTwoDigitDay;
  113. }
  114. function promptengine_getDateRegex()
  115. {
  116. return DateTimeFormatSetting.dateRegex;
  117. }
  118. function promptengine_setDateRegex(dateRegex)
  119. {
  120. DateTimeFormatSetting.dateRegex = dateRegex;
  121. }
  122. function promptengine_getDateTimeRegex()
  123. {
  124. return DateTimeFormatSetting.dateTineRegex;
  125. }
  126. function promptengine_setDateTimeRegex(dateTineRegex)
  127. {
  128. DateTimeFormatSetting.dateTineRegex = dateTineRegex;
  129. }
  130. ////////////////////////////////////////////
  131. // helper functions duplicate in dhtml lib
  132. function _convStr(s,nbsp,br)
  133. {
  134. s=''+s
  135. var ret=s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")
  136. if (nbsp)
  137. ret=ret.replace(/ /g,"&nbsp;")
  138. if (br)
  139. ret=ret.replace(/\n/g,"<br>")
  140. return ret
  141. }
  142. function _opt(val,txt,sel)
  143. {
  144. return '<option value="'+_convStr(val)+'" '+(sel?'selected':'')+'>'+_convStr(txt)+'</option>'
  145. }
  146. function _canScanFrames(w)
  147. {
  148. var ex=true,d=null
  149. if (_pe._moz)
  150. {
  151. _oldErrHandler=window.onerror
  152. window.onerror=localErrHandler
  153. }
  154. try
  155. {
  156. d=w.document
  157. ex=false
  158. }
  159. catch(expt)
  160. {
  161. }
  162. if (_pe._moz)
  163. window.onerror=_oldErrHandler
  164. return (!ex&&(d!=null))
  165. }
  166. function _restoreAllDisabledInputs(win,level)
  167. {
  168. if (_pe._ie&&window._peInputStackLevel!=null)
  169. {
  170. win=win?win:window
  171. if (_canScanFrames(win))
  172. {
  173. if (level==null)
  174. level=--window._peInputStackLevel
  175. var b=win.document.body,arr=b?b.getElementsByTagName("SELECT"):null,len=arr?arr.length:0
  176. for (var i=0;i<len;i++)
  177. {
  178. var inpt=arr[i]
  179. if (inpt._peDisableLevel==level)
  180. {
  181. inpt.disabled=false
  182. inpt._peDisableLevel=null
  183. }
  184. }
  185. var frames=win.frames,flen=frames.length
  186. for (var k=0;k<flen;k++)
  187. _restoreAllDisabledInputs(frames[k],level)
  188. }
  189. }
  190. }
  191. function _disableAllInputs(x,y,w,h,win,level)
  192. {
  193. if (_pe._ie)
  194. {
  195. win=win?win:window
  196. if (_canScanFrames(win))
  197. {
  198. var b=win.document.body,arr=b?b.getElementsByTagName("SELECT"):null,len=arr?arr.length:0
  199. if (level==null)
  200. {
  201. if (window._peInputStackLevel==null)
  202. window._peInputStackLevel=0
  203. level=window._peInputStackLevel++
  204. }
  205. for (var i=0;i<len;i++)
  206. {
  207. var inpt=arr[i]
  208. var inter=(x==null)||_isLayerIntersectRect(inpt,x,y,w,h)
  209. if (!inpt.disabled&&inter)
  210. {
  211. inpt._peDisableLevel=level
  212. inpt.disabled=true
  213. }
  214. }
  215. var frames=win.frames,flen=frames.length
  216. for (var k=0;k<flen;k++)
  217. _disableAllInputs(null,null,null,null,frames[k],level)
  218. }
  219. }
  220. }
  221. function _getBGIframe(id)
  222. {
  223. return '<iframe id="'+id+'" style="display:none;left:0px;position:absolute;top:0px" src="' + _pe._images + 'transp.gif' + '" frameBorder="0" scrolling="no"></iframe>'
  224. }
  225. function _eventCancelBubble(e,win)
  226. {
  227. win=win?win:window
  228. _pe._ie?win.event.cancelBubble=true:e.cancelBubble=true
  229. }
  230. function _append(e,s)
  231. {
  232. if (_pe._ie)
  233. e.insertAdjacentHTML("BeforeEnd",s)
  234. else
  235. {
  236. var curDoc = document
  237. var r=curDoc.createRange()
  238. r.setStartBefore(e)
  239. var frag=r.createContextualFragment(s)
  240. e.appendChild(frag)
  241. }
  242. }
  243. function _targetApp(s)
  244. {
  245. _append(document.body,s)
  246. }
  247. function _isLayerIntersectRect(l,x1,y1,w,h)
  248. {
  249. var xl1=_getPos(l).x,yl1=_getPos(l).y,xl2=xl1+l.offsetWidth,yl2=yl1+l.offsetHeight,x2=x1+w,y2=y1+h
  250. return ((x1>xl1)||(x2>xl1))&&((x1<xl2)||(x2<xl2)) && ((y1>yl1)||(y2>yl1))&&((y1<yl2)||(y2<yl2))
  251. }
  252. function _getPos(el,relTo)
  253. {
  254. relTo = relTo?relTo:null
  255. for (var lx=0,ly=0;(el!=null)&&(el!=relTo);
  256. lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);
  257. return {x:lx,y:ly}
  258. }
  259. function _getLayer(id)
  260. {
  261. return document.getElementById(id)
  262. }
  263. function _getWidget(layer)
  264. {
  265. if (layer==null)
  266. return null
  267. var w=layer._widget
  268. if (w!=null)
  269. return _pe._widgets[w]
  270. else
  271. return _getWidget(layer.parentNode)
  272. }
  273. function _isHidden(lyr)
  274. {
  275. if ((lyr==null)||(lyr.tagName=="BODY")) return false;var sty=lyr.style;if ((sty==null)||(sty.visibility==_pe._hide)||(sty.display=='none')) return true;return _isHidden(lyr.parentNode)
  276. }
  277. function _attr(key,val)
  278. {
  279. return (val!=null?' '+key+'="'+val+'" ':'')
  280. }
  281. function _img(src,w,h,align,att,alt)
  282. {
  283. att=(att?att:'')
  284. if (alt==null) alt=''
  285. return '<img'+_attr('width',w)+_attr('height',h)+_attr('src', src)+_attr(_pe._ie?'alt':'title',alt)+_attr("align", align)+' border="0" hspace="0" vspace="0" '+(att?att:'')+'>'
  286. }
  287. function _imgOffset(url,w,h,dx,dy,id,att,alt,st,align)
  288. {
  289. return _img(_pe._images+'transp.gif',w,h,align,
  290. (att?att:'') +' '+_attr('id',id)+' style="'+_backImgOffset(url,dx,dy)+(st?st:'')+'"',
  291. alt)
  292. }
  293. function _changeOffset(lyr,dx,dy,url,alt)
  294. {
  295. var st=lyr.style
  296. if (st)
  297. {
  298. if ((dx!=null)&&(dy!=null))
  299. st.backgroundPosition=''+(-dx)+'px '+(-dy)+'px'
  300. if (url)
  301. st.backgroundImage='url(\''+url+'\')'
  302. }
  303. if(alt) lyr.alt=alt
  304. }
  305. function _simpleImgOffset(url,w,h,dx,dy,id,att,alt,st,align)
  306. {
  307. if (_pe._ie)
  308. {
  309. if (dx==null) dx=0
  310. if (dy==null) dy=0
  311. return '<div '+(att?att:'')+' '+_attr("id",id)+' style="position:relative;padding:0px;width:'+w+'px;height:'+h+'px;overflow:hidden;'+(st?st:'')+'">'+_img(url,null,null,'top','style="margin:0px;position:relative;top:'+(-dy)+'px;left:'+(-dx)+'px"',alt)+'</div>'
  312. }
  313. else
  314. return _imgOffset(url,w,h,dx,dy,id,att,alt,st,align)
  315. }
  316. function _changeSimpleOffset(lyr,dx,dy,url,alt)
  317. {
  318. if (_pe._ie)
  319. {
  320. lyr=lyr.childNodes[0]
  321. var st=lyr.style
  322. if ((url!=null)&&(url!=lyr.src))
  323. lyr.src=url
  324. if (dx!=null)
  325. st.left=""+(-dx)+"px"
  326. if (dy!=null)
  327. st.top=""+(-dy)+"px"
  328. if (alt!=null)
  329. lyr.alt=alt
  330. }
  331. else
  332. _changeOffset(lyr,dx,dy,url,alt)
  333. }
  334. function _backImgOffset(url,dx,dy)
  335. {
  336. return 'background-image:url(\''+url+'\');background-position:'+(-dx)+'px '+(-dy)+'px;'
  337. }
  338. function _sty(key,val)
  339. {
  340. return (val!=null?key+':'+val+';' :'')
  341. }
  342. function _getSpace(w,h)
  343. {
  344. return '<table height="'+h+'" border="0" cellspacing="0" cellpadding="0"><tr><td>'+_img(_pe._images+'transp.gif',w,h)+'</td></tr></table>'
  345. }
  346. function _isTextInput(ev)
  347. {
  348. var source = _pe._ie?ev.srcElement:ev.target;
  349. var isText=false;
  350. if(source.tagName=="TEXTAREA")
  351. isText=true
  352. if((source.tagName=="INPUT") && (source.type.toLowerCase()=="text"))
  353. isText=true
  354. return isText;
  355. }
  356. function _documentWidth(win)
  357. // Gets the document(page) width
  358. // return [int]
  359. {
  360. var win=win?win:window;
  361. var width = Math.max(document.body.clientWidth,document.documentElement.clientWidth);
  362. width = Math.max(width,document.body.scrollWidth);
  363. return width;
  364. }
  365. function _documentHeight(win)
  366. // Gets the document(page) width
  367. // return [int]
  368. {
  369. var win=win?win:window;
  370. var height = Math.max(document.body.clientHeight,document.documentElement.clientHeight);
  371. height = Math.max(height,document.body.scrollHeight);
  372. return height;
  373. }
  374. function _winWidth(win)
  375. {
  376. var win=win?win:window
  377. var width;
  378. if(_pe._ie)
  379. {
  380. if(_pe._isQuirksMode)
  381. {
  382. width = win.document.body.clientWidth;
  383. }
  384. else
  385. {
  386. width = win.document.documentElement.clientWidth;
  387. }
  388. }
  389. else
  390. {
  391. width = win.innerWidth;
  392. }
  393. return width;
  394. }
  395. function _winHeight(win)
  396. {
  397. var win=win?win:window;
  398. var height;
  399. if(_pe._ie)
  400. {
  401. if(_pe._isQuirksMode)
  402. {
  403. height = document.body.clientHeight;
  404. }
  405. else
  406. {
  407. height = document.documentElement.clientHeight;
  408. }
  409. }
  410. else
  411. {
  412. height = win.innerHeight;
  413. }
  414. return height;
  415. }
  416. function _getScrollX(win)
  417. {
  418. var scrollLeft = 0;
  419. var win=win?win:window;
  420. if(typeof(win.scrollX ) == 'number') {
  421. scrollLeft = win.scrollX;
  422. }
  423. else {
  424. scrollLeft = Math.max(win.document.body.scrollLeft,win.document.documentElement.scrollLeft);
  425. }
  426. return scrollLeft;
  427. }
  428. function _getScrollY(win)
  429. {
  430. var scrollTop = 0;
  431. var win=win?win:window;
  432. if(typeof(win.scrollY ) == 'number') {
  433. scrollTop = window.scrollY;
  434. }
  435. else {
  436. scrollTop = Math.max(win.document.body.scrollTop,win.document.documentElement.scrollTop);
  437. }
  438. return scrollTop;
  439. }
  440. function _eventGetX(e)
  441. {
  442. return _pe._ie?window.event.clientX: e.clientX ? e.clientX : e.pageX;
  443. }
  444. function _eventGetY(e)
  445. {
  446. return _pe._ie?window.event.clientY: e.clientY ? e.clientY : e.pageY;
  447. }
  448. function _eventGetKey(e,win)
  449. {
  450. win=win?win:window
  451. return _pe._ie?win.event.keyCode:e.keyCode
  452. }
  453. function _isLayerDisplayed(lyr)
  454. {
  455. var css=lyr?lyr.style:null
  456. if(css)
  457. {
  458. if(css.display == "none" || css.visibility=="hidden")
  459. return false
  460. else
  461. {
  462. var par=lyr.parentNode
  463. if(par!=null)
  464. return _isLayerDisplayed(par)
  465. else
  466. return true
  467. }
  468. }
  469. else
  470. return true;
  471. }
  472. function _safeSetFocus(lyr)
  473. {
  474. if (lyr && lyr.focus && _isLayerDisplayed(lyr) && !lyr.disabled)
  475. lyr.focus()
  476. }
  477. /////////////////////////
  478. // Select Object Helper
  479. function PE_getLB(lyr)
  480. {
  481. var o=new Object
  482. o.lyr=lyr
  483. o.arr=new Array
  484. o.size=0
  485. o.add=LB_add
  486. o.update=LB_update
  487. return o
  488. }
  489. function LB_add(val,txt,sel)
  490. {
  491. var o=this
  492. o.arr[++o.size]=_opt(val,txt,sel)
  493. }
  494. function LB_update()
  495. {
  496. var o=this
  497. var a=o.arr
  498. if (!o.lyr) return
  499. var parent=o.lyr.parentNode
  500. var oldHTML=parent.innerHTML
  501. var bpos=oldHTML.indexOf('>')
  502. if (bpos == -1) return
  503. var epos=oldHTML.lastIndexOf('<')
  504. if (epos <= bpos) return
  505. a[0]=oldHTML.substring(0,bpos+1)
  506. a[o.size+1]=oldHTML.substr(epos)
  507. parent.innerHTML=a.join('')
  508. }
  509. //////////////////////////
  510. // Prompting Unit
  511. function newUnits(num,idh)
  512. {
  513. var o=new Object
  514. o.parr=new Array
  515. if(idh) o.idh=idh
  516. else o.idh=''
  517. o.num=num
  518. o.init=Units_init
  519. o.show=Units_show
  520. o.toggle=Units_toggle
  521. o.updateForm=Units_updateForm
  522. o.activate=Units_activate
  523. o.addP=Units_addP
  524. return o
  525. }
  526. function Units_init(uid)
  527. {
  528. var o=this
  529. o.toggle(uid)
  530. }
  531. function Units_show(uid,b)
  532. {
  533. var o=this
  534. var l=document.getElementById(o.idh+uid+'_PU')
  535. if (l)
  536. {
  537. var css=l.style
  538. if(b)
  539. css.display=''
  540. else
  541. css.display='none'
  542. }
  543. }
  544. function Units_activate(uid)
  545. {
  546. var o=this
  547. var l=document.getElementById(o.idh+uid+'_PU')
  548. if (l)
  549. {
  550. var scrY=_getScrollY(),scrX=_getScrollX()
  551. var h=l.offsetHeight, winCY=_winHeight(),y=_getPos(l).y
  552. if (y<scrY) window.scrollTo(scrX, y)
  553. else if (y+h>scrY+winCY) window.scrollTo(scrX, Math.max(y,y+h-winCY))
  554. }
  555. }
  556. function Units_toggle(uid)
  557. {
  558. var o=this,c=o.num
  559. for(var i=0;i<c;i++)
  560. o.show(i,true)
  561. o.activate(uid)
  562. }
  563. /*
  564. function Units_toggle(uid)
  565. {
  566. var o=this,c=o.num
  567. for(var i=0;i<c;i++)
  568. o.show(i,((i==uid)?true:false))
  569. }
  570. */
  571. function Units_addP(p)
  572. {
  573. var o=this
  574. var parr=o.parr
  575. parr[parr.length]=p
  576. }
  577. function Units_updateForm(form,vid,chk)
  578. {
  579. var o=this,parr=o.parr
  580. for(var i in parr)
  581. {
  582. var p=parr[i]
  583. if(p)
  584. {
  585. if (!p.updateForm(form,vid,chk))
  586. {
  587. o.toggle(p.uid)
  588. return false
  589. }
  590. }
  591. }
  592. return true
  593. }
  594. ///////////////////////////////////////////////////
  595. // Prompt Object
  596. function P_updateForm(form,vid,chk)
  597. {
  598. var o=this, b=false
  599. if(o.readonly==true) return true
  600. if(o.mul) b=promptengine_updateMultiValue(form, vid, o.id, o.vt, chk, o.valueRequired)
  601. else if(o.rn) b=promptengine_updateRangeValue(form, vid, o.id, o.vt, chk, o.valueRequired)
  602. else b=promptengine_updateDiscreteValue(form, vid, o.id, o.vt, chk, o.valueRequired)
  603. return b
  604. }
  605. function P_addV(v,d)
  606. {
  607. var o=this
  608. if(o.vl==null)
  609. {
  610. o.vl=new Array
  611. if (d)
  612. o.dl=new Array
  613. }
  614. var len=o.vl.length
  615. o.vl[len]=v
  616. if(o.dl)
  617. o.dl[len]=d
  618. }
  619. function P_findBatch(wty,tv)
  620. {
  621. if(!tv) return(-1)
  622. var o=this
  623. var vl=o.vl
  624. if(wty)
  625. {
  626. var lov=o.lov[wty]
  627. if(lov && lov.vl) vl=lov.vl
  628. }
  629. if(vl)
  630. {
  631. for(var i in vl)
  632. {
  633. var v=vl[i]
  634. if(v && v==tv) return(Math.floor(i/_pe._lovBS))
  635. }
  636. }
  637. return(-1)
  638. }
  639. function P_updateLOVNB(wty,b)
  640. {
  641. // b - if need to refresh batch list
  642. var o=this
  643. var pid=o.id
  644. var nav=document.getElementById(pid+wty+'Batch')
  645. if(!nav) return
  646. var lov=o.lov[wty]
  647. if(b)
  648. {
  649. var opts=nav.options
  650. opts.length=0
  651. var vl=o.vl, i=0
  652. if(lov.vl) vl=lov.vl
  653. var len=Math.ceil(vl.length/_pe._lovBS)
  654. while(i<len)
  655. {
  656. var d=i+1
  657. if(lov.sidx==i) d +='*'
  658. opts[opts.length]=new Option(d,i,false,false)
  659. i++
  660. }
  661. }
  662. if (lov.bidx>=0) nav.selectedIndex=lov.bidx
  663. }
  664. function P_updateLOV(wty,bi)
  665. {
  666. var o=this
  667. var pid=o.id
  668. var wid=pid+wty
  669. var l=document.getElementById(wid)
  670. if (!l) return
  671. var lov=o.lov[wty]
  672. var sel=null
  673. var vl=o.vl
  674. var dl=o.dl
  675. var si=-1
  676. if(lov)
  677. {
  678. sel=lov.sel
  679. if (lov.vl)
  680. {
  681. vl=lov.vl
  682. dl=lov.dl
  683. }
  684. }
  685. var lbCtl=PE_getLB(l)
  686. if(bi) lbCtl.add('','...')
  687. var sidx=lov.sidx
  688. if (lov.bidx<0) {
  689. lov.sidx=o.findBatch(wty,sel)
  690. if(lov.sidx>=0) lov.bidx=lov.sidx
  691. else lov.bidx=0
  692. sidx=-2
  693. }
  694. var bidx=lov.bidx
  695. var i=bidx*_pe._lovBS, len=vl.length, j=0
  696. while (i<len)
  697. {
  698. if(j >= _pe._lovBS) break;
  699. var v=vl[i]
  700. var d=null
  701. if (dl)
  702. {
  703. d=dl[i]
  704. if(d=='') d=v
  705. else if(o.dop==0) d=v+PE_VALUE_DESC_SEPARATOR+d
  706. }
  707. else d=v
  708. if (sel && sel==v)
  709. {
  710. si=j
  711. o.sidx=bidx
  712. }
  713. lbCtl.add(v,d)
  714. i++
  715. j++
  716. }
  717. lbCtl.update()
  718. l = document.getElementById(wid)
  719. if(si!=-1)
  720. {
  721. if(bi) si++
  722. l.selectedIndex=si
  723. }
  724. o.updateLOVNB(wty, sidx!=lov.sidx)
  725. }
  726. function P_getDesc(v)
  727. {
  728. if(!v) return null
  729. var o=this
  730. var vl=o.vl
  731. var dl=o.dl
  732. if(!dl) return null
  733. // stop searching description when the list is too long.
  734. // if (vl.length>1000) return null
  735. var j=-1
  736. for(var i in vl) if(vl[i]==v) {j=i; break;}
  737. if(j>=0) return dl[j]
  738. return null
  739. }
  740. function P_updateSLOV()
  741. {
  742. // NOTE:
  743. // This function can only be called in the beginning.
  744. // Selection object will not updated with user actions.
  745. var o=this
  746. var pid=o.id
  747. var lyr=document.getElementById(pid+'ListBox')
  748. if(!lyr) return
  749. var sel=o.sl
  750. if (typeof(sel)!='object') return
  751. var lbCtl=PE_getLB(lyr)
  752. var vl=o.vl
  753. var dl=o.dl
  754. for (var i in sel)
  755. {
  756. var v=sel[i]
  757. if (typeof(v)=='string')
  758. {
  759. var d=o.getDesc(v)
  760. var txt
  761. if(d && d!='')
  762. {
  763. if(o.dop) txt=d
  764. else txt=v+PE_VALUE_DESC_SEPARATOR+d
  765. }
  766. else txt=v
  767. lbCtl.add(v,txt,false)
  768. }
  769. else
  770. {
  771. var lo=v.l
  772. var up=v.u
  773. var lt=v.lt
  774. var ut=v.ut
  775. var val=null
  776. var txt=null
  777. if (lt==0 || lt==1)
  778. {
  779. val='('
  780. txt='('
  781. }
  782. else
  783. {
  784. val='['
  785. txt='['
  786. }
  787. if (lt)
  788. {
  789. val+=lo
  790. var d=o.getDesc(lo)
  791. if(d && d!='')
  792. {
  793. if(o.dop) txt+=d
  794. else txt+=lo+PE_VALUE_DESC_SEPARATOR+d
  795. }
  796. else txt+=lo
  797. }
  798. val+='_crRANGE_'
  799. txt+=' .. '
  800. if (ut)
  801. {
  802. val+=up
  803. var d=o.getDesc(up)
  804. if(d && d!='')
  805. {
  806. if(o.dop) txt+=d
  807. else txt+=up+PE_VALUE_DESC_SEPARATOR+d
  808. }
  809. else txt+=up
  810. }
  811. if (ut==0 || ut==1)
  812. {
  813. val+=')'
  814. txt+=')'
  815. }
  816. else
  817. {
  818. val+=']'
  819. txt+=']'
  820. }
  821. lbCtl.add(val,txt,false)
  822. }
  823. }
  824. lbCtl.update()
  825. }
  826. function P_update(wty)
  827. {
  828. var o=this
  829. if (wty)
  830. {
  831. if(wty=='AvailableList') o.updateLOV(wty)
  832. else if(wty=='ListBox') o.updateSLOV()
  833. else o.updateLOV(wty,true)
  834. }
  835. else
  836. {
  837. o.updateLOV('SelectValue',true)
  838. o.updateLOV('AvailableList')
  839. o.updateLOV('SelectLowerRangeValue',true)
  840. o.updateLOV('SelectUpperRangeValue',true)
  841. o.updateSLOV()
  842. }
  843. }
  844. // vl - value list
  845. // dl - description list
  846. function P_setLOV(vl,dl)
  847. {
  848. var o=this
  849. o.vl=vl
  850. if (vl)
  851. {
  852. if(!dl || vl.length!=dl.length)
  853. o.dl=null
  854. else
  855. o.dl=dl
  856. }
  857. else
  858. o.dl=null
  859. }
  860. function P_setInitSel(sel)
  861. {
  862. var o=this
  863. var lov=o.lov['SelectValue']
  864. lov.sel=sel
  865. }
  866. function P_setInitSelList(sl)
  867. {
  868. this.sl=sl
  869. }
  870. function P_setInitBound(lo,up)
  871. {
  872. var o=this
  873. var loB=o.lov['SelectLowerRangeValue']
  874. loB.sel=lo
  875. var upB=o.lov['SelectUpperRangeValue']
  876. upB.sel=up
  877. }
  878. function P_back(wty)
  879. {
  880. var o=this
  881. var lov=o.lov[wty]
  882. if(!lov) return
  883. var bidx=lov.bidx
  884. if (bidx > 0)
  885. {
  886. bidx--
  887. if (bidx<0) bidx=0
  888. lov.bidx=bidx
  889. o.update(wty)
  890. }
  891. }
  892. function P_next(wty)
  893. {
  894. var o=this
  895. var lov=o.lov[wty]
  896. if(!lov) return
  897. var len=((lov.vl) ? lov.vl.length : o.vl.length)
  898. var bidx=lov.bidx
  899. if ((bidx+1)*_pe._lovBS < len)
  900. {
  901. lov.bidx=bidx+1
  902. o.update(wty)
  903. }
  904. }
  905. function newLOV()
  906. {
  907. var o=new Object
  908. o.bidx=-1
  909. o.sidx=-1
  910. o.sel=null
  911. o.filter=null
  912. o.vl=null
  913. o.dl=null
  914. return o
  915. }
  916. function newP(units,uid,id,vt,mul,di,rn,dop,readonly,valueRequired)
  917. {
  918. var o=new Object
  919. o.id=id
  920. o.vt=vt
  921. o.mul=mul
  922. o.di=di
  923. o.rn=rn
  924. o.dop=dop
  925. o.readonly=readonly
  926. o.valueRequired=valueRequired
  927. o.units=units
  928. o.uid=uid
  929. o.lov=new Array
  930. o.lov['SelectValue']=newLOV()
  931. o.lov['AvailableList']=newLOV()
  932. o.lov['SelectLowerRangeValue']=newLOV()
  933. o.lov['SelectUpperRangeValue']=newLOV()
  934. o.vl=null
  935. o.dl=null
  936. o.sl=null
  937. o.addV=P_addV
  938. o.update=P_update
  939. o.setLOV=P_setLOV
  940. o.updateLOV=P_updateLOV
  941. o.updateSLOV=P_updateSLOV
  942. o.updateLOVNB=P_updateLOVNB
  943. o.getDesc=P_getDesc
  944. o.findBatch=P_findBatch
  945. o.back=P_back
  946. o.next=P_next
  947. o.showFilter=P_showFilter
  948. o.applyFilter=P_applyFilter
  949. o.setInitSel=P_setInitSel
  950. o.setInitBound=P_setInitBound
  951. o.setInitSelList=P_setInitSelList
  952. o.updateForm=P_updateForm
  953. _pe._prompts[id]=o
  954. if (units) units.addP(o)
  955. return o
  956. }
  957. function P_navigateCB(fid,pid,wty,cmd)
  958. {
  959. var o=_pe._prompts[pid]
  960. if (!o) return
  961. if(cmd=='p') o.back(wty)
  962. else if(cmd=='n') o.next(wty)
  963. }
  964. function P_selectCB(form,pid,wty,dty)
  965. {
  966. var o=_pe._prompts[pid]
  967. if (!o) return
  968. var did=pid+dty
  969. var wid=pid+wty
  970. promptengine_selectValue(form, wid, did)
  971. var lov=o.lov[wty]
  972. lov.sel=document.getElementById(did).value
  973. if(!lov.sel || lov.sel=='')
  974. {
  975. lov.sidx=-1
  976. lov.sel=null
  977. }
  978. else if (lov.sidx!=lov.bidx) lov.sidx=lov.bidx
  979. o.updateLOVNB(wty,true)
  980. }
  981. function P_batchCB(fid,pid,wty)
  982. {
  983. var o=_pe._prompts[pid]
  984. var el=document.getElementById(pid+wty+'Batch')
  985. if (!o || !el) return
  986. var i=el.selectedIndex
  987. if (i>=0)
  988. {
  989. var lov=o.lov[wty]
  990. if (!lov) return
  991. lov.bidx=i
  992. o.update(wty)
  993. }
  994. }
  995. function P_applyFilter(wty,filter)
  996. {
  997. if (filter==null) {return;}
  998. var o=this;
  999. var vl=o.vl;
  1000. var dl=o.dl;
  1001. if (!vl || vl.constructor != Array || vl.length==0) {return;}
  1002. var dlExists = true;
  1003. if (!dl || dl.constructor != Array) {
  1004. dlExists = false;
  1005. }
  1006. var lov=o.lov[wty];
  1007. if (!lov) {return;}
  1008. var oldfilter=lov.filter;
  1009. if (!oldfilter) oldfilter='';
  1010. if(filter==oldfilter) {return;}
  1011. var wvl=null;
  1012. var wdl=null;
  1013. if(filter=='') {
  1014. filter=null;
  1015. }
  1016. else {
  1017. wvl=[];
  1018. if (dlExists) {
  1019. wdl=[];
  1020. }
  1021. // Replace no-break spaces used by thousand separators with regular spaces
  1022. filter = filter.replace(String.fromCharCode(0xA0), ' ');
  1023. var j = 0;
  1024. // we always loop through vl because this is always guranteed to exist unlike dl
  1025. for (var i = 0, len = vl.length; i < len; i++) {
  1026. var value = vl[i];
  1027. var desc = (dlExists ? dl[i] : '');
  1028. var stringToSearch = '';
  1029. if (o.dop == 1) { //if description only prompt
  1030. if (desc == '') {
  1031. stringToSearch = value;
  1032. }
  1033. else {
  1034. stringToSearch = desc;
  1035. }
  1036. }
  1037. else {
  1038. stringToSearch = value;
  1039. if (desc != '') {
  1040. stringToSearch += PE_VALUE_DESC_SEPARATOR;
  1041. stringToSearch += desc;
  1042. }
  1043. }
  1044. // Replace no-break spaces used by thousand separators with regular spaces
  1045. stringToSearch = stringToSearch.replace(String.fromCharCode(0xA0), ' ');
  1046. if (stringToSearch && stringToSearch.toLowerCase().indexOf(filter.toLowerCase()) != -1) {
  1047. wvl[j] = value;
  1048. if(dlExists) {
  1049. wdl[j] = dl[i];
  1050. }
  1051. j++;
  1052. }
  1053. }
  1054. }
  1055. // update LOV
  1056. lov.filter=filter
  1057. lov.vl=wvl
  1058. lov.dl=wdl
  1059. lov.bidx=-1
  1060. lov.sidx=-1
  1061. o.updateLOV(wty,true)
  1062. }
  1063. function P_promptFilter(pid,wty, e)
  1064. {
  1065. var o=_pe._prompts[pid]
  1066. if (!o) return
  1067. var vl=o.vl
  1068. var dl=o.dl
  1069. if (!vl || vl.length==0) return
  1070. var lov=o.lov[wty]
  1071. if (!lov) return
  1072. var filter=lov.filter
  1073. if (!filter) filter=''
  1074. var filterIcon = e.target ? e.target : e.srcElement;
  1075. var pos = _findPos(filterIcon)
  1076. // Placing filter dialog below the filter icon
  1077. var x = pos.x + filterIcon.offsetWidth;
  1078. var y = pos.y + filterIcon.offsetHeight;
  1079. o.showFilter(wty,filter,x,y)
  1080. }
  1081. function P_promptClearFilter(pid,wty, e)
  1082. {
  1083. var o=_pe._prompts[pid];
  1084. if (!o) return;
  1085. if(o.filterDlg)
  1086. {
  1087. o.filterDlg.setValue('');
  1088. // if there's no filter dialog, we don't need to call o.applyFilter since no filter has been applied yet
  1089. o.applyFilter(wty, '');
  1090. }
  1091. }
  1092. function P_showFilter(wty,v,x,y)
  1093. {
  1094. var o=this
  1095. if (!o.filterDlg) o.filterDlg = newFilterDlg(o.id)
  1096. var dlg = o.filterDlg
  1097. dlg.wty = wty
  1098. dlg.setValue(v)
  1099. dlg.show(true)
  1100. dlg.initDlg(x,y)
  1101. }
  1102. function _findPos(el,relTo) {
  1103. var relTo = relTo?relTo:null
  1104. var posX = 0;
  1105. var posY = 0;
  1106. while(el.parentNode || el.offsetParent) {
  1107. if(el.offsetParent) {
  1108. posX +=el.offsetLeft;
  1109. posY += el.offsetTop;
  1110. el = el.offsetParent;
  1111. }
  1112. else if(el.parentNode) {
  1113. if(el.style) {
  1114. if(el.style.left) {
  1115. posX += el.style.left;
  1116. }
  1117. if(el.style.top) {
  1118. posY += el.style.top;
  1119. }
  1120. }
  1121. el = el.parentNode;
  1122. }
  1123. else {
  1124. break;
  1125. }
  1126. }
  1127. if(relTo) {
  1128. relToCord = getPos2(relTo);
  1129. posX -= relToCord.x;
  1130. posY -= relToCord.y;
  1131. }
  1132. return {x:posX,y:posY};
  1133. }
  1134. // Filter Dialog
  1135. function FilterDlg_okCB(dlgID)
  1136. {
  1137. var dlg=this
  1138. if(dlgID) dlg=_getWidget(_getLayer(dlgID))
  1139. if(dlg)
  1140. {
  1141. var o=_pe._prompts[dlg.promptid]
  1142. var filter=dlg.getValue()
  1143. dlg.show(false)
  1144. o.applyFilter(dlg.wty,filter)
  1145. }
  1146. }
  1147. function FilterDlg_cancelCB(dlgID)
  1148. {
  1149. var dlg=this
  1150. if(dlgID) dlg=_getWidget(_getLayer(dlgID))
  1151. if(dlg) dlg.show(false)
  1152. }
  1153. function FilterDlg_enterCB()
  1154. {
  1155. }
  1156. function newFilterDlg(pid)
  1157. {
  1158. var buttonsWidth= 60;
  1159. var buttonsHeight= 52;
  1160. var dlgWidth= 300;
  1161. var dlgHeight= 100;
  1162. var textWidth= 0.9*dlgWidth;
  1163. var dlgID="filterDlg"+pid
  1164. var o=newDlgBox(dlgID,L_SetFilter,dlgWidth,dlgHeight,FilterDlg_okCB,FilterDlg_cancelCB,false);
  1165. o.promptid=pid
  1166. o.setValue=FilterDlg_setValue
  1167. o.getValue=FilterDlg_getValue
  1168. o.initDlg=FilterDlg_initDlg
  1169. var okButton = newBtn(dlgID+"_okBtn", L_OK, "FilterDlg_okCB('" + dlgID + "')", buttonsWidth, "OK", "OK", 0, 0)
  1170. var cancelButton = newBtn(dlgID+"_cancelBtn", L_Cancel, "FilterDlg_cancelCB('" +dlgID + "')", buttonsWidth, "Cancel", "Cancel", 0, 0)
  1171. var textField = newTextField(dlgID+"_textFld",null,null,null,FilterDlg_enterCB,true,null,textWidth)
  1172. _targetApp(
  1173. o.beginHTML() +
  1174. '<table cellspacing="0" cellpadding="5" border="0"><tbody>'+
  1175. '<tr>'+
  1176. '<td>'+
  1177. '<table cellspacing="0" cellpadding="0" border="0"><tbody>' +
  1178. '<tr>' +
  1179. '<td><div style="overflow:auto">'+
  1180. textField.getHTML() +
  1181. '</div></td>'+
  1182. '</tr>' +
  1183. '</tbody></table>'+
  1184. '</td>' +
  1185. '</tr>' +
  1186. '<tr>' +
  1187. '<td align="center" valign="right">' +
  1188. '</td>' +
  1189. '</tr>' +
  1190. '<tr>' +
  1191. '<td align="right" valign="center">' +
  1192. '<table cellspacing="0" cellpadding="0" border="0"><tbody><tr>' +
  1193. '<td>' +
  1194. okButton.getHTML() +
  1195. '</td>' +
  1196. '<td>' + _getSpace(5,1)+ '</td>' +
  1197. '<td>' +
  1198. cancelButton.getHTML() +
  1199. '</td>' +
  1200. '</tr></tbody></table>'+
  1201. '</td>' +
  1202. '</tr>' +
  1203. '</table>' +
  1204. o.endHTML()
  1205. )
  1206. o.init()
  1207. okButton.init();
  1208. cancelButton.init();
  1209. textField.init();
  1210. o.textField=textField
  1211. return o
  1212. }
  1213. function FilterDlg_setValue(v)
  1214. {
  1215. var o=this
  1216. o.textField.setValue(v)
  1217. }
  1218. function FilterDlg_getValue()
  1219. {
  1220. var o=this
  1221. if (o.textField) return o.textField.getValue()
  1222. return null
  1223. }
  1224. function FilterDlg_initDlg(x,y)
  1225. {
  1226. var o=this
  1227. if(x + o.getWidth() > _winWidth() + _getScrollX()) {
  1228. x = Math.max(0,_winWidth() + _getScrollX() - o.getWidth() - 10);
  1229. }
  1230. if(y + o.getHeight() > _winHeight() + _getScrollY()) {
  1231. y = Math.max(0, _winHeight() + getScrollY() - o.getHeight() - 10);
  1232. }
  1233. o.move(x, y );
  1234. o.placeIframe(true,true)
  1235. var f=o.textField
  1236. f.select()
  1237. f.focus()
  1238. }
  1239. // Widget
  1240. function newCtl(id)
  1241. {
  1242. var o=new Object
  1243. o.id=id
  1244. o.layer=null
  1245. o.css=null
  1246. o.getHTML=Ctl_getHTML
  1247. o.beginHTML=Ctl_getHTML
  1248. o.endHTML=Ctl_getHTML
  1249. o.write=Ctl_write
  1250. o.begin=Ctl_begin
  1251. o.end=Ctl_end
  1252. o.init=Ctl_init
  1253. o.move=Ctl_move
  1254. o.resize=Ctl_resize
  1255. o.setBgColor=Ctl_setBgColor
  1256. o.show=Ctl_show
  1257. o.getWidth=Ctl_getWidth
  1258. o.getHeight=Ctl_getHeight
  1259. o.setHTML=Ctl_setHTML
  1260. o.setDisabled=Ctl_setDisabled
  1261. o.focus=Ctl_focus
  1262. o.setDisplay=Ctl_setDisplay
  1263. o.isDisplayed=Ctl_isDisplayed
  1264. o.setTooltip=Ctl_setTooltip
  1265. o.initialized=Ctl_initialized
  1266. o.widx=_pe._widgets.length
  1267. _pe._widgets[o.widx]=o
  1268. return o
  1269. }
  1270. function Ctl_getHTML()
  1271. {
  1272. return ''
  1273. }
  1274. function Ctl_write(i)
  1275. {
  1276. var txt = this.getHTML(i)
  1277. if (parent.writeSource)
  1278. parent.writeSource(txt)
  1279. document.write(txt)
  1280. }
  1281. function Ctl_begin()
  1282. {
  1283. document.write(this.beginHTML())
  1284. }
  1285. function Ctl_end()
  1286. {
  1287. document.write(this.endHTML())
  1288. }
  1289. function Ctl_init()
  1290. {
  1291. var o=this
  1292. o.layer=_getLayer(o.id)
  1293. o.css=o.layer.style
  1294. o.layer._widget=o.widx
  1295. if (o.initialHTML)
  1296. o.setHTML(o.initialHTML)
  1297. }
  1298. function Ctl_move(x,y)
  1299. {
  1300. c=this.css;if (x!=null){if (_pe._moz) c.left=""+x+"px";else c.pixelLeft=x}if (y!=null){if (_pe._moz) c.top=""+y+"px";else c.pixelTop=y}
  1301. }
  1302. function Ctl_focus()
  1303. {
  1304. _safeSetFocus(this.layer)
  1305. }
  1306. function Ctl_setBgColor(c)
  1307. {
  1308. this.css.backgroundColor=c
  1309. }
  1310. function Ctl_show(show)
  1311. {
  1312. this.css.visibility=show?_pe._show:_pe._hide
  1313. }
  1314. function Ctl_getWidth()
  1315. {
  1316. return this.layer.offsetWidth
  1317. }
  1318. function Ctl_getHeight()
  1319. {
  1320. return this.layer.offsetHeight
  1321. }
  1322. function Ctl_setHTML(s)
  1323. {
  1324. var o=this
  1325. if (o.layer)
  1326. o.layer.innerHTML=s
  1327. else
  1328. o.initialHTML=s
  1329. }
  1330. function Ctl_setDisplay(d)
  1331. {
  1332. this.css.display=d?"":"none"
  1333. }
  1334. function Ctl_isDisplayed()
  1335. {
  1336. if(this.css.display == "none")
  1337. return false
  1338. else
  1339. return true
  1340. }
  1341. function Ctl_setDisabled(d)
  1342. {
  1343. if (this.layer)
  1344. this.layer.disabled=d
  1345. }
  1346. function Ctl_resize(w,h)
  1347. {
  1348. if (w!=null) this.css.width=''+(Math.max(0,w))+'px';if (h!=null) this.css.height=''+(Math.max(0,h))+'px';
  1349. }
  1350. function Ctl_setTooltip(tooltip)
  1351. {
  1352. this.layer.title=tooltip
  1353. }
  1354. function Ctl_initialized()
  1355. {
  1356. return this.layer!=null
  1357. }
  1358. // BlockWidget
  1359. function PE_beginBlocking()
  1360. {
  1361. var w=newBlockWidget()
  1362. w.show(true)
  1363. }
  1364. function PE_endBlocking()
  1365. {
  1366. var lyr=_getLayer(_BlockWaitWidgetID)
  1367. if (lyr)
  1368. lyr.style.display="none"
  1369. }
  1370. function newBlockWidget()
  1371. {
  1372. if (window._PEBlockWidget!=null)
  1373. return window._PEBlockWidget
  1374. var o=newCtl(_BlockWaitWidgetID)
  1375. o.getPrivateHTML=BlockWidget_getPrivateHTML
  1376. o.init=BlockWidget_init
  1377. o.show=BlockWidget_show
  1378. window._PEBlockWidget=o
  1379. return o
  1380. }
  1381. function BlockWidget_init()
  1382. {
  1383. }
  1384. function BlockWidget_getPrivateHTML()
  1385. {
  1386. return '<div id="'+ this.id+'" onselectstart="return false" ondragstart="return false" onmousedown="'+'_eventCancelBubble(event)" border="0" hspace="0" vspace="0" style="background-image:url(\''+_pe._images+'transp.gif\')";z-index:6000;cursor:wait;position:absolute;top:0px;left:0px;width:100%;height:100%"></div>'
  1387. }
  1388. function BlockWidget_show(show)
  1389. {
  1390. var o=this
  1391. if (o.layer==null)
  1392. {
  1393. o.layer=_getLayer(o.id)
  1394. if (o.layer==null)
  1395. {
  1396. _targetApp(o.getPrivateHTML())
  1397. o.layer=_getLayer(o.id)
  1398. o.css=o.layer.style
  1399. }
  1400. else
  1401. {
  1402. o.css=o.layer.style
  1403. }
  1404. }
  1405. o.setDisplay(show)
  1406. }
  1407. // button
  1408. function newBtn(id,label,cb,width,hlp,tooltip,tabIndex,margin,url,w,h,dx,dy,imgRight,disDx,disDy)
  1409. {
  1410. var o=newCtl(id)
  1411. o.label=label
  1412. o.cb=cb
  1413. o.width=width
  1414. o.hlp=hlp
  1415. o.tooltip=tooltip
  1416. o.tabIndex=tabIndex
  1417. o.isGray=false
  1418. o.txt=null
  1419. o.icn=null
  1420. o.margin=margin?margin:0
  1421. o.extraStyle=""
  1422. if (url)
  1423. {
  1424. o.url=url
  1425. o.w=w
  1426. o.h=h
  1427. o.dx=dx
  1428. o.dy=dy
  1429. o.disDx=(disDx!=null)?disDx:dx
  1430. o.disDy=(disDy!=null)?disDy:dy
  1431. o.imgRight=imgRight?true:false
  1432. }
  1433. o.getHTML=Btn_getHTML
  1434. o.setDisabled=Btn_setDisabled
  1435. o.setText=Btn_setText
  1436. o.changeImg=Btn_changeImg
  1437. o.oldInit=o.init
  1438. o.init=Btn_init
  1439. o.isDisabled=Btn_isDisabled
  1440. o.instIndex=Btn_currInst
  1441. Btn_inst[Btn_currInst++]=o
  1442. return o;
  1443. }
  1444. Btn_inst=new Array
  1445. Btn_currInst=0
  1446. function Btn_getHTML()
  1447. {
  1448. with (this)
  1449. {
  1450. var clk='Btn_clickCB('+this.instIndex+');return false;"'
  1451. var clcbs= 'onclick="'+clk+'" '
  1452. if (_pe._ie) clcbs+= 'ondblclick="'+clk+'" '
  1453. var url1=_pe._images+"button.gif",addPar=' style="'+extraStyle+'cursor:'+_pe._hand+';margin-left:'+margin+'px; margin-right:'+margin+'px; "'+clcbs+' ',tip=_attr('title', tooltip),idText="theBttn"+id,bg=_backImgOffset(url1,0,42),idIcon="theBttnIcon"+id
  1454. var lnkB='<a '+_attr('id',idText)+' '+tip+' '+_attr('tabindex',tabIndex)+' href="javascript:void(0)" class="wizbutton">'
  1455. var l=(label!=null)
  1456. var im=(this.url?('<td align="'+(l?(this.imgRight?'right':'left'):'center')+'" style="'+bg+'" width="'+(!l&&(width!=null)?width+6:w+6)+'">'+(l?'':lnkB)+_simpleImgOffset(url,w,h,this.isGray?disDs:dx,this.isGray?disDy:dy,idIcon,null,(l?'':tooltip),'cursor:'+_pe._hand)+(l?'':'</a>')+'</td>'):'')
  1457. return '<table '+_attr('id',id)+' '+addPar+' border="0" cellspacing="0" cellpadding="0"><tr valign="middle">'+
  1458. '<td width="5">'+_simpleImgOffset(url1,5,21,0,0)+'</td>'+
  1459. (this.imgRight?'':im)+
  1460. (l?('<td '+_attr("width",width)+' align="center" class="'+(this.isGray?'wizbuttongray':'wizbutton')+'" style="padding-left:3px;padding-right:3px;'+bg+'"><nobr>'+lnkB+label+'</a></nobr></td>'):'')+
  1461. (this.imgRight?im:'')+
  1462. '<td width="5">'+_simpleImgOffset(url1,5,21,0,21)+'</td></tr></table>';
  1463. }
  1464. }
  1465. function Btn_setDisabled(d)
  1466. {
  1467. var o=this,newCur=d?'default':_pe._hand
  1468. o.isGray=d
  1469. if (o.layer)
  1470. {
  1471. o.txt.className=d?'wizbuttongray':'wizbutton'
  1472. o.txt.style.cursor=newCur
  1473. o.css.cursor=newCur
  1474. if(o.icn)
  1475. {
  1476. _changeSimpleOffset(o.icn,o.isGray?o.disDx:o.dx,o.isGray?o.disDy:o.dy)
  1477. o.icn.style.cursor=newCur
  1478. }
  1479. }
  1480. }
  1481. function Btn_isDisabled()
  1482. {
  1483. return this.isGray
  1484. }
  1485. function Btn_setText(str)
  1486. {
  1487. this.txt.innerHTML=convStr(str)
  1488. }
  1489. function Btn_init()
  1490. {
  1491. var o=this
  1492. o.oldInit()
  1493. o.txt=_getLayer('theBttn'+this.id)
  1494. o.icn=_getLayer('theBttnIcon'+this.id)
  1495. var className=o.isGray?'wizbuttongray':'wizbutton'
  1496. if (o.txt.className!=className)
  1497. o.txt.className=className
  1498. }
  1499. function Btn_changeImg(dx,dy,disDx,disDy,url,tooltip)
  1500. {
  1501. var o=this
  1502. if (url) o.url=url
  1503. if (dx!=null) o.dx=dx
  1504. if (dy!=null) o.dy=dy
  1505. if (disDx!=null) o.disDx=disDx
  1506. if (disDy!=null) o.disDy=disDy
  1507. if (tooltip!=null) o.tooltip=tooltip
  1508. if (o.icn)
  1509. _changeSimpleOffset(o.icn,o.isGray?o.disDx:o.dx,o.isGray?o.disDy:o.dy, o.url, o.tooltip)
  1510. }
  1511. function Btn_clickCB(index)
  1512. {
  1513. var btn=Btn_inst[index]
  1514. if (btn && !btn.isGray)
  1515. setTimeout("Btn_delayClickCB("+index+")",1)
  1516. }
  1517. function Btn_delayClickCB(index)
  1518. {
  1519. var btn=Btn_inst[index]
  1520. if (btn.cb)
  1521. {
  1522. if (typeof btn.cb!="string")
  1523. btn.cb()
  1524. else
  1525. eval(btn.cb)
  1526. }
  1527. }
  1528. // text field
  1529. function newTextField(id,changeCB,maxChar,keyUpCB,enterCB,noMargin,tooltip,width,focusCB,blurCB)
  1530. {
  1531. var o=newCtl(id)
  1532. o.tooltip=tooltip
  1533. o.changeCB=changeCB
  1534. o.maxChar=maxChar
  1535. o.keyUpCB=keyUpCB
  1536. o.enterCB=enterCB
  1537. o.noMargin=noMargin
  1538. o.width=width==null?null:''+width+'px'
  1539. o.focusCB=focusCB
  1540. o.blurCB=blurCB
  1541. o.getHTML=TextField_getHTML
  1542. o.getValue=TextField_getValue
  1543. o.setValue=TextField_setValue
  1544. o.intValue=TextField_intValue
  1545. o.intPosValue=TextField_intPosValue
  1546. o.select=TextField_select
  1547. o.beforeChange=null
  1548. o.wInit=o.init
  1549. o.init=TextField_init
  1550. o.oldValue=""
  1551. return o
  1552. }
  1553. function TextField_init()
  1554. {
  1555. var o=this
  1556. o.wInit()
  1557. o.layer.value=""+o.oldValue
  1558. }
  1559. function TextField_getHTML()
  1560. {
  1561. return '<input oncontextmenu="event.cancelBubble=true;return true" style="'+_sty("width",this.width)+(_pe._moz?'padding-left:3px;padding-right:3px;':'')+'margin-left:'+(this.noMargin?0:10)+'px" onfocus="'+'TextField_focus(this)" onblur="'+'TextField_blur(this)" onchange="'+'TextField_changeCB(event,this)" onkeyup="'+'TextField_keyUpCB(event,this);return true" type="text" '+_attr('maxLength',this.maxChar)+' ondragstart="event.cancelBubble=true;return true" onselectstart="event.cancelBubble=true;return true" class="textinputs" id="'+this.id+'" name="'+this.id+'"'+_attr('title',this.tooltip)+' value="">'
  1562. }
  1563. function TextField_getValue()
  1564. {
  1565. return this.layer.value
  1566. }
  1567. function TextField_setValue(s)
  1568. {
  1569. if (this.layer)
  1570. this.layer.value=''+s
  1571. else
  1572. this.oldValue=s
  1573. }
  1574. function TextField_changeCB(e,l)
  1575. {
  1576. var o=_getWidget(l)
  1577. if(o.beforeChange)
  1578. o.beforeChange()
  1579. if(o.changeCB)
  1580. o.changeCB(e)
  1581. }
  1582. function TextField_keyUpCB(e,l)
  1583. {
  1584. var o=_getWidget(l)
  1585. if (_eventGetKey(e)==13)
  1586. {
  1587. if (o.beforeChange)
  1588. o.beforeChange()
  1589. if (o.enterCB)
  1590. o.enterCB(e)
  1591. return false
  1592. }
  1593. else if(o.keyUpCB)
  1594. {
  1595. o.keyUpCB(e)
  1596. return true
  1597. }
  1598. }
  1599. function TextField_focus(l)
  1600. {
  1601. var o=_getWidget(l)
  1602. if (o.focusCB)
  1603. o.focusCB()
  1604. }
  1605. function TextField_blur(l)
  1606. {
  1607. var o=_getWidget(l)
  1608. if(o.beforeChange)
  1609. o.beforeChange()
  1610. if (o.blurCB)
  1611. o.blurCB()
  1612. }
  1613. function TextField_intValue(nanValue)
  1614. {
  1615. var n=parseInt(this.getValue())
  1616. return isNaN(n)?nanValue:n
  1617. }
  1618. function TextField_intPosValue(nanValue)
  1619. {
  1620. var n=this.intValue(nanValue)
  1621. return (n<0)?nanValue:n
  1622. }
  1623. function TextField_select()
  1624. {
  1625. this.layer.select()
  1626. }
  1627. // dialog
  1628. function newDlgBox(id,title,width,height,defaultCB,cancelCB,noCloseButton)
  1629. {
  1630. var o=newCtl(id)
  1631. o.title=title
  1632. o.width=width
  1633. o.height=height
  1634. o.defaultCB=defaultCB
  1635. o.cancelCB=cancelCB
  1636. o.noCloseButton=noCloseButton?noCloseButton:false
  1637. o.resizeable=false
  1638. o.oldKeyPress=null
  1639. o.oldMouseDown=null
  1640. o.oldCurrent=null
  1641. o.modal=null
  1642. o.hiddenVis=new Array
  1643. o.lastLink=null
  1644. o.firstLink=null
  1645. o.titleLayer = null
  1646. o.oldInit=o.init
  1647. o.oldShow=o.show
  1648. o.init=DlgBox_init
  1649. o.setResize=DlgBox_setResize
  1650. o.beginHTML=DlgBox_beginHTML
  1651. o.endHTML=DlgBox_endHTML
  1652. o.show=DlgBox_Show
  1653. o.center=DlgBox_center
  1654. o.focus=DlgBox_focus
  1655. o.setTitle=DlgBox_setTitle
  1656. o.getContainerWidth=DlgBox_getContainerWidth
  1657. o.getContainerHeight=DlgBox_getContainerHeight
  1658. _pe.DlgBox_instances[id]=o
  1659. o.modal=newCtl('modal_'+id)
  1660. o.placeIframe=DlgBox_placeIframe
  1661. o.oldResize=o.resize
  1662. o.resize=DlgBox_resize
  1663. return o
  1664. }
  1665. function DlgBox_setResize(resizeCB,minWidth,minHeight,noResizeW,noResizeH)
  1666. {
  1667. var o=this;
  1668. o.resizeable=true
  1669. o.resizeCB=resizeCB
  1670. o.minWidth=minWidth?minWidth:50
  1671. o.minHeight=minHeight?minHeight:50
  1672. o.noResizeW=noResizeW
  1673. o.noResizeH=noResizeH
  1674. }
  1675. function DlgBox_setTitle(title)
  1676. {
  1677. var o=this
  1678. o.title=title
  1679. if (o.titleLayer == null)
  1680. o.titleLayer = _getLayer('titledialog_'+this.id);
  1681. o.titleLayer.innerHTML=_convStr(title)
  1682. }
  1683. function DlgBox_setCloseIcon(lyr,isActive)
  1684. {
  1685. _changeOffset(lyr,0,(isActive==1?0:18))
  1686. }
  1687. function DlgBox_beginHTML()
  1688. {
  1689. with (this)
  1690. {
  1691. var moveableCb=' onselectstart="return false" ondragstart="return false" onmousedown="'+'DlgBox_down(event,\''+id+'\',this,false);return false;" '
  1692. var mdl=_pe._ie?('<img onselectstart="return false" ondragstart="return false" onmousedown="'+'_eventCancelBubble(event)" border="0" hspace="0" vspace="0" src="'+_pe._images+'transp.gif" id="modal_'+id+'" style="display:none;position:absolute;top:0px;left:0px;width:1px;height:1px">'):('<div onselectstart="return false" ondragstart="return false" onmousedown="'+'_eventCancelBubble(event)" border="0" hspace="0" vspace="0" src="'+_pe._images+'transp.gif" id="modal_'+id+'" style="position:absolute;top:0px;left:0px;width:1px;height:1px"></div>')
  1693. var titleBG="background-image:url('"+_pe._images+"dialogtitle.gif')"
  1694. return mdl+
  1695. '<a style="position:absolute;left:-30px;top:-30px; visibility:hidden" id="firstLink_'+this.id+'" href="javascript:void(0)" onfocus="'+'DlgBox_keepFocus(\''+this.id+'\');return false;" ></a>'+
  1696. _getBGIframe('dlgIF_'+id)+
  1697. '<table border="0" cellspacing="0" cellpadding="2" id="'+id+'" class="dialogbox" style="display:none;padding:0px;visibility:'+_pe._hide+';position:absolute;top:-2000px;left:-2000px;'+_sty("width",width?(""+width+"px"):null)+_sty("height",height?(""+height+"px"):null)+'"><tr><td id="dlgFirstTr_'+id+'" valign="top">'+
  1698. '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr valign="top">'+
  1699. '<td '+moveableCb+' style="cursor:move;'+titleBG+'" class="titlezone">'+_getSpace(5,18)+'</td>'+
  1700. '<td '+moveableCb+' style="cursor:move;'+titleBG+'" class="titlezone" width="100%" valign="middle" align="left"><nobr><span id="titledialog_'+id+'" tabIndex="0" class="titlezone">'+_convStr(title)+'</span></nobr></td>'+
  1701. '<td class="titlezone" style="'+titleBG+'">'+
  1702. (noCloseButton?'':'<a href="javascript:void(0)" onclick="'+'DlgBox_close(\''+id+'\');return false;" title="'+ L_closeDialog +'">'+_imgOffset(_pe._images+'dialogelements.gif',18,18,0,18,'dialogClose_'+this.id,'onmouseover="'+'DlgBox_setCloseIcon(this,1)" onmouseout="'+'DlgBox_setCloseIcon(this,0)" ',L_closeDialog,'cursor:'+_pe._hand)+'</a>')+
  1703. '</td>'+
  1704. '</tr></table></td></tr><tr valign="top" height="100%"><td id="dlgSecTr_'+id+'" >'
  1705. }
  1706. }
  1707. function DlgBox_endHTML()
  1708. {
  1709. var moveableCb=' onselectstart="return false" ondragstart="return false" onmousedown="'+'DlgBox_down(event,\''+this.id+'\',this,true);return false;" '
  1710. var resz=this.resizeable?('<tr onselectstart="return false" height="18" valign="bottom" align="right"><td>'+_img(_pe._images+"resize.gif",14,14,null, moveableCb + ' style="cursor:NW-resize" ')+'</td></tr>'):''
  1711. return '</td></tr>'+resz+'</table><a style="position:absolute;left:-30px;top:-30px; visibility:hidden" id="lastLink_'+this.id+'" href="javascript:void(0)" onfocus="'+'DlgBox_keepFocus(\''+this.id+'\');return false;" ></a>'
  1712. }
  1713. function DlgBox_getContainerWidth()
  1714. {
  1715. var o=this
  1716. return o.width-(2+2)
  1717. }
  1718. function DlgBox_getContainerHeight()
  1719. {
  1720. var o=this
  1721. return o.height-(2+18+2+2+2)
  1722. }
  1723. function DlgBox_close(id)
  1724. {
  1725. var o=_pe.DlgBox_instances[id]
  1726. if (o)
  1727. {
  1728. o.show(false)
  1729. if(o.cancelCB!=null) o.cancelCB()
  1730. }
  1731. }
  1732. function DlgBox_resizeIframeCB(id)
  1733. {
  1734. _pe.DlgBox_instances[id].placeIframe(true,false)
  1735. }
  1736. function DlgBox_placeIframe(bResize,bMove)
  1737. {
  1738. var o=this
  1739. if (o.iframe)
  1740. {
  1741. if (bResize)
  1742. o.iframe.resize(o.getWidth(),o.getHeight())
  1743. if (bMove)
  1744. o.iframe.move(o.layer.offsetLeft,o.layer.offsetTop)
  1745. }
  1746. }
  1747. function DlgBox_resize(w,h)
  1748. {
  1749. var o=this;
  1750. o.oldResize(w,h);
  1751. if (o.iframe)
  1752. {
  1753. o.iframe.resize(w,h);
  1754. if (o.firstTR)
  1755. {
  1756. if (w!=null)
  1757. o.firstTR.style.width=w-4
  1758. if (h!=null)
  1759. o.secondTR.style.height=h-44
  1760. }
  1761. }
  1762. }
  1763. function DlgBox_init()
  1764. {
  1765. if (this.layer!=null)
  1766. return
  1767. var o=this
  1768. o.oldInit();
  1769. o.modal.init();
  1770. o.lastLink=newCtl("lastLink_"+o.id)
  1771. o.firstLink=newCtl("firstLink_"+o.id)
  1772. o.lastLink.init()
  1773. o.firstLink.init()
  1774. if (!o.noCloseButton)
  1775. {
  1776. o.closeButton=_getLayer('dialogClose_'+o.id)
  1777. DlgBox_setCloseIcon(o.closeButton,false)
  1778. }
  1779. if (_pe._moz&&!_pe._saf)
  1780. {
  1781. o.firstTR=_getLayer("dlgFirstTr_"+o.id)
  1782. o.secondTR=_getLayer("dlgSecTr_"+o.id)
  1783. }
  1784. o.iframe=newCtl('dlgIF_'+o.id)
  1785. o.iframe.init()
  1786. }
  1787. function DlgBox_down(e,id,obj,isResize)
  1788. {
  1789. _pe._dlgResize=isResize
  1790. var o=_pe.DlgBox_instances[id],lyr=o.layer,mod=o.modal.layer
  1791. lyr.onmousemove=mod.onmousemove=eval('DlgBox_move')
  1792. lyr.onmouseup=mod.onmouseup=eval('DlgBox_up')
  1793. lyr.dlgStartPosx=mod.dlgStartPosx=parseInt(lyr.style.left)
  1794. lyr.dlgStartPosy=mod.dlgStartPosy=parseInt(lyr.style.top)
  1795. lyr.dlgStartx=mod.dlgStartx=_eventGetX(e)
  1796. lyr.dlgStarty=mod.dlgStarty=_eventGetY(e)
  1797. lyr.dlgStartw=mod.dlgStartw=o.getWidth()
  1798. lyr.dlgStarth=mod.dlgStarth=o.getHeight()
  1799. lyr._widget=mod._widget=o.widx
  1800. _pe._theLYR=lyr
  1801. _eventCancelBubble(e)
  1802. if (lyr.setCapture)
  1803. lyr.setCapture(true)
  1804. }
  1805. function DlgBox_move(e)
  1806. {
  1807. var o=_pe._theLYR,dlg=_getWidget(o)
  1808. if(dlg)
  1809. {
  1810. if (_pe._dlgResize)
  1811. {
  1812. var newW=Math.max(dlg.minWidth,o.dlgStartw+_eventGetX(e)-o.dlgStartx)
  1813. var newH=Math.max(dlg.minHeight,o.dlgStarth+_eventGetY(e)-o.dlgStarty)
  1814. dlg.resize(dlg.noResizeW?null:newW,dlg.noResizeH?null:newH)
  1815. if (dlg.firstTR)
  1816. {
  1817. if (!dlg.noResizeW)
  1818. dlg.firstTR.style.width=newW-4
  1819. if (!dlg.noResizeH)
  1820. dlg.secondTR.style.height=newH-44
  1821. }
  1822. if (dlg.resizeCB)
  1823. dlg.resizeCB(newW,newH)
  1824. }
  1825. else
  1826. {
  1827. var x=Math.max(0,o.dlgStartPosx-o.dlgStartx+_eventGetX(e))
  1828. var y=Math.max(0,o.dlgStartPosy-o.dlgStarty+_eventGetY(e))
  1829. x = Math.min( Math.max(10,_winWidth()-10), x)
  1830. y = Math.min( Math.max(10,_winHeight()-18), y)
  1831. dlg.iframe.move(x,y)
  1832. dlg.move(x,y)
  1833. }
  1834. }
  1835. _eventCancelBubble(e)
  1836. return false
  1837. }
  1838. function DlgBox_up(e)
  1839. {
  1840. var o=_getWidget(_pe._theLYR),lyr=o.layer,mod=o.modal.layer;
  1841. lyr.onmousemove=mod.onmousemove=null;
  1842. lyr.onmouseup=mod.onmouseup=null;
  1843. if (lyr.releaseCapture)
  1844. lyr.releaseCapture();
  1845. _pe._theLYR=null
  1846. }
  1847. function DlgBox_keypress(e)
  1848. {
  1849. var dlg=_pe.DlgBox_current
  1850. if (dlg!=null)
  1851. {
  1852. switch( _eventGetKey(e))
  1853. {
  1854. case 13:
  1855. var sourceId = _pe._ie?window.event.srcElement.id:e.target.id;
  1856. if ((sourceId == "insRepText" || sourceId == "renRepText") && (dlg.defaultCB!=null))
  1857. {
  1858. dlg.defaultCB();return false;
  1859. }
  1860. if(dlg.yes && !dlg.no){ dlg.defaultCB();return false; }
  1861. break;
  1862. case 27:
  1863. dlg.show(false)
  1864. //hideBlockWhileWaitWidget()
  1865. if (dlg.cancelCB!=null) dlg.cancelCB()
  1866. return false;
  1867. break;
  1868. case 8:
  1869. return _isTextInput(_pe._ie?window.event:e);
  1870. break;
  1871. }
  1872. }
  1873. }
  1874. function DlgBoxResizeModals(e)
  1875. {
  1876. for (var i in _pe.DlgBox_modals)
  1877. {
  1878. m_sty=_pe.DlgBox_modals[i]
  1879. m_sty.width=_documentWidth();
  1880. m_sty.height=_documentHeight();
  1881. }
  1882. }
  1883. function DlgBox_center()
  1884. {
  1885. var o=this,scrY=_getScrollY(),scrX=_getScrollX()
  1886. o.height=o.layer.offsetHeight;
  1887. o.width=o.layer.offsetWidth;
  1888. o.move(Math.max(0,scrX+(_winWidth()-o.width)/2),Math.max(0,scrY+(_winHeight()-o.height)/2));
  1889. o.placeIframe(true,true)
  1890. }
  1891. function DlgBox_Show(sh)
  1892. {
  1893. with (this)
  1894. {
  1895. m_sty=modal.css
  1896. l_sty=css
  1897. if (sh)
  1898. {
  1899. oldCurrent=_pe.DlgBox_current
  1900. _pe.DlgBox_current=this
  1901. if (_pe._ie)
  1902. {
  1903. oldKeyPress=document.onkeydown
  1904. document.onkeydown=eval('window.'+'DlgBox_keypress')
  1905. }
  1906. else
  1907. {
  1908. document.addEventListener("keydown", eval('window.'+'DlgBox_keypress'), false)
  1909. }
  1910. oldMouseDown=document.onmousedown
  1911. document.onmousedown=null
  1912. //hideBlockWhileWaitWidget()
  1913. _disableAllInputs()
  1914. }
  1915. else
  1916. {
  1917. _pe.DlgBox_current=oldCurrent
  1918. oldCurrent=null
  1919. if (_pe._ie)
  1920. {
  1921. document.onkeydown=oldKeyPress
  1922. }
  1923. else
  1924. {
  1925. document.removeEventListener("keydown", eval('window.'+'DlgBox_keypress'), false)
  1926. }
  1927. document.onmousedown=oldMouseDown
  1928. _restoreAllDisabledInputs()
  1929. }
  1930. var sameState=(layer.isShown==sh)
  1931. if (sameState)
  1932. return
  1933. layer.isShown=sh
  1934. if (sh)
  1935. {
  1936. if (window.DialogBoxWidget_zindex==null)
  1937. window.DialogBoxWidget_zindex=1000
  1938. this.iframe.css.zIndex=window.DialogBoxWidget_zindex++;
  1939. m_sty.zIndex=window.DialogBoxWidget_zindex++;
  1940. l_sty.zIndex=window.DialogBoxWidget_zindex++;
  1941. _pe.DlgBox_modals[_pe.DlgBox_modals.length]=m_sty
  1942. m_sty.display=''
  1943. l_sty.display='block'
  1944. this.iframe.setDisplay(true)
  1945. DlgBoxResizeModals()
  1946. this.height=layer.offsetHeight;
  1947. this.width=layer.offsetWidth;
  1948. if (_isHidden(layer))
  1949. {
  1950. this.center()
  1951. }
  1952. if (this.firstTR)
  1953. {
  1954. this.firstTR.style.width=this.getWidth()-4
  1955. this.secondTR.style.height=this.getHeight()-44
  1956. }
  1957. if (this.resizeCB)
  1958. this.resizeCB(this.width,this.height)
  1959. }
  1960. else
  1961. {
  1962. var l=_pe.DlgBox_modals.length=Math.max(0,_pe.DlgBox_modals.length-1)
  1963. m_sty.width='1px'
  1964. m_sty.height='1px'
  1965. m_sty.display='none'
  1966. l_sty.display='none'
  1967. move(-2000,-2000);
  1968. this.iframe.setDisplay(false)
  1969. }
  1970. modal.show(sh);
  1971. firstLink.show(sh)
  1972. lastLink.show(sh)
  1973. oldShow(sh);
  1974. if (_pe.DlgBox_current!=null && sh==true)
  1975. _pe.DlgBox_current.focus();
  1976. }
  1977. }
  1978. function DlgBox_keepFocus(id)
  1979. {
  1980. var o=_pe.DlgBox_instances[id];
  1981. if (o) o.focus();
  1982. }
  1983. function DlgBox_focus()
  1984. {
  1985. with (this)
  1986. {
  1987. if (titleLayer == null)
  1988. titleLayer = _getLayer('titledialog_'+id);
  1989. if (titleLayer.focus)titleLayer.focus();
  1990. }
  1991. }
  1992. //////////////////////////////////////////////////////
  1993. // promptengine_prompts functions
  1994. //////////////////////////////
  1995. // GLOBAL VAR
  1996. var isJava = false; // do encodeURIComponent for Java only
  1997. var isNetscape = navigator.appName.indexOf("Netscape") != -1;
  1998. var LEFT_ARROW_KEY = 37;
  1999. var RIGHT_ARROW_KEY = 39;
  2000. var ENTER_KEY = 13;
  2001. ///////////////////////////////
  2002. // properly encode prompt values
  2003. function promptengine_encodePrompt (prompt)
  2004. {
  2005. if (isJava)
  2006. {
  2007. return encodeURIComponent(prompt);
  2008. }
  2009. else
  2010. {
  2011. return promptengine_urlEncode(prompt);
  2012. }
  2013. }
  2014. ////////////////////////////////
  2015. // add number, currency, string from dropdown/textbox to list box
  2016. // where multiple prompt values are supported
  2017. function promptengine_addDiscreteValue (
  2018. fid,
  2019. type,
  2020. pid)
  2021. {
  2022. var form=document.getElementById(fid)
  2023. var sLyr = document.getElementById(pid + "DiscreteValue")
  2024. var src = sLyr
  2025. var sLT=sLyr.type.toLowerCase()
  2026. var fromLB=false
  2027. if (sLT!="text" && sLT!="hidden" && sLT!="password")
  2028. {
  2029. //select box not a textbox
  2030. src = sLyr.options[sLyr.selectedIndex];
  2031. fromLB=true
  2032. }
  2033. var sval=src.value
  2034. if (!promptengine_checkValue (sval, type) )
  2035. {
  2036. _safeSetFocus(sLyr)
  2037. return false;
  2038. }
  2039. var dLyr = document.getElementById(pid + "ListBox");
  2040. PE_clearSel(dLyr)
  2041. var si=promptengine_findOptionInList(dLyr,sval)
  2042. if (si < 0)
  2043. {
  2044. si=dLyr.length
  2045. dLyr.options[si] = new Option(((src.text)?src.text:sval),sval,false,false);
  2046. }
  2047. dLyr.options[si].selected=true
  2048. _safeSetFocus(sLyr)
  2049. if (sLyr.select) sLyr.select();
  2050. if (fromLB && sLyr.selectedIndex < sLyr.length - 1)
  2051. sLyr.selectedIndex = sLyr.selectedIndex + 1; //... or move to next selection in listbox
  2052. }
  2053. function PE_clearSel(lb)
  2054. {
  2055. var i=0, c=lb.length
  2056. if(lb.type=='select-one') {
  2057. i=lb.selectedIndex
  2058. if (i<0) return
  2059. c=i+1
  2060. }
  2061. while(i<c) lb.options[i++].selected=false
  2062. }
  2063. ////////////////////////////////
  2064. // add number, currency, string from available list box to selected list box
  2065. // where multiple prompt values are supported
  2066. function promptengine_addValueFromPickList(
  2067. form,
  2068. type,
  2069. pid)
  2070. {
  2071. return PE_addValues(form,type,pid,false)
  2072. }
  2073. ////////////////////////////////
  2074. // add all number, currency, string from available list box to selected list box
  2075. // where multiple prompt values are supported
  2076. function promptengine_addAllValues(
  2077. form,
  2078. type,
  2079. pid)
  2080. {
  2081. return PE_addValues(form,type,pid,true)
  2082. }
  2083. function PE_addValues(form,type,pid,all)
  2084. {
  2085. var alLyr = document.getElementById(pid + "AvailableList");
  2086. var slLyr = document.getElementById(pid + "ListBox");
  2087. var numOfAL=alLyr.length
  2088. if(numOfAL==0) return false
  2089. var numOfSL=slLyr.length
  2090. var alOpts=alLyr.options;
  2091. var slOpts=slLyr.options;
  2092. var copyAL=new Array(numOfAL)
  2093. var copySL=new Array(numOfSL)
  2094. var redraw=false
  2095. var lastSI=-1;
  2096. for(var i=0;i<numOfAL;i++)
  2097. {
  2098. if(all || alOpts[i].selected)
  2099. {
  2100. var v=alOpts[i].value
  2101. var si=promptengine_findOptionInList(slLyr, v, alOpts[i].text)
  2102. if(si<0) copyAL[i]=v
  2103. else copySL[si]=v
  2104. redraw=true
  2105. if(!all) lastSI=i
  2106. }
  2107. }
  2108. if(!redraw) return false
  2109. var slCtl=PE_getLB(slLyr)
  2110. for(var i=0;i<numOfSL;i++)
  2111. {
  2112. var opt=slOpts[i]
  2113. slCtl.add(opt.value, opt.text, copySL[i]!=null)
  2114. }
  2115. var changed = false;
  2116. for (var i=0; i <numOfAL; i++)
  2117. {
  2118. if(copyAL[i])
  2119. {
  2120. var opt=alOpts[i]
  2121. slCtl.add(opt.value, opt.text,true)
  2122. changed=true
  2123. }
  2124. }
  2125. slCtl.update()
  2126. // set focus to the next item in the available list
  2127. if(!all && lastSI >= 0 && lastSI+1<numOfAL)
  2128. {
  2129. PE_clearSel(alLyr)
  2130. alOpts[lastSI+1].selected=true
  2131. }
  2132. return changed;
  2133. }
  2134. ////////////////////////////////////
  2135. // adds Range prompt to listbox where multiple values are supported
  2136. function promptengine_addRangeValue (
  2137. form,
  2138. type,
  2139. promptID )
  2140. {
  2141. var lowerBoundPickList = document.getElementById(promptID + "SelectLowerRangeValue");
  2142. var upperBoundPickList = document.getElementById(promptID + "SelectUpperRangeValue");
  2143. lowerBound = document.getElementById(promptID + "LowerBound");
  2144. upperBound = document.getElementById(promptID + "UpperBound");
  2145. //handle select box, not text box case
  2146. if ( lowerBound.type.toLowerCase () != "text" &&
  2147. lowerBound.type.toLowerCase () != "hidden" &&
  2148. lowerBound.type.toLowerCase () != "password" ) //either upper or lower, doesn't matter
  2149. {
  2150. lowerBound = lowerBound.options[lowerBound.selectedIndex];
  2151. upperBound = upperBound.options[upperBound.selectedIndex];
  2152. }
  2153. lowerUnBounded = document.getElementById(promptID + "NoLBoundCheck").checked;
  2154. upperUnBounded = document.getElementById(promptID + "NoUBoundCheck").checked;
  2155. lvalue = uvalue = "";
  2156. if ( ! lowerUnBounded )
  2157. {
  2158. if ( ! promptengine_checkRangeBoundValue ( lowerBound.value, type ) ) {
  2159. if ( lowerBound.focus && lowerBound.type.toLowerCase () != "hidden")
  2160. lowerBound.focus ();
  2161. return false;
  2162. }
  2163. lvalue = lowerBound.value;
  2164. }
  2165. if ( ! upperUnBounded )
  2166. {
  2167. if ( ! promptengine_checkRangeBoundValue ( upperBound.value, type ) ) {
  2168. if ( upperBound.focus && upperBound.type.toLowerCase () != "hidden")
  2169. upperBound.focus ();
  2170. return false;
  2171. }
  2172. uvalue = upperBound.value;
  2173. }
  2174. var ldisplay = "";
  2175. var udisplay = "";
  2176. var found = false;
  2177. if (lowerBoundPickList != null && lvalue != null && lvalue.length > 0)
  2178. {
  2179. var cItems = lowerBoundPickList.length;
  2180. for (var item = 0; item < cItems; item++)
  2181. {
  2182. var value = lowerBoundPickList.options[item].value;
  2183. if (value != null && value.length > 0 && value == lvalue)
  2184. {
  2185. ldisplay = lowerBoundPickList.options[item].text;
  2186. found = true;
  2187. break;
  2188. }
  2189. }
  2190. }
  2191. if (!found)
  2192. ldisplay = (lowerBound.text && !lowerUnBounded) ? lowerBound.text : lvalue;
  2193. found = false;
  2194. if (upperBoundPickList != null && uvalue != null && uvalue.length > 0)
  2195. {
  2196. var cItems = upperBoundPickList.length;
  2197. for (var item = 0; item < cItems; item++)
  2198. {
  2199. var value = upperBoundPickList.options[item].value;
  2200. if (value != null && value == uvalue)
  2201. {
  2202. udisplay = upperBoundPickList.options[item].text;
  2203. found = true;
  2204. break;
  2205. }
  2206. }
  2207. }
  2208. if (!found)
  2209. udisplay = (upperBound.text && !upperUnBounded) ? upperBound.text : uvalue;
  2210. lowerChecked = document.getElementById(promptID + "LowerCheck").checked;
  2211. upperChecked = document.getElementById(promptID + "UpperCheck").checked;
  2212. // value for showing in the list box only, no need encode here
  2213. value = ( lowerChecked && ! lowerUnBounded ) ? "[" : "(";
  2214. if ( ! lowerUnBounded ) //unbounded is empty string not quoted empty string (e.g not "_crEMPTY_")
  2215. value += (lvalue);
  2216. value += "_crRANGE_"
  2217. if ( ! upperUnBounded )
  2218. value += (uvalue);
  2219. value += (upperChecked && ! upperUnBounded ) ? "]" : ")";
  2220. display = ( lowerChecked && ! lowerUnBounded ) ? "[" : "(";
  2221. display += ldisplay;
  2222. display += " .. "
  2223. display += udisplay;
  2224. display += (upperChecked && ! upperUnBounded ) ? "]" : ")";
  2225. promptEntry = new Option(display,value,false,false);
  2226. theList = document.getElementById(promptID + "ListBox");
  2227. // search the list/select box for the new option, if the returned index is -1, i.e., no such option, add it
  2228. // otherwise, highlight that option
  2229. var idx = promptengine_findOptionInList(theList, value);
  2230. if (idx > -1)
  2231. theList.selectedIndex = idx;
  2232. else
  2233. theList.options[theList.length] = promptEntry;
  2234. return true;
  2235. }
  2236. ////////////////////////////////////
  2237. // search the given select object for the given option value, and returns its index.
  2238. function promptengine_findOptionInList(selectObj,val)
  2239. {
  2240. if (selectObj==null || val==null )
  2241. return -1;
  2242. var c=selectObj.length, opts=selectObj.options
  2243. for(var i=0;i<c;i++)
  2244. {
  2245. if(opts[i].value==val) return i
  2246. }
  2247. return -1
  2248. }
  2249. ////////////////////////////////////
  2250. // disable check boxes / dropdowns / textboxes based on user selection on the range parameters
  2251. function promptengine_onNoBoundCheckClicked(
  2252. form,
  2253. promptID,
  2254. lowOrUpBound)
  2255. {
  2256. if (lowOrUpBound == 0) {
  2257. if (document.getElementById(promptID + "NoLBoundCheck").checked) {
  2258. document.getElementById(promptID + "NoUBoundCheck").disabled = true;
  2259. document.getElementById(promptID + "LowerCheck").disabled = true;
  2260. document.getElementById(promptID + "LowerBound").disabled = true;
  2261. if (document.getElementById(promptID + "SelectLowerRangeValue") != null)
  2262. document.getElementById(promptID + "SelectLowerRangeValue").disabled = true;
  2263. }
  2264. else {
  2265. document.getElementById(promptID + "NoUBoundCheck").disabled = false;
  2266. document.getElementById(promptID + "LowerCheck").disabled = false;
  2267. document.getElementById(promptID + "LowerBound").disabled = false;
  2268. if (document.getElementById(promptID + "SelectLowerRangeValue") != null)
  2269. document.getElementById(promptID + "SelectLowerRangeValue").disabled = false;
  2270. }
  2271. } else if (lowOrUpBound == 1) {
  2272. if (document.getElementById(promptID + "NoUBoundCheck").checked) {
  2273. document.getElementById(promptID + "NoLBoundCheck").disabled = true;
  2274. document.getElementById(promptID + "UpperCheck").disabled = true;
  2275. document.getElementById(promptID + "UpperBound").disabled = true;
  2276. if (document.getElementById(promptID + "SelectUpperRangeValue") != null)
  2277. document.getElementById(promptID + "SelectUpperRangeValue").disabled = true;
  2278. } else {
  2279. document.getElementById(promptID + "NoLBoundCheck").disabled = false;
  2280. document.getElementById(promptID + "UpperCheck").disabled = false;
  2281. document.getElementById(promptID + "UpperBound").disabled = false;
  2282. if (document.getElementById(promptID + "SelectUpperRangeValue") != null)
  2283. document.getElementById(promptID + "SelectUpperRangeValue").disabled = false;
  2284. }
  2285. }
  2286. }
  2287. ////////////////////////////////////
  2288. // disable text boxes / list boxes based on whether setNull is checked
  2289. function promptengine_onSetNullCheckClicked(
  2290. form,
  2291. promptID)
  2292. {
  2293. if (document.getElementById(promptID + "NULL").checked)
  2294. {
  2295. if (document.getElementById(promptID + "DiscreteValue") != null)
  2296. document.getElementById(promptID + "DiscreteValue").disabled = true;
  2297. if (document.getElementById(promptID + "SelectValue") != null)
  2298. document.getElementById(promptID + "SelectValue").disabled = true;
  2299. }
  2300. else
  2301. {
  2302. if (document.getElementById(promptID + "DiscreteValue") != null)
  2303. document.getElementById(promptID + "DiscreteValue").disabled = false;
  2304. if (document.getElementById(promptID + "SelectValue") != null)
  2305. document.getElementById(promptID + "SelectValue").disabled = false;
  2306. }
  2307. }
  2308. ////////////////////////////////////
  2309. // puts "select" value into text box for an editable prompt which also has defaults
  2310. function promptengine_selectValue(
  2311. form,
  2312. selectCtrl,
  2313. textCtrl)
  2314. {
  2315. // If no selection, return unchanged.
  2316. if(document.getElementById(selectCtrl).selectedIndex < 0)
  2317. return false;
  2318. selectedOption = document.getElementById(selectCtrl).options[document.getElementById(selectCtrl).selectedIndex];
  2319. if (selectedOption.value == null && document.getElementById(textCtrl).value == null)
  2320. return false;
  2321. var changed = true;
  2322. if (selectedOption.value == document.getElementById(textCtrl).value)
  2323. changed = false;
  2324. document.getElementById(textCtrl).value = selectedOption.value;
  2325. return changed;
  2326. }
  2327. function promptengine_hasValueInTextBox(
  2328. form,
  2329. textboxID)
  2330. {
  2331. if (document.getElementById(textboxID).value == null)
  2332. return false;
  2333. return true;
  2334. }
  2335. /////////////////////////////////////////
  2336. // set cascading prompt id into value field.
  2337. function promptengine_setCascadingPID(
  2338. form,
  2339. valueID,
  2340. promptID)
  2341. {
  2342. valueField = document.getElementById(valueID);
  2343. curVal = valueField.value;
  2344. if (curVal.length > 0)
  2345. curVal += "&";
  2346. curVal += "cascadingPID" + "=" + promptID;
  2347. valueField.value = curVal;
  2348. return true;
  2349. }
  2350. /////////////////////////////////////////////////
  2351. // remove selected values from multi-value prompt
  2352. function PE_removeValue(
  2353. form,
  2354. pid,
  2355. all)
  2356. {
  2357. var lyr = document.getElementById(pid+"ListBox")
  2358. var opts=lyr.options
  2359. var len= lyr.length
  2360. if (len==0) return false
  2361. var changed = false
  2362. var lastSelected = -1
  2363. var lbCtl=PE_getLB(lyr)
  2364. for(var i=0; i<len; i++)
  2365. {
  2366. if(!all)
  2367. {
  2368. var opt=opts[i]
  2369. if (!opt.selected)
  2370. {
  2371. lbCtl.add(opt.value,opt.text)
  2372. continue
  2373. }
  2374. lastSelected=i
  2375. }
  2376. changed=true
  2377. }
  2378. if(!changed) return false
  2379. lbCtl.update()
  2380. // resync and update selection
  2381. if (lastSelected >= 0)
  2382. {
  2383. lyr = document.getElementById(pid+"ListBox")
  2384. if (lastSelected < lyr.length)
  2385. lyr.options[lastSelected].selected = true; // highlight the next item
  2386. else if (lastSelected == lyr.length && lastSelected > 0)
  2387. lyr.options[lastSelected-1].selected = true; // highlight the last item
  2388. }
  2389. return true;
  2390. }
  2391. function promptengine_removeValue(form, pid)
  2392. {
  2393. return PE_removeValue(form,pid,false)
  2394. }
  2395. function promptengine_onRemoveValue(
  2396. form,
  2397. promptID)
  2398. {
  2399. promptengine_removeValue(form, promptID);
  2400. }
  2401. /////////////////////////////////////////////////
  2402. // remove all values from multi-value prompt
  2403. function promptengine_removeAllValues(form, pid)
  2404. {
  2405. return PE_removeValue(form,pid,true)
  2406. }
  2407. function promptengine_onRemoveAllValues(
  2408. form,
  2409. promptID)
  2410. {
  2411. promptengine_removeAllValues(form, promptID);
  2412. }
  2413. /////////////////////////////////////
  2414. // update hidden value field with encoded value
  2415. function promptengine_updateValueField (
  2416. form,
  2417. valueID,
  2418. promptID,
  2419. value)
  2420. {
  2421. valueField = document.getElementById(valueID);
  2422. curVal = valueField.value;
  2423. if (curVal.length > 0)
  2424. curVal += "&";
  2425. var encoded = promptengine_encodeValueField(value);
  2426. curVal += promptID + "=" + encoded;
  2427. valueField.value = curVal;
  2428. return true;
  2429. }
  2430. ///////////////////////////////////////
  2431. // reset hidden value field
  2432. function promptengine_resetValueField (
  2433. form,
  2434. valueID)
  2435. {
  2436. valueField = document.getElementById(valueID);
  2437. valueField.value = "";
  2438. }
  2439. /////////////////////////////////////
  2440. // sets prompt value into the hidden form field in proper format so that it can be submitted
  2441. function promptengine_updateDiscreteValue (
  2442. form,
  2443. valueID,
  2444. promptID,
  2445. type,
  2446. checkValue,
  2447. valueRequired)
  2448. {
  2449. var value = "";
  2450. if (document.getElementById(promptID + "NULL") != null &&
  2451. document.getElementById(promptID + "NULL").checked )
  2452. {
  2453. value = "_crNULL_"; //NULL is a literal for, uhmm.. a NULL
  2454. }
  2455. else
  2456. {
  2457. valueField = document.getElementById(promptID + "DiscreteValue");
  2458. if (valueField.type.toLowerCase () != "text" &&
  2459. valueField.type.toLowerCase () != "hidden" &&
  2460. valueField.type.toLowerCase () != "password")
  2461. {
  2462. value = valueField.options[valueField.selectedIndex].value;
  2463. }
  2464. else
  2465. {
  2466. value = valueField.value;
  2467. }
  2468. if (!valueRequired && (value == null || value.length == 0)) {
  2469. return promptengine_updateValueField(form, valueID, promptID, "");
  2470. }
  2471. if ( checkValue && !promptengine_checkValue ( value, type ) )
  2472. {
  2473. if (valueField.focus && valueField.type.toLowerCase () != "hidden")
  2474. valueField.focus ();
  2475. else
  2476. {
  2477. var focusField = document.getElementById(promptID + "SelectValue");
  2478. if (focusField != null && focusField.focus)
  2479. focusField.focus();
  2480. }
  2481. return false;
  2482. }
  2483. }
  2484. return promptengine_updateValueField(form, valueID, promptID, value);
  2485. }
  2486. /////////////////////////////////////
  2487. // sets prompt value for a range into the hidden form field in proper format so that it can be submitted
  2488. function promptengine_updateRangeValue (
  2489. form,
  2490. valueID,
  2491. promptID,
  2492. type,
  2493. checkValue,
  2494. valueRequired)
  2495. {
  2496. if (document.getElementById(promptID + "NULL") != null &&
  2497. document.getElementById(promptID + "NULL").checked )
  2498. {
  2499. value = "_crNULL_"; //NULL is a literal for, uhmm.. a NULL
  2500. }
  2501. else
  2502. {
  2503. lowerBound = document.getElementById(promptID + "LowerBound");
  2504. upperBound = document.getElementById(promptID + "UpperBound");
  2505. //handle select box, not text box case
  2506. if (lowerBound.type.toLowerCase () != "text" &&
  2507. lowerBound.type.toLowerCase () != "hidden" &&
  2508. lowerBound.type.toLowerCase () != "password") //either upper or lower, doesn't matter
  2509. {
  2510. lowerBound = lowerBound.options[lowerBound.selectedIndex];
  2511. upperBound = upperBound.options[upperBound.selectedIndex];
  2512. }
  2513. lowerUnBounded = document.getElementById(promptID + "NoLBoundCheck").checked;
  2514. upperUnBounded = document.getElementById(promptID + "NoUBoundCheck").checked;
  2515. lowerChecked = document.getElementById(promptID + "LowerCheck").checked;
  2516. upperChecked = document.getElementById(promptID + "UpperCheck").checked;
  2517. uvalue = lvalue = "";
  2518. if (!valueRequired &&
  2519. (lowerBound.value == null || lowerBound.value.length == 0 || lowerUnBounded) &&
  2520. (upperBound.value == null || upperBound.value.length == 0 || upperUnBounded)) {
  2521. return promptengine_updateValueField(form, valueID, promptID, "");
  2522. }
  2523. if ( ! lowerUnBounded )
  2524. {
  2525. if ( checkValue && !promptengine_checkRangeBoundValue ( lowerBound.value, type ) ) {
  2526. if ( lowerBound.focus && lowerBound.type.toLowerCase () != "hidden")
  2527. lowerBound.focus();
  2528. else
  2529. {
  2530. var focusField = document.getElementById(promptID + "SelectLowerRangeValue");
  2531. if (focusField != null && focusField.focus)
  2532. focusField.focus();
  2533. }
  2534. return false;
  2535. }
  2536. lvalue = lowerBound.value;
  2537. }
  2538. if ( ! upperUnBounded )
  2539. {
  2540. if ( checkValue && !promptengine_checkRangeBoundValue ( upperBound.value, type ) ) {
  2541. if ( upperBound.focus && upperBound.type.toLowerCase () != "hidden")
  2542. upperBound.focus ();
  2543. else
  2544. {
  2545. var focusField = document.getElementById(promptID + "SelectUpperRangeValue");
  2546. if (focusField != null && focusField.focus)
  2547. focusField.focus();
  2548. }
  2549. return false;
  2550. }
  2551. uvalue = upperBound.value;
  2552. }
  2553. value = ( lowerChecked && ! lowerUnBounded ) ? "[" : "(";
  2554. if ( ! lowerUnBounded )
  2555. value += lvalue;
  2556. value += "_crRANGE_"
  2557. if ( ! upperUnBounded )
  2558. value += uvalue;
  2559. value += (upperChecked && ! upperUnBounded ) ? "]" : ")";
  2560. }
  2561. return promptengine_updateValueField(form, valueID, promptID, value);
  2562. }
  2563. /////////////////////////////////////
  2564. // sets prompt value into the hidden form field in proper format so that it can be submitted
  2565. function promptengine_updateMultiValue (
  2566. form,
  2567. valueID,
  2568. promptID,
  2569. type,
  2570. checkValue,
  2571. valueRequired)
  2572. {
  2573. values = document.getElementById(promptID + "ListBox").options;
  2574. value = "";
  2575. if (document.getElementById(promptID + "NULL") != null &&
  2576. document.getElementById(promptID + "NULL").checked)
  2577. {
  2578. value = "_crNULL_"; //NULL is a literal for, uhmm.. a NULL
  2579. }
  2580. else
  2581. {
  2582. if ( values.length == 0 )
  2583. {
  2584. if (checkValue && valueRequired)
  2585. {
  2586. var focusField = document.getElementById(promptID + "ListBox");
  2587. if (focusField != null && focusField.focus)
  2588. focusField.focus();
  2589. return false;
  2590. }
  2591. value = "_crEMPTY_"; //if value is empty, set to empty string
  2592. }
  2593. else
  2594. {
  2595. for ( i = 0; i < values.length; i++ )
  2596. {
  2597. // first value could be empty string, then chcking value.length != 0 could miss one empty string
  2598. if ( i != 0 )
  2599. value += "_crMULT_"
  2600. value += values[i].value;
  2601. }
  2602. }
  2603. }
  2604. //NOTE: we'll always return true as the validation is done before values are added to select box
  2605. return promptengine_updateValueField(form, valueID, promptID, value);
  2606. }
  2607. ///////////////////////////////////////
  2608. // check and alert user about any errors based on type of prompt
  2609. var regNumber = /^(\+|-)?((\d+(\.|,|'| |\xA0)?\d*)+|(\d*(\.|,| |\xA0)?\d+)+)$/
  2610. var regCurrency = regNumber;
  2611. var regDate = /^(D|d)(A|a)(T|t)(E|e) *\( *\d{4} *, *(0?[1-9]|1[0-2]) *, *((0?[1-9]|[1-2]\d)|3(0|1)) *\)$/
  2612. var regDateTime = /^(D|d)(A|a)(T|t)(E|e)(T|t)(I|i)(M|m)(E|e) *\( *\d{4} *, *(0?[1-9]|1[0-2]) *, *((0?[1-9]|[1-2]\d)|3(0|1)) *, *([0-1]?\d|2[0-3]) *, *[0-5]?\d *, *[0-5]?\d *\)$/
  2613. var regTime = /^(T|t)(I|i)(M|m)(E|e) *\( *([0-1]?\d|2[0-3]) *, *[0-5]?\d *, *[0-5]?\d *\)$/
  2614. var regDateTimeHTML = /^ *\d{4} *- *(0?[1-9]|1[0-2]) *- *((0?[1-9]|[1-2]\d)|3(0|1)) * *([0-1]?\d|2[0-3]) *: *[0-5]?\d *: *[0-5]?\d *$/
  2615. var regDateHTML = /^ *\d{4} *- *(0?[1-9]|1[0-2]) *- *((0?[1-9]|[1-2]\d)|3(0|1)) *$/
  2616. var regTimeHTML = /^ *([0-1]?\d|2[0-3]) *: *[0-5]?\d *: *[0-5]?\d *$/
  2617. function promptengine_getDateSpec()
  2618. {
  2619. var datePattern = promptengine_getDatePattern();
  2620. datePattern = datePattern.replace("Y", L_YYYY);
  2621. datePattern = datePattern.replace("M", L_MM);
  2622. datePattern = datePattern.replace("D", L_DD);
  2623. return datePattern;
  2624. }
  2625. function promptengine_checkValue (
  2626. value,
  2627. type)
  2628. {
  2629. if (value == null)
  2630. return false;
  2631. if (value=="_crNULL_")
  2632. return true;
  2633. if (type==_pe._nm && !regNumber.test (value))
  2634. {
  2635. if (value.length > 0)
  2636. alert ( L_BadNumber );
  2637. return false;
  2638. }
  2639. else if (type==_pe._cy && !regCurrency.test ( value ))
  2640. {
  2641. if (value.length > 0)
  2642. alert ( L_BadCurrency );
  2643. return false;
  2644. }
  2645. else if (type==_pe._da)
  2646. {
  2647. var regex = promptengine_getDateRegex();
  2648. if((regex == null || !regex.test(value)) && ! regDate.test ( value ) && !regDateHTML.test( value ))
  2649. {
  2650. if (value.length > 0)
  2651. {
  2652. var badDate = L_BadDate.replace("%1", promptengine_getDateSpec());
  2653. alert ( badDate );
  2654. }
  2655. return false;
  2656. }
  2657. }
  2658. else if (type==_pe._dt)
  2659. {
  2660. var regex = promptengine_getDateTimeRegex();
  2661. if((regex == null || !regex.test(value)) && ! regDateTime.test ( value ) && !regDateTimeHTML.test( value ))
  2662. {
  2663. if (value.length > 0)
  2664. {
  2665. var badDateTime = L_BadDateTime.replace("%1", promptengine_getDateSpec());
  2666. alert ( badDateTime );
  2667. }
  2668. return false;
  2669. }
  2670. }
  2671. else if (type==_pe._tm && !regTime.test ( value ) && !regTimeHTML.test( value ) )
  2672. {
  2673. if (value.length > 0)
  2674. alert ( L_BadTime );
  2675. return false;
  2676. }
  2677. //by default let it go...
  2678. return true;
  2679. }
  2680. function promptengine_checkRangeBoundValue (
  2681. value,
  2682. type)
  2683. {
  2684. if (value == null || value.length == 0)
  2685. return false;
  2686. return promptengine_checkValue(value, type);
  2687. }
  2688. function promptengine_isSubmitEvent(evt)
  2689. {
  2690. var b=false
  2691. if (isNetscape)
  2692. {
  2693. if (evt.which == ENTER_KEY && (evt.target.type == "text" || evt.target.type == "password"))
  2694. b=true;
  2695. }
  2696. else
  2697. {
  2698. if (window.event.keyCode == ENTER_KEY && (window.event.srcElement.type == "text" || window.event.srcElement.type == "password"))
  2699. b=true;
  2700. }
  2701. if (b) _eventCancelBubble(evt)
  2702. return b;
  2703. }
  2704. function promptengine_isEnterKey(evt)
  2705. {
  2706. var b=false
  2707. if (isNetscape)
  2708. {
  2709. if (evt.which == ENTER_KEY && evt.target.tagName.toLowerCase() != "a")
  2710. b=true;
  2711. }
  2712. else
  2713. {
  2714. if (window.event.keyCode == ENTER_KEY && window.event.srcElement.tagName.toLowerCase() != "a")
  2715. b=true;
  2716. }
  2717. if (b) _eventCancelBubble(evt)
  2718. return b
  2719. }
  2720. //This function should only be called from the COM components.
  2721. //Use encodeURIComponent for Java
  2722. function promptengine_urlEncode(strToBeEncoded)
  2723. {
  2724. var encodedString = new String("");
  2725. for( var i = 0; i < strToBeEncoded.length; i++ )
  2726. {
  2727. var nextChar = strToBeEncoded.charAt(i);
  2728. switch( nextChar )
  2729. {
  2730. //Unsafe characters
  2731. case '%':
  2732. {
  2733. encodedString += "%25";
  2734. break;
  2735. }
  2736. case '+':
  2737. {
  2738. encodedString += "%2B";
  2739. break;
  2740. }
  2741. case ' ':
  2742. {
  2743. encodedString += "%20";
  2744. break;
  2745. }
  2746. case '<':
  2747. {
  2748. encodedString += "%3C";
  2749. break;
  2750. }
  2751. case '>':
  2752. {
  2753. encodedString += "%3E";
  2754. break;
  2755. }
  2756. case '"':
  2757. {
  2758. encodedString += "%22";
  2759. break;
  2760. }
  2761. case '\'':
  2762. {
  2763. encodedString += "%27";
  2764. break;
  2765. }
  2766. case '#':
  2767. {
  2768. encodedString += "%23";
  2769. break;
  2770. }
  2771. case '{':
  2772. {
  2773. encodedString += "%7B";
  2774. break;
  2775. }
  2776. case '}':
  2777. {
  2778. encodedString += "%7D";
  2779. break;
  2780. }
  2781. case '|':
  2782. {
  2783. encodedString += "%7C";
  2784. break;
  2785. }
  2786. case '\\':
  2787. {
  2788. encodedString += "%5C";
  2789. break;
  2790. }
  2791. case '^':
  2792. {
  2793. encodedString += "%5E";
  2794. break;
  2795. }
  2796. case '~':
  2797. {
  2798. encodedString += "%7E";
  2799. break;
  2800. }
  2801. case '`':
  2802. {
  2803. encodedString += "%60";
  2804. break;
  2805. }
  2806. case '[':
  2807. {
  2808. encodedString += "%5B";
  2809. break;
  2810. }
  2811. case ']':
  2812. {
  2813. encodedString += "%5D";
  2814. break;
  2815. }
  2816. //Reserved characters
  2817. case ';':
  2818. {
  2819. encodedString += "%3B";
  2820. break;
  2821. }
  2822. case '/':
  2823. {
  2824. encodedString += "%2F";
  2825. break;
  2826. }
  2827. case '?':
  2828. {
  2829. encodedString += "%3F";
  2830. break;
  2831. }
  2832. case ':':
  2833. {
  2834. encodedString += "%3A";
  2835. break;
  2836. }
  2837. case '@':
  2838. {
  2839. encodedString += "%40";
  2840. break;
  2841. }
  2842. case '=':
  2843. {
  2844. encodedString += "%3D";
  2845. break;
  2846. }
  2847. case '&':
  2848. {
  2849. encodedString += "%26";
  2850. break;
  2851. }
  2852. default:
  2853. {
  2854. encodedString += nextChar;
  2855. break;
  2856. }
  2857. }
  2858. }
  2859. return encodedString;
  2860. }
  2861. function promptengine_CancelRightClick(evt)
  2862. {
  2863. if (isNetscape)
  2864. {
  2865. if (evt.target.type != "text" && evt.target.type != "textarea")
  2866. {
  2867. evt.preventDefault();
  2868. evt.cancelBubble = true;
  2869. return true;
  2870. }
  2871. }
  2872. else
  2873. {
  2874. if (window.event.srcElement.type != "text" && window.event.srcElement.type != "textarea")
  2875. {
  2876. window.event.cancelBubble = true;
  2877. window.event.returnValue = false;
  2878. }
  2879. }
  2880. }
  2881. function promptengine_showHidePromptByKey(fieldSetId, imgId, currentImgPath, changeImgPath, evt)
  2882. {
  2883. var correctKey = false;
  2884. var fieldSet = document.getElementById(fieldSetId);
  2885. if (fieldSet == null)
  2886. return;
  2887. if (isNetscape)
  2888. {
  2889. if ( (evt.which == LEFT_ARROW_KEY && fieldSet.style.display == "") ||
  2890. (evt.which == RIGHT_ARROW_KEY && fieldSet.style.display == "none") )
  2891. correctKey = true;
  2892. }
  2893. else
  2894. {
  2895. if ( (window.event.keyCode == LEFT_ARROW_KEY && fieldSet.style.display == "") ||
  2896. (window.event.keyCode == RIGHT_ARROW_KEY && fieldSet.style.display == "none") )
  2897. correctKey = true;
  2898. }
  2899. if (correctKey == true)
  2900. promptengine_showHidePrompt(fieldSetId, imgId, currentImgPath, changeImgPath, evt)
  2901. }
  2902. function promptengine_showHidePrompt(fieldSetId, imgId, currentImgPath, changeImgPath, evt)
  2903. {
  2904. var imgElem;
  2905. imgElem = document.getElementById(imgId);
  2906. if (imgElem!= null && fieldSetId != null)
  2907. {
  2908. if (!imgElem.origImage)
  2909. imgElem.origImage = imgElem.src;
  2910. var fieldSet = document.getElementById(fieldSetId);
  2911. if (fieldSet != null)
  2912. {
  2913. if (fieldSet.style.display == "")
  2914. fieldSet.style.display = "none";
  2915. else
  2916. fieldSet.style.display = "";
  2917. if (!imgElem.changed || imgElem.changed == false)
  2918. {
  2919. imgElem.src = changeImgPath;
  2920. imgElem.changed = true;
  2921. }
  2922. else
  2923. {
  2924. imgElem.src = currentImgPath;
  2925. imgElem.changed = false;
  2926. }
  2927. }
  2928. }
  2929. }
  2930. function promptengine_scrollTo(elt)
  2931. {
  2932. if (!elt) return;
  2933. var scrY=_getScrollY(),scrX=_getScrollX()
  2934. var h=elt.offsetHeight, winCY=_winHeight(), y=_getPos(elt).y
  2935. if (y<scrY) window.scrollTo(scrX, y)
  2936. else if (y+h>scrY+winCY) window.scrollTo(scrX, Math.max(y,y+h-winCY))
  2937. }
  2938. function doNothing() {
  2939. };
  2940. function promptengine_anchorOnKeyPress(e) {
  2941. var evt = e ? e : window.event;
  2942. var target = evt.srcElement ? evt.srcElement : evt.target;
  2943. if(evt.keyCode == 13 && target.onclick) {
  2944. target.onclick.apply(target,[e]);
  2945. }
  2946. return true;
  2947. }
  2948. function promptengine_encodeUTF8(string) {
  2949. var arr = [];
  2950. var strLen = string.length;
  2951. for(var i = 0; i < strLen; i++) {
  2952. var c = string.charCodeAt(i);
  2953. if(c < 0x80) {
  2954. arr.push(c);
  2955. }
  2956. else if(c < 0x0800) {
  2957. arr.push((c >> 6) | 0xc0);
  2958. arr.push(c & 0x3f | 0x80);
  2959. }
  2960. else if(c < 0xd800 || c >= 0xe000) {
  2961. arr.push((c >> 12) | 0xe0);
  2962. arr.push((c >> 6) & 0x3f | 0x80);
  2963. arr.push(c & 0x3f | 0x80);
  2964. }
  2965. else if(c < 0xdc00) {
  2966. var c2 = string.charCodeAt(i + 1);
  2967. if(isNaN(c2) || c2 < 0xdc00 || c2 >= 0xe000) {
  2968. arr.push(0xef, 0xbf, 0xbd);
  2969. continue;
  2970. }
  2971. i++;
  2972. val = ((c & 0x3ff) << 10) | (c2 & 0x3ff);
  2973. val += 0x10000;
  2974. arr.push((val >> 18) | 0xf0);
  2975. arr.push((val >> 12) & 0x3f | 0x80);
  2976. arr.push((val >> 6) & 0x3f | 0x80);
  2977. arr.push(val & 0x3f | 0x80);
  2978. }
  2979. else {
  2980. arr.push(0xef, 0xbf, 0xbd);
  2981. }
  2982. }
  2983. return arr;
  2984. }
  2985. function promptengine_encodeBASE64(byteArray) {
  2986. var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  2987. var arr = [];
  2988. var c1, c2, c3, e1, e2, e3, e4;
  2989. var i = 0, arrLen = byteArray.length;
  2990. while(i < arrLen) {
  2991. c1 = byteArray[i++];
  2992. c2 = byteArray[i++];
  2993. c3 = byteArray[i++];
  2994. e1 = c1 >> 2;
  2995. e2 = ((c1 & 3) << 4) | (c2 >> 4);
  2996. e3 = ((c2 & 15) << 2) | (c3 >> 6);
  2997. e4 = c3 & 63;
  2998. if (isNaN(c2)) {
  2999. e3 = e4 = 64;
  3000. } else if(isNaN(c3)) {
  3001. e4 = 64;
  3002. }
  3003. arr.push(keyStr.charAt(e1));
  3004. arr.push(keyStr.charAt(e2));
  3005. arr.push(keyStr.charAt(e3));
  3006. arr.push(keyStr.charAt(e4));
  3007. }
  3008. return arr.join('');
  3009. }
  3010. function promptengine_encodeValueField(value)
  3011. {
  3012. return promptengine_encodePrompt(promptengine_encodeBASE64(promptengine_encodeUTF8(value)));
  3013. }
  3014. /* Crystal Decisions Confidential Proprietary Information */