Guest User

Untitled

a guest
Feb 17th, 2017
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. function logout(name, password, save)
  2. {
  3. userName = null;
  4. userXP = 0;
  5. userData = {};
  6.  
  7. window.localStorage.removeItem("userName", userName);
  8. window.localStorage.removeItem("userPassword", password);
  9.  
  10. showMsg("<span class='glyphicon glyphicon-log-out'></span> Atsijungta<br>");
  11. if(currentMenu == 2)
  12. {
  13. menuProfile();
  14. document.getElementById("leftPanelIcon").style.display = "none";
  15. }
  16. document.getElementById("avatarSelect").innerHTML = "";
  17. clearInterval(onlineCheckerTimer);
  18. menuChatHTML();
  19. }
  20. function loginUser(name, password, save)
  21. {
  22. if(name != null)
  23. {
  24. $.mobile.loading('show');
  25. $.post("http://sarg.lt/app/login.php", {name: name, password: password, code: "0ay3j5as1Zua55f9T9s2upo"}, function( data )
  26. {
  27. if(data == "-1")
  28. {
  29. showWarningMsg("Serveris nepasiekiamas!");
  30. }
  31. else if(data == "-2")
  32. {
  33. showWarningMsg("Prisijungimas laikinai užblokuotas!");
  34. }
  35. else if(data != "0")
  36. {
  37. userData = parseINIString(data);
  38. if(userData["token"] == 0)
  39. {
  40. showWarningMsg("Serveris nepasiekiamas!");
  41. }
  42. else
  43. {
  44. userName = userData["name"];
  45. if(save)
  46. {
  47. if($("#autologin").is(':checked'))
  48. {
  49. window.localStorage.setItem("userName", userName);
  50. window.localStorage.setItem("userPassword", password);
  51. }
  52. }
  53. showMsg("<span class='glyphicon glyphicon-log-in'></span> Prisijungta<br>");
  54. if(currentMenu == 2)
  55. {
  56. menuProfile();
  57. document.getElementById("leftPanelIcon").style.display = "block";
  58. }
  59. document.getElementById("avatarSelect").innerHTML = '<b>Avataras:</b><br><img src="' + userData["avatar"] + '" alt="Avatar" class="img-circle" width="50" height="50" ><br>\
  60. <br>Tinka .png arba .gif nedidesni už 100x100<input type="url" id="userAvatarInput" class="form-control input-sm" maxlength="120" placeholder="http://"/>\
  61. <button class="ui-btn" onclick="userAvatarUpdate()">Pakeisti</button>';
  62. menuChatHTML();
  63. onlineChecker();
  64. onlineCheckerTimer = setInterval(onlineChecker, 60000);
  65. }
  66. }
  67. else
  68. {
  69. if(save)
  70. showWarningMsg("Blogas slaptažodis arba slapyvardis!");
  71. else
  72. {
  73. showWarningMsg("Prisijungti nepavyko!");
  74. window.localStorage.removeItem("userName", userName);
  75. window.localStorage.removeItem("userPassword", password);
  76. }
  77. }
  78. $.mobile.loading('hide');
  79. });
  80. }
  81. }
  82.  
  83. function userNameInput()
  84. {
  85. if(!isInternetConnection)
  86. {
  87. noInternetAlert();
  88. return;
  89. }
  90. var input = document.getElementById("userName").value;
  91. if (input.indexOf('_') === -1 || input.search(/^[a-zA-Z]'?([a-zA-Z]|\.|_)+$/) === -1)
  92. {
  93. showWarningMsg("Blogas slaptažodis arba slapyvardis!");
  94. return;
  95. }
  96. else
  97. {
  98. loginUser(document.getElementById("userName").value, md5(document.getElementById("userPassword").value), 1);
  99. }
  100. }
Add Comment
Please, Sign In to add comment