-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.html
More file actions
62 lines (56 loc) · 1.86 KB
/
Copy pathparser.html
File metadata and controls
62 lines (56 loc) · 1.86 KB
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
<html>
<head>
<title>Booole Function Parser</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8;"/>
<meta name="description" content="Boolean algebra function parser" />
<meta name="author" content="NohponeX" />
<script type="text/javascript" src="parser.js"></script>
</head>
<body>
<div id="input_area">
<span>Enter logical function ( Use ! for Negation , + for logical OR, ^ FOR XOR ) :</span><br/>
ƒ=<input type="text" id="input_box" onkeyup="keyPressedEvt(event)" value="A+!(BC)"/>
<input type="button" value="Eval" onClick="eval();"/>
</div>
<div id="results">
</div>
<div id="footer">
<p><a href="https://github.com/NohponeX/booleanfunctions">Created by NohponeX</a></p>
</div>
<script type="text/javascript">
function keyPressedEvt( e ) {
if (e.keyCode)
x = e.keyCode;
else if (e.which)
x = e.which;
if (x == 13) {//Enter key pressed
eval();
}
}
function eval(){
parser(document.getElementById("input_box").value, eval_callback);
}
function eval_callback( err, variables, variations, TruthTableValues, TruthTableResult ){
var result = document.getElementById("results");
var out = "";
//Output
out += "<table><tr>";
for (var i = 0; i < variables.length; i++) {
out += "<th>" + variables[i] + "</th>";
}
out += "<th>ƒ</th></tr>";
for (var i = 0; i < variations; i++) {
var cclass = (i % 2 == 0 ? "lineA" : "lineB" );
out += "<tr class=\"" + cclass + "\">";
for (var v = 0; v < variables.length; v++) {
out += "<td>" + (TruthTableValues[i][v] == true ? 1 : 0 ) + "</td>";
}
out += "<td class=\"result\">" + TruthTableResult[i] + "</td></tr>";
}
out += "</table>";
result.innerHTML = out;
}
</script>
</body>
</html>