CRange.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| BI and PM: prmt
  5. *| (C) Copyright IBM Corp. 2002, 2011
  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. CRange.js
  14. This script is used to provide interactivity for the
  15. range versions of each of the prompt controls.
  16. */
  17. //Constructor to create a CRange component
  18. // oRadioFrom: 'from' range radio button
  19. // oFrom: 'from' control javascript object
  20. // oRadioFromAll: not implemented
  21. // oRadioTo: 'to' range radio button
  22. // oTo: 'to' control javascript object
  23. // oRadioToAll: not implemented
  24. // sDataType: the type of data to validate (e.g. number)
  25. // bRequired: a flag to determine whether input is required
  26. // sSubmitType: 'default' will submit as a standard form
  27. // 'XML' will convert the submission to XML and submit
  28. // iInitialState: controls whether to check radio buttons
  29. // RANGE_NO_VALUE will select lowest to highest
  30. // RANGE_START_VALUE will select from a particular value to highest
  31. // RANGE_END_VALUE will select from lowest to a particular value
  32. // RANGE_BOUND_VALUE will select a range
  33. // RANGE_EQUAL_VALUE will select a single value
  34. function CRange(oSubmit, oRadioFrom, oFrom, oRadioFromAll, oRadioTo, oTo, oRadioToAll, sDataType, bRequired, sSubmitType, iInitialState, sCVId)
  35. {
  36. this.setCVId(sCVId);
  37. this.m_oSubmit = oSubmit;
  38. this.m_oRadioTo = oRadioTo;
  39. this.m_oTo = oTo;
  40. this.m_oRadioToAll = oRadioToAll;
  41. this.m_oRadioFrom = oRadioFrom;
  42. this.m_oFrom = oFrom;
  43. this.m_oRadioFromAll = oRadioFromAll;
  44. //the range data type
  45. this.m_sDataType = sDataType;
  46. //is this control required?
  47. this.m_bRequired = bRequired;
  48. this.m_bValid = false;
  49. this.m_sSubmitType = sSubmitType;
  50. if (iInitialState)
  51. {
  52. this.m_iInitialSate = iInitialState;
  53. }
  54. else
  55. {
  56. this.m_iInitialSate = null;
  57. }
  58. //set the radio button states
  59. this.initControls();
  60. }
  61. CRange.prototype = new CPromptControl();
  62. //the 'to' control has received focus
  63. //handle this event
  64. function CRange_toGotFocus()
  65. {
  66. if (this.m_oRadioTo)
  67. {
  68. this.m_oRadioTo.checked = true;
  69. this.rangeNotify();
  70. }
  71. }
  72. //the 'from' control has received focus
  73. //handle this event
  74. function CRange_fromGotFocus()
  75. {
  76. if (this.m_oRadioFrom)
  77. {
  78. this.m_oRadioFrom.checked = true;
  79. this.rangeNotify();
  80. }
  81. }
  82. //update the range control radio buttons
  83. function CRange_initControls()
  84. {
  85. if (this.m_iInitialSate)
  86. {
  87. // RANGE_BOUND_VALUE will select a range or single value
  88. if ((this.m_iInitialSate == RANGE_BOUND_VALUE) || (this.m_iInitialSate == RANGE_EQUAL_VALUE))
  89. {
  90. this.toGotFocus();
  91. this.fromGotFocus();
  92. }
  93. // RANGE_START_VALUE will select from a particular value to highest
  94. else if (this.m_iInitialSate == RANGE_START_VALUE)
  95. {
  96. this.fromGotFocus();
  97. }
  98. // RANGE_END_VALUE will select from lowest to a particular value
  99. else if (this.m_iInitialSate == RANGE_END_VALUE)
  100. {
  101. this.toGotFocus();
  102. }
  103. }
  104. else
  105. {
  106. if (this.toGetValue() != K_PRMT_sEMPTY)
  107. {
  108. this.toGotFocus();
  109. }
  110. if (this.fromGetValue() != K_PRMT_sEMPTY)
  111. {
  112. this.fromGotFocus();
  113. }
  114. }
  115. }
  116. function CRange_toGetValue()
  117. {
  118. var sValue = K_PRMT_sEMPTY;
  119. if (this.isRangeReversed()) {
  120. sValue = new String(this.m_oFrom.sGetValue());
  121. }
  122. else {
  123. sValue = this.m_oTo.sGetValue();
  124. }
  125. if ( this.getDataType() == 'date' && typeof this.m_oTo == K_PRMT_sOBJECT && this.m_oTo.m_iDateTimeType === 0 )
  126. {
  127. // We are using a date control for a datetime value.
  128. // Make sure the value ends with T23:59:59.999
  129. sValue = sValue.replace( /T\d\d:\d\d:\d\d\.\d\d\d\s*$/, "T23:59:59.999" );
  130. }
  131. return sValue;
  132. }
  133. function CRange_fromGetValue()
  134. {
  135. var sValue = K_PRMT_sEMPTY;
  136. if (this.isRangeReversed()) {
  137. sValue = this.m_oTo.sGetValue();
  138. }
  139. else {
  140. sValue = new String(this.m_oFrom.sGetValue());
  141. }
  142. if ( this.getDataType() == 'date' && typeof this.m_oTo == K_PRMT_sOBJECT && this.m_oTo.m_iDateTimeType === 0 )
  143. {
  144. // We are using a date control for a datetime value.
  145. // make sure the value ends with T00:00:00.000
  146. sValue = sValue.replace( /T\d\d:\d\d:\d\d\.\d\d\d\s*$/, "T00:00:00.000" );
  147. }
  148. return sValue;
  149. }
  150. function CRange_toGetFormatValue()
  151. {
  152. if (this.isRangeReversed()) {
  153. return this.m_oFrom.sGetFormatValue();
  154. }
  155. else {
  156. return this.m_oTo.sGetFormatValue();
  157. }
  158. }
  159. function CRange_fromGetFormatValue()
  160. {
  161. if (this.isRangeReversed()) {
  162. return this.m_oTo.sGetFormatValue();
  163. }
  164. else {
  165. return this.m_oFrom.sGetFormatValue();
  166. }
  167. }
  168. //Return a localized string that can be used for the display value
  169. // this uses the following function to do the substitutions:
  170. // sReplaceToken(sMessage, sTokenValue, sNewValue)
  171. function CRange_sGetFormatValue()
  172. {
  173. var s = K_PRMT_sEMPTY;
  174. var sFromValue = (this.fromGetValue().toString() == 'false') ? K_PRMT_sEMPTY : this.fromGetValue();
  175. var sToValue = (this.toGetValue().toString() == 'false') ? K_PRMT_sEMPTY : this.toGetValue();
  176. var sFromFormatValue = this.fromGetFormatValue();
  177. var sToFormatValue = this.toGetFormatValue();
  178. var sEqualTo = 'equal to ^1';
  179. var sGreaterThanOrEqualTo = 'greater than or equal to ^1';
  180. var sLessThanOrEqualTo = 'less than or equal to ^1';
  181. var sBetweenTo = 'between ^1 and ^2';
  182. if (typeof PMT_RNG_FILTER_LESS_THAN_EQUAL_TO_STRING == K_PRMT_sSTRING) {
  183. sLessThanOrEqualTo = PMT_RNG_FILTER_LESS_THAN_EQUAL_TO_STRING;
  184. }
  185. if (typeof PMT_RNG_FILTER_EQUAL_STRING == K_PRMT_sSTRING) {
  186. sEqualTo = PMT_RNG_FILTER_EQUAL_STRING;
  187. }
  188. if (typeof PMT_RNG_FILTER_BETWEEN_STRING == K_PRMT_sSTRING) {
  189. sBetweenTo = PMT_RNG_FILTER_BETWEEN_STRING;
  190. }
  191. if (typeof PMT_RNG_FILTER_GREATER_THAN_EQUAL_TO_STRING == K_PRMT_sSTRING) {
  192. sGreaterThanOrEqualTo = PMT_RNG_FILTER_GREATER_THAN_EQUAL_TO_STRING;
  193. }
  194. switch (this.getFilterType(sFromValue,sToValue))
  195. {
  196. //FILTER_EQUAL_TO
  197. case 0:
  198. s = sReplaceToken(sEqualTo, "^1", sFromFormatValue);
  199. break;
  200. //FILTER_GREATER_THAN_OR_EQUAL_TO
  201. case 1:
  202. s = sReplaceToken(sGreaterThanOrEqualTo, "^1", sFromFormatValue);
  203. break;
  204. //FILTER_LESS_THAN_OR_EQUAL_TO
  205. case 2:
  206. s = sReplaceToken(sLessThanOrEqualTo, "^1", sToFormatValue);
  207. break;
  208. //FILTER_BETWEEN
  209. case 3:
  210. s = sReplaceToken(sBetweenTo, "^1", sFromFormatValue);
  211. s = sReplaceToken(s, "^2", sToFormatValue);
  212. break;
  213. default:
  214. return false;
  215. }
  216. return s;
  217. }
  218. //return the range ?p? in the format that the query engine expects expects
  219. // [x] in_range {1,2,3, 10 : 100, 201}
  220. // [x] in_range ?p?
  221. // [x] in_range {'a' : 'z'}
  222. function CRange_sGetValue()
  223. {
  224. var s = K_PRMT_sEMPTY;
  225. var sFromValue = (this.fromGetValue().toString() == 'false') ? K_PRMT_sEMPTY : this.fromGetValue();
  226. var sToValue = (this.toGetValue().toString() == 'false') ? K_PRMT_sEMPTY : this.toGetValue();
  227. //perform any special formating
  228. var singleQuote = K_PRMT_sEMPTY;
  229. //treat as a string if there is no data type
  230. if (this.m_sDataType == null)
  231. {
  232. singleQuote = "'";
  233. }
  234. switch (this.getFilterType(sFromValue,sToValue))
  235. {
  236. //FILTER_EQUAL_TO
  237. case 0:
  238. s = singleQuote + encodeURIComponent(sFromValue) + singleQuote;
  239. break;
  240. //FILTER_GREATER_THAN_OR_EQUAL_TO
  241. case 1:
  242. s = singleQuote + encodeURIComponent(sFromValue) + singleQuote + K_PRMT_sCOLON;
  243. break;
  244. //FILTER_LESS_THAN_OR_EQUAL_TO
  245. case 2:
  246. s = K_PRMT_sCOLON + singleQuote + encodeURIComponent(sToValue) + singleQuote;
  247. break;
  248. //FILTER_BETWEEN
  249. case 3:
  250. s = singleQuote + encodeURIComponent(sFromValue) + singleQuote + " : " + singleQuote + encodeURIComponent(sToValue)+ singleQuote;
  251. break;
  252. default:
  253. return false;
  254. }
  255. return s;
  256. }
  257. function CRange_getFilterType(sFromVal, sToVal)
  258. {
  259. var filtertype = null;
  260. var bFrom = false;
  261. var sFromValue = sFromVal;
  262. var bTo = false;
  263. var sToValue = sToVal;
  264. if (this.m_bRequired == true)
  265. {
  266. if (sFromValue != K_PRMT_sEMPTY)
  267. {
  268. bFrom = true;
  269. }
  270. if (sToValue != K_PRMT_sEMPTY)
  271. {
  272. bTo = true;
  273. }
  274. }
  275. else
  276. {
  277. //check filters
  278. if ((this.m_oRadioFrom.checked == true) && (sFromValue != K_PRMT_sEMPTY))
  279. {
  280. bFrom = true;
  281. }
  282. if ((this.m_oRadioTo.checked == true) && (sToValue != K_PRMT_sEMPTY))
  283. {
  284. bTo = true;
  285. }
  286. }
  287. //determine type
  288. if ((bFrom == true) && (bTo == false))
  289. {
  290. filtertype = FILTER_GREATER_THAN_OR_EQUAL_TO;
  291. return filtertype;
  292. }
  293. else if ((bFrom == false) && (bTo == true))
  294. {
  295. filtertype = FILTER_LESS_THAN_OR_EQUAL_TO;
  296. return filtertype;
  297. }
  298. else if ((bFrom == true) && (bTo == true))
  299. {
  300. if (sFromValue == sToValue)
  301. {
  302. filtertype = FILTER_EQUAL_TO;
  303. }
  304. else
  305. {
  306. filtertype = FILTER_BETWEEN;
  307. }
  308. return filtertype;
  309. }
  310. return false;
  311. }
  312. function CRange_getDataType()
  313. {
  314. return this.m_sDataType;
  315. }
  316. //perform any special processing for the server.
  317. // convert to the following format
  318. // <selectChoices>
  319. // <selectBoundRange selected="[true | false]">
  320. // <start displayValue="[user value]" useValue="[system value]"/>
  321. // <end displayValue="[user value]" useValue="[system value]"/>
  322. // </selectBoundRange>
  323. // <selectUnboundedEndRange selected="[true | false]">
  324. // <start displayValue="[user value]" useValue="[system value]"/>
  325. // </selectUnboundedEndRange>
  326. // <selectUnboundedStartRange selected="[true | false]">
  327. // <end displayValue="[user value]" useValue="[system value]"/>
  328. // </selectUnboundedStartRange>
  329. // <selectOption displayValue="[user value]" useValue="[system value]" selected="[true | false]"/>
  330. // </selectChoices>
  331. function CRange_preProcess()
  332. {
  333. if (this.m_sSubmitType == K_PRMT_sXML)
  334. {
  335. var sURLValues = K_PRMT_sEMPTY;
  336. var sFromValue = this.fromGetValue();
  337. var sFromFormatValue = this.fromGetFormatValue();
  338. var sToValue = this.toGetValue();
  339. var sToFormatValue = this.toGetFormatValue();
  340. switch (this.getFilterType(sFromValue,sToValue))
  341. {
  342. //equals FILTER_EQUAL_TO
  343. case 0:
  344. sURLValues += '<selectOption';
  345. sURLValues += ' displayValue="' + sXmlEncode(sFromFormatValue) +'"';
  346. sURLValues += ' useValue="' + sXmlEncode(sFromValue) + '"';
  347. sURLValues += ' selected="true" />';
  348. break;
  349. //greater than or equal to FILTER_GREATER_THAN_OR_EQUAL_TO
  350. case 1:
  351. sURLValues += '<selectUnboundedEndRange selected="true">';
  352. sURLValues += '<start displayValue="'+ sXmlEncode(sFromFormatValue) +'" useValue="'+ sXmlEncode(sFromValue) +'"/>';
  353. sURLValues += '</selectUnboundedEndRange>';
  354. break;
  355. //less than or equal to FILTER_LESS_THAN_OR_EQUAL_TO
  356. case 2:
  357. sURLValues += '<selectUnboundedStartRange selected="true">';
  358. sURLValues += '<end displayValue="'+ sXmlEncode(sToFormatValue) +'" useValue="'+ sXmlEncode(sToValue) +'"/>';
  359. sURLValues += '</selectUnboundedStartRange>';
  360. break;
  361. //between FILTER_BETWEEN
  362. case 3:
  363. sURLValues += '<selectBoundRange selected="true">';
  364. sURLValues += '<start displayValue="'+ sXmlEncode(sFromFormatValue) +'" useValue="'+ sXmlEncode(sFromValue) +'"/>';
  365. sURLValues += '<end displayValue="'+ sXmlEncode(sToFormatValue) +'" useValue="'+ sXmlEncode(sToValue) +'"/>';
  366. sURLValues += '</selectBoundRange>';
  367. break;
  368. default:
  369. break;
  370. }
  371. addSelectChoices(this.m_oSubmit, sURLValues);
  372. }
  373. else
  374. {
  375. this.m_oSubmit.value = this.sGetValue();
  376. }
  377. }
  378. //verify if the control has values
  379. function CRange_checkData()
  380. {
  381. var bRequired = this.isRequired();
  382. var bFromValid = true;
  383. var bToValid = true;
  384. //determine if to/from controls have valid values
  385. if ((this.m_oRadioFrom) && (this.m_oRadioTo))
  386. {
  387. if (this.m_oRadioFrom.checked == true)
  388. {
  389. bFromValid = this.m_oFrom.isValid();
  390. }
  391. if (this.m_oRadioTo.checked == true)
  392. {
  393. bToValid = this.m_oTo.isValid();
  394. }
  395. }
  396. else
  397. {
  398. bFromValid = this.m_oFrom.isValid();
  399. bToValid = this.m_oTo.isValid();
  400. }
  401. //is a value required?
  402. if ((bRequired == true) && ((bFromValid = false) || (bToValid == false)))
  403. {
  404. this.m_bValid = false;
  405. this.notify(gFAIL, this);
  406. return false;
  407. }
  408. this.m_bValid = true;
  409. this.notify(gPASS, this);
  410. return true;
  411. }
  412. //verify if the control has values
  413. //without sending a notification
  414. function CRange_update()
  415. {
  416. var bRequired = this.isRequired();
  417. //determine if to/from controls have valid values
  418. var bFromValid = this.m_oFrom.getValid();
  419. var bToValid = this.m_oTo.getValid();
  420. //is a value required?
  421. if ((bRequired == true) && ((bFromValid = false) || (bToValid == false)))
  422. {
  423. this.m_bValid = false;
  424. return false;
  425. }
  426. this.m_bValid = true;
  427. return true;
  428. }
  429. function CRange_hasValue()
  430. {
  431. if ((this.m_oRadioFrom) && (this.m_oRadioTo))
  432. {
  433. if ( (this.m_oRadioFrom.checked == true) && (this.m_oFrom.hasValue() ) || ( this.m_oRadioTo.checked == true) && (this.m_oTo.hasValue() ) )
  434. {
  435. return true;
  436. }
  437. else
  438. {
  439. return false;
  440. }
  441. }
  442. else
  443. {
  444. if ((this.m_oFrom.hasValue() ) && (this.m_oTo.hasValue()) )
  445. {
  446. return true;
  447. }
  448. else
  449. {
  450. return false;
  451. }
  452. }
  453. }
  454. //provides the ability to notify other controls when
  455. //the state of the range control changes
  456. //typically used for radio button selections
  457. function CRange_rangeNotify()
  458. {
  459. this.notify(gUPDATE, this);
  460. }
  461. //check the radio button that has been typed in
  462. function CRange_fromCheckRadioState(evt)
  463. {
  464. //trap the tab key and shift-tab
  465. evt = (evt) ? evt : ((event) ? event : null);
  466. if (evt)
  467. {
  468. var keyCode = (evt.keyCode) ? evt.keyCode : evt.which;
  469. //trap the tab key and shift-tab
  470. if ((keyCode != '0') && (keyCode != '9') && (keyCode != '16'))
  471. {
  472. this.fromGotFocus();
  473. }
  474. }
  475. }
  476. //catch the backspace key
  477. //some browsers (IE5.5 don't capture this event)
  478. function CRange_fromKeyPress(sKeyCode)
  479. {
  480. if (typeof event != K_PRMT_sUNDEFINED)
  481. {
  482. if ((sKeyCode=='8'))
  483. {
  484. //check the data that has been typed in
  485. this.fromCheckRadioState(event);
  486. }
  487. }
  488. return true;
  489. }
  490. //check the radio button that has been typed in
  491. function CRange_toCheckRadioState(evt)
  492. {
  493. //trap the tab key and shift-tab
  494. evt = (evt) ? evt : ((event) ? event : null);
  495. if (evt)
  496. {
  497. var keyCode = (evt.keyCode) ? evt.keyCode : evt.which;
  498. //trap the tab key and shift-tab
  499. if ((keyCode != '0') && (keyCode != '9') && (keyCode != '16'))
  500. {
  501. this.toGotFocus();
  502. }
  503. }
  504. }
  505. //catch the backspace key
  506. //some browsers (IE5.5 don't capture this event)
  507. function CRange_toKeyPress(sKeyCode)
  508. {
  509. if (typeof event != K_PRMT_sUNDEFINED)
  510. {
  511. if ((sKeyCode=='8'))
  512. {
  513. //check the data that has been typed in
  514. this.toCheckRadioState(event);
  515. }
  516. }
  517. return true;
  518. }
  519. function CRange_isRangeReversed(from, to)
  520. {
  521. if (typeof from == K_PRMT_sUNDEFINED) {
  522. from = this.m_oFrom.sGetValue();
  523. }
  524. if (typeof to == K_PRMT_sUNDEFINED) {
  525. to = this.m_oTo.sGetValue();
  526. }
  527. if (from == null || from == K_PRMT_sEMPTY || to == null || to == K_PRMT_sEMPTY || (this.m_oRadioTo && this.m_oRadioTo.checked == false) || (this.m_oRadioFrom && this.m_oRadioFrom.checked == false)) {
  528. return false;
  529. }
  530. var fromValue;
  531. var toValue;
  532. if (this.getDataType() == 'number' || this.getDataType() == 'currency' ||
  533. this.getDataType() == 'integer' || this.getDataType() == 'natural' ||
  534. this.getDataType() == 'whole' || this.getDataType() == 'percentage')
  535. {
  536. fromValue = (+sParseByDataType(from,this.getDataType(),true));
  537. toValue = (+sParseByDataType(to,this.getDataType(),true));
  538. }
  539. else if (this.getDataType() == 'interval')
  540. {
  541. if (from == "000 00:00:00.000" || to == "000 00:00:00.000") {
  542. return false;
  543. }
  544. fromValue = parseInt(from.substring(0, from.indexOf(K_PRMT_sSP)), 10);
  545. toValue = parseInt(to.substring(0, to.indexOf(K_PRMT_sSP)), 10);
  546. if (fromValue > toValue) { //days
  547. return true;
  548. }
  549. fromValue = parseInt(from.substring((from.indexOf(K_PRMT_sSP) + 1), from.indexOf(K_PRMT_sCOLON)), 10);
  550. toValue = parseInt(to.substring((to.indexOf(K_PRMT_sSP) + 1), to.indexOf(K_PRMT_sCOLON)), 10);
  551. if (fromValue > toValue) { //hours
  552. return true;
  553. }
  554. fromValue = parseInt(from.substring((from.indexOf(K_PRMT_sCOLON) + 1), from.lastIndexOf(K_PRMT_sCOLON)), 10);
  555. toValue = parseInt(to.substring((to.indexOf(K_PRMT_sCOLON) + 1), to.lastIndexOf(K_PRMT_sCOLON)), 10);
  556. if (fromValue > toValue) { //minutes
  557. return true;
  558. }
  559. fromValue = parseInt(from.substring((from.lastIndexOf(K_PRMT_sCOLON) + 1), from.indexOf(K_PRMT_sDOT)), 10);
  560. toValue = parseInt(to.substring((to.lastIndexOf(K_PRMT_sCOLON) + 1), to.indexOf(K_PRMT_sDOT)), 10);
  561. if (fromValue > toValue) { //seconds
  562. return true;
  563. }
  564. fromValue = parseInt(from.substr((from.indexOf(K_PRMT_sDOT) + 1)), 10);
  565. toValue = parseInt(to.substr((to.indexOf(K_PRMT_sDOT) + 1)), 10);
  566. if (fromValue > toValue) { //milliseconds
  567. return true;
  568. }
  569. return false;
  570. }
  571. else
  572. {
  573. //determine if this is a number or identifier and if so, parse it as a float
  574. //so that it can be sorted properly
  575. //otherwise, this is a string
  576. if ((bNumbersOnly(from) == true) && (bNumbersOnly(to) == true))
  577. {
  578. fromValue = parseFloat(from);
  579. toValue = parseFloat(to);
  580. }
  581. else
  582. {
  583. fromValue = from;
  584. toValue = to;
  585. }
  586. }
  587. return (fromValue > toValue);
  588. }
  589. CRange.prototype.toGotFocus = CRange_toGotFocus;
  590. CRange.prototype.fromGotFocus = CRange_fromGotFocus;
  591. CRange.prototype.toGetValue = CRange_toGetValue;
  592. CRange.prototype.fromGetValue = CRange_fromGetValue;
  593. CRange.prototype.toGetFormatValue = CRange_toGetFormatValue;
  594. CRange.prototype.fromGetFormatValue = CRange_fromGetFormatValue;
  595. CRange.prototype.sGetFormatValue = CRange_sGetFormatValue;
  596. CRange.prototype.sGetValue = CRange_sGetValue;
  597. CRange.prototype.getFilterType = CRange_getFilterType;
  598. CRange.prototype.getDataType = CRange_getDataType;
  599. CRange.prototype.preProcess = CRange_preProcess;
  600. CRange.prototype.checkData = CRange_checkData;
  601. CRange.prototype.update = CRange_update;
  602. CRange.prototype.initControls = CRange_initControls;
  603. CRange.prototype.hasValue = CRange_hasValue;
  604. CRange.prototype.rangeNotify = CRange_rangeNotify;
  605. CRange.prototype.fromCheckRadioState = CRange_fromCheckRadioState;
  606. CRange.prototype.fromKeyPress = CRange_fromKeyPress;
  607. CRange.prototype.toCheckRadioState = CRange_toCheckRadioState;
  608. CRange.prototype.toKeyPress = CRange_toKeyPress;
  609. CRange.prototype.isRangeReversed = CRange_isRangeReversed;
  610. //CONSTANTS
  611. //constants for filters
  612. //note that netscape 4.7x does not support these for use in
  613. //switch statements. If these variables are modified, the
  614. //switch statements will need to be modified as well
  615. var FILTER_EQUAL_TO = 0;
  616. var FILTER_GREATER_THAN_OR_EQUAL_TO = 1;
  617. var FILTER_LESS_THAN_OR_EQUAL_TO = 2;
  618. var FILTER_BETWEEN = 3;
  619. //constants for range initialization
  620. //these will determine whether to select/deselect radio buttons
  621. var RANGE_UNKNOWN_VALUE = 0;
  622. var RANGE_START_VALUE = 1;
  623. var RANGE_END_VALUE = 2;
  624. var RANGE_BOUND_VALUE = 3;
  625. var RANGE_EQUAL_VALUE = 4;
  626. var RANGE_NO_VALUE = 5;
  627. //this function can be called to notify
  628. //any range controls to check their states
  629. function rangeNotify()
  630. {
  631. if (typeof checkRanges != K_PRMT_sUNDEFINED)
  632. {
  633. checkRanges();
  634. }
  635. }
  636. //this function will check to see if all controls are
  637. //ready for navigation to the next page
  638. function checkRanges()
  639. {
  640. if (typeof rangeObserverArray != K_PRMT_sUNDEFINED)
  641. {
  642. var kCount = rangeObserverArray.length;
  643. var k = 0;
  644. for (k=0; k<kCount; k++)
  645. {
  646. var promptElement = eval(rangeObserverArray[k]);
  647. //verify that the range control Valid
  648. promptElement.update();
  649. }
  650. }
  651. }