Home page progress + start of db manipulations

This commit is contained in:
2024-09-10 17:59:39 +02:00
parent ccc632a418
commit 20b47856d5
6 changed files with 77 additions and 6 deletions

View File

@@ -0,0 +1,5 @@
create table if not exists players
(
id integer primary key not null,
name text not null
)

View File

@@ -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
)

View File

@@ -22,4 +22,12 @@ body {
color: #1e1e2e;
font-family: "Segoe UI";
font-size: 20px;
}
.app > h2 {
color: white;
}
.app > h1 {
color: yellow;
}

View File

@@ -1,9 +1,10 @@
<!doctype html>
<html lang="en">
<head>
<base href="/" target="_top">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="static/js/index.js" defer="true"></script>
<script src="static/js/index.js" defer="defer"></script>
<title>VOTE!</title>
<link rel="stylesheet" href="static/css/index.css">
</head>

View File

@@ -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);
}

BIN
vote.db

Binary file not shown.