Guest User

Untitled

a guest
Aug 7th, 2018
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1.  
  2. <script type="text/javascript">
  3. $("#username").focus();
  4.  
  5. $(document).ready(function(){
  6. // Check to see if already logged in.
  7. $.post("ajax/getsession.php", {getLogin: "yes"}, function(data){
  8. if(data == 1){
  9. $("#loginBoxContainer").fadeOut(250, function(){
  10. css = {position: "absolute", top: "175px", left: "150px", width: "700px", height: "350px"};
  11. $("#loginBox").animate(css, 250, function(){
  12. $("#deckSelection").fadeIn(250);
  13. });
  14. });
  15. }else{
  16. //Not logged in
  17. }
  18. });
  19.  
  20.  
  21. $("#loginButton").click(function(){
  22. // Constants
  23. var errM1 = "The username or password entered was incorrect. Please try again.<br><br>";
  24. var errM2 = "Please enter a username.<br><br>";
  25. var errM3 = "Please enter a password.<br><br>";
  26.  
  27. // Define username, password with current values
  28. username = $("#username").val();
  29. password = $("#password").val();
  30.  
  31. // Validate fields (Empty username, empty password, else submit)
  32. if(username == ""){
  33. $("#loginFail").html(errM2);
  34. $("#username").focus();
  35. $("#loginFormWrapper").animate({top: "50px"}, 500, function(){
  36. $("#loginFail").removeClass("displayNone").animate({opacity:1}, 500);
  37. });
  38. }else if(password == ""){
  39. $("#loginFail").html(errM3);
  40. $("#password").focus();
  41. $("#loginFormWrapper").animate({top: "50px"}, 500, function(){
  42. $("#loginFail").removeClass("displayNone").animate({opacity:1}, 500);
  43. });
  44. }else{
  45. $.post("ajax/login.php", {username: username, password: password}, function(data){
  46.  
  47. errorHandler(data);
  48.  
  49. if(data == -103){
  50. $("#loginFail").html(errM1);
  51. $("#password").val("").focus();
  52. $("#loginFormWrapper").animate({top: "50px"}, 500, function(){
  53. $("#loginFail").removeClass("displayNone").animate({opacity:1}, 500);
  54. });
  55. }else if(data == 2){
  56. $("#username").addClass("successGlow");
  57. $("#password").addClass("successGlow");
  58. // We will re-use the login box and morph it into the size necessary for deck selection.
  59. $("#loginBoxContainer").fadeOut(1000, function(){
  60. css = {position: "absolute", top: "175px", left: "150px", width: "700px", height: "350px"};
  61. $("#loginBox").animate(css, 500, function(){
  62. $("#deckSelection").fadeIn(500);
  63. });
  64. });
  65. }else{
  66. errorHandler(-102);
  67. }
  68. });
  69. }
  70. }); // End #loginButton bind
  71.  
  72. // Deck Selection Gallery
  73.  
  74. // Constants
  75. var decks = new Array("adflatus", "dreamenchantress", "erotica", "fey", "greenwood", "novelsandfantasy", "paulina", "reflections", "scenery", "sidhe", "tarotduchat", "universalfantasy", "universalgoddess", "visionquest");
  76. var currentPosLeft = "adflatus";
  77.  
  78. // Set up the gallery when the page loads.
  79. $("#lol")
  80.  
  81. $("#dgLeftArrow").hover(function(){
  82. $("#dgLeftArrow").animate({color: "#333"}, 50)
  83. }, function(){
  84. $("#dgLeftArrow").animate({color: "#c5c7cb"}, 50)
  85. });
  86.  
  87. $("#dgRightArrow").hover(function(){
  88. $("#dgRightArrow").animate({color: "#333"}, 50)
  89. }, function(){
  90. $("#dgRightArrow").animate({color: "#c5c7cb"}, 50)
  91. });
  92.  
  93. $("#dgLeftArrow").click(function(){ alert("Clicked")});
  94.  
  95. }); // End documentReady
  96.  
  97. function errorHandler(err){
  98. if(err == "-100"){
  99. alert("A connection to the MySQL database could not be made (-100)");
  100. }else if(err == "-101"){
  101. alert("A connection to the MySQL database could not be made (-101)");
  102. }else if(err == "-102"){
  103. alert("Unknown response encountered (-102)");
  104. }else if(err == "-103"){
  105. //Login failed
  106. }else if(err == "-104"){
  107. alert("MySQL query failure.");
  108. }else if(err == "-105"){
  109. alert("Please login to your account first.");
  110. }else{
  111. // no fatal errors
  112. }
  113. }
  114. </script>
Add Comment
Please, Sign In to add comment