-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
64 lines (58 loc) · 2.18 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 xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="./index.css" />
<title>TypeCalc</title>
</head>
<body>
<header>
TypeCalc
</header>
<div id="entryBox">
<textarea id="entryText" spellcheck="false" placeholder="Type here!" type="text" name="entryText"
oninput="parseInput(this.value)">
</textarea>
<div id="resultsBox" style="overflow-y: scroll"></div>
</div>
<footer>
You can type numbers separated by "/" or "*" or "+" or "-".
You can use "()" for grouping.
You can use phrases of the form "300 + 30%".
You can convert an IP address to integer form.
Each line is evaluated independently. Everything after # in a line is ignored.
All changes saved automatically.
</footer>
<script src="nearley.js"></script>
<script src="grammar.js"></script>
<script src="script.js"></script>
<script>
var isSyncingLeftScroll = false;
var isSyncingRightScroll = false;
var leftDiv = document.getElementById('entryText');
var rightDiv = document.getElementById('resultsBox');
leftDiv.onscroll = function () {
if (!isSyncingLeftScroll) {
isSyncingRightScroll = true;
rightDiv.scrollTop = this.scrollTop;
}
isSyncingLeftScroll = false;
}
rightDiv.onscroll = function () {
if (!isSyncingRightScroll) {
isSyncingLeftScroll = true;
leftDiv.scrollTop = this.scrollTop;
}
isSyncingRightScroll = false;
}
window.onload = function () {
document.getElementById("entryText").value = "";
document.getElementById("resultsBox").textContent = '';
if (localStorage.getItem('input_text')) {
document.getElementById("entryText").value = localStorage.getItem('input_text');
parseInput(document.getElementById("entryText").value);
}
}
</script>
</body>
</html>