-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
102 lines (88 loc) · 2.71 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="google-site-verification" content="RP8Ro2heX1vbxqsFN-B7iE4Kd-FUIGANYwbdtxwqOAA" />
<meta charset="UTF-8">
<title>Odwrotna notacja polska</title>
<link rel="stylesheet" href="style.css">
</head>
<p>repo: <a href="https://github.com/Ptelka/onp.github.io">https://github.com/Ptelka/onp.github.io</a></p>
<h1>Konwerter notacja infiksowa - odwrotna notacja polska ONP</h1>
<table id="operators">
<tr>
<td>Nazwa</td>
<td>Operator</td>
<td>Priorytet</td>
</tr>
<tr>
<td>Nawias otwierający</td>
<td>(</td>
<td>0</td>
</tr>
<tr>
<td>Nawias zamykający</td>
<td>)</td>
<td>1</td>
</tr>
<tr>
<td>Dodawanie, odejmowanie</td>
<td>+, -</td>
<td>1</td>
</tr>
<tr>
<td>Mnożenie, dzielenie</td>
<td>*, /</td>
<td>2</td>
</tr>
<tr>
<td>Potęgowanie</td>
<td>^</td>
<td>3</td>
</tr>
<tr>
<td>Negacja, sinus, cosinus, tangens, cotangens</td>
<td>!, sin, cos, tg, ctg</td>
<td>4</td>
</tr>
</table>
<span style="display:block; height:50px;"></span>
<b>Przykład: a + b - (7 * sinc)^4</b>
<span style="display:block; height:20px;"></span>
<p>Konwerter nie sprawdza poprawności wprowadzanego wyrażenia</p>
<input type="text" name="enter" class="enter" value="" id="text_input"/>
<input type="button" value="ok" OnClick="onClick()"/>
<span style="display:block; height:10px;"></span>
<table id="table" class="greyGridTable">
<tr>
<td>Wyrażenie</td>
<td>Stos</td>
<td>Wynik</td>
<td>Typ</td>
<td>Wartość</td>
<td>Priorytet</td>
<td>Działanie</td>
</tr>
</table>
<script type="text/javascript" src="onp.js"></script>
<script type="text/javascript">
let input = document.getElementById('text_input');
let table = document.getElementById('table');
let originalHTML = table.innerHTML;
function onClick() {
let result = convert(parse(input.value));
table.innerHTML = originalHTML;
for (let step of result) {
let row = table.insertRow(-1);
row.insertCell(0).innerHTML = step.expressions.join(" ");
row.insertCell(1).innerHTML = step.stack.join(", ");
row.insertCell(2).innerHTML = step.result.join(" ");
row.insertCell(3).innerHTML = step.expression.type;
row.insertCell(4).innerHTML = step.expression.value;
row.insertCell(5).innerHTML = step.expression.priority;
row.insertCell(6).innerHTML = OperationDescriptions.get(step.expression.type);
}
}
</script>
<body>
</body>
</html>