calc_numpad.nv
· 4.7 KiB · Text
原始檔案
Playground
| #strings, br, app, button, calc-output, div,
AC, All Clear, C, Clear,
0,9,8,7,6,5,4,3,2,1,
+,/,*,-,.,=,
,Press 7, Press 8, Press 9, Press Divide
,Press 4, Press 5, Press 6, Press Multiply
,Press 1, Press 2, Press 3, Press Subtract
,Press 0, Press Dot, Press Equal, Press Add
|
| #slots, DOM id, inner content, vera event, num A, num B |
| #port, on log string, needs, @on log, clears, @on log |
| #port, on clear log, needs, @clear log, clears, @clear log |
| #port, on reset ui, needs, @reset ui, clears, @reset ui |
| #port, create element, needs, @create element, clears, @create element |
| #port, mount element by id, needs, @mount element by id, clears, @mount element by id |
|_| Works ased on the currently mounted element. Maybe a bit clunky, but works for now.
| #port, clear element content, needs, @clear element content, clears, @clear element content |
| #port, append string to element, needs, @append string to element, clears, @append string to element |
|| ui init
| ui init |
@reset ui,
add string app, mount element by id,
create display label,
create buttons,
mount to output,
| create button |
set slot inner content,
set slot vera event,
create button.2
| create button.2 |
add string button, create element
| next row |
add string br, create element
| create element | @create element
| mount element by id | @mount element by id
| create display label |
add string calc-output, set DOM id, create display label.2,
| set DOM id | set slot DOM id
| create display label.2 |
add string div, create element, finish label row
| finish label row | next row
| create buttons |
create AC C row,
create 7 8 9 / row,
create 4 5 6 * row,
create 1 2 3 - row,
create 0 . = +
| create AC C row | create AC button, create C button
| create AC button | add string AC, add string All Clear, create button
| create C button | add string C, add string Clear, create button, ACC finish
|ACC finish| next row
| create 7 8 9 / row | add button 7, add button 8, add button 9, add button /
| add button 7 | add string 7, add string Press 7, create button
| add button 8 | add string 8, add string Press 8, create button
| add button 9 | add string 9, add string Press 9, create button
| add button / | add string /, add string Press Divide, create button, 789 Finish
|789 Finish| next row
| create 4 5 6 * row | add button 4, add button 5, add button 6, add button *
| add button 4 | add string 4, add string Press 4, create button
| add button 5 | add string 5, add string Press 5, create button
| add button 6 | add string 6, add string Press 6, create button,
| add button * | add string *, add string Press Multiply, create button, 456 Finish
|456 Finish| next row
| create 1 2 3 - row | add button 1, add button 2, add button 3, add button -
| add button 1 | add string 1, add string Press 1, create button
| add button 2 | add string 2, add string Press 2, create button
| add button 3 | add string 3, add string Press 3, create button
| add button - | add string -, add string Press Subtract, create button, 123 Finish
|123 Finish| next row
| create 0 . = + | add button 0, add button ., add button =, add button +
| add button 0 | add string 0, add string Press 0, create button
| add button . | add string ., add string Press Dot, create button
| add button = | add string =, add string Press Equal, create button
| add button + | add string +, add string Press Add, create button
| mount to output | add string calc-output, mount element by id
| Clear | add string Clear, on log
| on log | @on log
| add char | string append, ac.1, display acc
| ac.1 | set slot acc
| display acc | dc.1
| dc.1 | dc.2, clear element content
| dc.2 | dc.3, fetch slot acc
| dc.3 | @append string to element
| Number Button Pressed | mount to output, fetch slot acc, get button char, Finish Number Button Press
| get button char, b0 | add string 0
| get button char, b1 | add string 1
| get button char, b2 | add string 2
| get button char, b3 | add string 3
| get button char, b4 | add string 4
| get button char, b5 | add string 5
| get button char, b6 | add string 6
| get button char, b7 | add string 7
| get button char, b8 | add string 8
| get button char, b9 | add string 9
| get button char, b. | add string .
| Finish Number Button Press | add char
| Press 0 | Number Button Pressed, b0
| Press 1 | Number Button Pressed, b1
| Press 2 | Number Button Pressed, b2
| Press 3 | Number Button Pressed, b3
| Press 4 | Number Button Pressed, b4
| Press 5 | Number Button Pressed, b5
| Press 6 | Number Button Pressed, b6
| Press 7 | Number Button Pressed, b7
| Press 8 | Number Button Pressed, b8
| Press 9 | Number Button Pressed, b9
| Press Dot | Number Button Pressed, b.
1 | | #strings, br, app, button, calc-output, div, |
2 | AC, All Clear, C, Clear, |
3 | 0,9,8,7,6,5,4,3,2,1, |
4 | +,/,*,-,.,=, |
5 | ,Press 7, Press 8, Press 9, Press Divide |
6 | ,Press 4, Press 5, Press 6, Press Multiply |
7 | ,Press 1, Press 2, Press 3, Press Subtract |
8 | ,Press 0, Press Dot, Press Equal, Press Add |
9 | | |
10 | |
11 | | #slots, DOM id, inner content, vera event, num A, num B | |
12 | |
13 | | #port, on log string, needs, @on log, clears, @on log | |
14 | | #port, on clear log, needs, @clear log, clears, @clear log | |
15 | | #port, on reset ui, needs, @reset ui, clears, @reset ui | |
16 | | #port, create element, needs, @create element, clears, @create element | |
17 | | #port, mount element by id, needs, @mount element by id, clears, @mount element by id | |
18 | |
19 | |_| Works ased on the currently mounted element. Maybe a bit clunky, but works for now. |
20 | | #port, clear element content, needs, @clear element content, clears, @clear element content | |
21 | | #port, append string to element, needs, @append string to element, clears, @append string to element | |
22 | |
23 | |
24 | || ui init |
25 | |
26 | | ui init | |
27 | @reset ui, |
28 | add string app, mount element by id, |
29 | create display label, |
30 | create buttons, |
31 | mount to output, |
32 | |
33 | | create button | |
34 | set slot inner content, |
35 | set slot vera event, |
36 | create button.2 |
37 | |
38 | | create button.2 | |
39 | add string button, create element |
40 | |
41 | | next row | |
42 | add string br, create element |
43 | |
44 | | create element | @create element |
45 | | mount element by id | @mount element by id |
46 | |
47 | | create display label | |
48 | add string calc-output, set DOM id, create display label.2, |
49 | | set DOM id | set slot DOM id |
50 | | create display label.2 | |
51 | add string div, create element, finish label row |
52 | |
53 | | finish label row | next row |
54 | |
55 | | create buttons | |
56 | create AC C row, |
57 | create 7 8 9 / row, |
58 | create 4 5 6 * row, |
59 | create 1 2 3 - row, |
60 | create 0 . = + |
61 | |
62 | | create AC C row | create AC button, create C button |
63 | | create AC button | add string AC, add string All Clear, create button |
64 | | create C button | add string C, add string Clear, create button, ACC finish |
65 | |ACC finish| next row |
66 | |
67 | | create 7 8 9 / row | add button 7, add button 8, add button 9, add button / |
68 | | add button 7 | add string 7, add string Press 7, create button |
69 | | add button 8 | add string 8, add string Press 8, create button |
70 | | add button 9 | add string 9, add string Press 9, create button |
71 | | add button / | add string /, add string Press Divide, create button, 789 Finish |
72 | |789 Finish| next row |
73 | |
74 | |
75 | | create 4 5 6 * row | add button 4, add button 5, add button 6, add button * |
76 | | add button 4 | add string 4, add string Press 4, create button |
77 | | add button 5 | add string 5, add string Press 5, create button |
78 | | add button 6 | add string 6, add string Press 6, create button, |
79 | | add button * | add string *, add string Press Multiply, create button, 456 Finish |
80 | |456 Finish| next row |
81 | |
82 | | create 1 2 3 - row | add button 1, add button 2, add button 3, add button - |
83 | |
84 | | add button 1 | add string 1, add string Press 1, create button |
85 | | add button 2 | add string 2, add string Press 2, create button |
86 | | add button 3 | add string 3, add string Press 3, create button |
87 | | add button - | add string -, add string Press Subtract, create button, 123 Finish |
88 | |123 Finish| next row |
89 | |
90 | |
91 | | create 0 . = + | add button 0, add button ., add button =, add button + |
92 | | add button 0 | add string 0, add string Press 0, create button |
93 | | add button . | add string ., add string Press Dot, create button |
94 | | add button = | add string =, add string Press Equal, create button |
95 | | add button + | add string +, add string Press Add, create button |
96 | |
97 | | mount to output | add string calc-output, mount element by id |
98 | |
99 | | Clear | add string Clear, on log |
100 | |
101 | | on log | @on log |
102 | |
103 | | add char | string append, ac.1, display acc |
104 | | ac.1 | set slot acc |
105 | |
106 | | display acc | dc.1 |
107 | | dc.1 | dc.2, clear element content |
108 | | dc.2 | dc.3, fetch slot acc |
109 | | dc.3 | @append string to element |
110 | |
111 | | Number Button Pressed | mount to output, fetch slot acc, get button char, Finish Number Button Press |
112 | | get button char, b0 | add string 0 |
113 | | get button char, b1 | add string 1 |
114 | | get button char, b2 | add string 2 |
115 | | get button char, b3 | add string 3 |
116 | | get button char, b4 | add string 4 |
117 | | get button char, b5 | add string 5 |
118 | | get button char, b6 | add string 6 |
119 | | get button char, b7 | add string 7 |
120 | | get button char, b8 | add string 8 |
121 | | get button char, b9 | add string 9 |
122 | | get button char, b. | add string . |
123 | | Finish Number Button Press | add char |
124 | |
125 | | Press 0 | Number Button Pressed, b0 |
126 | | Press 1 | Number Button Pressed, b1 |
127 | | Press 2 | Number Button Pressed, b2 |
128 | | Press 3 | Number Button Pressed, b3 |
129 | | Press 4 | Number Button Pressed, b4 |
130 | | Press 5 | Number Button Pressed, b5 |
131 | | Press 6 | Number Button Pressed, b6 |
132 | | Press 7 | Number Button Pressed, b7 |
133 | | Press 8 | Number Button Pressed, b8 |
134 | | Press 9 | Number Button Pressed, b9 |
135 | | Press Dot | Number Button Pressed, b. |
136 |