From 20b47856d5fcbe144385445e85387a46d2cba96a Mon Sep 17 00:00:00 2001 From: AINDUSTRIES Date: Tue, 10 Sep 2024 17:59:39 +0200 Subject: [PATCH] Home page progress + start of db manipulations --- migrations/1725982950_players.sql | 5 +++ migrations/1725983390_votes.sql | 11 ++++++ static/css/index.css | 8 +++++ static/html/index.html | 3 +- static/js/index.js | 56 +++++++++++++++++++++++++++--- vote.db | Bin 4096 -> 20480 bytes 6 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 migrations/1725982950_players.sql create mode 100644 migrations/1725983390_votes.sql 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 7ee7c113a09428e4daafacb6e70a35d18573e608..cca3ffbd28496dc9aa04be35bc36682b735c1080 100644 GIT binary patch literal 20480 zcmeI&QAiVU90%~*?R2`Biypefh(Cy+%wcKmY;|fB*y_009U<00RF>U|tklq9{5RJeG1rqqA9yn#E03UrY+dB@z#Y zA`&T{^0=ElZZ$>Jj72A@L2`zwE5;m|p>rgYwMZtfX{{c&rRvnQ6g@{$3R_<7isZDs zDep>98Oo^1nT(=SV$lLi_d8|rMuRG5HnT6LXVuI>Sxd14)0V=2%Ik5r%s5?QLxba% zuLzUVlsRgc+dE+o&i2WF$#*4ccE!zKEBj)kgXZ?bt+E6BP!X(*POWz(x@^LzTQ zjFM(IVP%$$m)%T4;eqgQoQ%Z6L%~>roR<=<#dwOENkh%q9gw&*9w)<5R>vZdQkbb) zil)(&Y{$bx(r7$5G_rFMIVbf8$0BjkHx`RY!*O}%lG5#FKAEJZNkY+RL<$b?+*gVw zr)YA<%9-O=73|}pd`W&2^Nznp>VQY9<$y@9(U~Rb) zL-tpmvDfl7_SenBD({VO-p6c%0s#m>00Izz00bZa0SG_<0uX?}Uj;7lEan%H>1QhPkm zxEOdF9s1}zy+-CgEgkuK;@KlHG`5^@xP*pM;;GH;H!XWp2fBMZ+E-}(=jvp7Vxv8fp;uL~$zTpY093;UZ~y=R