@@ -16,14 +16,12 @@ package body Frontend is
16
16
function Request_CB (Request : AWS.Status.Data) return AWS.Response.Data is
17
17
URI : constant String := AWS.Status.URI (Request);
18
18
Parms : AWS.Parameters.List;
19
- Current_Tab_Ix : Positive;
20
19
begin
21
20
if URI = " /" then
22
21
return AWS.Response.Build (" text/html" , Build_Main_Page (1 ));
23
22
elsif URI = " /buttonpress" then
24
23
Parms := AWS.Status.Parameters (Request);
25
- Decode_And_Send_Key (To_String (AWS.Parameters.Get (Parms, 1 ).Value),
26
- To_String (AWS.Parameters.Get (Parms, 2 ).Value), Current_Tab_Ix);
24
+ Send_Key (To_String (AWS.Parameters.Get (Parms, 1 ).Value), To_String (AWS.Parameters.Get (Parms, 2 ).Value));
27
25
return AWS.Response.Build (" text/html" , " OK" );
28
26
elsif URI = " /shutdown" then
29
27
Shutting_Down := True;
@@ -42,22 +40,23 @@ package body Frontend is
42
40
" .kp-selector {position:absolute; height:12mm; top:1px; right:2px; font-size:10mm;} " &
43
41
" .kp-pad {align-content:stretch;} " &
44
42
" .kp-btn {margin:0; font-size:calc(4vw + 4vh + 2vmin); border-radius:4mm; background-color:black; padding:2mm; color:white;}" &
45
- " </style><meta charset="" UTF-8"" ><title>Keypadder</title></head>" & ASCII.LF &
46
- " <body>" ;
43
+ " </style><meta charset="" UTF-8"" ><title>Keypadder</title></head>" &
44
+ " <body>" & ASCII.LF ;
47
45
Trailer_HTML : constant String :=
48
46
" <script>" &
49
47
" function selTab(){var selector=document.getElementById('kpselect');openTab(selector.options[selector.selectedIndex].value);}" &
50
- " function openTab(tabName) { " &
51
- " var i; var x = document.getElementsByClassName('kp-pad');" &
52
- " for (i=0; i<x.length; i++) { x[i].style.display = 'none';}" &
53
- " document.getElementById(tabName).style.display = 'block'; } " &
54
- " function aget(tab, id) { " & -- Get via AJAX
48
+
49
+ " function openTab(tabName){var x=document.getElementsByClassName('kp-pad');" &
50
+ " for (let i=0; i<x.length; i++) {x[i].style.display='none';}" &
51
+ " document.getElementById(tabName).style.display='block';} " &
52
+
53
+ " function aget(tab, id) {" & -- Get via AJAX
55
54
" var form = new FormData(document.getElementById("" kpForm"" )); " &
56
- " form.append("" tab"" , tab); form.append("" id"" , id); " &
55
+ " form.append("" tab"" , tab); form.append("" id"" , id); " &
57
56
" var data = new URLSearchParams(form).toString(); " &
58
57
" var xhr = new XMLHttpRequest(); " &
59
58
" xhr.open("" GET"" , "" buttonpress?"" + data); " &
60
- " xhr.send(); return false; }" &
59
+ " xhr.send(); return false;}" &
61
60
" </script></form></body></html>" ;
62
61
Main_HTML : Unbounded_String := Null_Unbounded_String;
63
62
Tmp_Style : Unbounded_String := Null_Unbounded_String;
@@ -127,17 +126,15 @@ package body Frontend is
127
126
return To_String (Main_HTML);
128
127
end Build_Main_Page ;
129
128
130
- procedure Decode_And_Send_Key (T, I : String; Tab : out Positive ) is
131
- Tab_Ix : constant Positive := Positive'Value (T); -- (Key_ID (Index (Key_ID, "t") + 1 .. Index (Key_ID, "i") - 1));
132
- Key_Ix : constant Positive := Positive'Value (I); -- (Key_ID (Index (Key_ID, "i") + 1 .. Key_ID'Last));
129
+ procedure Send_Key (T, I : String) is
130
+ Tab_Ix : constant Positive := Positive'Value (T);
131
+ Key_Ix : constant Positive := Positive'Value (I);
133
132
begin
134
- -- Put_Line ("Decoded Tab:" & Tab_Ix'Image & " and Index:" & Key_Ix'Image);
135
- Tab := Tab_Ix;
136
133
Injector.Injector_Task.Send (Conf.Tabs (Tab_Ix).Keys (Key_Ix).Send_Events);
137
134
exception
138
135
when Error : others =>
139
136
Put_Line (" Error in Decode_And_Send_Key: " );
140
137
Put_Line (Exception_Information (Error));
141
- end Decode_And_Send_Key ;
138
+ end Send_Key ;
142
139
143
140
end Frontend ;
0 commit comments