Initial commit

This commit is contained in:
2023-09-28 14:57:13 -04:00
commit cfa1f6fa3f
2 changed files with 192 additions and 0 deletions

51
rangevote.html Normal file
View File

@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>POST DEMO</title>
</head>
<body>
<form id="my-form" action="/range_vote" method="post" oninput=UpdateValues(event)>
This page is an experiment in voting. Half of the people who visit this site vote using Plurality Voting
where a voter selects their top candidate, and the winner is the candidate with the most votes. The other
half use Range Voting where voters score all familiar candidates based on how happy they would be should
that candidate win. You have been randomly selected to vote using Range Voting.
<br>
<br>
<table>
<tr>
<th>Candidate</th>
<th><span id="spanid"> </th>
<th>Happiness</th>
</tr>
<!-- INJECT0 -->
</table>
<br>
<button type="submit" value="submit">Submit</button>
</form>
</body>
<script>
function CanId(c)
{
let w=c.split(" ");
let lastname=w[w.length-1].toLowerCase();
let id=lastname.split("-");
let rval=id[id.length-1];
return(rval);
}
function UpdateValues(event)
{
let id=event.srcElement.id;
console.log(id);
let slider=document.getElementById(id);
let output=document.getElementById('o-'+CanId(id));
if (slider.value==-1) output.innerHTML="No Opinion";
else output.innerHTML=slider.value+"%";
}
</script>