Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function logout(name, password, save)
- {
- userName = null;
- userXP = 0;
- userData = {};
- window.localStorage.removeItem("userName", userName);
- window.localStorage.removeItem("userPassword", password);
- showMsg("<span class='glyphicon glyphicon-log-out'></span> Atsijungta<br>");
- if(currentMenu == 2)
- {
- menuProfile();
- document.getElementById("leftPanelIcon").style.display = "none";
- }
- document.getElementById("avatarSelect").innerHTML = "";
- clearInterval(onlineCheckerTimer);
- menuChatHTML();
- }
- function loginUser(name, password, save)
- {
- if(name != null)
- {
- $.mobile.loading('show');
- $.post("http://sarg.lt/app/login.php", {name: name, password: password, code: "0ay3j5as1Zua55f9T9s2upo"}, function( data )
- {
- if(data == "-1")
- {
- showWarningMsg("Serveris nepasiekiamas!");
- }
- else if(data == "-2")
- {
- showWarningMsg("Prisijungimas laikinai užblokuotas!");
- }
- else if(data != "0")
- {
- userData = parseINIString(data);
- if(userData["token"] == 0)
- {
- showWarningMsg("Serveris nepasiekiamas!");
- }
- else
- {
- userName = userData["name"];
- if(save)
- {
- if($("#autologin").is(':checked'))
- {
- window.localStorage.setItem("userName", userName);
- window.localStorage.setItem("userPassword", password);
- }
- }
- showMsg("<span class='glyphicon glyphicon-log-in'></span> Prisijungta<br>");
- if(currentMenu == 2)
- {
- menuProfile();
- document.getElementById("leftPanelIcon").style.display = "block";
- }
- document.getElementById("avatarSelect").innerHTML = '<b>Avataras:</b><br><img src="' + userData["avatar"] + '" alt="Avatar" class="img-circle" width="50" height="50" ><br>\
- <br>Tinka .png arba .gif nedidesni už 100x100<input type="url" id="userAvatarInput" class="form-control input-sm" maxlength="120" placeholder="http://"/>\
- <button class="ui-btn" onclick="userAvatarUpdate()">Pakeisti</button>';
- menuChatHTML();
- onlineChecker();
- onlineCheckerTimer = setInterval(onlineChecker, 60000);
- }
- }
- else
- {
- if(save)
- showWarningMsg("Blogas slaptažodis arba slapyvardis!");
- else
- {
- showWarningMsg("Prisijungti nepavyko!");
- window.localStorage.removeItem("userName", userName);
- window.localStorage.removeItem("userPassword", password);
- }
- }
- $.mobile.loading('hide');
- });
- }
- }
- function userNameInput()
- {
- if(!isInternetConnection)
- {
- noInternetAlert();
- return;
- }
- var input = document.getElementById("userName").value;
- if (input.indexOf('_') === -1 || input.search(/^[a-zA-Z]'?([a-zA-Z]|\.|_)+$/) === -1)
- {
- showWarningMsg("Blogas slaptažodis arba slapyvardis!");
- return;
- }
- else
- {
- loginUser(document.getElementById("userName").value, md5(document.getElementById("userPassword").value), 1);
- }
- }
Add Comment
Please, Sign In to add comment