Guest User

Untitled

a guest
Feb 19th, 2018
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*jslint white:false plusplus:false browser:true nomen:false */
  2. /*globals $, nav, log, lang, window */
  3.  
  4. var UPP = {
  5.  
  6.     // class methods
  7.     code_submit: function() {
  8.         $('.error').hide();
  9.         return nav.formjax($(this), UPP.register, log.error);
  10.  
  11.     },
  12.     email_submit: function() {
  13.         $('.error').hide();
  14.         return nav.formjax($(this), UPP.thank_you, log.error);
  15.     },
  16.     vip_submit: function() {
  17.         $('.error').hide();
  18.         return nav.formjax($(this), UPP.thank_you_vip, log.error);
  19.     },
  20.     thank_you: function(response) {
  21.         if (response.rc === 0) {
  22.             $('.popper').hide();
  23.             $('#thank_you').show();
  24.         }
  25.         else {
  26.             $('.error').html(lang(response.error)).show();
  27.         }
  28.     },
  29.     thank_you_vip: function(response) {
  30.         if (response.rc === 0) {
  31.             $('.grad').hide();
  32.             $('#thank_you_vip').show();
  33.         }
  34.         else {
  35.             $('.error').html(lang(response.error)).show();
  36.         }
  37.     },
  38.     register: function(response) {
  39.         if (response.rc === 0) {
  40.             $('#popup').hide();
  41.             $('#register').show();
  42.             $('#vip_code').val(response.code);
  43.         }
  44.         else {
  45.             $('.error').html(lang(response.error)).show();
  46.         }
  47.     },
  48.     band_color: function() {
  49.         var color = $(this).attr('href');
  50.         $('.band_color').removeClass('selected');
  51.         $(color).addClass('selected');
  52.         $('#band_color').val(color.substring(1));
  53.         return false;
  54.     },
  55.     colors: function(request) {
  56.         return [
  57.             { 'label' : "<span class='band_color white'></span> White", 'value' : 'White' },
  58.             { 'label' : "<span class='band_color gray'></span> Gray", 'value': 'Gray' },
  59.             { 'label' : "<span class='band_color blue'></span> Blue", 'value' : 'Blue' },
  60.             { 'label' :  "<span class='band_color red'></span> Red", 'value' : 'Red' }
  61.         ];
  62.     },
  63.     colors2: function(request) {
  64.         return [
  65.             { 'label' : "<span class='band_color white'></span> White", 'value' : 'White' },
  66.             { 'label' : "<span class='band_color gray'></span> Gray", 'value': 'Gray' },
  67.             { 'label' : "<span class='band_color blue'></span> Blue", 'value' : 'Blue' },
  68.             { 'label' :  "<span class='band_color red'></span> Red", 'value' : 'Red' },
  69.             { 'label' : "I'll wait for my first choice", 'value' : 'Wait' },
  70.             { 'label' : "I'll take whatever I can get", 'value' : 'Whatever' }
  71.         ];
  72.     },    
  73.     countries: function(request) {
  74.         var matcher, countries = [
  75.             "United States",
  76.             "United Kingdom",
  77.             "Germany",
  78.             "Cananda",
  79.             "---",
  80.             "Abkhazia",
  81.             "Afghanistan",
  82.             "Akrotiri and Dhekelia",
  83.             "Aland",
  84.             "Albania",
  85.             "Algeria",
  86.             "American Samoa",
  87.             "Andorra",
  88.             "Angola",
  89.             "Anguilla",
  90.             "Antigua and Barbuda",
  91.             "Argentina",
  92.             "Armenia",
  93.             "Aruba",
  94.             "Ascension Island",
  95.             "Australia",
  96.             "Austria",
  97.             "Azerbaijan",
  98.             "Bahamas, The",
  99.             "Bahrain",
  100.             "Bangladesh",
  101.             "Barbados",
  102.             "Belarus",
  103.             "Belgium",
  104.             "Belize",
  105.             "Benin",
  106.             "Bermuda",
  107.             "Bhutan",
  108.             "Bolivia",
  109.             "Bosnia and Herzegovina",
  110.             "Botswana",
  111.             "Brazil",
  112.             "Brunei",
  113.             "Bulgaria",
  114.             "Burkina Faso",
  115.             "Burundi",
  116.             "Cambodia",
  117.             "Cameroon",
  118.             "Canada",
  119.             "Cape Verde",
  120.             "Cayman Islands",
  121.             "Central Africa Republic",
  122.             "Chad",
  123.             "Chile",
  124.             "China",
  125.             "Christmas Island",
  126.             "Cocos (Keeling) Islands",
  127.             "Colombia",
  128.             "Comoros",
  129.             "Congo",
  130.             "Cook Islands",
  131.             "Costa Rica",
  132.             "Cote d'lvoire",
  133.             "Croatia",
  134.             "Cuba",
  135.             "Cyprus",
  136.             "Czech Republic",
  137.             "Denmark",
  138.             "Djibouti",
  139.             "Dominica",
  140.             "Dominican Republic",
  141.             "East Timor Ecuador",
  142.             "Egypt",
  143.             "El Salvador",
  144.             "Equatorial Guinea",
  145.             "Eritrea",
  146.             "Estonia",
  147.             "Ethiopia",
  148.             "Falkland Islands",
  149.             "Faroe Islands",
  150.             "Fiji",
  151.             "Finland",
  152.             "France",
  153.             "French Polynesia",
  154.             "Gabon",
  155.             "Gambia, The",
  156.             "Georgia",
  157.             "Germany",
  158.             "Ghana",
  159.             "Gibraltar",
  160.             "Greece",
  161.             "Greenland",
  162.             "Grenada",
  163.             "Guam",
  164.             "Guatemala",
  165.             "Guemsey",
  166.             "Guinea",
  167.             "Guinea-Bissau",
  168.             "Guyana",
  169.             "Haiti",
  170.             "Honduras",
  171.             "Hong Kong",
  172.             "Hungary",
  173.             "Iceland",
  174.             "India",
  175.             "Indonesia",
  176.             "Iran",
  177.             "Iraq",
  178.             "Ireland",
  179.             "Isle of Man",
  180.             "Israel",
  181.             "Italy",
  182.             "Jamaica",
  183.             "Japan",
  184.             "Jersey",
  185.             "Jordan",
  186.             "Kazakhstan",
  187.             "Kenya",
  188.             "Kiribati",
  189.             "Korea, North",
  190.             "Korea, South",
  191.             "Kosovo",
  192.             "Kuwait",
  193.             "Kyrgyzstan",
  194.             "Laos",
  195.             "Latvia",
  196.             "Lebanon",
  197.             "Lesotho",
  198.             "Liberia",
  199.             "Libya",
  200.             "Liechtenstein",
  201.             "Lithuania",
  202.             "Luxembourg",
  203.             "Macao",
  204.             "Macedonia",
  205.             "Madagascar",
  206.             "Malawi",
  207.             "Malaysia",
  208.             "Maldives",
  209.             "Mali",
  210.             "Malta",
  211.             "Marshall Islands",
  212.             "Mauritania",
  213.             "Mauritius",
  214.             "Mayotte",
  215.             "Mexico",
  216.             "Micronesia",
  217.             "Moldova",
  218.             "Monaco",
  219.             "Mongolia",
  220.             "Montenegro",
  221.             "Montserrat",
  222.             "Morocco",
  223.             "Mozambique",
  224.             "Myanmar",
  225.             "Nagorno-Karabakh",
  226.             "Namibia",
  227.             "Nauru",
  228.             "Nepal",
  229.             "Netherlands",
  230.             "Netherlands Antilles",
  231.             "New Caledonia",
  232.             "New Zealand",
  233.             "Nicaragua",
  234.             "Niger",
  235.             "Nigeria",
  236.             "Niue",
  237.             "Norfolk Island",
  238.             "Northern Cyprus",
  239.             "Northern Mariana Islands",
  240.             "Norway",
  241.             "Oman",
  242.             "Pakistan",
  243.             "Palau",
  244.             "Palestine",
  245.             "Panama",
  246.             "Papua New Guinea",
  247.             "Paraguay",
  248.             "Peru",
  249.             "Philippines",
  250.             "Pitcairn Islands",
  251.             "Poland",
  252.             "Portugal",
  253.             "Puerto Rico",
  254.             "Qatar",
  255.             "Romania",
  256.             "Russia",
  257.             "Rwanda",
  258.             "Sahrawi Arab Democratic Republic",
  259.             "Saint-Barthelemy",
  260.             "Saint Helena",
  261.             "Saint Kitts and Nevis",
  262.             "Saint Lucia",
  263.             "Saint Martin",
  264.             "Saint Pierre and Miquelon",
  265.             "Saint Vincent and Grenadines",
  266.             "Samos",
  267.             "San Marino",
  268.             "Sao Tome and Principe",
  269.             "Saudi Arabia",
  270.             "Senegal",
  271.             "Serbia",
  272.             "Seychelles",
  273.             "Sierra Leone",
  274.             "Singapore",
  275.             "Slovakia",
  276.             "Slovenia",
  277.             "Solomon Islands",
  278.             "Somalia",
  279.             "Somaliland",
  280.             "South Africa",
  281.             "South Ossetia",
  282.             "Spain",
  283.             "Sri Lanka",
  284.             "Sudan",
  285.             "Suriname",
  286.             "Svalbard",
  287.             "Swaziland",
  288.             "Sweden",
  289.             "Switzerland",
  290.             "Syria",
  291.             "Tajikistan",
  292.             "Tanzania",
  293.             "Thailand",
  294.             "Togo",
  295.             "Tokelau",
  296.             "Tonga",
  297.             "Transnistria",
  298.             "Trinidad and Tobago",
  299.             "Tristan da Cunha",
  300.             "Tunisia",
  301.             "Turkey",
  302.             "Turkmenistan",
  303.             "Turks and Caicos Islands",
  304.             "Tuvalu",
  305.             "Uganda",
  306.             "Ukraine",
  307.             "United Arab Emirates",
  308.             "United Kingdom",
  309.             "United States",
  310.             "Uruguay",
  311.             "Uzbekistan",
  312.             "Vanuatu",
  313.             "Vatican City",
  314.             "Venezuela",
  315.             "Vietnam",
  316.             "Virgin Islands, British",
  317.             "Virgin Islands, U.S.",
  318.             "Wallis and Futuna",
  319.             "Yemen",
  320.             "Zambia",
  321.             "Zimbabwe"
  322.         ];
  323.         if (request.term === '---') {
  324.             return countries;
  325.         }
  326.         matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
  327.         return $.map(countries, function(n, i) {
  328.             if ( matcher.test(n) ) {
  329.                 return n;
  330.             }
  331.             else {
  332.                 return null;
  333.             }
  334.         });
  335.     },
  336.     states: function(request) {
  337.         var matcher, states = [
  338.             "Alabama",
  339.             "Alaska",
  340.             "Arizona",
  341.             "Arkansas",
  342.             "California",
  343.             "Colorado",
  344.             "Connecticut",
  345.             "Delaware",
  346.             "Florida",
  347.             "Georgia",
  348.             "Hawaii",
  349.             "Idaho",
  350.             "Illinois",
  351.             "Indiana",
  352.             "Iowa",
  353.             "Kansas",
  354.             "Kentucky",
  355.             "Louisiana",
  356.             "Maine",
  357.             "Maryland",
  358.             "Massachusetts",
  359.             "Michigan",
  360.             "Minnesota",
  361.             "Mississippi",
  362.             "Missouri",
  363.             "Montana",
  364.             "Nebraska",
  365.             "Nevada",
  366.             "New Hampshire",
  367.             "New Jersey",
  368.             "New Mexico",
  369.             "New York",
  370.             "North Carolina",
  371.             "North Dakota",
  372.             "Ohio",
  373.             "Oklahoma",
  374.             "Oregon",
  375.             "Pennsylvania",
  376.             "Rhode Island",
  377.             "South Carolina",
  378.             "South Dakota",
  379.             "Tennessee",
  380.             "Texas",
  381.             "Utah",
  382.             "Vermont",
  383.             "Virginia",
  384.             "Washington",
  385.             "West Virginia",
  386.             "Wisconsin",
  387.             "Wyoming",
  388.             "*",
  389.             "District of Columbia",
  390.             "Puerto Rico",
  391.             "Guam",
  392.             "American Samoa",
  393.             "U.S. Virgin Islands",
  394.             "Northern Mariana Islands"
  395.         ];
  396.         if (request.term === "---") {
  397.             return states;
  398.         }
  399.         matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
  400.         return $.map(states, function(n, i) {
  401.             if ( matcher.test(n) ) {
  402.                 return n;
  403.             }
  404.             else {
  405.                 return null;
  406.             }
  407.         });
  408.     },
  409.     combo: function(input, button, completion, classy) {
  410.         input.autocomplete({
  411.             'delay':0,
  412.             'source':function( request, response ) {
  413.                 response(completion(request));
  414.             }});
  415.         input.autocomplete('widget').addClass(classy);
  416.         button.bind('click', function() {
  417.             if (input.autocomplete( "widget" ).is( ":visible" ) ) {
  418.                 input.autocomplete( "close" );
  419.                 return false;
  420.             }
  421.             // work around a bug (likely same cause as #5265)
  422.             $( this ).blur();
  423.             // pass empty string as value to search for, displaying all results
  424.             input.autocomplete( "search", "---" );
  425.             input.focus();
  426.             return false;
  427.         });
  428.     }
  429. };
  430.  
  431. $(document).ready(function() {
  432.     $('#submit_code').bind('submit', UPP.code_submit);
  433.     $('#submit_email').bind('submit', UPP.email_submit);
  434.     $('#submit_vip').bind('submit', UPP.vip_submit);
  435.     $('.band_color').bind('click', UPP.band_color);
  436.  
  437.     if (window.location.hash === '#vip') {
  438.         $('#enter_passcode').fadeIn();
  439.     }
  440.     else {
  441.         $('#stay_informed').fadeIn();
  442.     }
  443.  
  444.     UPP.combo($("#country"),$('#country-picker'), UPP.countries, 'country-fill');
  445.     UPP.combo($("#state"),$('#state-picker'), UPP.states, 'state-fill');
  446.     UPP.combo($("#color"),$('#color-picker'), UPP.colors, 'color-fill');
  447.     UPP.combo($("#color2"),$('#color2-picker'), UPP.colors2, 'color-fill');
  448. });
Add Comment
Please, Sign In to add comment