CMultipleRange.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| BI and PM: prmt
  5. *| (C) Copyright IBM Corp. 2002, 2016
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or
  8. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *|
  10. *+------------------------------------------------------------------------+
  11. */
  12. /*
  13. CMultipleRange.js
  14. This script is used to provide interactivity for the
  15. multiple select versions for range controls.
  16. */
  17. //Constructor to create a CMultipleRange component
  18. // oRangeControl: the range picker control
  19. // oLstChoices: the name of the select form control
  20. // oSubmit: the form control to submit selections to the server
  21. // bRequired: is this a required field true/false
  22. // sSubmitType: submit this as a standard form, or as XML
  23. // oErrorFeedback: object used to provide validation feedback
  24. // oSizer: image object used to control the minimum size of the multiple select list
  25. // sRef: the id for the control
  26. // oInsertButton: the insert button
  27. // oRemoveButton: the remove button
  28. function CMultipleRange(oRangeControl, oLstChoices, oSubmit, bRequired, sSubmitType, oErrorFeedback, oSizer, sRef, oInsertButton, oRemoveButton, sCVId)
  29. {
  30. this.setCVId(sCVId);
  31. this.m_oRangeControl = oRangeControl;
  32. this.m_oLstChoices = oLstChoices;
  33. this.m_oSubmit = oSubmit;
  34. this.m_bRequired = bRequired;
  35. this.m_bValid = false;
  36. this.m_sSubmitType = sSubmitType;
  37. this.m_oErrorFeedback = oErrorFeedback;
  38. this.m_sErrorFeedbackClass = "clsFeedbackWidgetParseErrorArrowLeft";
  39. this.m_oSizer = oSizer;
  40. this.m_sRef = sRef;
  41. this.m_aSuperRangeLiterals = new Array();
  42. if (oInsertButton)
  43. {
  44. this.m_oInsertButton = oInsertButton;
  45. }
  46. if (oRemoveButton)
  47. {
  48. this.m_oRemoveButton = oRemoveButton;
  49. }
  50. this.checkData();
  51. if (this.m_oSizer)
  52. {
  53. this.m_bSizeAvailable = false;
  54. this.m_iResizeTestCounter = 0;
  55. this.m_iInterval = window.setInterval ('multipleRange'+ this.m_sRef +'.testResize()', 250);
  56. }
  57. //check the states of the insert and remove buttons
  58. this.checkInsertRemove();
  59. }
  60. CMultipleRange.prototype = new CPromptControl();
  61. //select all items
  62. function CMultipleRange_selectAll()
  63. {
  64. for (var i=0; i < this.m_oLstChoices.options.length; i++)
  65. {
  66. this.m_oLstChoices.options[i].selected = true;
  67. }
  68. //check the states of the insert and remove buttons
  69. this.checkInsertRemove();
  70. }
  71. //remove selection from all items
  72. function CMultipleRange_deSelectAll()
  73. {
  74. for (var i=0; i < this.m_oLstChoices.options.length; i++)
  75. {
  76. this.m_oLstChoices.options[i].selected = false;
  77. }
  78. //check the states of the insert and remove buttons
  79. this.checkInsertRemove();
  80. }
  81. //insert values from the picker control (deprecated)
  82. //use values in the following format
  83. // simpleParmValueItem (equals) [value]
  84. // boundRangeParmValueItem (between) [value from]:[value to]
  85. // unboundedEndRangeParmValueItem (greater than or equal to) [value from]:
  86. // unboundedStartRangeParmValueItem (less than or equal to) :[value to]
  87. //
  88. // display values formatted in a way that is appropriate for the user's locale
  89. function CMultipleRange_insert()
  90. {
  91. var sInsertUse = decodeURIComponent(this.m_oRangeControl.sGetValue());
  92. var sInsertDisplay = this.m_oRangeControl.sGetFormatValue();
  93. if ((sInsertUse) && (sInsertDisplay))
  94. {
  95. this.m_oLstChoices.options[this.m_oLstChoices.options.length] = new Option(sInsertDisplay, sInsertUse, false, false);
  96. //resize the list to fit the data if required
  97. this.resizeList();
  98. this.resizeList();
  99. }
  100. else
  101. {
  102. //animate the controls that are missing values
  103. //if the browser has the capability
  104. if (document.getElementById)
  105. {
  106. animateValueMissing("tdRangeFrom" + this.m_sRef,"tdRangeTo" + this.m_sRef);
  107. }
  108. }
  109. this.checkData();
  110. //check the states of the insert and remove buttons
  111. this.checkInsertRemove();
  112. }
  113. //remove selections from the list of choices (deprecated)
  114. function CMultipleRange_remove()
  115. {
  116. this.removeSelectedChoices();
  117. //resize the list to fit the data if required
  118. this.resizeList();
  119. //check the states of the insert and remove buttons
  120. this.checkInsertRemove();
  121. }
  122. //perform any special processing for the server.
  123. // convert to the following format
  124. // <selectChoices>
  125. // <selectBoundRange selected="[true | false]">
  126. // <start displayValue="[user value]" useValue="[system value]"/>
  127. // <end displayValue="[user value]" useValue="[system value]"/>
  128. // </selectBoundRange>
  129. // <selectUnboundedEndRange selected="[true | false]">
  130. // <start displayValue="[user value]" useValue="[system value]"/>
  131. // </selectUnboundedEndRange>
  132. // <selectUnboundedStartRange selected="[true | false]">
  133. // <end displayValue="[user value]" useValue="[system value]"/>
  134. // </selectUnboundedStartRange>
  135. // <selectOption displayValue="[user value]" useValue="[system value]" selected="[true | false]"/>
  136. // </selectChoices>
  137. function CMultipleRange_preProcess()
  138. {
  139. if (this.m_sSubmitType == K_PRMT_sXML)
  140. {
  141. //convert the data to XML and submit
  142. var sURLValues = K_PRMT_sEMPTY;
  143. if (this.m_aSuperRangeLiterals.length > 0)
  144. {
  145. for (var j=0; j < this.m_aSuperRangeLiterals.length; j++)
  146. {
  147. //determine the type of filter
  148. switch (this.m_aSuperRangeLiterals[j].getType())
  149. {
  150. //equals FILTER_EQUAL_TO
  151. case 0:
  152. sURLValues += '<selectOption';
  153. sURLValues += ' displayValue="' + sXmlEncode(this.m_aSuperRangeLiterals[j].getStartDisplayValue()) +'"';
  154. sURLValues += ' useValue="' + sXmlEncode(this.m_aSuperRangeLiterals[j].getStartUseValue()) +'"';
  155. if (this.m_aSuperRangeLiterals[j].selected == true)
  156. {
  157. sURLValues += ' selected="true" />';
  158. }
  159. else
  160. {
  161. sURLValues += ' selected="false" />';
  162. }
  163. break;
  164. //greater than or equal to FILTER_GREATER_THAN_OR_EQUAL_TO
  165. case 1:
  166. sURLValues += '<selectUnboundedEndRange';
  167. if (this.m_aSuperRangeLiterals[j].selected == true)
  168. {
  169. sURLValues += ' selected="true" >';
  170. }
  171. else
  172. {
  173. sURLValues += ' selected="false" >';
  174. }
  175. sURLValues += '<start displayValue="'+ sXmlEncode(this.m_aSuperRangeLiterals[j].getStartDisplayValue()) +'" useValue="'+ sXmlEncode(this.m_aSuperRangeLiterals[j].getStartUseValue()) +'"/>';
  176. sURLValues += '</selectUnboundedEndRange>';
  177. break;
  178. //less than or equal to FILTER_LESS_THAN_OR_EQUAL_TO
  179. case 2:
  180. sURLValues += '<selectUnboundedStartRange';
  181. if (this.m_aSuperRangeLiterals[j].selected == true)
  182. {
  183. sURLValues += ' selected="true" >';
  184. }
  185. else
  186. {
  187. sURLValues += ' selected="false" >';
  188. }
  189. sURLValues += '<end displayValue="'+ sXmlEncode(this.m_aSuperRangeLiterals[j].getEndDisplayValue()) +'" useValue="'+ sXmlEncode(this.m_aSuperRangeLiterals[j].getEndUseValue()) +'"/>';
  190. sURLValues += '</selectUnboundedStartRange>';
  191. break;
  192. //between FILTER_BETWEEN
  193. case 3:
  194. sURLValues += '<selectBoundRange';
  195. if (this.m_aSuperRangeLiterals[j].selected == true)
  196. {
  197. sURLValues += ' selected="true" >';
  198. }
  199. else
  200. {
  201. sURLValues += ' selected="false" >';
  202. }
  203. sURLValues += '<start displayValue="'+ sXmlEncode(this.m_aSuperRangeLiterals[j].getStartDisplayValue()) +'" useValue="'+ sXmlEncode(this.m_aSuperRangeLiterals[j].getStartUseValue()) +'"/>';
  204. sURLValues += '<end displayValue="'+ sXmlEncode(this.m_aSuperRangeLiterals[j].getEndDisplayValue()) +'" useValue="'+ sXmlEncode(this.m_aSuperRangeLiterals[j].getEndUseValue()) +'"/>';
  205. sURLValues += '</selectBoundRange>';
  206. break;
  207. default:
  208. break;
  209. }
  210. }
  211. }
  212. addSelectChoices(this.m_oSubmit, sURLValues);
  213. }
  214. else
  215. {
  216. //select all the choices so they can be submitted with the form
  217. var i=0;
  218. for(i = 0; i < this.m_oLstChoices.options.length; i ++)
  219. {
  220. this.m_oLstChoices.options[i].selected = true;
  221. }
  222. }
  223. }
  224. //return true unless this is a required prompt
  225. //and there are no values
  226. function CMultipleRange_checkData()
  227. {
  228. if ((this.m_bRequired == true) && (this.m_oLstChoices.options.length === 0))
  229. {
  230. this.m_bValid = false;
  231. this.checkFail();
  232. return false;
  233. }
  234. else
  235. {
  236. this.m_bValid = true;
  237. this.checkPass();
  238. return true;
  239. }
  240. }
  241. //wait until the size of the list box is known
  242. //then trigger a resize -- used in conjunction with an interval
  243. function CMultipleRange_testResize()
  244. {
  245. if (this.m_bSizeAvailable == false)
  246. {
  247. if (this.m_oSizer.width != 0 || this.m_iResizeTestCounter < 100)
  248. {
  249. this.m_bSizeAvailable = true;
  250. this.resizeList();
  251. }
  252. else
  253. {
  254. this.m_iResizeTestCounter++;
  255. }
  256. }
  257. else
  258. {
  259. window.clearInterval(this.m_iInterval);
  260. }
  261. }
  262. //make sure that choices are always visible and set a minimum size
  263. //resize the list to fit the data if required
  264. //if there are no items, prevent the list from
  265. //shrinking too small
  266. //allow the list to expand to fit the biggest item
  267. function CMultipleRange_resizeList()
  268. {
  269. if (this.m_oSizer)
  270. {
  271. if(this.m_oLstChoices.style.tableLayout!='fixed')
  272. {
  273. this.m_oLstChoices.style.width='auto';
  274. }
  275. if (this.m_oSizer.width < 200)
  276. {
  277. this.m_oLstChoices.style.width='200px';
  278. }
  279. }
  280. }
  281. //Trap whether the user has pressed the delete key
  282. //in the choices box. Note that this function is
  283. //IE specific
  284. function CMultipleRange_catchDeleteKey(iKeyCode)
  285. {
  286. //catch the Delete key code
  287. if (iKeyCode == 46)
  288. {
  289. this.removeChoiceList();
  290. }
  291. }
  292. //enable and disable the insert and remove buttons
  293. //based on what the user has selected
  294. function CMultipleRange_checkInsertRemove()
  295. {
  296. if (this.m_oInsertButton)
  297. {
  298. //determine if the range is required
  299. if (this.m_bRequired == true)
  300. {
  301. if ((this.m_oRangeControl.getValid() == true) && this.m_oRangeControl.hasValue())
  302. {
  303. this.m_oInsertButton.disabled = false;
  304. }
  305. else
  306. {
  307. this.m_oInsertButton.disabled = true;
  308. this.m_oInsertButton.className = "clsInsertRemoveButton";
  309. }
  310. }
  311. else
  312. {
  313. if ((this.m_oRangeControl.getValid() == true) && this.m_oRangeControl.hasValue())
  314. {
  315. this.m_oInsertButton.disabled = false;
  316. }
  317. else
  318. {
  319. this.m_oInsertButton.disabled = true;
  320. this.m_oInsertButton.className = "clsInsertRemoveButton";
  321. }
  322. }
  323. }
  324. if (this.m_oRemoveButton)
  325. {
  326. if (this.m_oLstChoices.selectedIndex == -1)
  327. {
  328. this.m_oRemoveButton.disabled = true;
  329. this.m_oRemoveButton.className = "clsInsertRemoveButton";
  330. }
  331. else
  332. {
  333. this.m_oRemoveButton.disabled = false;
  334. }
  335. }
  336. }
  337. //used to add super range literal items when rendering the UI
  338. function CMultipleRange_addSuperRangeLiteral(sStartUse, sStartDisplay, sEndUse, sEndDisplay, sDataType)
  339. {
  340. var newRangeLiteral = new CSuperRangeLiteral(sStartUse, sStartDisplay, sEndUse, sEndDisplay, sDataType);
  341. //add the new range literal
  342. this.m_aSuperRangeLiterals = this.m_aSuperRangeLiterals.concat(newRangeLiteral);
  343. var rangeOption = document.createElement("option");
  344. rangeOption.text = newRangeLiteral.getLabel();
  345. rangeOption.value = newRangeLiteral.getLiteral();
  346. if (window.ie)
  347. {
  348. this.m_oLstChoices.add(rangeOption);
  349. }
  350. else
  351. {
  352. this.m_oLstChoices.add(rangeOption, null);
  353. }
  354. }
  355. //used to add user specified ranges when the user presses the insert button
  356. function CMultipleRange_insertSuperRangeLiteral()
  357. {
  358. //check filters
  359. var sStartUse = null;
  360. var sStartDisplay = null;
  361. var sEndUse = null;
  362. var sEndDisplay = null;
  363. var sDataType = null;
  364. var oRangeControl = this.m_oRangeControl;
  365. if ( oRangeControl.isRequired() || (oRangeControl.m_oRadioFrom.checked == true))
  366. {
  367. var fromGetValue = oRangeControl.fromGetValue();
  368. if (( fromGetValue!= K_PRMT_sEMPTY) || ( fromGetValue!= null) || ( fromGetValue != false))
  369. {
  370. sStartUse = fromGetValue;
  371. }
  372. var fromGetFormatValue = oRangeControl.fromGetFormatValue();
  373. if (( fromGetFormatValue!= K_PRMT_sEMPTY) || ( fromGetFormatValue!= null) || ( fromGetFormatValue != false))
  374. {
  375. sStartDisplay = fromGetFormatValue;
  376. }
  377. }
  378. if ( oRangeControl.isRequired() || (oRangeControl.m_oRadioTo.checked == true))
  379. {
  380. var toGetValue = oRangeControl.toGetValue();
  381. if (( toGetValue!= K_PRMT_sEMPTY) || ( toGetValue!= null) || ( toGetValue != false))
  382. {
  383. sEndUse = toGetValue;
  384. }
  385. var toGetFormatValue = oRangeControl.toGetFormatValue();
  386. if (( toGetFormatValue!= K_PRMT_sEMPTY) || ( toGetFormatValue!= null) || ( toGetFormatValue != false))
  387. {
  388. sEndDisplay = toGetFormatValue;
  389. }
  390. }
  391. if (oRangeControl.isRangeReversed(sStartUse, sEndUse))
  392. {
  393. var sTempUse = sStartUse;
  394. sStartUse = sEndUse;
  395. sEndUse = sTempUse;
  396. var sTempDisplay = sStartDisplay;
  397. sStartDisplay = sEndDisplay;
  398. sEndDisplay = sTempDisplay;
  399. }
  400. this.addSuperRangeLiteral(sStartUse, sStartDisplay, sEndUse, sEndDisplay, sDataType);
  401. }
  402. //used to remove user specified ranges when the user presses the remove button
  403. function CMultipleRange_removeSuperRangeLiteral(ipos)
  404. {
  405. //split array in two, remove the given item, join the arrays together
  406. var firstPart = this.m_aSuperRangeLiterals.slice(0,ipos);
  407. var secondPart = this.m_aSuperRangeLiterals.slice(ipos+1);
  408. this.m_aSuperRangeLiterals = firstPart.concat (secondPart);
  409. }
  410. function CMultipleRange_initChoiceList()
  411. {
  412. //clear the list
  413. this.m_oLstChoices.options.length = 0;
  414. //add all the range literals to the list box
  415. for (var j=0; j < this.m_aSuperRangeLiterals.length; j++)
  416. {
  417. //insert into the list box
  418. var sInsertUse = this.m_aSuperRangeLiterals[j].getLiteral();
  419. var sInsertDisplay = this.m_aSuperRangeLiterals[j].getLabel();
  420. if ((sInsertUse) && (sInsertDisplay))
  421. {
  422. this.m_oLstChoices.options[this.m_oLstChoices.options.length] = new Option(sInsertDisplay, sInsertUse, false, false);
  423. }
  424. }
  425. this.checkData();
  426. //resize the list to fit the data if required
  427. this.resizeList();
  428. //check the states of the insert and remove buttons
  429. this.checkInsertRemove();
  430. }
  431. //adds an item to the list box
  432. function CMultipleRange_insertChoiceList()
  433. {
  434. this.insertSuperRangeLiteral();
  435. this.checkData();
  436. //resize the list to fit the data if required
  437. this.resizeList();
  438. //check the states of the insert and remove buttons
  439. this.checkInsertRemove();
  440. }
  441. //removes user selected item(s) from the list box and
  442. //removes the corresponding range literals from the array
  443. function CMultipleRange_removeChoiceList()
  444. {
  445. var sl = this.m_oLstChoices.selectedIndex;
  446. if (sl != -1)
  447. {
  448. for (var i=this.m_oLstChoices.options.length-1; i > -1 ; i--)
  449. {
  450. if (this.m_oLstChoices.options[i].selected == true)
  451. {
  452. this.m_oLstChoices.options[i]=null;
  453. //remove the corresponding range literal
  454. this.removeSuperRangeLiteral(i);
  455. }
  456. }
  457. }
  458. else
  459. {
  460. var sPrompt_Select_Item_First = "sPrompt_Select_Item_First";
  461. if (typeof PMT_UIM_sPrompt_Select_Item_First == K_PRMT_sSTRING)
  462. {
  463. sPrompt_Select_Item_First = PMT_UIM_sPrompt_Select_Item_First;
  464. }
  465. alert(sPrompt_Select_Item_First);
  466. }
  467. this.checkData();
  468. //resize the list to fit the data if required
  469. this.resizeList();
  470. //check the states of the insert and remove buttons
  471. this.checkInsertRemove();
  472. }
  473. //Prototypes to assign methods to new instances of the object
  474. CMultipleRange.prototype.selectAll = CMultipleRange_selectAll;
  475. CMultipleRange.prototype.deSelectAll = CMultipleRange_deSelectAll;
  476. CMultipleRange.prototype.insert = CMultipleRange_insert;
  477. CMultipleRange.prototype.remove = CMultipleRange_remove;
  478. CMultipleRange.prototype.preProcess = CMultipleRange_preProcess;
  479. CMultipleRange.prototype.checkData = CMultipleRange_checkData;
  480. CMultipleRange.prototype.resizeList = CMultipleRange_resizeList;
  481. CMultipleRange.prototype.catchDeleteKey = CMultipleRange_catchDeleteKey;
  482. CMultipleRange.prototype.checkInsertRemove = CMultipleRange_checkInsertRemove;
  483. CMultipleRange.prototype.testResize = CMultipleRange_testResize;
  484. CMultipleRange.prototype.addSuperRangeLiteral = CMultipleRange_addSuperRangeLiteral;
  485. CMultipleRange.prototype.insertSuperRangeLiteral = CMultipleRange_insertSuperRangeLiteral;
  486. CMultipleRange.prototype.removeSuperRangeLiteral = CMultipleRange_removeSuperRangeLiteral;
  487. CMultipleRange.prototype.initChoiceList = CMultipleRange_initChoiceList;
  488. CMultipleRange.prototype.insertChoiceList = CMultipleRange_insertChoiceList;
  489. CMultipleRange.prototype.removeChoiceList = CMultipleRange_removeChoiceList;
  490. /* Range Literal Object */
  491. /* Note that this object is deprecated */
  492. // Creates an object that does the work of determining
  493. // the filter type and provides access to properties
  494. // constructor
  495. // sLiteral: the expression that defines the literal
  496. // sLabel: the localized text description of the literal
  497. function CRangeLiteral(sLiteral, sLabel)
  498. {
  499. this.m_sLiteral = sLiteral;
  500. this.m_sLabel = sLabel;
  501. this.m_filterType = this.parseFilterType(sLiteral);
  502. this.m_sFirstValue = this.getFirstValue();
  503. this.m_sSecondValue = this.getSecondValue();
  504. }
  505. //Parse a range literal into it's component pieces
  506. //return the type of filter and set the appropriate values
  507. // :100 less than or equal to 100
  508. // 100: greater than or equal to 100
  509. // 100 equal to 100
  510. // 100 : 1000 between 100 and 1000
  511. // strings need to be surrounded by quotes
  512. function CRangeLiteral_parseFilterType(s)
  513. {
  514. //does the value contain a range delimeter (e.g. ':')
  515. var iTest = s.indexOf(K_PRMT_sCOLON);
  516. var iType = null;
  517. //at the begining?
  518. if (iTest === 0)
  519. {
  520. iType = FILTER_LESS_THAN_OR_EQUAL_TO;
  521. this.setFirstValue(false);
  522. this.setSecondValue(decodeURIComponent(stripSingleQuote(s.substring(1,s.length))));
  523. }
  524. //at the end?
  525. else if (iTest == (s.length -1))
  526. {
  527. iType = FILTER_GREATER_THAN_OR_EQUAL_TO;
  528. this.setFirstValue(decodeURIComponent(stripSingleQuote(s.substring(0,s.length-1))));
  529. this.setSecondValue(false);
  530. }
  531. //at all?
  532. else if (iTest == -1)
  533. {
  534. iType = FILTER_EQUAL_TO;
  535. this.setFirstValue(decodeURIComponent(stripSingleQuote(s)));
  536. this.setSecondValue(decodeURIComponent(stripSingleQuote(s)));
  537. }
  538. else
  539. {
  540. //look for the between range delimeter,
  541. //a colon with spaces ' : '
  542. var rDelimiters = /\s:\s/g;
  543. var arTokens = s.split(rDelimiters);
  544. //is this a between expression?
  545. if (arTokens.length == 2)
  546. {
  547. //yes
  548. iType = FILTER_BETWEEN;
  549. this.setFirstValue(decodeURIComponent(stripSingleQuote(arTokens[0])));
  550. this.setSecondValue(decodeURIComponent(stripSingleQuote(arTokens[1])));
  551. }
  552. else
  553. {
  554. //no, treat the whole thing as one item
  555. //this could be due to time, date, interval and datetime formats
  556. iType = FILTER_EQUAL_TO;
  557. this.setFirstValue(decodeURIComponent(stripSingleQuote(s)));
  558. this.setSecondValue(decodeURIComponent(stripSingleQuote(s)));
  559. }
  560. }
  561. return iType;
  562. }
  563. //Return a localized string that can be used for the display value
  564. // this uses the following function to do the substitutions:
  565. // sReplaceToken(sMessage, sTokenValue, sNewValue)
  566. function CRangeLiteral_getFormatValue()
  567. {
  568. var s = K_PRMT_sEMPTY;
  569. var sFromValue = this.getFirstValue();
  570. var sToValue = this.getSecondValue();
  571. var sEqualTo = 'equal to ^1';
  572. var sGreaterThanOrEqualTo = 'greater than or equal to ^1';
  573. var sLessThanOrEqualTo = 'less than or equal to ^1';
  574. var sBetweenTo = 'between ^1 and ^2';
  575. if (typeof PMT_RNG_FILTER_LESS_THAN_EQUAL_TO_STRING == K_PRMT_sSTRING) {
  576. sLessThanOrEqualTo = PMT_RNG_FILTER_LESS_THAN_EQUAL_TO_STRING;
  577. }
  578. if (typeof PMT_RNG_FILTER_EQUAL_STRING == K_PRMT_sSTRING) {
  579. sEqualTo = PMT_RNG_FILTER_EQUAL_STRING;
  580. }
  581. if (typeof PMT_RNG_FILTER_BETWEEN_STRING == K_PRMT_sSTRING) {
  582. sBetweenTo = PMT_RNG_FILTER_BETWEEN_STRING;
  583. }
  584. if (typeof PMT_RNG_FILTER_GREATER_THAN_EQUAL_TO_STRING == K_PRMT_sSTRING) {
  585. sGreaterThanOrEqualTo = PMT_RNG_FILTER_GREATER_THAN_EQUAL_TO_STRING;
  586. }
  587. switch (this.getFilterType())
  588. {
  589. //FILTER_EQUAL_TO
  590. case 0:
  591. s = sReplaceToken(sEqualTo, "^1", sFromValue);
  592. break;
  593. //FILTER_GREATER_THAN_OR_EQUAL_TO
  594. case 1:
  595. s = sReplaceToken(sGreaterThanOrEqualTo, "^1", sFromValue);
  596. break;
  597. //FILTER_LESS_THAN_OR_EQUAL_TO
  598. case 2:
  599. s = sReplaceToken(sLessThanOrEqualTo, "^1", sToValue);
  600. break;
  601. //FILTER_BETWEEN
  602. case 3:
  603. s = sReplaceToken(sBetweenTo, "^1", sFromValue);
  604. s = sReplaceToken(s, "^2", sToValue);
  605. break;
  606. default:
  607. return false;
  608. }
  609. return s;
  610. }
  611. function CRangeLiteral_setLabel(s)
  612. {
  613. this.m_sLabel = s;
  614. }
  615. function CRangeLiteral_getLabel()
  616. {
  617. return this.m_sLabel;
  618. }
  619. function CRangeLiteral_setFilterType(s)
  620. {
  621. this.m_filterType = s;
  622. }
  623. function CRangeLiteral_getFilterType()
  624. {
  625. return this.m_filterType;
  626. }
  627. function CRangeLiteral_getFirstValue()
  628. {
  629. return this.m_sFirstValue;
  630. }
  631. function CRangeLiteral_getSecondValue()
  632. {
  633. return this.m_sSecondValue;
  634. }
  635. function CRangeLiteral_setFirstValue(s)
  636. {
  637. this.m_sFirstValue = s;
  638. }
  639. function CRangeLiteral_setSecondValue(s)
  640. {
  641. this.m_sSecondValue = s;
  642. }
  643. CRangeLiteral.prototype.getFirstValue = CRangeLiteral_getFirstValue;
  644. CRangeLiteral.prototype.getSecondValue = CRangeLiteral_getSecondValue;
  645. CRangeLiteral.prototype.setFirstValue = CRangeLiteral_setFirstValue;
  646. CRangeLiteral.prototype.setSecondValue = CRangeLiteral_setSecondValue;
  647. CRangeLiteral.prototype.getLabel = CRangeLiteral_getLabel;
  648. CRangeLiteral.prototype.setLabel = CRangeLiteral_setLabel;
  649. CRangeLiteral.prototype.parseFilterType = CRangeLiteral_parseFilterType;
  650. CRangeLiteral.prototype.setFilterType = CRangeLiteral_setFilterType;
  651. CRangeLiteral.prototype.getFilterType = CRangeLiteral_getFilterType;
  652. CRangeLiteral.prototype.getFormatValue = CRangeLiteral_getFormatValue;
  653. var objPlay1 = null;
  654. var objPlay2 = null;
  655. function animateValueMissing(s1,s2)
  656. {
  657. var obj1 = document.getElementById(s1);
  658. var obj2 = document.getElementById(s2);
  659. objPlay1 = obj1;
  660. objPlay2 = obj2;
  661. if ((objPlay1) && (objPlay1))
  662. {
  663. animate();
  664. }
  665. }
  666. function animate()
  667. {
  668. CURLOOP = 0;
  669. ANIMATING = setInterval(animateEffect,EFFECTSPEED);
  670. }
  671. //Global variables
  672. var MAXLOOPS = 5;
  673. var CURLOOP = 1;
  674. var EFFECTSPEED = 100;
  675. var ANIMATING = null;
  676. //animation function
  677. function animateEffect()
  678. {
  679. if (CURLOOP==MAXLOOPS)
  680. {
  681. objPlay1.style.filter = "glow(color=#990000, strength=0, enabled=false)";
  682. objPlay2.style.filter = "glow(color=#990000, strength=0, enabled=false)";
  683. clearInterval(ANIMATING);
  684. return;
  685. }
  686. objPlay1.style.filter = "glow(color=#FF6600, strength="+CURLOOP+", enabled=true)";
  687. objPlay2.style.filter = "glow(color=#FF6600, strength="+CURLOOP+", enabled=true)";
  688. CURLOOP ++;
  689. }
  690. //the SuperRange Literal is an enhanced version of its predecessor, the Range Literal
  691. function CSuperRangeLiteral(sStartUse, sStartDisplay, sEndUse, sEndDisplay, sDataType)
  692. {
  693. this.m_sStartUse = sStartUse;
  694. this.m_sStartDisplay = sStartDisplay;
  695. this.m_sEndUse = sEndUse;
  696. this.m_sEndDisplay = sEndDisplay;
  697. this.m_sDataType = sDataType;
  698. this.m_iType = this.getType();
  699. }
  700. function CSuperRangeLiteral_getStartUseValue()
  701. {
  702. return this.m_sStartUse;
  703. }
  704. function CSuperRangeLiteral_setStartUseValue(sStartUse)
  705. {
  706. this.m_sStartUse = sStartUse;
  707. }
  708. function CSuperRangeLiteral_getStartDisplayValue()
  709. {
  710. return this.m_sStartDisplay;
  711. }
  712. function CSuperRangeLiteral_setStartDisplayValue(sStartDisplay)
  713. {
  714. this.m_sStartDisplay = sStartDisplay;
  715. }
  716. function CSuperRangeLiteral_getEndUseValue()
  717. {
  718. return this.m_sEndUse;
  719. }
  720. function CSuperRangeLiteral_setEndUseValue(sEndUse)
  721. {
  722. this.m_sEndUse = sEndUse;
  723. }
  724. function CSuperRangeLiteral_getEndDisplayValue()
  725. {
  726. return this.m_sEndDisplay;
  727. }
  728. function CSuperRangeLiteral_setEndDisplayValue(sEndDisplay)
  729. {
  730. this.m_sEndDisplay = sEndDisplay;
  731. }
  732. function CSuperRangeLiteral_getType()
  733. {
  734. var sFromValue = (this.getStartUseValue() != null) ? this.getStartUseValue().toString() : null;
  735. var sToValue = (this.getEndUseValue() != null) ? this.getEndUseValue().toString() : null;
  736. var sFilterType = false;
  737. //determine type
  738. if ((sFromValue) && (!sToValue))
  739. {
  740. sFilterType = FILTER_GREATER_THAN_OR_EQUAL_TO;
  741. }
  742. else if((!sFromValue) && (sToValue))
  743. {
  744. sFilterType = FILTER_LESS_THAN_OR_EQUAL_TO;
  745. }
  746. else if ((sFromValue) && (sToValue))
  747. {
  748. if (sFromValue == sToValue)
  749. {
  750. sFilterType = FILTER_EQUAL_TO;
  751. }
  752. else
  753. {
  754. sFilterType = FILTER_BETWEEN;
  755. }
  756. }
  757. return sFilterType;
  758. }
  759. function CSuperRangeLiteral_getLabel()
  760. {
  761. var s = K_PRMT_sEMPTY;
  762. var sFromValue = this.getStartDisplayValue();
  763. var sToValue = this.getEndDisplayValue();
  764. var sEqualTo = 'equal to ^1';
  765. var sGreaterThanOrEqualTo = 'greater than or equal to ^1';
  766. var sLessThanOrEqualTo = 'less than or equal to ^1';
  767. var sBetweenTo = 'between ^1 and ^2';
  768. if (typeof PMT_RNG_FILTER_LESS_THAN_EQUAL_TO_STRING == K_PRMT_sSTRING) {
  769. sLessThanOrEqualTo = PMT_RNG_FILTER_LESS_THAN_EQUAL_TO_STRING;
  770. }
  771. if (typeof PMT_RNG_FILTER_EQUAL_STRING == K_PRMT_sSTRING) {
  772. sEqualTo = PMT_RNG_FILTER_EQUAL_STRING;
  773. }
  774. if (typeof PMT_RNG_FILTER_BETWEEN_STRING == K_PRMT_sSTRING) {
  775. sBetweenTo = PMT_RNG_FILTER_BETWEEN_STRING;
  776. }
  777. if (typeof PMT_RNG_FILTER_GREATER_THAN_EQUAL_TO_STRING == K_PRMT_sSTRING) {
  778. sGreaterThanOrEqualTo = PMT_RNG_FILTER_GREATER_THAN_EQUAL_TO_STRING;
  779. }
  780. switch (this.getType())
  781. {
  782. //FILTER_EQUAL_TO
  783. case 0:
  784. s = sReplaceToken(sEqualTo, "^1", sFromValue);
  785. break;
  786. //FILTER_GREATER_THAN_OR_EQUAL_TO
  787. case 1:
  788. s = sReplaceToken(sGreaterThanOrEqualTo, "^1", sFromValue);
  789. break;
  790. //FILTER_LESS_THAN_OR_EQUAL_TO
  791. case 2:
  792. s = sReplaceToken(sLessThanOrEqualTo, "^1", sToValue);
  793. break;
  794. //FILTER_BETWEEN
  795. case 3:
  796. s = sReplaceToken(sBetweenTo, "^1", sFromValue);
  797. s = sReplaceToken(s, "^2", sToValue);
  798. break;
  799. default:
  800. return false;
  801. }
  802. return s;
  803. }
  804. function CSuperRangeLiteral_getLiteral()
  805. {
  806. var sFromValue = this.getStartUseValue();
  807. var sToValue = this.getEndUseValue();
  808. var sLiteral = K_PRMT_sEMPTY;
  809. if (sFromValue)
  810. {
  811. sLiteral += sFromValue;
  812. }
  813. sLiteral += K_PRMT_sCOLON;
  814. if (sToValue)
  815. {
  816. sLiteral += sToValue;
  817. }
  818. return sLiteral;
  819. }
  820. CSuperRangeLiteral.prototype.getStartUseValue = CSuperRangeLiteral_getStartUseValue;
  821. CSuperRangeLiteral.prototype.setStartUseValue = CSuperRangeLiteral_setStartUseValue;
  822. CSuperRangeLiteral.prototype.getStartDisplayValue = CSuperRangeLiteral_getStartDisplayValue;
  823. CSuperRangeLiteral.prototype.setStartDisplayValue = CSuperRangeLiteral_setStartDisplayValue;
  824. CSuperRangeLiteral.prototype.getEndUseValue = CSuperRangeLiteral_getEndUseValue;
  825. CSuperRangeLiteral.prototype.setEndUseValue = CSuperRangeLiteral_setEndUseValue;
  826. CSuperRangeLiteral.prototype.getEndDisplayValue = CSuperRangeLiteral_getEndDisplayValue;
  827. CSuperRangeLiteral.prototype.setEndDisplayValue = CSuperRangeLiteral_setEndDisplayValue;
  828. CSuperRangeLiteral.prototype.getType = CSuperRangeLiteral_getType;
  829. CSuperRangeLiteral.prototype.getLabel = CSuperRangeLiteral_getLabel;
  830. CSuperRangeLiteral.prototype.getLiteral = CSuperRangeLiteral_getLiteral;