From c99115b886e38e962598a0678476f5aee6a967c5 Mon Sep 17 00:00:00 2001 From: A-INDUSTRIES Date: Sat, 14 Sep 2024 12:04:33 +0200 Subject: [PATCH] Repo Cleanup --- ...f49453766684f9cdf724178c9320a12a56bac.json | 20 ----------- migrations/1725982950_players.sql | 5 --- migrations/1725983390_votes.sql | 11 ------- .../20240911124945_drop_votes_convert.sql | 2 -- migrations/20240911125144_votes_convert.sql | 11 ------- static/js/index.js | 31 +++++++++++------- vote.db | Bin 20480 -> 0 bytes 7 files changed, 19 insertions(+), 61 deletions(-) delete mode 100644 .sqlx/query-630981b7637ee724554aa5a4ad1f49453766684f9cdf724178c9320a12a56bac.json delete mode 100644 migrations/1725982950_players.sql delete mode 100644 migrations/1725983390_votes.sql delete mode 100644 migrations/20240911124945_drop_votes_convert.sql delete mode 100644 migrations/20240911125144_votes_convert.sql delete mode 100644 vote.db diff --git a/.sqlx/query-630981b7637ee724554aa5a4ad1f49453766684f9cdf724178c9320a12a56bac.json b/.sqlx/query-630981b7637ee724554aa5a4ad1f49453766684f9cdf724178c9320a12a56bac.json deleted file mode 100644 index 063d733..0000000 --- a/.sqlx/query-630981b7637ee724554aa5a4ad1f49453766684f9cdf724178c9320a12a56bac.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "db_name": "SQLite", - "query": "SELECT id name FROM players", - "describe": { - "columns": [ - { - "name": "name", - "ordinal": 0, - "type_info": "Integer" - } - ], - "parameters": { - "Right": 0 - }, - "nullable": [ - false - ] - }, - "hash": "630981b7637ee724554aa5a4ad1f49453766684f9cdf724178c9320a12a56bac" -} diff --git a/migrations/1725982950_players.sql b/migrations/1725982950_players.sql deleted file mode 100644 index 5d24182..0000000 --- a/migrations/1725982950_players.sql +++ /dev/null @@ -1,5 +0,0 @@ -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 deleted file mode 100644 index d812a87..0000000 --- a/migrations/1725983390_votes.sql +++ /dev/null @@ -1,11 +0,0 @@ -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/migrations/20240911124945_drop_votes_convert.sql b/migrations/20240911124945_drop_votes_convert.sql deleted file mode 100644 index cf672d1..0000000 --- a/migrations/20240911124945_drop_votes_convert.sql +++ /dev/null @@ -1,2 +0,0 @@ --- Add migration script here -drop table if exists votes \ No newline at end of file diff --git a/migrations/20240911125144_votes_convert.sql b/migrations/20240911125144_votes_convert.sql deleted file mode 100644 index c753a12..0000000 --- a/migrations/20240911125144_votes_convert.sql +++ /dev/null @@ -1,11 +0,0 @@ -create table if not exists votes -( -id integer primary key not null, -timestamp text 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 -) diff --git a/static/js/index.js b/static/js/index.js index 506a49e..eddde29 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -56,13 +56,23 @@ async function load_page(id) { let submit = document.createElement("button"); submit.textContent = "A Voté"; submit.addEventListener("click", async () => { - Vote.vote_moins_id = vote_id_select.value; - Vote.vote_moins_nickname = vote_nickname_input.value; - Vote.vote_moins_reason = vote_reason_input.value; - if (await send_vote(Vote)) { - confirm_popup(); - save_state(); - } + if (vote.vote_plus_id === null || vote.vote_moins_id === null) { + const popUp = document.createElement("div"); + popUp.className = "popup"; + const message = document.createElement("h2"); + message.textContent = "Tu dois dire pour qui tu vote!"; + const page = document.body; + popUp.append(message); + page.append(popUp); + } else { + Vote.vote_moins_id = vote_id_select.value; + Vote.vote_moins_nickname = vote_nickname_input.value; + Vote.vote_moins_reason = vote_reason_input.value; + if (await send_vote(Vote)) { + confirm_popup(); + save_state(); + } + } }) submit.className = "right"; previous.className = "left"; @@ -113,13 +123,10 @@ function get_state() { let cookie = document.cookie; return cookie.includes("hasvoted=true"); } -async function send_vote(vote) { - if (vote.vote_plus_id === null || vote.vote_moins_id === null) { - return false; - } +async function send_vote(vote) { vote.vote_plus_id = parseInt(vote.vote_plus_id, 10); vote.vote_moins_id = parseInt(vote.vote_moins_id, 10); let body = JSON.stringify(vote); let result = await fetch(window.location.href + "post", {method: "POST", body: body}).then(r => r.status); return result === 200; -} \ No newline at end of file +} diff --git a/vote.db b/vote.db deleted file mode 100644 index 247054d7347fcda771a0ec108a2ec60c52696a34..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 20480 zcmeI4du$X%7{GUL_g-7}hF3Xit(}HoL0jncfzlAQR}N^oYoS~#Mdh;HoAZ|L<9fRb zZ4D~*9TiQ~1dZ_@LLw>>6Cx%OF%;uJLPW$M1cJ)L`1}V95~I%E^#Nzme>4X2O*)-# zzHh#7W`4Uj$xe1>)yk-15u7rznq=WRW-{Y)F?V6iFpPU7(;}CgIzJ*i1$&u%HPOw? z8_bC4BEyRTCh#=c9k_`KkbnRX00KY&2mk>f00e*l5C8)I6M>;1?+pfn?4#n4n3oKu-YDh-gVIa2UfAQ@4L!W{7*v53N7=Ozkshvu^0V0AV7s5{qN!t7J~ z6Pj{=R&aI&Cx}yI=E1n}@n%2|tQfC})S=!PT$16HoVoe?0czL9|DrZj;Q_d zsBNsRoAPeO!PnnkS@~(vj)ot8{qg+PTLLF9zA?1rh3~e>uN>Qc_L=zY(H+K3YZ}h= zbgnGXIoFzRtQ6;Uheo?-Ih4#Anfw;c-}KY}&4U<9O)Y?xG)O z?%Em*ckb_Iy?kjtaQf`XPRo^{>lZZE)*K)u-+JWKis9J{r*5A8-A7+6ym#N6S=xI` ze%g8A$XhPvgV5TItAC56>RO-RAG~qzevW(cVS!##9(~E6i|A)`nhKDB01yBIKmZ5; z0U!VbfB+Bx0zd!=0D)_VfWW!g{FVwoDz+Trd>qd@yAv)i$NN*K(r3lM1!iX8s1KbF z97Som1F$P_4sAitqQ}ri^cngXnJ9t0D2|q)JJ14Dg>FD7aEZPxaPitf0V4$hKm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