tlsd 2.15.0 → 2.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/rpc_static/rpc/index.html +206 -0
package/package.json
CHANGED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>⚙️</text></svg>">
|
|
7
|
+
<title>RPC Tool</title>
|
|
8
|
+
<style>
|
|
9
|
+
* {
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 0;
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
body {
|
|
16
|
+
font-family: Arial, sans-serif;
|
|
17
|
+
height: 100vh;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.grid-container {
|
|
22
|
+
display: grid;
|
|
23
|
+
grid-template-columns: 1fr 1fr;
|
|
24
|
+
grid-template-rows: 1fr 1fr;
|
|
25
|
+
height: 100vh;
|
|
26
|
+
gap: 10px;
|
|
27
|
+
padding: 10px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.textarea-group {
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
height: 100%;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.textarea-group:first-child {
|
|
37
|
+
position: relative;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.send-button {
|
|
41
|
+
position: absolute;
|
|
42
|
+
top: 0;
|
|
43
|
+
right: 0;
|
|
44
|
+
background-color: #007bff;
|
|
45
|
+
color: white;
|
|
46
|
+
border: none;
|
|
47
|
+
border-radius: 4px;
|
|
48
|
+
padding: 6px 12px;
|
|
49
|
+
font-size: 12px;
|
|
50
|
+
font-weight: bold;
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
transition: background-color 0.2s;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.send-button:hover {
|
|
56
|
+
background-color: #0056b3;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.send-button:active {
|
|
60
|
+
background-color: #004085;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.textarea-label {
|
|
64
|
+
font-weight: bold;
|
|
65
|
+
margin-bottom: 5px;
|
|
66
|
+
color: #333;
|
|
67
|
+
font-size: 14px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.textarea-input {
|
|
71
|
+
flex: 1;
|
|
72
|
+
resize: none;
|
|
73
|
+
border: 2px solid #ddd;
|
|
74
|
+
border-radius: 5px;
|
|
75
|
+
padding: 10px;
|
|
76
|
+
font-family: monospace;
|
|
77
|
+
font-size: 14px;
|
|
78
|
+
line-height: 1.4;
|
|
79
|
+
background-color: #f9f9f9;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.textarea-input:focus {
|
|
83
|
+
outline: none;
|
|
84
|
+
border-color: #007bff;
|
|
85
|
+
background-color: white;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.textarea-input:hover {
|
|
89
|
+
border-color: #007bff;
|
|
90
|
+
}
|
|
91
|
+
</style>
|
|
92
|
+
<script src="/rpc/rpc.js"></script>
|
|
93
|
+
</head>
|
|
94
|
+
<body>
|
|
95
|
+
<div class="grid-container">
|
|
96
|
+
<div class="textarea-group">
|
|
97
|
+
<label class="textarea-label">Message Data</label>
|
|
98
|
+
<button class="send-button">Send</button>
|
|
99
|
+
<textarea class="textarea-input" id="e_input" ></textarea>
|
|
100
|
+
</div>
|
|
101
|
+
<div class="textarea-group">
|
|
102
|
+
<label class="textarea-label">Preview</label>
|
|
103
|
+
<textarea class="textarea-input" id="e_preview" ></textarea>
|
|
104
|
+
</div>
|
|
105
|
+
<div class="textarea-group">
|
|
106
|
+
<label class="textarea-label">Sent to Server →</label>
|
|
107
|
+
<textarea class="textarea-input" id="e_sent" ></textarea>
|
|
108
|
+
</div>
|
|
109
|
+
<div class="textarea-group">
|
|
110
|
+
<label class="textarea-label">← Received from Server</label>
|
|
111
|
+
<textarea class="textarea-input" id="e_received" ></textarea>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
<script>
|
|
116
|
+
|
|
117
|
+
// Get the send button and first textarea
|
|
118
|
+
const sendButton = document.querySelector('.send-button');
|
|
119
|
+
const e_input = document.querySelector('#e_input');
|
|
120
|
+
const e_preview = document.querySelector('#e_preview');
|
|
121
|
+
const e_sent = document.querySelector('#e_sent');
|
|
122
|
+
const e_received = document.querySelector('#e_received');
|
|
123
|
+
|
|
124
|
+
// Add click event listener to the send button
|
|
125
|
+
sendButton.addEventListener('click', function() {
|
|
126
|
+
// Get the content from the first textarea
|
|
127
|
+
const textareaContent = e_input.value;
|
|
128
|
+
|
|
129
|
+
// Store the content in local storage
|
|
130
|
+
localStorage.setItem('textareaContent', textareaContent);
|
|
131
|
+
let data = parse_input( textareaContent );
|
|
132
|
+
|
|
133
|
+
let json_out = o2j( data, null, 2 );
|
|
134
|
+
e_sent.value = json_out;
|
|
135
|
+
|
|
136
|
+
let x_data = j2o( o2j( data ) );
|
|
137
|
+
delete x_data.action;
|
|
138
|
+
let x_json = o2j( x_data, null, 4 );
|
|
139
|
+
|
|
140
|
+
e_received.value = "...";
|
|
141
|
+
|
|
142
|
+
RPC( data, function( rsp ) {
|
|
143
|
+
e_received.value = o2j( rsp, null, 2 );
|
|
144
|
+
}, function( err ) {
|
|
145
|
+
e_received.value = "ERROR:\n" + o2j( err, null, 2 );
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// Load content from local storage when page loads
|
|
151
|
+
window.addEventListener('pageshow', function() {
|
|
152
|
+
const savedContent = localStorage.getItem('textareaContent');
|
|
153
|
+
if (savedContent) {
|
|
154
|
+
e_input.value = savedContent;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
function toInt( v ) {
|
|
159
|
+
return parseInt( v );
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function j2o( v ) {
|
|
163
|
+
return JSON.parse( v );
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function o2j( v, null_to_empty, indent ) {
|
|
167
|
+
return JSON.stringify( v, null, indent );
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// parse the input into a data object
|
|
171
|
+
function parse_input( input ) {
|
|
172
|
+
let data = {};
|
|
173
|
+
let action = null;
|
|
174
|
+
let lines = input.trim().split( /\n+/ ).filter( ln => ln );
|
|
175
|
+
for( let line of lines ) {
|
|
176
|
+
let words = line.split( /\s+/ );
|
|
177
|
+
let k = words.shift();
|
|
178
|
+
let v = words.join( " " );
|
|
179
|
+
if( k == "action" ) {
|
|
180
|
+
action = v;
|
|
181
|
+
}
|
|
182
|
+
if( k[ 0 ] == "#" ) {
|
|
183
|
+
continue; // ignore
|
|
184
|
+
}
|
|
185
|
+
else
|
|
186
|
+
if( v[ 0 ] == "{" || v[ 0 ] == "[" ) {
|
|
187
|
+
v = j2o( v ) || v;
|
|
188
|
+
}
|
|
189
|
+
else
|
|
190
|
+
if( /^[\d]+$/.test( v ) ) {
|
|
191
|
+
v = toInt( v );
|
|
192
|
+
}
|
|
193
|
+
data[ k ] = v;
|
|
194
|
+
}
|
|
195
|
+
return data;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
setInterval( function() {
|
|
199
|
+
let data = parse_input( e_input.value );
|
|
200
|
+
let json_out = o2j( data, null, 2 );
|
|
201
|
+
e_preview.value = json_out;
|
|
202
|
+
}, 500 );
|
|
203
|
+
|
|
204
|
+
</script>
|
|
205
|
+
</body>
|
|
206
|
+
</html>
|