import React, { ReactElement, useState } from 'react'; import Layout from '../../components/layout'; import Link from 'next/link'; import GradeCalc from '../../components/_gc'; function GradeCalcPage() { const [calculator, setCalculator] = useState(); let [jsonInput, setJsonInput] = useState('[]'); function loadConfig(filename: string): void { const client = new XMLHttpRequest(); client.open('GET', filename); client.onreadystatechange = () => { setJsonInput(client.responseText); } client.send(); } function generate() { setCalculator(''); let conf = null; try { conf = JSON.parse(jsonInput); } catch (e) { console.log(e); return; } let cb = (out: ReactElement[]) => { setCalculator([... calculator, out]); } const gc = new GradeCalc(conf, cb); if (calculator) setCalculator([... calculator, React.createElement('div', {className: 'asf'}, gc.elemTotal)]); } return (

About

Check out the README.md file to learn more about the configuration structure.

Usage

  1. Either configure the calculator using the text box below or load one from the existing JSON files to generate one.
  2. Click Generate.
  3. Enter the input values.

Configuration


Load config from file

{calculator}
) } // export default GradeCalcPage; export default function WIP() { return (
Check back later as the port of this page is a Work in Progress.
); }