Skip to content

Commit

Permalink
fix #748, no spam with timers
Browse files Browse the repository at this point in the history
  • Loading branch information
Areso committed Feb 15, 2023
1 parent f4ea43c commit 2936a10
Showing 1 changed file with 45 additions and 37 deletions.
82 changes: 45 additions & 37 deletions js/lib/mech_online.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ function remoteRegLogin() {
postEventLog(msg);
msg = "you got a 'registered user' badge and 10 ambers";
postEventLog(msg);
msg = "please, make a log-in now!";
postEventLog(msg);
pullAmberTimer = setInterval(pullAmber, 3000);
}
};
Expand All @@ -84,48 +86,54 @@ function remoteRegLogin() {
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send(dataToParse);
} else {
showModal(0, '', getAck, locObj.requiredFieldsNotFilled.txt, locObj.okay.txt, '')
showModal(0, '', getAck, locObj.requiredFieldsNotFilled.txt, locObj.okay.txt, '');
}
}
if (reglogin==="login"){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState === 4 && this.status === 200) {
if (config.debug){
console.log(session);
console.log(this.responseText);
}
resp_data = JSON.parse(this.responseText);
session = resp_data["session"];
game.role = resp_data["role"];
game.nickname = resp_data["login"];
msg = "login successfull";
postEventLog(msg);
if (config.isOnline === false){
config.isOnline = true;
setUpBackendTimers();
enableOnlineCounter();
if (isLoginFilled && isPasswordFilled) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState === 4 && this.status === 200) {
if (config.debug){
console.log(session);
console.log(this.responseText);
}
resp_data = JSON.parse(this.responseText);
session = resp_data["session"];
game.role = resp_data["role"];
game.nickname = resp_data["login"];
msg = "login successfull";
postEventLog(msg);
if (config.isOnline === false){
config.isOnline = true;
setUpBackendTimers();
enableOnlineCounter();
}
if (typeof setupNickname === "function") { setupNickname() };
if (pullAmberTimer === null) {
pullAmberTimer = setInterval(pullAmber, 3000);
}
}
if (typeof setupNickname === "function") { setupNickname() };
pullAmberTimer = setInterval(pullAmber, 3000);
}
if (this.readyState === 4 && this.status !== 200) {
if (config.debug){
console.log(session);
console.log(this.responseText);
if (this.readyState === 4 && this.status !== 200) {
if (config.debug){
console.log(session);
console.log(this.responseText);
}
resp_data = JSON.parse(this.responseText);
msg = "login unsuccessfull, please try again";
postEventLog(msg);
}
resp_data = JSON.parse(this.responseText);
msg = "login unsuccessfull, please try again";
postEventLog(msg);
}
};
login = document.getElementById("login").value;
password = document.getElementById("password").value;
dataToParse = login+delimiter+password;
endpoint = webserver + "/api/v1.1/login_user";
xhttp.open("POST", endpoint, true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send(dataToParse);
};
login = document.getElementById("login").value;
password = document.getElementById("password").value;
dataToParse = login+delimiter+password;
endpoint = webserver + "/api/v1.1/login_user";
xhttp.open("POST", endpoint, true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send(dataToParse);
} else {
showModal(0, '', getAck, locObj.requiredFieldsNotFilled.txt, locObj.okay.txt, '');
}
}
}
function fpullMessages() {
Expand Down

0 comments on commit 2936a10

Please sign in to comment.