diff --git a/migrations/1725982950_players.sql b/migrations/1725982950_players.sql new file mode 100644 index 0000000..5d24182 --- /dev/null +++ b/migrations/1725982950_players.sql @@ -0,0 +1,5 @@ +create table if not exists players +( +id integer primary key not null, +name text not null +) \ No newline at end of file diff --git a/migrations/1725983390_votes.sql b/migrations/1725983390_votes.sql new file mode 100644 index 0000000..d812a87 --- /dev/null +++ b/migrations/1725983390_votes.sql @@ -0,0 +1,11 @@ +create table if not exists votes +( +id integer primary key not null, +timestamp date not null, +plus_id integer not null, +plus_nickname text not null, +plus_reason text not null, +moins_id integer not null, +moins_nickname text not null, +moins_reason text not null +) \ No newline at end of file diff --git a/static/css/index.css b/static/css/index.css index 1cbd8f9..43d3907 100644 --- a/static/css/index.css +++ b/static/css/index.css @@ -22,4 +22,12 @@ body { color: #1e1e2e; font-family: "Segoe UI"; font-size: 20px; +} + +.app > h2 { + color: white; +} + +.app > h1 { + color: yellow; } \ No newline at end of file diff --git a/static/html/index.html b/static/html/index.html index b306a65..51bd227 100644 --- a/static/html/index.html +++ b/static/html/index.html @@ -1,9 +1,10 @@ + - + VOTE! diff --git a/static/js/index.js b/static/js/index.js index d26ad9f..9007585 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -1,6 +1,4 @@ -App = { - div: document.getElementById("app"), - current_page: 0, +Vote = { vote_plus_id: null, vote_plus_nickname: null, vote_plus_reason: null, @@ -9,8 +7,56 @@ App = { vote_moins_reason: null } -load_page(App["current_page"]) +load_page(0) function load_page(id) { - console.log("He he") + const header = document.createElement("h1"); + const buttons = document.createElement("div"); + + const vote_id = document.createElement("h2"); + vote_id.textContent = "Pour qui votes-tu?" + const vote_id_select = document.createElement("select"); + const vote_nickname = document.createElement("h2"); + vote_nickname.textContent = "As-tu un surnom à lui donner?"; + const vote_nickname_input = document.createElement("input"); + vote_nickname_input.inputMode = "text"; + const vote_reason = document.createElement("h2"); + vote_reason.textContent = "Pourquoi votes-tu pour lui?"; + const vote_reason_input = document.createElement("textarea"); + vote_reason_input.maxLength = 1000; + + if (id) { + vote_id_select.value = Vote.vote_moins_id; + vote_nickname_input.value = Vote.vote_moins_nickname; + vote_reason_input.value = Vote.vote_moins_reason; + header.textContent = "Vote -"; + let previous = document.createElement("button"); + previous.textContent = "Précédent"; + previous.addEventListener("click", () => { + Vote.vote_moins_id = vote_id.value; + Vote.vote_moins_nickname = vote_nickname_input.value; + Vote.vote_moins_reason = vote_reason_input.value; + load_page(0)}); + let submit = document.createElement("button"); + submit.textContent = "A Voté"; + buttons.append(previous, submit); + } else { + vote_id_select.value = Vote.vote_plus_id; + vote_nickname_input.value = Vote.vote_plus_nickname; + vote_reason_input.value = Vote.vote_plus_reason; + header.textContent = "Vote +"; + let next = document.createElement("button"); + next.innerText = "Suivant"; + next.addEventListener("click", () => { + Vote.vote_plus_id = vote_id.value; + Vote.vote_plus_nickname = vote_nickname_input.value; + Vote.vote_plus_reason = vote_reason_input.value; + load_page(1) + }); + buttons.appendChild(next); + } + + const div = document.getElementById("app"); + div.innerHTML = ""; + div.append(header,vote_id, vote_id_select, vote_nickname, vote_nickname_input, vote_reason, vote_reason_input, buttons); } \ No newline at end of file diff --git a/vote.db b/vote.db index 7ee7c11..cca3ffb 100644 Binary files a/vote.db and b/vote.db differ