-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
64 lines (60 loc) · 2.17 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html>
<head>
<title>parsemath Equation Tester</title>
<script src="./parsemath.js" defer></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous" />
<link rel="stylesheet" href="https://latex.now.sh/style.min.css" />
</head>
<body>
<script>
window.newRowHtml = `
<div class="row">
<div class="col-4">
<input type="text" placeholder="Variable Name" class="form-control" />
</div>
<div class="col">
<input type="text" placeholder="Variable Value" class="form-control" />
</div>
</div>
`
window.submit = () => {
let submissionVariables = {};
const variables = document.getElementById('variables').children;
for (var i = 0; i < variables.length; i++) {
const variable = variables[i];
const name = variable.firstElementChild.firstElementChild.value;
const value = Number(variable.lastElementChild.firstElementChild.value);
submissionVariables[name] = value;
}
document.getElementById('result').innerText = ParseMath(document.getElementById('math-input').value, true, submissionVariables);
}
</script>
<h1>parsemath Equation Tester</h1>
<div class="container">
<div class="row">
<div class="col">
<input type="text" placeholder="Input any valid Math string" id="math-input" class="form-control" />
</div>
<div class="col-md-auto">
<button type="button" class="btn btn-warning" onClick="window.submit();">Submit</button>
</div>
</div>
</div>
<br />
<div class="container">
<div class="row">
<div class="col"><button type="button" class="btn btn-primary"
onClick="document.getElementById('variables').insertAdjacentHTML('beforeend', window.newRowHtml)">Add
Variable</button>
</div>
</div><br />
<div id="variables">
</div>
</div>
<br />
<p id="result" style="color: black; font-weight: bold;"></p>
<br />
<a href="https://github.com/sd0e/parsemath" target="_blank" rel="nofollow">View the code and use the library on GitHub</a>
</body>
</html>