92 lines
3.5 KiB
JavaScript
92 lines
3.5 KiB
JavaScript
const {ipcRenderer} = require("electron");
|
|
const packageJson = require("../../package.json")
|
|
const ipc = ipcRenderer;
|
|
const fs = require("fs")
|
|
|
|
|
|
const closeBtn = document.getElementById("closeBtn");
|
|
const content = document.getElementById("content")
|
|
const retryButtonSpan = document.getElementById("retryButtonSpan")
|
|
const loadingSpan = document.getElementById("loadingSpan")
|
|
const minimizeBtn = document.getElementById("minimizeBtn")
|
|
|
|
document.getElementById("version").innerHTML = packageJson.version
|
|
|
|
ipc.on("needRetry", () => {
|
|
|
|
ipc.send("retryLogin")
|
|
})
|
|
|
|
ipc.send("stateOfConnection")
|
|
|
|
closeBtn.addEventListener("click", () => {
|
|
|
|
ipc.send("close");
|
|
|
|
});
|
|
|
|
minimizeBtn.addEventListener("click", () => {
|
|
|
|
ipc.send("minimize")
|
|
})
|
|
|
|
|
|
|
|
ipc.on("connectSuccess", () => {
|
|
|
|
content.innerHTML = '<div class="content"> <div class="box"> <p>Connexion vers Discord</p> <span id="discordLogoSpan" class="loadingSpan"><img class="discord-logo" src="../common/discord-icon-svgrepo-com.svg"></span> <br> <span class="infoSpan"><p>Pour contrôler le bot, vérifie ton compte Discord !</p></span> <br> <span id="discord-span" class="actionsSpan"><button id="discord-connect" class="buttonTryAgain">Vérifier</button></span> </div> </div>'
|
|
const discordconnect = document.getElementById("discord-connect")
|
|
const discorSpan = document.getElementById("discord-span")
|
|
const discordLogoSpan = document.getElementById("discordLogoSpan")
|
|
|
|
discordconnect.addEventListener("click", () => {
|
|
|
|
discorSpan.innerHTML = '<img style="width: 5%; height: 5%;" class="loading" src="../common/spinner-third-svgrepo-com.svg">'
|
|
ipc.send("discordlogin")
|
|
})
|
|
|
|
ipc.on("discordFailed", () => {
|
|
|
|
discorSpan.innerHTML = '<button id="discord-connect" class="buttonTryAgain">Vérifier</button>'
|
|
const reDiscord = document.getElementById("discord-connect")
|
|
reDiscord.addEventListener("click", () => {
|
|
discordLogoSpan.innerHTML = '<img class="discord-logo" src="../common/discord-icon-svgrepo-com.svg">'
|
|
discorSpan.innerHTML = '<img style="width: 5%; height: 5%;" class="loading" src="../common/spinner-third-svgrepo-com.svg">'
|
|
ipc.send("discordlogin")
|
|
})
|
|
|
|
}),
|
|
|
|
ipc.on("discordCheckFailed", () => {
|
|
|
|
discorSpan.innerHTML = '<button id="discord-connect" class="buttonTryAgain">Vérifier</button>'
|
|
discordLogoSpan.innerHTML = "<p style='font-size: 16px; color: red;'>Vérification échouée : Vous n'êtes pas sur le serveur de Code Luc Player ou vous n'avez pas le Code Scipio</p>"
|
|
const reDiscord = document.getElementById("discord-connect")
|
|
reDiscord.addEventListener("click", () => {
|
|
discordLogoSpan.innerHTML = '<img class="discord-logo" src="../common/discord-icon-svgrepo-com.svg">'
|
|
discorSpan.innerHTML = '<img style="width: 5%; height: 5%;" class="loading" src="../common/spinner-third-svgrepo-com.svg">'
|
|
ipc.send("discordlogin")
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
ipc.on("connectFailed", () => {
|
|
|
|
retryButtonSpan.innerHTML = '<button id="retryButton" class="buttonTryAgain">Réessayer</button>'
|
|
loadingSpan.innerHTML = "<p style='font-size: 16px; color: red;'>Echec de la connexion vers le serveur !</p>"
|
|
const retryButton = document.getElementById("retryButton")
|
|
|
|
retryButton.addEventListener("click",() => {
|
|
loadingSpan.innerHTML = '<img class="loading" src="../common/spinner-third-svgrepo-com.svg">'
|
|
retryButtonSpan.innerHTML = ""
|
|
ipc.send("retryLogin")
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|