Mayor V2 refactor. Now also available on DockerHub

This commit is contained in:
Glenn de Haan
2021-01-16 09:45:22 +01:00
parent 0e2053846a
commit 22162db21a
35 changed files with 4720 additions and 6962 deletions

View File

@@ -1,6 +1,4 @@
import mitt from 'mitt';
import 'gsap/TweenMax';
import 'gsap/TimelineMax';
import settings from './settings';
/**

View File

@@ -1,4 +1,5 @@
import io from 'socket.io-client';
import animejs from 'animejs';
export default class Socket {
constructor({el}) {
@@ -13,8 +14,6 @@ export default class Socket {
this.errorContainer = document.querySelector("#error");
this.preloader = document.querySelector("#preloader");
this.tl = new TimelineMax();
document.querySelector("#voucher button").addEventListener("click", () => this.requestVoucher());
this.init();
@@ -46,12 +45,12 @@ export default class Socket {
this.socket.emit('uuid');
}
this.tl
.to(this.mainContainer, 0.5, {
opacity: 0,
display: "none"
})
.add(() => {
animejs({
targets: this.mainContainer,
duration: 250,
opacity: [1, 0],
easing: 'linear',
complete: () => {
if (!this.userSignedIn) {
this.signInContainer.classList.remove("hidden");
} else {
@@ -59,11 +58,15 @@ export default class Socket {
}
this.errorContainer.classList.add("hidden");
})
.to(this.mainContainer, 0.5, {
opacity: 1,
display: "block"
});
animejs({
targets: this.mainContainer,
duration: 250,
opacity: [0, 1],
easing: 'linear',
});
}
});
}
/**
@@ -72,20 +75,24 @@ export default class Socket {
disconnect() {
console.log('[SOCKET] Disconnected!');
this.tl
.to(this.mainContainer, 0.5, {
opacity: 0,
display: "none"
})
.add(() => {
animejs({
targets: this.mainContainer,
duration: 250,
opacity: [1, 0],
easing: 'linear',
complete: () => {
this.signInContainer.classList.add("hidden");
this.voucherContainer.classList.add("hidden");
this.errorContainer.classList.remove("hidden");
})
.to(this.mainContainer, 0.5, {
opacity: 1,
display: "block"
});
animejs({
targets: this.mainContainer,
duration: 250,
opacity: [0, 1],
easing: 'linear'
});
}
});
}
/**
@@ -94,20 +101,24 @@ export default class Socket {
error() {
console.log('[SOCKET] Error!');
this.tl
.to(this.mainContainer, 0.5, {
opacity: 0,
display: "none"
})
.add(() => {
animejs({
targets: this.mainContainer,
duration: 250,
opacity: [1, 0],
easing: 'linear',
complete: () => {
this.signInContainer.classList.add("hidden");
this.voucherContainer.classList.add("hidden");
this.errorContainer.classList.remove("hidden");
})
.to(this.mainContainer, 0.5, {
opacity: 1,
display: "block"
});
animejs({
targets: this.mainContainer,
duration: 250,
opacity: [0, 1],
easing: 'linear'
});
}
});
}
/**
@@ -124,20 +135,24 @@ export default class Socket {
if (data.success) {
this.userSignedIn = true;
this.tl
.to(this.mainContainer, 0.5, {
opacity: 0,
display: "none"
})
.add(() => {
animejs({
targets: this.mainContainer,
duration: 250,
opacity: [1, 0],
easing: 'linear',
complete: () => {
site.modules.Signin.resetForm();
this.signInContainer.classList.add("hidden");
this.voucherContainer.classList.remove("hidden");
})
.to(this.mainContainer, 0.5, {
opacity: 1,
display: "block"
});
animejs({
targets: this.mainContainer,
duration: 250,
opacity: [0, 1],
easing: 'linear'
});
}
});
} else {
site.modules.Signin.invalidCode();
}

View File

@@ -1,33 +0,0 @@
/**
* Function to post data to the API
*
* @param method
* @param data
* @param callback
* @param auth
*/
export default (method, data, callback, auth = "") => {
const xmlhttp = new XMLHttpRequest();
let route = "/api";
xmlhttp.open("POST", route);
xmlhttp.setRequestHeader("Content-Type", "application/json");
xmlhttp.setRequestHeader("Bearer", auth);
xmlhttp.send(JSON.stringify(data));
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState === XMLHttpRequest.DONE) {
const responseCode = xmlhttp.status;
const response = JSON.parse(xmlhttp.responseText);
console.log('response', response);
console.log('responseCode', responseCode);
if (responseCode === 200) {
callback({error: false});
} else {
callback({error: true, fields: response.fields, raw_error: response.error});
}
}
}
}