diff --git a/html/index.html b/back/html/index.html similarity index 62% rename from html/index.html rename to back/html/index.html index 808ae93..723c768 100644 --- a/html/index.html +++ b/back/html/index.html @@ -7,10 +7,10 @@ TLT Guesser - - - - @@ -18,22 +18,21 @@

Défi :

- - - - -
+
+ - - - - + + + + +
- +
- + + @@ -51,4 +50,4 @@ Prendre un fichier midi : ---> +--> \ No newline at end of file diff --git a/back/html/monscript.js b/back/html/monscript.js new file mode 100644 index 0000000..390d3a8 --- /dev/null +++ b/back/html/monscript.js @@ -0,0 +1,50 @@ +const content = document.getElementById("content"); +const audios = document.getElementById("audios"); +const answerButton = document.getElementById("submit"); + +const select = document.createElement("select"); + +const messageText = document.getElementById("message"); + +let realAnswer = ""; + +function checkAnswer() { + messageText.hidden = false; + if (select.value === realAnswer) { + messageText.innerText = "Bravo !"; + } else { + messageText.innerText = "Dommage, la réponse était : " + realAnswer; + } +} + +function addAudio(data) { + const audio = document.createElement("audio"); + audio.controls = true; + audio.src = "data:audio/ogg;base64," + data; + audios.append(audio); +} + +function updateAudios(response) { + addAudio(response.dataOne); + addAudio(response.dataTwo); + addAudio(response.dataThree); + addAudio(response.dataFour); + + content.append(document.createElement("br")); + + response.answers.forEach(element => { + const option = document.createElement("option"); + option.innerText = element; + select.append(option); + }); + content.append(select); + + realAnswer = response.answer; + answerButton.disabled = false; +} + +fetch("/newchallenge", { + method: "POST" +}) +.then((response) => response.json()) +.then((json) => updateAudios(json)); diff --git a/src/main.cpp b/back/src/main.cpp similarity index 100% rename from src/main.cpp rename to back/src/main.cpp diff --git a/src/stx-execpipe.cpp b/back/src/stx-execpipe.cpp similarity index 100% rename from src/stx-execpipe.cpp rename to back/src/stx-execpipe.cpp diff --git a/src/stx-execpipe.h b/back/src/stx-execpipe.h similarity index 100% rename from src/stx-execpipe.h rename to back/src/stx-execpipe.h diff --git a/xmake.lua b/back/xmake.lua similarity index 100% rename from xmake.lua rename to back/xmake.lua diff --git a/docker-compose.yaml b/docker-compose.yaml index 6cdef99..a8eb6f4 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,10 +1,7 @@ services: web: - image: nginx - volumes: - - ./html:/usr/share/nginx/html + build: + context: . + dockerfile: images/Dockerfile ports: - - "8080:80" - environment: - - NGINX_HOST=foobar.com - - NGINX_PORT=80 + - "8080:8080" diff --git a/html/indie.mid b/html/indie.mid deleted file mode 100644 index b22957e..0000000 Binary files a/html/indie.mid and /dev/null differ diff --git a/html/monscript.js b/html/monscript.js deleted file mode 100644 index 0c91658..0000000 --- a/html/monscript.js +++ /dev/null @@ -1,25 +0,0 @@ -document.getElementById(""); - -// src="data:audio/ogg;base64,BASE64CODE" - -function updateAudios(response) { - document.getElementById("one").src = "data:audio/ogg;base64," + response.dataOne; - document.getElementById("two").src = "data:audio/ogg;base64," + response.dataTwo; - document.getElementById("three").src = "data:audio/ogg;base64," + response.dataThree; - document.getElementById("four").src = "data:audio/ogg;base64," + response.dataFour; - document.getElementById("answer").innerText = "Réponse : " + response.answer; - - const select = document.createElement("select"); - response.answers.forEach(element => { - const option = document.createElement("option"); - option.innerText = element; - select.append(option); - }); - document.getElementById("content").append(select); -} - -fetch("/newchallenge", { - method: "POST", -}) -.then((response) => response.json()) -.then((json) => updateAudios(json)); diff --git a/images/Dockerfile b/images/Dockerfile new file mode 100644 index 0000000..bc211e2 --- /dev/null +++ b/images/Dockerfile @@ -0,0 +1,19 @@ +FROM debian:latest + +RUN apt update && apt install -y g++ git 7zip make cmake libmysqlcppconn-dev ffmpeg + +RUN git clone --recursive https://github.com/xmake-io/xmake.git \ +&& cd ./xmake \ +&& ./configure \ +&& make \ +&& make install + +ENV XMAKE_ROOT=y + +WORKDIR /app + +COPY back /app + +RUN xmake -y + +ENTRYPOINT xmake run \ No newline at end of file