const {ipcRenderer} = require("electron")

ipcRenderer.on("posterURL", (event, posterURL) => {
    document.getElementById("posterURL").src = posterURL
})

ipcRenderer.on("posterLargeURL", (event, posterLargeURL) => {
    document.getElementById("posterLargeURL").href = posterLargeURL
    document.getElementById("posterLargeURL").onclick = "return true"
})

ipcRenderer.on("posterDisabled", (event) => {
    document.getElementById("posterLargeURL").href = "javascript: void(0)"
})

ipcRenderer.on("title", (event, title) => {
    document.getElementById("message").innerHTML = title
})

ipcRenderer.on("count", (event, count) => {
    if (count >= 1) {
        document.getElementById("message").innerHTML = "Clicked: " + count
    }
})

ipcRenderer.on("unlock", (event) => {
    document.getElementById("start").disabled = false
    document.getElementById("start").innerHTML = "New Game"
})

document.getElementById("start").addEventListener("click", function (event) {
    document.getElementById("start").disabled = true
    document.getElementById("start").innerHTML = "Loading"
    ipcRenderer.send("newGame", null)
})

document.getElementById("about").addEventListener("click", function (event) {
    ipcRenderer.send("about", null)
})
