www/pages/grade-calc/index.html

116 lines
3.6 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta name="Grade Calculator" content="School grade calculation">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/stylesheets/persia.css">
<title>Grade Calc</title>
</head>
<style>
* {
box-sizing: border-box;
}
.about-container {
padding: 1rem;
}
.json-textarea,
.calculator-container {
width: 50%;
padding: 1rem;
float: left;
}
.json-textarea textarea {
max-width: 100%;
min-width: 100%;
width: 100%;
}
.button-container button {
width: 100%;
}
@media screen and (max-width: 900px) {
.json-textarea,
.calculator-container {
width: 100%;
}
}
</style>
<body>
<h1 class="title"><a href="/">PaulW.XYZ</a> / <a href="/pages/">Pages</a> / Grade Calculator</h1>
<div class="block">
<div class="about-container">
<h2>About</h2>
Check out the <a href="https://github.com/lambdapaul/www/blob/master/pages/grade-calc/README.md">README.md</a> file
to learn more about the configuration structure.
<h3>Usage</h3>
<ol>
<li>Either configure the calculator using the text box below or load one from the existing JSON files to
generate one.</li>
<li>Click <code>Generate</code>.</li>
<li>Enter the input values.</li>
</ol>
</div>
<div class="json-textarea">
<h2>Configuration</h2>
<hr>
<h3>Load config from file</h3>
<ul>
<li><a href="javascript:void(0)" onclick="loadConfig('./config/map2302.json')">MAP2302 - ODE I Fall 2019 (map2302.json)</a></li>
<li><a href="javascript:void(0)" onclick="loadConfig('./config/eee3307c.json')">EEE3307C - Electronics I Spring 2021 (eee3307c.json)</a></li>
<li><a href="javascript:void(0)" onclick="loadConfig('./config/eel4742c.json')">EEL4742C - Embedded Systems Spring 2021 (eel4742c.json)</a></li>
<li><a href="javascript:void(0)" onclick="loadConfig('./config/eel4781.json')">EEL4781 - Computer Comm. Networks Spring 2021 (eel4781.json)</a></li>
</ul>
<div class="button-container">
<button class="button" onclick="generate()">Generate &#8594;</button>
</div>
<textarea id="json" id="" rows="30"></textarea>
</div>
<div class="calculator-container">
</div><span class="clear"></span>
</div>
<script type="text/javascript" src="gc_client.js"></script>
<script>
function generate() {
var let;
let calcSection = document.querySelector(".calculator-container");
calcSection.innerHTML = "";
try {
conf = JSON.parse(document.getElementById("json").value);
}
catch (e) {
console.log(e);
calcSection.innerHTML = e;
return;
}
let cb = (out) => {
for (let o of out) {
calcSection.appendChild(o);
}
}
gc = new GradeCalc(conf, cb);
calcSection.appendChild(gc.elemTotal);
}
function loadConfig(filename) {
var client = new XMLHttpRequest();
client.open('GET', filename);
client.onreadystatechange = function () {
document.getElementById("json").value = (client.responseText);
}
client.send();
}
</script>
</body>
</html>