bpd-checklist/index.php

48 lines
2.2 KiB
PHP

<?php include "questions.php"; ?>
<html>
<head>
<link rel="stylesheet" href="https://bootswatch.com/5/darkly/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
<script type="text/javascript" >
function update() {
let total = document.querySelectorAll("input:checked").length;
let text = "==== Results ====\n";
for(let i = 0; i < <?=count($questions)?>; i++) {
let count = document.querySelectorAll("[id*='" + i + "_']:checked").length;
let max = document.querySelectorAll("[id*='" + i + "_']").length;
document.getElementById(i).innerText = count;
text += "Section " + (i + 1) + ": " + count + " / " + max + "\n";
}
text += "Total: " + total;
document.querySelector("textarea").innerHTML = text;
}
</script>
</head>
<body class="container py-5">
<h1 class="text-center">The Beautiful Princess Disorder Checklist</h1>
<p>This is a checklist to help one understand Borderline Personality Disorder. One may use it to self-diagnose or as a worksheet to present to a doctor or therapist or other medical professional and better communicate symptoms they are experiencing. All information is taken from the DSM-5.</p>
<p>Taken from <a href="https://shitborderlinesdo.tumblr.com/post/102600734264/the-borderline-personality-disorder-checklist">shitborderlinesdo's tumblr</a>.</p>
<?php
foreach ($questions as $id => $section) {
if($id=="")
?>
<h3>Section <?=$id+1?></h3>
<hr>
<p><?=$descriptors[$id]?></p>
<ul class="list-group">
<?php foreach ($section as $qid => $question) { ?>
<li class="list-group-item">
<input class="form-check-input me-1" type="checkbox" id="<?=$id?>_<?=$qid?>" onchange="update()">
<label class="form-check-label" for="<?=$id?>_<?=$qid?>"><?=$question?></label>
</li>
<?php }?>
</ul>
<p><span id="<?=$id?>">0</span> / <?=count($section)?></p>
<br>
<?php }?>
<textarea class="form-control bg-dark text-light" rows="9" readonly style="resize:none;">Results:</textarea>
<a href="https://git.lgbt/root/bpd-checklist">Website Source</a>
<script type="text/javascript" defer>update()</script>
</body>
</html>