De server staat in read-only mode. Exporteer je projecten vóór 1 september 2019 om 00:00. Hierna gaat de GitLab server met pensioen.

...
 
Commits (14)
votes/vote_*
tokens.json
votes.json
.htpasswd
......@@ -27,11 +27,12 @@ function countVotesList($files, $vote){
$html .= "<tr><td>" . $key . "</td><td>" . $options_counted[$key] . "</td><td>" .$options_counted[$key]/$count * 100 . "%</td></tr>";
}
}
$html .= "<tr><td><strong>Totaal</strong></td><td><strong>".count($files)."</strong></td><td></td></tr>";
$html .= "</table>";
return $html;
}
function countVotesGrid($files, $vote){
$options_counted = array();;
$options_counted = array();
foreach ($vote['options_vertical'] as $option){
$option = titleToPostName($option);
$options_counted[$option] = array();
......@@ -40,33 +41,38 @@ function countVotesGrid($files, $vote){
}
$count = 0;
foreach ($files as $file){
foreach ($vote['options_horizontal'] as $option2)
if($option2 == json_decode(file_get_contents($file), true)[$option]){
$options_counted[$option][$option2] += 1;
if(json_decode(file_get_contents($file), true)[$option] != "ONTHOUDEN"){ //TODO: Make it possible to change orientation of grid.
$count += 1;
foreach ($vote['options_horizontal'] as $option2) {
$chosenOption = json_decode(file_get_contents($file), true)[$option];
if($option2 == $chosenOption){
$options_counted[$option][$option2] += 1;
if($chosenOption != "ONTHOUDEN"){ //TODO: Make it possible to change orientation of grid.
$count += 1;
}
}
}
}
$options_counted[$option]["total"] = $count;
$options_counted[$option]["Totaal"] = $count;
}
$html = "<table class='table'>";
$html .= "<tr><th>Optie</th>";
foreach (array_keys($options_counted[array_keys($options_counted)[0]]) as $header){
$html .= "<th>" . $header . "</th>";
}
$html .= "</tr>";
foreach (array_keys($options_counted) as $key){
$html .= "<tr>";
$html .= "<td>" . $key ."</td>";
foreach (array_keys($options_counted[$key]) as $count_key){
if($count == 0 ){
$count_value = $options_counted[$key][$count_key];
$count_total = $options_counted[$key]['Totaal'];
if($count_value === 0 ){
$html .= "<td>0</td>";
}elseif ($count_key == "Onthouden" || $count_key == "total"){
$html .= "<td>".$options_counted[$key][$count_key]."</td>";
}elseif ($count_key == "Onthouden" || $count_key == "Totaal"){
$html .= "<td>".$count_value."</td>";
}else{
$html .= "<td>" . $options_counted[$key][$count_key] . " - " . round($options_counted[$key][$count_key]/$options_counted[$key]['total'] * 100, 2) . "%</td>";
$html .= "<td>" . $count_value . " - " . round($count_value/$count_total * 100, 2) . "%</td>";
}
}
$html .= "</tr>";
......
......@@ -55,7 +55,7 @@
<tr><th>Tokens (<?php echo count($tokens); ?>)</th></tr>
<?php
foreach ($tokens as $token){
echo "<tr><td>$token</td></tr>";
echo "<tr><td class='readable-token'>$token</td></tr>";
}
?>
</table>
......
......@@ -48,7 +48,7 @@
<div class="row">
<div class="col">
<p>
Welkom op de website voor het digitaal stemmen van Studievereniging Syntax. Alle resultaten zijn anoniem.
Welkom op de website voor het digitaal stemmen van <a href="https://syntaxleiden.nl" target="_blank">Studievereniging Syntax</a>. Alle stemmen zijn anoniem.
</p>
</div>
</div>
......@@ -72,15 +72,27 @@
<?php
}
?>
<input type="text" class="form-control" id="token" aria-describedby="tokenHelp" placeholder="Vul token in.." name="token" required>
<small id="emailHelp" class="form-text text-muted" style="color: black !important;">
<input
id="token"
class="form-control readable-token"
type="text"
aria-describedby="tokenHelp"
placeholder="Vul token in.."
name="token"
required maxlength="19"
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"
>
<p id="tokenHelp" class="form-text text-muted" style="color: #000 !important;">
Dit is je persoonlijke anonieme token. Deze token is niet te herleiden naar jou als
persoon tenzij je je token deelt met anderen.
</small>
</p>
</div>
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1" name="disclaimer" required>
<label class="form-check-label" for="exampleCheck1" style="color: black;">
<input type="checkbox" class="form-check-input" id="legalRequirements" name="disclaimer" required>
<label class="form-check-label" for="legalRequirements" style="color: black;">
<ul style="list-style:none;padding-inline-start: 0px;">
<li>Ik verklaar dat de ingevulde token van mij is;</li>
<li>ik een stemgerechtigd lid ben van <a href="https://syntaxleiden.nl" target="_blank">S.V. Syntax</a>;</li>
......@@ -97,5 +109,6 @@
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
<script src="ux-helper.js"></script>
</body>
</html>
......@@ -97,6 +97,12 @@ function handleVote($votes, $vote_id)
$string = file_get_contents("votes.json");
$votes = json_decode($string, true);
// Remove the helper spaces every 4th character.
if (isset($_POST['token'])) {
$_POST['token'] = str_replace(' ', '', $_POST['token']);
}
if(isset($_POST['vote_id']) && (array_key_exists($_POST['vote_id'], $votes) || $_POST['vote_id'] == "__DEADEND")){
$vote_id = $_POST['vote_id'];
$token = isset($_POST['token']) ? htmlspecialchars($_POST['token']) : die("This is not supposed to happen (ERROR_ID_1)");
......@@ -108,12 +114,22 @@ if(isset($_POST['vote_id']) && (array_key_exists($_POST['vote_id'], $votes) || $
$vote = $votes[$vote_id];
if ($vote['status'] == "closed"){
$html = "<h2>" . $vote['title'] . "</h2>";
$html .= '<div class="alert alert-warning" role="alert">Deze stemming is nog gesloten.</div><br>';
$html .= '<div class="alert alert-warning" role="alert">Deze stemming is (nog) gesloten.</div><br>';
// Form to reload the current vote.
$html .= "<form method='post' action='stem.php'>";
$html .= "<input type='hidden' value='". $vote_id . "' name='vote_id'>";
$html .= "<input type='hidden' value='". $token . "' name='token'>";
$html .= "<input type='submit' value='Verversen' class='btn btn-primary float-right'>";
$html .= "</form>";
// Form to go to the next vote.
$html .= "<form method='post' action='stem.php'>";
$html .= "<input type='hidden' value='". getNextVote($votes, $vote_id) . "' name='vote_id'>";
$html .= "<input type='hidden' value='". $token . "' name='token'>";
$html .= "<input type='submit' value='Volgende Stemming' class='btn btn-primary float-right'>";
$html .= "<input type='submit' value='Stemming Overslaan' class='btn btn-default float-left'>";
$html .= "</form>";
$vote_html = $html;
}else{
if ($vote['type'] === "list"){
......@@ -126,10 +142,15 @@ if(isset($_POST['vote_id']) && (array_key_exists($_POST['vote_id'], $votes) || $
//end of vote
$vote_html = '
<div class="alert alert-success" role="alert">
<h4 class="alert-heading">Dit was de stemming.</h4>
<p>We willen je bedanken voor het uitbrengen van jouw stem als lid van de vereniging!</p>
<hr>
<p class="mb-0">Deze stemsoftware is open-source en <a href="https://git.syntaxleiden.nl/Stan/voting-machine" class="alert-link" target="_blank">hier beschikbaar</a>.</p>
<h4 class="alert-heading">Dit was de laatste stemming.</h4>
<p>We willen je bedanken voor het uitbrengen van jouw stem als lid van de vereniging!</p>
<hr>
<p class="mb-0">
Deze stemsoftware is <a href="https://git.syntaxleiden.nl/Stan/voting-machine" class="alert-link" target="_blank">open-source</a> beschikbaar.
Stemresultaten worden na afloop van de ALV gepubliceerd op het
<a href="https://leden.syntaxleiden.nl" class="alert-link" target="_blank">
ledenportal</a>.
</p>
</div>
';
}else{
......@@ -192,10 +213,10 @@ if(isset($_POST['vote_id']) && (array_key_exists($_POST['vote_id'], $votes) || $
<div class="row">
<div class="col">
<p>
Welkom op de website voor het digitaal stemmen van syntax. Alle resultaten zijn anoniem.
Welkom op de website voor het digitaal stemmen van <a href="https://syntaxleiden.nl" target="_blank">S.V. Syntax</a>. Alle stemmen zijn anoniem.
</p>
<p>
Je token is: <strong><?php echo $token; ?></strong>
Je unieke token is: <strong class="readable-token"><?php echo chunk_split($token, 4, ' '); ?></strong>
</p>
</div>
</div>
......
......@@ -32,9 +32,9 @@ td input[type=radio] {
display: block;
}
label.form-check-label.radio-syntax {
padding-left: 10px;
padding-top: 4px;
.readable-token {
font-family: source-code-pro, monospace;
font-size: 87.5%
}
/* Alleen dikgedrukt toevoegen aangezien je deze class al hebt */
......@@ -47,9 +47,20 @@ label.form-check-label.radio-syntax {
.table thead th:first-of-type {
text-align: left;
}
/* Fancy checkboxes and radio inputs for mobile devices. */
@media screen and (max-width: 768px) {
input[type=radio] {
input[type=radio],
input#legalRequirements {
width: 22px;
height: 22px;
}
label.form-check-label.radio-syntax {
padding-left: 10px;
padding-top: 4px;
}
label.form-check-label[for=legalRequirements] {
padding-left: 10px;
padding-top: 3px;
}
}
["ODCAFNSYGTTM14QZ","BW74F0Y0LISL4TDI","DDB0XGBKRK32J8T7","YA6WEWE0W6U1CUUG","BHUBPRFFTN1KS8UQ","LMQ16ORSBTH2GKJA","JY6TKGQAAMR9R083","39OHSJI1C3M5O90N","8MDJB78CHJBSCAI3","GMWJLG6ZPE4PCXWO","AXTG2XR4VFLBJD0E","F9Y7OX402Q772QBE","T9SQLHCKTOE1GUSK","P47XT0L0VLUB3T8W","4NQAJ9M8LY7D5IWH","QXJ08KM898W5FUBG","GAGTPM8DDM4JMRTV","EBEWHQXDH6NPQU88","W6LIV9A6MB872DKV","DY22LE96AMXLT7EG","M3H5YGZO8U0VLPOG","RFRPHQD1J2FN6OAK","QCB0FO1TUVB4L5S6","UT39NFMMMY93QEDV","DJV641XBXNXUKTJA","X0L81ASKADL6JJ8W","59M68J4CEFH42V9V","R6AFW3H4CFPQBAF7","2PEV5UNW3IYRM3PT","9VGBP82AJGPKW590","XNCLT4FBAHNRKMKJ","RNEEG5EZQPJAR9PX","90C4RYW5Y4RI71VZ","B0ZU829AV1D0NCTX","7D5EHSZDO28M1YSF","IFBDRXSYNTD5WQCC","RYW2ICKX8BUO5CT1","6XGO2IOTLQD4C6RV","VPVKYDK1PYPESIXM","ZCTXFPCGYES1W5VC","R7GIGYA9IT7NT6T4","FGLBMBB1LX9B3NCT","WO8MATHEYT4QIDBS","X062NLDHSYBZ1KNY","KJUWW342LKJ59XI3","MRDFM8I8N3IGMLL5","EI8XXQUCYSWYD895","XB5O04ZCMIT7PV6L","WDP3HWRCOBLHALGA","1323BWCICWJ8W4UA","9D0OST43SFDVOKDN","T5TFMDAH0HT5SANH","8EIRXSCCJNSH67KQ","S5U4UTM65NY9O2HZ","7S2N66F2UH0W5SAV","VMIX2QMJBW8AWHOS","QU4VRY6ZW71NSPM0","CXUPIGRF3XVB7AVD","K4CJSBFF5A2PIJOC","LPBOGZ06DS84YZBX","Z3W7YGWUBORZWB5W","23C0R4LCL6JPZFHK","O6RH1YE3NFIOC0L8","IOOVV3Z3XTFZZILD","ML9JNHKZMC1LF79Z","GCHMJ8XJQIRDZHQV","IIYQ0ZA1QSLI58WF","CVC79F8BZUR0BS23","4YUUEUA507QYT3ES","02TOIY1KNYYC88BO","6Y6G40AFCNMK60X3","GKB1JPNITB3G0PNO","NJIFECKR6013SJNU","AIDWRUQ8ZJWECBJU","3LMIDZE5WVM451UV","GBKMOCA1ZILFOLSR","XOQUET4GY2ARMFWN","P8CPGOA8YFLVLYIJ","PL04761C3TZCDT1Z","U48FLFSLZ4VMUM81","EL9W0G0N8L7I27EA","8TZYG5OLROU2VG6L","V8U1LW34UOE6N920","3BJD9JV53VVNV8V2","Y5X3FXGJ3JGC51JI","6WGBZXFQ3PSZBZZT","M3HW3NWI9PUEOP7D","QVQGZIKD6NMS52VL","7IQVH56JHH4YEJBO","9R6FUD8SK2F52FVH","AHC5TUG6FZZP8W6K","ZOY5MF8OENOSI16A","98ZV5432BVXDIP62","EIUR9U9ZJLG3H7E5","RVTVWNB1MP4UI2B7","RYVKAGH3JKRJM4DJ","K2PDHOQPV7I61QGS","FFVL48O69K0UMII9","7WLSTO6ZD85COELV","DM5V6N27BG2KAVPX"]
\ No newline at end of file
/* shameless copypaste from https://stackoverflow.com/a/29320829/1878974
adjusted to also make a-z uppercase. */
document.getElementById('token').addEventListener('input', function (e) {
var target = e.target,
position = target.selectionEnd,
length = target.value.length
target.value = target.value.toUpperCase().replace(/[^\dA-Z]/g, '').replace(/(.{4})/g, '$1 ').trim()
target.selectionEnd = position += ((target.value.charAt(position - 1) === ' ' && target.value.charAt(length - 1) === ' ' && length !== target.value.length) ? 1 : 0)
})
{
"EXAMPLE_VOTE_1": {
"title": "Voorbeeld list vote",
"type": "list",
"options": [
"Voor",
"Tegen",
"Blanco",
"Onthouden"
],
"status": "open"
},
"EXAMPLE_VOTE_2": {
"title": "Voorbeeld grid vote",
"type": "grid",
"options_vertical": ["Voorzitter", "Vice Voorzitter", "Penningmeester", "Secretaris", "Intern", "Extern", "Tegen", "Blanco", "Onthouden"],
"options_horizontal": ["Naam 1", "Naam 2", "Naam 3", "Naam 4"],
"status": "closed"
}
}