Advertisement
Guest User

Untitled

a guest
Sep 20th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.51 KB | None | 0 0
  1. activeButton = "";
  2. clickedButton = "";
  3. SPPId = "";
  4. loginFormSubmitted = false;
  5. jQuery(document).ready(function() {
  6.  
  7. $( window ).unload(function() {
  8. loginFormSubmitted = false;
  9. });
  10.  
  11. /*radioInit();
  12. returnUrlInit();*/
  13.  
  14. /*$(".form_element_spacing").click(function(event){
  15. clickedButton = this.id;
  16. slideToggle($("#"+clickedButton+"_option"),"visible");
  17. if (activeButton != clickedButton) {
  18. slideToggle($("#"+activeButton+"_option"));
  19. }
  20. activeButton = clickedButton;
  21. clearHHonorsFields();
  22. });
  23.  
  24.  
  25. $("a.help_link").fancybox({
  26. 'transitionIn' : 'elastic',
  27. 'transitionOut' : 'elastic',
  28. 'width' : 650,
  29. 'height' : 450,
  30. 'type' : 'iframe'
  31. });
  32. */
  33. $("label").inFieldLabels();
  34.  
  35. $("#locale_select").change(function() {
  36. if (location.href.split("?").length > 1) {
  37. reg = new RegExp("locale=[a-z]{2}");
  38. if (location.href.match(reg)) {
  39. location.href = location.href.replace(reg, "locale="+$(this).val());
  40. } else {
  41. location.href = location.href + "&locale="+$(this).val();
  42. }
  43. }
  44. });
  45.  
  46. /*
  47. $("#HHUsername").change(function() {
  48. clearNonHHonorsFields();
  49. });
  50.  
  51. $("#HHPassword").change(function() {
  52. clearNonHHonorsFields();
  53. });
  54.  
  55. $("#HHRoomNumber").change(function() {
  56. clearNonHHonorsFields();
  57. });
  58. */
  59. });
  60.  
  61.  
  62.  
  63. /*
  64. function radioInit(){
  65. var optionRadios = document.getElementsByName("option");
  66. for (var i = 0; i < optionRadios.length; i++) {
  67. if (optionRadios[i].checked){
  68. activeButton = optionRadios[i].id;
  69. $("#"+activeButton+"_option").slideDown(500);
  70. }
  71. }
  72. }
  73.  
  74. function clearHHonorsFields(){
  75. var HHUsernameField = document.getElementById('HHUsername');
  76. if (HHUsernameField){
  77. HHUsernameField.focus();
  78. HHUsernameField.value="";
  79. HHUsernameField.blur();
  80. }
  81. var HHPasswordField = document.getElementById('HHPassword');
  82. if (HHPasswordField){
  83. HHPasswordField.focus();
  84. HHPasswordField.value="";
  85. HHPasswordField.blur();
  86. }
  87. var HHRoomNumberField = document.getElementById('HHRoomNumber');
  88. if (HHRoomNumberField){
  89. HHRoomNumberField.focus();
  90. HHRoomNumberField.value="";
  91. HHRoomNumberField.blur();
  92. }
  93. return true;
  94. }
  95.  
  96. function clearNonHHonorsFields(){
  97. var textfields = ["AccessCode","LastName","RoomNumber","PromotionCode","username","password","memberpass"];
  98. for (var i in textfields) {
  99. var thisTextfield = document.getElementById(textfields[i]);
  100. if(thisTextfield){
  101. thisTextfield.focus();
  102. thisTextfield.value = "";
  103. thisTextfield.blur();
  104. }
  105. }
  106.  
  107. var radiobuttons = ["promo_button","folio_button","pms_button","ccbill_button","subscriber_button"];
  108. for (var i in radiobuttons) {
  109. var thisRadiobutton = document.getElementById(radiobuttons[i]);
  110. if(thisRadiobutton){
  111. thisRadiobutton.checked = false;
  112. $("#"+thisRadiobutton.id+"_option").slideUp(500);
  113. activeButton = "";
  114. }
  115. }
  116. var roamRealmMenu = document.getElementById('roamRealm');
  117. if(roamRealmMenu){
  118. roamRealmMenu.selectedIndex = 0;
  119. }
  120. return true;
  121. }
  122. */
  123.  
  124. function validateHiltonLoginForm(form){
  125. if (loginFormSubmitted) {
  126. return false;
  127. }
  128.  
  129. var validated = false;
  130.  
  131. var AccessCode = document.getElementById('AccessCode');
  132. var HHUsername = document.getElementById('HHUsername');
  133. var HHPassword = document.getElementById('HHPassword');
  134. var HHRoomNumber = document.getElementById('HHRoomNumber');
  135. var LastName = document.getElementById('LastName');
  136. var RoomNumber = document.getElementById('RoomNumber');
  137. var PromotionCode = document.getElementById('PromotionCode');
  138. var aupAgree = document.getElementById('aupAgree');
  139. var username = document.getElementById('username');
  140. var password = document.getElementById('password');
  141. var roamRealm = document.getElementById('roamRealm');
  142.  
  143.  
  144. var hhonors_button = document.getElementById('hhonors_button');
  145. var subscriber_button = document.getElementById('subscriber_button');
  146. var complimentary_button = document.getElementById('complimentary_button');
  147. var promo_button = document.getElementById('promo_button');
  148. var folio_button = document.getElementById('folio_button');
  149. var ccbill_button = document.getElementById('ccbill_button');
  150. var pms_button = document.getElementById('pms_button');
  151. var purchase_button = document.getElementById('purchase_button');
  152. var adddevice_button = document.getElementById('adddevice_button');
  153.  
  154. var optionChecked = false;
  155. /*var elements = ["AccessCode","HHUsername","HHPassword","HHRoomNumber","LastName","RoomNumber","PromotionCode","username","password"];
  156. var dataEntered = false;
  157. var radioChecked = false;
  158. for (var i in elements) {
  159. listElement = document.getElementById(elements[i]);
  160.  
  161. if (listElement && trim(listElement.value) != "") {
  162. dataEntered = true;
  163. }
  164. }
  165. */
  166. //if (!dataEntered) {
  167. var optionRadios = document.getElementsByName("option");
  168. if(optionRadios){
  169. for (var i = 0; i < optionRadios.length; i++) {
  170. if (optionRadios[i].checked){
  171. optionChecked = true;
  172. }
  173. }
  174. }
  175. //}
  176. /*
  177. if(!optionChecked && form.PaymentMethod.value != "Passthrough" ){
  178. alert(makeSelectAlert);
  179. return false;
  180. }
  181. */
  182.  
  183. if(!validated){
  184. if(promo_button && (promo_button.checked)){
  185. form.PaymentMethod.value = PromotionCodePm;
  186. form.ValidationHash.value = PromotionCodeHash;
  187. form.action = PromotionCodeAction;
  188. validated = true;
  189. }
  190. }
  191.  
  192.  
  193. if(!validated){
  194. if(folio_button && (folio_button.checked)){
  195. form.PaymentMethod.value = FolioPm;
  196. form.ValidationHash.value = FolioHash;
  197. form.action = FolioAction;
  198. validated = true;
  199. }
  200. }
  201.  
  202. if(!validated){
  203. if(purchase_button && (purchase_button.checked)){
  204. form.PaymentMethod.value = FolioPm;
  205. form.ValidationHash.value = FolioHash;
  206. form.PO.value = '1';
  207. form.compTier.value = '0';
  208. form.action = FolioAction;
  209. validated = true;
  210. }
  211. }
  212.  
  213. if(!validated){
  214. if(subscriber_button && (subscriber_button.checked)){
  215. form.PaymentMethod.value = MembershipPm;
  216. form.ValidationHash.value = MembershipHash;
  217. form.action = MembershipAction;
  218. validated = true;
  219. }
  220. }
  221.  
  222. if(!validated){
  223. if(complimentary_button && (complimentary_button.checked)){
  224. form.PaymentMethod.value = FolioPm;
  225. form.ValidationHash.value = FolioHash;
  226. form.compTier.value = '1';
  227. form.PO.value = '1';
  228. form.action = FolioAction;
  229. validated = true;
  230. }
  231. }
  232.  
  233. if(!validated){
  234. if(adddevice_button && (adddevice_button.checked)){
  235. form.PaymentMethod.value = FolioPm;
  236. form.ValidationHash.value = FolioHash;
  237. form.addDeviceFlag.value = '1';
  238. form.action = FolioAction;
  239. validated = true;
  240. }
  241. }
  242.  
  243. if(!validated){
  244. if(hhonors_button && (hhonors_button.checked)){
  245. form.PaymentMethod.value = HiltonHonorsPm;
  246. form.ValidationHash.value = HiltonHonorsHash;
  247. form.action = HiltonHonorsAction;
  248. validated = true;
  249. }
  250. }
  251.  
  252. if(form.PaymentMethod.value == "Passthrough"){
  253. validated = true;
  254. }
  255.  
  256.  
  257. if(validated){
  258. if(aupAgree && !(aupAgree.type == "hidden")){
  259. if(!(aupAgree.checked)){
  260. alert(aupAlert);
  261. aupAgree.focus();
  262. validated = false;
  263. }
  264. }
  265. }
  266.  
  267.  
  268. if(validated){
  269. if(loginFormSubmitted){
  270. // multiclick protection
  271. return false;
  272. } else {
  273. loginFormSubmitted = true;
  274. return true;
  275. }
  276. } else {
  277. loginFormSubmitted = false;
  278. return false;
  279. }
  280.  
  281. }
  282.  
  283. function validateHiltonPurchaseForm(form){
  284. if (loginFormSubmitted) {
  285. return false;
  286. }
  287.  
  288. var validated = false;
  289.  
  290. var ccbill_button = document.getElementById('ccbill_button');
  291. var pms_button = document.getElementById('pms_button');
  292.  
  293. var optionChecked = false;
  294.  
  295. if(!validated){
  296. if(folio_button && (folio_button.checked)){
  297. form.PaymentMethod.value = FolioPm;
  298. form.ValidationHash.value = FolioHash;
  299. form.action = FolioAction;
  300. validated = true;
  301. }
  302. }
  303.  
  304. if(!validated){
  305. if(ccbill_button && (ccbill_button.checked)){
  306. form.PaymentMethod.value = CreditCardPm;
  307. form.ValidationHash.value = CreditCardHash;
  308. form.action = CreditCardAction;
  309. validated = true;
  310. }
  311. }
  312.  
  313. if(validated){
  314. if(loginFormSubmitted){
  315. // multiclick protection
  316. return false;
  317. } else {
  318. loginFormSubmitted = true;
  319. return true;
  320. }
  321. } else {
  322. loginFormSubmitted = false;
  323. return false;
  324. }
  325.  
  326. }
  327.  
  328. function validatePromoCodeForm(form) {
  329. if (loginFormSubmitted) {
  330. return false;
  331. }
  332. var validated = false;
  333. var PromotionCode = document.getElementById('PromotionCode');
  334.  
  335. if(!validated){
  336.  
  337. if(trim(PromotionCode.value) == ""){
  338. alert(couponAlert);
  339. PromotionCode.focus();
  340. return false;
  341. } else {
  342. var couponReg = new RegExp("^wp");
  343. var couponString = trim(PromotionCode.value).toLowerCase() ;
  344. if (couponString.match(couponReg)) {
  345. form.PaymentMethod.value = CouponPm;
  346. form.ValidationHash.value = CouponHash;
  347. form.action = CouponAction;
  348. } else {
  349. form.PaymentMethod.value = PromotionCodePm;
  350. form.ValidationHash.value = PromotionCodeHash;
  351. form.action = PromotionCodeAction;
  352. }
  353. validated = true;
  354. var aupAgree = document.getElementById('aupAgree');
  355. if(aupAgree && !(aupAgree.type == "hidden")){
  356. if(!(aupAgree.checked)){
  357. alert(aupAlert);
  358. aupAgree.focus();
  359. validated = false;
  360. }
  361. }
  362. }
  363. }
  364.  
  365. if(validated){
  366. if(loginFormSubmitted){
  367. // multiclick protection
  368. return false;
  369. } else {
  370. loginFormSubmitted = true;
  371. return true;
  372. }
  373. } else {
  374. loginFormSubmitted = false;
  375. return false;
  376. }
  377.  
  378. }
  379.  
  380.  
  381. function validatePMSForm(form) {
  382. if (loginFormSubmitted) {
  383. return false;
  384. }
  385. var validated = false;
  386. var LastName = document.getElementById('LastName');
  387. var RoomNumber = document.getElementById('RoomNumber');
  388. var PromotionCode = document.getElementById('PromotionCode');
  389.  
  390. if(!validated){
  391. if(RoomNumber.value == ""){
  392. alert(roomNumberAlert);
  393. RoomNumber.focus();
  394. return false;
  395. } else if(LastName.value == ""){
  396. alert(lastNameAlert);
  397. LastName.focus();
  398. return false;
  399. } else {
  400. form.PaymentMethod.value = FolioPm;
  401. form.ValidationHash.value = FolioHash;
  402. form.action = FolioAction;
  403. validated = true;
  404. }
  405. }
  406.  
  407.  
  408. if(validated){
  409. if(loginFormSubmitted){
  410. // multiclick protection
  411. return false;
  412. } else {
  413. loginFormSubmitted = true;
  414. return true;
  415. }
  416. } else {
  417. loginFormSubmitted = false;
  418. return false;
  419. }
  420.  
  421. }
  422.  
  423. function validateSubscriberForm(form) {
  424. if (loginFormSubmitted) {
  425. return false;
  426. }
  427. var validated = false;
  428. var username = document.getElementById('username');
  429. var password = document.getElementById('password');
  430. var roamRealm = document.getElementById('roamRealm');
  431.  
  432.  
  433. if(!validated){
  434.  
  435. var usernameVal = trim(username.value);
  436. var passwordVal = trim(password.value);
  437. if(usernameVal == "") {
  438. alert(usernameAlert);
  439. username.focus();
  440. return false;
  441. } else if (passwordVal == "") {
  442. alert(passwordAlert);
  443. password.focus();
  444. return false;
  445. } else if (roamRealm.selectedIndex == 0){
  446. alert(DomainAlert);
  447. roamRealm.focus();
  448. return false;
  449. } else {
  450. form.PaymentMethod.value = MembershipPm;
  451. form.ValidationHash.value = MembershipHash;
  452. form.action = MembershipAction;
  453. validated = true;
  454. }
  455. }
  456.  
  457.  
  458. if(validated){
  459. if(loginFormSubmitted){
  460. // multiclick protection
  461. return false;
  462. } else {
  463. loginFormSubmitted = true;
  464. return true;
  465. }
  466. } else {
  467. loginFormSubmitted = false;
  468. return false;
  469. }
  470.  
  471. }
  472.  
  473. function validateHHonorsForm(form) {
  474. if (loginFormSubmitted) {
  475. return false;
  476. }
  477. var validated = false;
  478. var HHUsername = document.getElementById('HHUsername');
  479. var HHPassword = document.getElementById('HHPassword');
  480. var HHRoomNumber = document.getElementById('HHRoomNumber');
  481.  
  482.  
  483. var HHUsernameVal = trim(HHUsername.value);
  484. var HHPasswordVal = trim(HHPassword.value);
  485.  
  486. if( (HHUsernameVal != "") || (HHPasswordVal != "") ) {
  487. if(HHUsernameVal == ""){
  488. alert(hhAccountAlert);
  489. HHUsername.focus();
  490. return false;
  491. } else if(HHPasswordVal == "") {
  492. alert(hhPinAlert);
  493. HHPassword.focus();
  494. return false;
  495. } else if(HHRoomNumber && trim(HHRoomNumber.value) == "") {
  496. alert(roomNumberAlert);
  497. HHRoomNumber.focus();
  498. return false;
  499. } else {
  500. //form.PaymentMethod.value = HiltonHonorsPm;
  501. //form.ValidationHash.value = HiltonHonorsHash;
  502. validated = true;
  503. }
  504. }
  505.  
  506. if(validated){
  507. if(loginFormSubmitted){
  508. // multiclick protection
  509. return false;
  510. } else {
  511. loginFormSubmitted = true;
  512. return true;
  513. }
  514. } else {
  515. loginFormSubmitted = false;
  516. return false;
  517. }
  518.  
  519. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement