From 60c4dbd1f49e4fc0d5b808985e6060cc890407cc Mon Sep 17 00:00:00 2001 From: quegzacov Date: Fri, 30 Dec 2022 12:24:45 +0100 Subject: [PATCH] 3.14159265358979323846264338327950288419 --- bdd.db | Bin 16384 -> 0 bytes index.php | 30 ------------------------------ script.js | 54 +++++++++++++++++++++++++++++++++++------------------- 3 files changed, 35 insertions(+), 49 deletions(-) delete mode 100755 bdd.db delete mode 100755 index.php diff --git a/bdd.db b/bdd.db deleted file mode 100755 index 3379a578a4580ec76f56ffefe797841eeb6f1ba5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI(zfZzI6u|L2N+iWVU6AN>=>&ne_z#HMm_|UXC6S3#Qz8izfigHc_^0s~Ik0+% zKN49?81ehkm-aPx&3m8ihTh#ahiR+^li4^*)u}iTQi?OBgb&1`Son-?=bKF z3QL^yj|)y&WQt4SycL)FMj(Iy0tg_000IagfB*srAh4Z4$J#5`YOm`#bmrC-ryB@$#1{0Ik zuU1|2%2k!T?fRFl?YBek$_whcG)=p9=-r2=dY%lEbiQ7o%TD088bME8d%cR;ryAYx z#&7E{x4d>(&6`091Q0*~0R#|0009ILKmY**5ZG~nf}T%0??PV$0tg_000IagfB*sr zAb - - - - - Roulette à eau - - - - - query('SELECT * FROM Info'); -$res = $query -> fetchArray(); -var_dump($res); -?> - - - - - - - - - - - diff --git a/script.js b/script.js index b42d0ad..4220c0e 100755 --- a/script.js +++ b/script.js @@ -18,6 +18,7 @@ function draw_roulette(x, y, r, names){ text.setAttribute("y", text_coo[1]); text.setAttribute("textLength", r/2); text.setAttribute('text-anchor', 'middle'); + text.setAttribute('alignment-baseline', 'middle'); text.setAttribute("font-size", r/5) text.setAttribute("stroke-width", "1"); text.setAttribute("transform", "rotate("+(360)/nb_person*(i+0.5)+", "+center[0]+", "+center[1]+")"); @@ -31,31 +32,46 @@ function draw_roulette(x, y, r, names){ }; -function rotate(nb_person){ +function rotate(){ + nb_person = names.length; let winner = Math.random() * nb_person; let angle = Math.floor(Math.random()*15)*360 - winner * 360/nb_person; let result = new Promise((resolve, reject) => { let i = 0; let add = 0; let interval = setInterval(() => { - if (i >= angle){ - document.getElementById('roulette').style.transform = 'rotate('+angle+'deg)'; - clearInterval(interval); - resolve(names[Math.floor(winner)]); - } - else { - if (i > angle/2){ - add -= 1; - } - else{ - add += 1; - } - add = Math.abs(add); - i += add; - document.getElementById('roulette').style.transform = 'rotate('+i+'deg)'; - } + if (i >= angle){ + document.getElementById('roulette').style.transform = 'rotate('+angle+'deg)'; + clearInterval(interval); + resolve(names[Math.floor(winner)]); + } + else { + if (i > angle/2){ + add -= 1; + } + else{ + add += 1; + } + add = Math.abs(add); + i += add; + document.getElementById('roulette').style.transform = 'rotate('+i+'deg)'; + } }, 5); }); - console.log(result); - result.then((val) => console.log(val)); + result.then((val) => show_winner(val)); }; + +function show_winner(winner){ + let h1 = document.getElementById('winner'); + h1.innerText = winner; +}; + +function validateForm() { + let x = document.forms["myForm"]["fname"].value; + if (x == "") { + alert("Name must be filled out"); + return false; + } + names.push(x); + draw_roulette(200,200,200, names); +}