2020-12-08 23:04:57 +01:00
|
|
|
let launchBtn = document.querySelector('#launch-btn');
|
|
|
|
let fullProgressBar = document.querySelector('#fullprogressbar')
|
|
|
|
let progressBar = document.querySelector('#progressbar')
|
|
|
|
let loadingMessage = document.querySelector('#loading-message')
|
2020-12-08 23:19:42 +01:00
|
|
|
let disconnectBtn = document.querySelector('#disconnect-btn')
|
2020-12-08 19:59:56 +01:00
|
|
|
|
|
|
|
ipcRenderer.on("nick", (event, args) => {
|
|
|
|
console.log(args)
|
|
|
|
document.querySelector("#nick-span").innerHTML = args.name
|
|
|
|
})
|
|
|
|
|
2020-12-08 23:04:57 +01:00
|
|
|
launchBtn.addEventListener("click", e => {
|
|
|
|
launchBtn.classList.add('hidden');
|
|
|
|
fullProgressBar.classList.remove('hidden');
|
|
|
|
loadingMessage.classList.remove('hidden');
|
2020-12-08 19:59:56 +01:00
|
|
|
ipcRenderer.send('launch', {
|
2020-12-09 11:46:11 +01:00
|
|
|
minMem: document.querySelector('#minMem').value,
|
|
|
|
maxMem: document.querySelector('#maxMem').value
|
2020-12-08 19:59:56 +01:00
|
|
|
})
|
2020-12-08 23:04:57 +01:00
|
|
|
launchBtn.disabled = true
|
2020-12-09 11:46:11 +01:00
|
|
|
if(document.querySelector('#minMem').value.trim() && document.querySelector('#maxMem').value.trim()){
|
|
|
|
localStorage.setItem("minMem", document.querySelector('#minMem').value.trim())
|
|
|
|
localStorage.setItem("maxMem", document.querySelector('#maxMem').value.trim())
|
|
|
|
}
|
2020-12-08 23:04:57 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
ipcRenderer.on("progress", (e, args) => {
|
|
|
|
progressBar.style.width = (args.task / args.total) * 100 + "%"
|
|
|
|
loadingMessage.innerHTML = "Téléchargement de " + args.type + ": " + args.task + " sur " + args.total;
|
|
|
|
})
|
|
|
|
|
|
|
|
ipcRenderer.on("close", (e, args) => {
|
|
|
|
launchBtn.classList.remove('hidden');
|
|
|
|
fullProgressBar.classList.add('hidden');
|
|
|
|
loadingMessage.classList.add('hidden');
|
|
|
|
loadingMessage.innerHTML = "Téléchargement de Minecraft en cours..."
|
|
|
|
progressBar.style.width = "0"
|
|
|
|
launchBtn.disabled = false
|
2020-12-08 23:19:42 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
disconnectBtn.addEventListener('click', e => {
|
|
|
|
ipcRenderer.send('disconnect')
|
2020-12-09 11:46:11 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
window.addEventListener("DOMContentLoaded", () => {
|
|
|
|
document.querySelector('#minMem').value = localStorage.getItem("minMem") != null ? localStorage.getItem("minMem") : "2G"
|
|
|
|
document.querySelector('#maxMem').value = localStorage.getItem("maxMem") != null ? localStorage.getItem("maxMem") : "4G"
|
2020-12-08 19:59:56 +01:00
|
|
|
})
|