Guest User

main js with dank comments lelelelelel

a guest
Jan 14th, 2016
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. PROJECT: HOME-IFY
  3. Author: Jay Chowdhary
  4. BRO ARE YOU A FUCKING ASIAN CHOWMEIN COOK? FUCKING Chowdhary LMAO IT SOUNDS LIKE THAT SPICE CALLED CHOWDER BUT THEN SINCE YOU A ASIAN NIGGA, YOU HAVE CHOWDHARY
  5. Date: 11/10/2015
  6. File: main.js
  7. */
  8.  
  9. /* global, alert, $, JQuery, confirm */
  10.  
  11. /* User Structure */
  12. var User = {
  13.   name: "",
  14.   email: "",
  15.   id: "",
  16.   username: "",
  17.   password: "",
  18.   dob: "",
  19.   gender: ""
  20. };
  21.  
  22. /* too lazy */
  23. var icon = "<span class='glyphicon glyphicon-remove'></span> ";
  24.  
  25. /* Accounts Array */
  26. var Accounts = (localStorage.getItem("Accounts") !== null) ? JSON.parse(localStorage.getItem("Accounts")) : [];
  27.  
  28. /* Returns User Session [Active] */
  29. var c_user = (localStorage.getItem("Logged") !== null) ? JSON.parse(localStorage.getItem("Logged")) : [];
  30.  
  31. /* Register */
  32. function register() {
  33.   // Checks for errors
  34.   if ((document.getElementById("first-name").value === "") || (document.getElementById("last-name").value === "")) {
  35.       document.getElementById("error").innerHTML = icon + "Please enter your full name.";
  36.       return;
  37.   } else {
  38.     User.name = document.getElementById("first-name").value + " " + document.getElementById("last-name").value;
  39.   }
  40.  
  41.   if ((document.getElementById("email-id").value === "") || (document.getElementById("email-provider").value === "")) {
  42.       document.getElementById("error").innerHTML = icon + "Please enter a valid e-mail.";
  43.       return;
  44.   } else {
  45.     User.email = document.getElementById("email-id").value + "@" + document.getElementById("email-provider").value;
  46.   }
  47.  
  48.   if (document.getElementById("username").value === "") {
  49.       document.getElementById("error").innerHTML = icon + "Please enter a valid username";
  50.       return;
  51.   } else {
  52.     User.username = document.getElementById("username").value;
  53.   }
  54.  
  55.   if (document.getElementById("password").value === "") {
  56.       document.getElementById("error").innerHTML = icon + "Please enter a valid password.";
  57.       return;
  58.   }
  59.  
  60.   if (document.getElementById("password").value !== document.getElementById("verify-password").value) {
  61.       document.getElementById("error").innerHTML = icon + "The passwords entered do not match";
  62.       return;
  63.   } else {
  64.     User.password = document.getElementById("password").value;
  65.   }
  66.  
  67.   if ((document.getElementById("dob-month").value === "") || (document.getElementById("dob-day").value === "") || (document.getElementById("dob-year").value === "")) {
  68.     document.getElementById("error").innerHTML = icon + "Please enter a valid birthday.";
  69.     return;
  70.   } else {
  71.     User.dob = document.getElementById("dob-month").value + " " + document.getElementById("dob-day").value + " " + document.getElementById("dob-year").value;
  72.   }
  73.  
  74.   if ((document.getElementById("gender-male").checked === false) && (document.getElementById("gender-female").checked === false)) {
  75.     document.getElementById("error").innerHTML = icon + "Please select a gender.";
  76.     return;
  77.   } else {
  78.     if (document.getElementById("gender-male").checked === true) {
  79.       User.gender = "male";
  80.     } else {
  81.       User.gender = "female";
  82.     }
  83.   }
  84.  
  85.   User.id = Accounts.length;
  86.   Accounts.push(User); // Pushes the object User into the array Accounts
  87.   localStorage.setItem("Accounts", JSON.stringify(Accounts));
  88.  
  89.   localStorage.setItem("Logged", JSON.stringify(User.id));
  90.   alert("Sucessfully registered!");
  91.   window.location = "portal.html";
  92. }
  93.  
  94. //Logs c_user in
  95. function Login() {
  96.     for (var i = 0; i < Accounts.length; i++) {
  97.         if (document.getElementById("login-user").value === Accounts[i].username && document.getElementById("login-psw").value === Accounts[i].password) {
  98.           localStorage.setItem("Logged", i); // Sets logged in User
  99.           window.location.href = "profiel.html";
  100.           return;
  101.         }
  102.     }
  103.     alert("Invalid username or password!");
  104. }
  105.  
  106. //Logs c_user out
  107. function Logout() {
  108.   localStorage.removeItem("Logged");
  109.   window.location = "index.html";
  110. }
  111.  
  112. /* Portal Page [Registration] */
  113. function PortalPage() {
  114.   var marrigestatus;
  115.   // FINNA FUCKIN REMAIN SINGLE CUZ YOU CANT SPELL MARRIAGE YOU FUCKING DICKBRAIN
  116.   var countryregion;
  117.   var provincestate;
  118.   var city;
  119.   var address;
  120.   var countrycode;
  121.   var phone;
  122.   var occupation;
  123.   var salary;
  124.   var transportation;
  125.   var arts;
  126.   var education;
  127.   var environment;
  128.   var tech;
  129.   var business;
  130.   var health;
  131.   var roommatestatus;
  132.   var pricehome;
  133.   var lengthstay;
  134.  
  135. // THIS IS WHY YOUR PARENTS DONT WANT YOU TO DO RES FOR UNI YOU FUCKING WASTE
  136.   document.getElementById('char-name').innerHTML = Accounts[c_user].name;
  137.  
  138.   /* Portal Page Configuration */
  139.   var navListItems = $('ul.setup-panel li a'),
  140.       allWells = $('.setup-content');
  141.  
  142.   allWells.hide();
  143.  
  144.   navListItems.click(function(e)
  145.   {
  146.       e.preventDefault();
  147.       var $target = $($(this).attr('href')),
  148.           $item = $(this).closest('li');
  149.  
  150.       if (!$item.hasClass('disabled')) {
  151. // IF YOU ARE DISABLED? WHAT DO YOU MEAN IF LMAOOO
  152.           navListItems.closest('li').removeClass('active');
  153.           navListItems.closest('li').addClass('disabled');
  154.           $item.addClass('active');
  155.           allWells.hide();
  156.           $target.show();
  157.       }
  158.   });
  159.  
  160.   $('ul.setup-panel li.active a').trigger('click');
  161.  
  162.   // Step 1 to 2 Button
  163.   $('#activate-step-2').on('click', function(e) {
  164.     var marrigestatus = document.getElementById("marrigestatus"),
  165.         countryregion = document.getElementById("countryregion"),
  166.         provincestate = document.getElementById("provincestate");
  167.  
  168.  
  169.     if (marrigestatus.options[marrigestatus.selectedIndex].value === "Select...") {
  170.         document.getElementById("error").innerHTML = icon + "Please indicate your marital status.";
  171.         return;
  172.     }
  173.     // LMFAO BITCH YOU FINNA BE SINGLE AF LMAOOOOO
  174.  
  175.     if (countryregion.options[countryregion.selectedIndex].value === "Select...") {
  176.         document.getElementById("error").innerHTML = icon + "Please select a valid country.";
  177.         return;
  178.     }
  179.  
  180.     if (provincestate.options[provincestate.selectedIndex].value === "Select...") {
  181.         document.getElementById("error").innerHTML = icon + "Please select a valid province.";
  182.         return;
  183.     }
  184.  
  185.     if (document.getElementById("city").value === "") {
  186.         document.getElementById("error").innerHTML = icon + "Please select a valid city.";
  187.         // WE DONT SERVE YOU MALTON ASS MOTHERFUCKERS....sandalwood represent bitch
  188.         return;
  189.     }
  190.  
  191.     if (document.getElementById("address").value === "") {
  192.         document.getElementById("error").innerHTML = icon + "Please enter a valid address.";
  193.         return;
  194.     }
  195.  
  196.     if (document.getElementById("country-code").value === "") {
  197.         document.getElementById("error").innerHTML = icon + "Please enter your country code.";
  198.         return;
  199.     }
  200.  
  201.     if (document.getElementById("phone").value === "") {
  202.         document.getElementById("error").innerHTML = icon + "Please enter your phone number.";
  203.         // CALL ME ON YOUR CELLLLLPHONNEEEEEEEE DAY NIGHT WHEN U NEED MY PORN
  204.         return;
  205.     }
  206.  
  207.     marrigestatus = marrigestatus.options[marrigestatus.selectedIndex].value;
  208.     countryregion = countryregion.options[countryregion.selectedIndex].value;
  209.     provincestate = provincestate.options[provincestate.selectedIndex].value;
  210.     city = document.getElementById("city").value;
  211.     address = document.getElementById("address").value;
  212.     countrycode = document.getElementById("country-code").value;
  213.     phone = document.getElementById("phone").value;
  214.  
  215.     $('ul.setup-panel li:eq(1)').removeClass('disabled');
  216.     $('ul.setup-panel li a[href="#step-2"]').trigger('click');
  217.     $(this).remove();
  218.   })
  219.  
  220.     // Step 2 to 3 Button
  221.   $('#activate-step-3').on('click', function(e) {
  222.     salary = document.getElementById("salary");
  223.  
  224.     // broke ass nigga
  225.     transportation = document.getElementById("transportation");
  226.     // your mom gives me a piggyback ride to osmows
  227.  
  228.     if (document.getElementById("occupation").value === "") {
  229.       // twitch streaming aint an occupation you jizz-for-brains fuck
  230.         document.getElementById("error-two").innerHTML = icon + "Please enter your occupation.";
  231.         return;
  232.     }
  233.  
  234.     if (salary.options[salary.selectedIndex].value === "Select...") {
  235.         document.getElementById("error-two").innerHTML = icon + "Please enter your estimated salary.";
  236.         return;
  237.     }
  238.  
  239.     if (transportation.options[transportation.selectedIndex].value === "Select...") {
  240.         document.getElementById("error-two").innerHTML = icon + "Please select your method of transportation.";
  241.         return;
  242.     }
  243.     if ((document.getElementById("student-no").checked === false) && (document.getElementById("student-yes").checked === false)) {
  244.         document.getElementById("error-two").innerHTML = icon + "Please indicate whether you are a student.";
  245.         return;
  246.     }
  247.  
  248.     var interests = document.getElementById("arts").checked || document.getElementById("education").checked || document.getElementById("environment").checked || document.getElementById("tech").checked || document.getElementById("business").checked || document.getElementById("health").checked;
  249.  
  250.     if (interests === false) {
  251.         document.getElementById("error-two").innerHTML = icon + "Please select atleast one area of interest.";
  252.         return;
  253.     }
  254.  
  255.     occupation = document.getElementById("occupation").value;
  256.     salary = salary.options[salary.selectedIndex].value;
  257.     transportation = transportation.options[transportation.selectedIndex].value;
  258.     arts = document.getElementById("arts").checked;
  259.     education = document.getElementById("education").checked;
  260.     environment = document.getElementById("environment").checked;
  261.     tech = document.getElementById("tech").checked;
  262.     business = document.getElementById("business").checked;
  263.     health = document.getElementById("health").checked;
  264.  
  265.     $('ul.setup-panel li:eq(2)').removeClass('disabled');
  266.     $('ul.setup-panel li a[href="#step-3"]').trigger('click');
  267.     // TRIGGER? BOMB TRIGGER? I KNEW YOU WERE A FUCKING TERRORIST....
  268.     $(this).remove();
  269.   })
  270.  
  271.   $('#finish-portal').on('click', function(e) {
  272.     roommatestatus = document.getElementById("roommatestatus");
  273.     pricehome = document.getElementById("pricehome");
  274.     lengthstay = document.getElementById("lengthstay");
  275.  
  276.     if (roommatestatus.options[roommatestatus.selectedIndex].value === "Select...") {
  277.       document.getElementById("error-three").innerHTML = icon + "Please select what you are looking for.";
  278.       return;
  279.     }
  280.  
  281.     if (pricehome.options[pricehome.selectedIndex].value === "Select...") {
  282.         document.getElementById("error-three").innerHTML = icon + "Please select your budget range.";
  283.         return;
  284.     }
  285.  
  286.     if ((document.getElementById("petsafe-no").checked === false) && (document.getElementById("petsafe-yes").checked === false)) {
  287.         document.getElementById("error-three").innerHTML = icon + "Please indicate whether the house should be petsafe.";
  288.         return;
  289.     }
  290.  
  291.     if ((document.getElementById("smoking-no").checked === false) && (document.getElementById("smoking-yes").checked === false)) {
  292.         document.getElementById("error-three").innerHTML = icon + "Please indicate whether the house should be smoke free.";
  293.         return;
  294.     }
  295.     if (lengthstay.options[lengthstay.selectedIndex].value === "Select...") {
  296.         document.getElementById("error-three").innerHTML = icon + "Please select how long you wish to stay.";
  297.         return;
  298.     }
  299.  
  300.     pricehome = pricehome.options[pricehome.selectedIndex].value;
  301.     lengthstay = lengthstay.options[lengthstay.selectedIndex].value;
  302.  
  303.     Accounts[c_user].marrigestatus = marrigestatus;
  304.     Accounts[c_user].countryregion = countryregion;
  305.     Accounts[c_user].provincestate = provincestate;
  306.     Accounts[c_user].city = city;
  307.     Accounts[c_user].address = address;
  308.     Accounts[c_user].countrycode = countrycode;
  309.     Accounts[c_user].phone = phone;
  310.     Accounts[c_user].occupation;
  311.     Accounts[c_user].salary = salary;
  312.     Accounts[c_user].transportation = transportation;
  313.     Accounts[c_user].arts = arts;
  314.     Accounts[c_user].education = education;
  315.     Accounts[c_user].environment = environment;
  316.     Accounts[c_user].tech = tech;
  317.     Accounts[c_user].business = business;
  318.     Accounts[c_user].health = health;
  319.     Accounts[c_user].roommatestatus = roommatestatus;
  320.     Accounts[c_user].pricehome = pricehome;
  321.     Accounts[c_user].lengthstay = lengthstay;
  322.  
  323.     localStorage.setItem("Accounts", JSON.stringify(Accounts));
  324.     alert("Sucessfully registered!");
  325.     // THATS THE ONLY SUCCESS YOU'VE EVER HAD....REGISTERING....AND BEING THE CHOSEN SPERM.....FUCKING WASTE
  326.     window.location = "profile.html";
  327.   })
  328. }
  329.  
  330. function FindMatches() {
  331.   var nArray = [];
  332.   var matchCount = 0;
  333.   for (var i = 0; i < Accounts.length; i += 1) {
  334.  
  335.       if (i != c_user) {
  336.             if(Accounts[i].marrigestatus == Accounts[c_user].marrigestatus) {
  337.                 matchCount = matchCount + 1;
  338.             }
  339.             if(Accounts[i].countryregion == Accounts[c_user].countryregion) {
  340.                 matchCount = matchCount + 1;
  341.             }
  342.             if(Accounts[i].provincestate == Accounts[c_user].provincestate) {
  343.               matchCount = matchCount + 1;
  344.             }
  345.             if(Accounts[i].city == Accounts[c_user].city) {
  346.               matchCount = matchCount + 1;
  347.             }
  348.             if(Accounts[i].address == Accounts[c_user].city) {
  349.               matchCount = matchCount + 1;
  350.             }
  351.             if(Accounts[i].countrycode == Accounts[c_user].countrycode) {
  352.               matchCount = matchCount + 1;
  353.             }
  354.             if(Accounts[i].phone == Accounts[c_user].phone) {
  355.               matchCount = matchCount + 1;
  356.             }
  357.             if(Accounts[i].occupation == Accounts[c_user].occupation) {
  358.               matchCount = matchCount + 1;
  359.             }
  360.             if(Accounts[i].salary == Accounts[c_user].salary) {
  361.               matchCount = matchCount + 1;
  362.             }
  363.             if(Accounts[i].transportation == Accounts[c_user].transportation) {
  364.               matchCount = matchCount + 1;
  365.             }
  366.             if(Accounts[i].arts == Accounts[c_user].arts) {
  367.               matchCount = matchCount + 1;
  368.             }
  369.             if(Accounts[i].education == Accounts[c_user].education) {
  370.               matchCount = matchCount + 1;
  371.             }
  372.             if(Accounts[i].environment == Accounts[c_user].environment) {
  373.               matchCount = matchCount + 1;
  374.             }
  375.             if(Accounts[i].tech == Accounts[c_user].tech) {
  376.               matchCount = matchCount + 1;
  377.             }
  378.             if(Accounts[i].business == Accounts[c_user].business) {
  379.               matchCount = matchCount + 1;
  380.             }
  381.             if(Accounts[i].health == Accounts[c_user].health) {
  382.               matchCount = matchCount + 1;
  383.             }
  384.             if(Accounts[i].roommatestatus == Accounts[c_user].roommatestatus) {
  385.               matchCount = matchCount + 1;
  386.             }
  387.             if(Accounts[i].pricehome == Accounts[c_user].pricehome) {
  388.               matchCount = matchCount + 1;
  389.             }
  390.             if(Accounts[i].lengthstay == Accounts[c_user].lengthstay) {
  391.               matchCount = matchCount + 1;
  392.             }
  393.             // ADD THIS FUCKING SHIT INTO THE ARRAY OF OBJECTS YOU FUCKING WHORE
  394.             nArray.push(Accounts[i] + " " + matchCount);
  395.             // RESET THE FUCKING MATCHCOUNT YOU ASSWIPING CUNTLICKERLOVERLOL
  396.             matchCount = 0;
  397.  
  398.       }
  399.     }
  400. }
  401. // LMAO YOU CAN SEARCH PAGE BUT YOU SUCK AT SEARCHING FOR A GRILLFRAND HAHAHA
  402. function SearchPage() {
  403.   document.getElementById('char-name').innerHTML = Accounts[c_user].name;
  404. }
Add Comment
Please, Sign In to add comment