2023-04-24 15:51:18 +00:00
const { ipcRenderer } = require ( "electron" ) ;
2023-04-26 21:26:20 +00:00
const packageJson = require ( "../../package.json" )
2023-04-24 15:51:18 +00:00
const ipc = ipcRenderer ;
const fs = require ( "fs" )
const closeBtn = document . getElementById ( "closeBtn" ) ;
2023-04-26 21:26:20 +00:00
const content = document . getElementById ( "content" )
const retryButtonSpan = document . getElementById ( "retryButtonSpan" )
const loadingSpan = document . getElementById ( "loadingSpan" )
const minimizeBtn = document . getElementById ( "minimizeBtn" )
2023-04-24 15:51:18 +00:00
2023-04-26 21:26:20 +00:00
document . getElementById ( "version" ) . innerHTML = packageJson . version
2023-04-29 12:43:58 +00:00
ipc . on ( "needRetry" , ( ) => {
2023-04-26 21:26:20 +00:00
2023-04-29 12:43:58 +00:00
ipc . send ( "retryLogin" )
} )
ipc . send ( "stateOfConnection" )
2023-04-26 21:26:20 +00:00
closeBtn . addEventListener ( "click" , ( ) => {
2023-04-24 15:51:18 +00:00
ipc . send ( "close" ) ;
2023-04-26 21:26:20 +00:00
2023-04-24 15:51:18 +00:00
} ) ;
2023-04-26 21:26:20 +00:00
minimizeBtn . addEventListener ( "click" , ( ) => {
ipc . send ( "minimize" )
} )
ipc . on ( "connectSuccess" , ( ) => {
2023-04-29 12:43:58 +00:00
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>'
2023-04-26 21:26:20 +00:00
const discordconnect = document . getElementById ( "discord-connect" )
const discorSpan = document . getElementById ( "discord-span" )
2023-04-29 12:43:58 +00:00
const discordLogoSpan = document . getElementById ( "discordLogoSpan" )
2023-04-26 21:26:20 +00:00
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>'
2023-04-27 10:10:23 +00:00
const reDiscord = document . getElementById ( "discord-connect" )
reDiscord . addEventListener ( "click" , ( ) => {
2023-04-29 12:43:58 +00:00
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" )
} )
2023-04-27 10:10:23 +00:00
2023-04-29 12:43:58 +00:00
} ) ,
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">'
2023-04-27 10:10:23 +00:00
discorSpan . innerHTML = '<img style="width: 5%; height: 5%;" class="loading" src="../common/spinner-third-svgrepo-com.svg">'
ipc . send ( "discordlogin" )
} )
2023-04-26 21:26:20 +00:00
} )
} )
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" )
} )
} )