Skip to content

Commit 1a17c6b

Browse files
committed
Draft variable templating
1 parent aab4a7c commit 1a17c6b

2 files changed

Lines changed: 27 additions & 15 deletions

File tree

web/dist/index.html

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,8 @@
2525
</div>
2626
<div class="col d-grid gap-2">
2727
<div class="container" id="variables">
28-
<div class="row">
29-
<div class="d-inline-flex">
30-
<input type="text" class="form-control" value="var_one" placeholder="Variable Name"/>
31-
<select class="form-select">
32-
<option selected>Integer</option>
33-
<option>Real</option>
34-
<option>Complex</option>
35-
<option>String</option>
36-
<option>Logical</option>
37-
</select>
38-
<input type="number" class="form-control" value="0" step="1"/>
39-
<button type="button" class="btn btn-outline-danger"><i class="bi bi-trash"></i></button>
40-
</div>
41-
</div>
4228
</div>
43-
<button type="button" class="btn btn-secondary"> <i class="bi bi-plus-lg"></i> Add variable</button>
29+
<button type="button" class="btn btn-secondary" id="add-variable"> <i class="bi bi-plus-lg"></i> Add variable</button>
4430
</div>
4531
</div>
4632
<div class="row border rounded-3 bg-light my-2 py-1">
@@ -56,5 +42,22 @@ <h1>Output</h1>
5642
</div>
5743
</div>
5844
</main>
45+
<template id="variable-template">
46+
<link rel="stylesheet" href="style.css"/>
47+
<div class="row">
48+
<div class="d-inline-flex">
49+
<input type="text" class="form-control" value="var_one" placeholder="Variable Name"/>
50+
<select class="form-select">
51+
<option selected>Integer</option>
52+
<option>Real</option>
53+
<option>Complex</option>
54+
<option>String</option>
55+
<option>Logical</option>
56+
</select>
57+
<input type="number" class="form-control" value="0" step="1"/>
58+
<button type="button" class="btn btn-outline-danger"><i class="bi bi-trash"></i></button>
59+
</div>
60+
</div>
61+
</template>
5962
</body>
6063
</html>

web/src/js/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
var Module = require("Formatter/out");
22
require("bootstrap");
33

4+
const { VariableInput } = require("./variables.js");
5+
46
let runFirst = false;
57

68
let urlInfo = new URLSearchParams(window.location.search);
@@ -23,6 +25,13 @@ async function load() {
2325
formatStmt.value = stmt;
2426
updateFormatStmt();
2527
}
28+
29+
30+
let addVar = document.getElementById("add-variable");
31+
let variables = document.getElementById("variables");
32+
addVar.addEventListener("click", () => {
33+
variables.appendChild(new VariableInput());
34+
});
2635

2736
function printErr(e) {
2837
output.innerText += e + "\n";

0 commit comments

Comments
 (0)