@gogoqiu/tencent-http-server 0.0.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/bin/gogoqiu-node-http-service +3 -0
- package/dist/build.d.ts +3 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +3 -0
- package/dist/build.js.map +1 -0
- package/dist/routes/index.d.ts +4 -0
- package/dist/routes/index.d.ts.map +1 -0
- package/dist/routes/index.js +106 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +318 -0
- package/dist/server.js.map +1 -0
- package/dist/serverCmd.d.ts +8 -0
- package/dist/serverCmd.d.ts.map +1 -0
- package/dist/serverCmd.js +44 -0
- package/dist/serverCmd.js.map +1 -0
- package/dist/shell/install.d.ts +5 -0
- package/dist/shell/install.d.ts.map +1 -0
- package/dist/shell/install.js +221 -0
- package/dist/shell/install.js.map +1 -0
- package/dist/shell/postinst.d.ts +2 -0
- package/dist/shell/postinst.d.ts.map +1 -0
- package/dist/shell/postinst.js +4 -0
- package/dist/shell/postinst.js.map +1 -0
- package/dist/shell.d.ts +2 -0
- package/dist/shell.d.ts.map +1 -0
- package/dist/shell.js +249 -0
- package/dist/shell.js.map +1 -0
- package/package.json +82 -0
- package/public/captures1//346/265/213/350/257/225/347/224/250captures +0 -0
- package/public/chat/offer.html +796 -0
- package/public/chat/options.html +58 -0
- package/public/chat/server-info.html +32 -0
- package/public/chat2.html +272 -0
- package/public/chat3.html +246 -0
- package/public/chat4.html +302 -0
- package/public/chat5.html +41 -0
- package/public/formdata.html +41 -0
- package/public/hls-player.htm +41 -0
- package/public/img/back.svg +1 -0
- package/public/img/offline.svg +1 -0
- package/public/img/online.svg +1 -0
- package/public/ip-record.html +28 -0
- package/public/js/encrypt.js +36 -0
- package/public/js/socket.io.min.js +7 -0
- package/public/js/socket.io.min.js.map +1 -0
- package/public/myhost/hostReg.html +35 -0
- package/public/mylog-chat.htm +260 -0
- package/public/mylog3.html +245 -0
- package/public/navbar.css +17 -0
- package/public/readme.txt +3 -0
- package/public/scroll.htm +139 -0
- package/public/ssh-client.html +0 -0
- package/public/upload-file.html +226 -0
- package/public/upload.html +23 -0
- package/public/uploads1/files-1757866537383-447469495.jpg +0 -0
- package/public/uploads1/files-1757867389485-764531720.jpg +0 -0
- package/public/uploads1/files-1757867518311-278635302.jpg +0 -0
- package/public/uploads1/files-1757867629687-688924576.jpg +0 -0
- package/public/uploads1/files-1757868630683-52261917.jpg +0 -0
- package/public/uploads1/files-1757869187061-619427683.jpg +0 -0
- package/public/uploads1/small_files-1757869187061-619427683.jpg +0 -0
- package/public/uploads1//346/265/213/350/257/225/347/224/250upload +0 -0
- package/public/utils.html +57 -0
- package/public/utils.js +161 -0
- package/public/webrtc/rtc-client.html +238 -0
- package/public/webrtc/rtc-file-transfer-client.html +238 -0
- package/public/webrtc/rtc-file-transfer-server.html +453 -0
- package/public/webrtc/rtc-server.html +453 -0
- package/public/webrtc/video-client-input.html +264 -0
- package/public/webrtc/video-server-input.html +312 -0
- package/public/webrtc/webrtc-chat-with-files.html +581 -0
- package/public/webrtc/webrtc-chat.html +367 -0
- package/public/webrtc/webrtc-file-offer.html +88 -0
- package/public/webrtc/webrtc1.html +186 -0
- package/readme.txt +71 -0
- package/views/chat.ejs +53 -0
- package/views/index.ejs +125 -0
- package/views/special-message.ejs +8 -0
- package/views/ssh.ejs +142 -0
- package/views/utils.ejs +0 -0
- package/views/webrtc/client.ejs +203 -0
- package/views/webrtc/server.ejs +365 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<title>测试http传送大文件到git, 大文件分块上传(带刷新提示)</title>
|
|
6
|
+
<style>
|
|
7
|
+
#progress {
|
|
8
|
+
height: 20px;
|
|
9
|
+
background: #eee;
|
|
10
|
+
margin: 10px 0;
|
|
11
|
+
border-radius: 10px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#progress-bar {
|
|
15
|
+
height: 100%;
|
|
16
|
+
background: #4CAF50;
|
|
17
|
+
width: 0;
|
|
18
|
+
border-radius: 10px;
|
|
19
|
+
transition: width 0.3s;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.status {
|
|
23
|
+
color: #666;
|
|
24
|
+
margin: 10px 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.capture{
|
|
28
|
+
width: fit-content;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.box{
|
|
32
|
+
border: 1px solid brown;
|
|
33
|
+
border-radius: 3px;
|
|
34
|
+
margin: 3px;
|
|
35
|
+
padding: 1px;
|
|
36
|
+
}
|
|
37
|
+
</style>
|
|
38
|
+
</head>
|
|
39
|
+
|
|
40
|
+
<body>
|
|
41
|
+
<input type="file" id="fileInput">
|
|
42
|
+
<div class="status" id="status">请选择文件后点击上传</div>
|
|
43
|
+
<div id="progress">
|
|
44
|
+
<div id="progress-bar"></div>
|
|
45
|
+
</div>
|
|
46
|
+
<button onclick="uploadFile()">开始上传</button>
|
|
47
|
+
<button onclick="cancelUpload()" style="margin-left:10px; display:none" id="cancelBtn">取消上传</button>
|
|
48
|
+
<div class="box">
|
|
49
|
+
<div id="uploads">
|
|
50
|
+
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
<div>Captures</div>
|
|
54
|
+
<div class="box">
|
|
55
|
+
<input type="file" id="captureInput" accept="image/*" multiple="false">
|
|
56
|
+
<button onclick="uploadCapture()">上传图片</button>
|
|
57
|
+
<div id="captures">
|
|
58
|
+
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
<script>
|
|
62
|
+
const CHUNK_SIZE = 2 * 1024 * 1024; // 5MB 每块
|
|
63
|
+
let file;
|
|
64
|
+
let isUploading = false; // 标记是否正在上传
|
|
65
|
+
let abortController = null; // 用于取消上传请求
|
|
66
|
+
const url = 'http://git.my.host:28888/usr/bin/upload.php'
|
|
67
|
+
const prefix = "http://git.my.host:28888"
|
|
68
|
+
|
|
69
|
+
// 监听文件选择
|
|
70
|
+
document.getElementById('fileInput').addEventListener('change', (e) => {
|
|
71
|
+
file = e.target.files[0];
|
|
72
|
+
if (file) {
|
|
73
|
+
document.getElementById('status').textContent =
|
|
74
|
+
`已选择:${file.name}(${(file.size / 1024 / 1024).toFixed(2)}MB)`;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// 监听窗口刷新/关闭事件
|
|
79
|
+
window.addEventListener('beforeunload', (e) => {
|
|
80
|
+
if (isUploading) {
|
|
81
|
+
// 标准浏览器会显示默认提示,自定义提示文字可能被忽略
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
e.returnValue = '文件正在上传中,确定要离开吗?';
|
|
84
|
+
return e.returnValue;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// 开始上传
|
|
89
|
+
async function uploadFile() {
|
|
90
|
+
if (!file) return alert('请选择文件');
|
|
91
|
+
if (isUploading) return alert('正在上传中,请稍候');
|
|
92
|
+
|
|
93
|
+
isUploading = true;
|
|
94
|
+
abortController = new AbortController(); // 初始化取消控制器
|
|
95
|
+
document.getElementById('cancelBtn').style.display = 'inline-block';
|
|
96
|
+
document.getElementById('status').textContent = '开始上传...';
|
|
97
|
+
|
|
98
|
+
const totalChunks = Math.ceil(file.size / CHUNK_SIZE);
|
|
99
|
+
const fileHash = file.name + '-' + file.size + '-' + file.lastModified;
|
|
100
|
+
let uploadedChunks = 0;
|
|
101
|
+
|
|
102
|
+
try {
|
|
103
|
+
for (let chunkIndex = 0; chunkIndex < totalChunks; chunkIndex++) {
|
|
104
|
+
// 如果已取消上传,终止循环
|
|
105
|
+
if (!isUploading) break;
|
|
106
|
+
|
|
107
|
+
const start = chunkIndex * CHUNK_SIZE;
|
|
108
|
+
const end = Math.min(start + CHUNK_SIZE, file.size);
|
|
109
|
+
const chunk = file.slice(start, end);
|
|
110
|
+
|
|
111
|
+
const formData = new FormData();
|
|
112
|
+
formData.append('cmd', "putPiece");
|
|
113
|
+
formData.append('chunk', chunk);
|
|
114
|
+
formData.append('chunkIndex', chunkIndex);
|
|
115
|
+
formData.append('totalChunks', totalChunks);
|
|
116
|
+
formData.append('fileHash', fileHash);
|
|
117
|
+
formData.append('fileName', file.name);
|
|
118
|
+
|
|
119
|
+
// 上传分块(附带取消信号)
|
|
120
|
+
const response = await fetch(url, {
|
|
121
|
+
method: 'POST',
|
|
122
|
+
body: formData,
|
|
123
|
+
signal: abortController.signal // 关联取消控制器
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const results = await response.json();
|
|
127
|
+
if (results.length && !results[results.length - 1].retVal) {
|
|
128
|
+
const result = results[results.length - 1];
|
|
129
|
+
throw new Error(`分块 ${chunkIndex} 上传失败:${result.msg}`);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
uploadedChunks++;
|
|
133
|
+
// 更新进度
|
|
134
|
+
const progress = (uploadedChunks / totalChunks) * 100;
|
|
135
|
+
document.getElementById('progress-bar').style.width = `${progress}%`;
|
|
136
|
+
document.getElementById('status').textContent =
|
|
137
|
+
`上传中:${progress.toFixed(1)}%(${uploadedChunks}/${totalChunks})`;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// 所有分块上传完成后合并
|
|
141
|
+
if (isUploading) {
|
|
142
|
+
document.getElementById('status').textContent = '正在合并文件...';
|
|
143
|
+
const formData = new FormData();
|
|
144
|
+
formData.append('cmd', "mergePieces");
|
|
145
|
+
formData.append('totalChunks', totalChunks);
|
|
146
|
+
formData.append('fileHash', fileHash);
|
|
147
|
+
formData.append('fileName', file.name);
|
|
148
|
+
const rr = await fetch(url, {
|
|
149
|
+
method: 'POST',
|
|
150
|
+
body:formData,
|
|
151
|
+
signal: abortController.signal
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
const r = await rr.json()
|
|
155
|
+
if( r.length && r[r.length-1].retVal ){
|
|
156
|
+
document.getElementById('status').textContent = '上传完成!';
|
|
157
|
+
alert('文件上传成功!');
|
|
158
|
+
}else{
|
|
159
|
+
document.getElementById('status').textContent = `上传失败:${r[r.length-1].msg}`;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
} catch (err) {
|
|
163
|
+
if (err.name !== 'AbortError') { // 排除主动取消的错误
|
|
164
|
+
document.getElementById('status').textContent = `上传失败:${err.message}`;
|
|
165
|
+
console.error('上传错误:', err);
|
|
166
|
+
}
|
|
167
|
+
} finally {
|
|
168
|
+
// 重置状态
|
|
169
|
+
isUploading = false;
|
|
170
|
+
document.getElementById('cancelBtn').style.display = 'none';
|
|
171
|
+
abortController = null;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// 取消上传
|
|
176
|
+
function cancelUpload() {
|
|
177
|
+
if (isUploading && abortController) {
|
|
178
|
+
if (confirm('确定要取消上传吗?已上传部分将被丢弃。')) {
|
|
179
|
+
abortController.abort(); // 取消当前请求
|
|
180
|
+
isUploading = false;
|
|
181
|
+
document.getElementById('status').textContent = '上传已取消';
|
|
182
|
+
document.getElementById('cancelBtn').style.display = 'none';
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function addCapture( src ){
|
|
188
|
+
const img = document.createElement("img")
|
|
189
|
+
img.classList.add("capture")
|
|
190
|
+
img.src = src
|
|
191
|
+
const captures = document.querySelector("#captures")
|
|
192
|
+
captures.appendChild( img )
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function uploadCapture(){
|
|
196
|
+
let file = document.querySelector("#captureInput")
|
|
197
|
+
//console.log( file.files )
|
|
198
|
+
if ( file.files.length ){
|
|
199
|
+
file = file.files[0]
|
|
200
|
+
if (!file || !file.type.match('image.*')) {
|
|
201
|
+
alert('请选择一个图片文件!');
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
// 1. 使用 FileReader 读取文件,得到 Data URL(用于预览)
|
|
205
|
+
const reader = new FileReader();
|
|
206
|
+
reader.onload = async function(e) {
|
|
207
|
+
const imageDataUrl = e.target.result; // 这是原始文件的 Data URL
|
|
208
|
+
const fd = new FormData
|
|
209
|
+
fd.append( "dataurl", imageDataUrl )
|
|
210
|
+
fd.append( "cmd", "putCapture" )
|
|
211
|
+
const rr = await fetch(url, {
|
|
212
|
+
method: 'POST',
|
|
213
|
+
body:fd} )
|
|
214
|
+
const r = await rr.json()
|
|
215
|
+
if( r.length && r[r.length-1].retVal ){
|
|
216
|
+
addCapture( prefix + r[r.length-3].data)
|
|
217
|
+
addCapture( prefix + r[r.length-2].data)
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
reader.readAsDataURL(file); // 开始读取文件
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
</script>
|
|
224
|
+
</body>
|
|
225
|
+
|
|
226
|
+
</html>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<body>
|
|
2
|
+
<input type="file" id="file" accept="image/*"/>
|
|
3
|
+
<button onclick="upload()">上传</button>
|
|
4
|
+
<script>
|
|
5
|
+
/*
|
|
6
|
+
files-1759843106007-943643431.jpg
|
|
7
|
+
small_files-1759843106007-943643431.jpg
|
|
8
|
+
*/
|
|
9
|
+
const file = document.querySelector("#file")
|
|
10
|
+
function upload(){
|
|
11
|
+
if ( file.files.length ){
|
|
12
|
+
const fd = new FormData
|
|
13
|
+
fd.append( "files", file.files[0] )
|
|
14
|
+
fetch( "/mylog/upload", {method:"POST", body: fd })
|
|
15
|
+
.then( r=>r.json()).then( r=>{
|
|
16
|
+
if( r.length && r[r.length-1].retVal ){
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
23
|
+
</body>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<style>
|
|
2
|
+
textarea {
|
|
3
|
+
width: 500px;
|
|
4
|
+
height: 300px;
|
|
5
|
+
}
|
|
6
|
+
</style>
|
|
7
|
+
<link rel="stylesheet" href="navbar.css">
|
|
8
|
+
<body>
|
|
9
|
+
<div class="board" style="display: flex;">
|
|
10
|
+
<div>
|
|
11
|
+
<a href="/"><img id="icon" class="back imgbutton"></img></a>
|
|
12
|
+
</div>
|
|
13
|
+
<div>
|
|
14
|
+
<img id="status" class="offline imgbutton" />
|
|
15
|
+
</div>
|
|
16
|
+
<div>
|
|
17
|
+
<h1>测试http/ws两种模式下的mylog的上传</h1>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
<textarea placeholder="some string..." id="textarea"></textarea>
|
|
21
|
+
<button id="base64">Base64</button>
|
|
22
|
+
<button id="svg">Base64-SVG</button>
|
|
23
|
+
<script>
|
|
24
|
+
/*
|
|
25
|
+
*/
|
|
26
|
+
document.querySelector("#base64").onclick = function(){
|
|
27
|
+
const string = document.querySelector("#textarea").value;
|
|
28
|
+
if( string.length == 0 )
|
|
29
|
+
return;
|
|
30
|
+
var fd = new FormData();
|
|
31
|
+
fd.append("string", document.querySelector("#textarea").value);
|
|
32
|
+
fetch("/utils/tobase64", { method: "POST", body: fd } ).then( r=>r.json())
|
|
33
|
+
.then( r=>{
|
|
34
|
+
if( r[r.length-1].retVal ){
|
|
35
|
+
document.querySelector("#textarea").value = r[r.length-1].msg;
|
|
36
|
+
}else{
|
|
37
|
+
alert(r[r.length-1].msg);
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
document.querySelector("#svg").onclick = function(){
|
|
42
|
+
const string = document.querySelector("#textarea").value;
|
|
43
|
+
if( string.length == 0 )
|
|
44
|
+
return;
|
|
45
|
+
var fd = new FormData();
|
|
46
|
+
fd.append("string", string);
|
|
47
|
+
fetch("/utils/tobase64svg", { method: "POST", body: fd } ).then( r=>r.json())
|
|
48
|
+
.then( r=>{
|
|
49
|
+
if( r[r.length-1].retVal ){
|
|
50
|
+
document.querySelector("#textarea").value = r[r.length-1].msg;
|
|
51
|
+
}else{
|
|
52
|
+
alert(r[r.length-1].msg);
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
</script>
|
|
57
|
+
</body>
|
package/public/utils.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
|
|
2
|
+
let chatDomKeys = ["from", "to"]
|
|
3
|
+
let mylogDomKeys = ["from"]
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
部署dom,部署dom事件,事件回调内关联"属性"
|
|
8
|
+
部署dom:
|
|
9
|
+
1. <select id="from"></select>
|
|
10
|
+
2. <select id="to"></select>
|
|
11
|
+
部署dom事件:
|
|
12
|
+
1. document.querySelector(`#${id}`).onchange // 回写
|
|
13
|
+
事件回调内关联"属性":
|
|
14
|
+
1. onPost
|
|
15
|
+
document.querySelector(`#${id}`).value
|
|
16
|
+
有些库,把部署dom也封装进函数了,而不是手动添加html
|
|
17
|
+
*/
|
|
18
|
+
function fillselects(isChat) {
|
|
19
|
+
function fill(id, hostnames) {
|
|
20
|
+
// add unknown
|
|
21
|
+
const option = document.createElement('option')
|
|
22
|
+
option.value = "unknown"
|
|
23
|
+
option.text = "unknown"
|
|
24
|
+
document.querySelector(`#${id}`).appendChild(option)
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
hosts也搞一个如video-site一样可以tag选的模式
|
|
28
|
+
*/
|
|
29
|
+
hostnames.forEach(e => {
|
|
30
|
+
//console.log( e )
|
|
31
|
+
const option = document.createElement('option')
|
|
32
|
+
option.value = e
|
|
33
|
+
option.text = e
|
|
34
|
+
document.querySelector(`#${id}`).appendChild(option)
|
|
35
|
+
})
|
|
36
|
+
// 设置回写当前选项
|
|
37
|
+
document.querySelector(`#${id}`).onchange = function () {
|
|
38
|
+
// from/to
|
|
39
|
+
setHostnameToStorage( id )
|
|
40
|
+
}
|
|
41
|
+
// 设置当前选项
|
|
42
|
+
const v = getHostnameFromStorage( id )
|
|
43
|
+
if( v )
|
|
44
|
+
document.querySelector(`#${id}`).value = v
|
|
45
|
+
}
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
/*
|
|
48
|
+
connection: keep-alive
|
|
49
|
+
[2025-09-02T16:19:09.240] [INFO] default - A user connected [ '::1' ]
|
|
50
|
+
[2025-09-02T16:29:08.265] [ERROR] default - OnError [
|
|
51
|
+
'getdnsRecords',
|
|
52
|
+
Error: read ETIMEDOUT
|
|
53
|
+
10分钟就超时了?
|
|
54
|
+
*/
|
|
55
|
+
fetch('/hosts/dns').then(r => r.json()).then(r => {
|
|
56
|
+
r = r[r.length - 1]
|
|
57
|
+
if (r.retVal) {
|
|
58
|
+
let hostnames = []
|
|
59
|
+
r.data.forEach(e => {
|
|
60
|
+
//console.log( e )
|
|
61
|
+
if (e.type == 0)
|
|
62
|
+
hostnames.push(e.hostname)
|
|
63
|
+
})
|
|
64
|
+
if (isChat) {
|
|
65
|
+
for (const key of chatDomKeys) {
|
|
66
|
+
fill(key, hostnames)
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
for (const key of mylogDomKeys) {
|
|
70
|
+
fill(key, hostnames)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/*
|
|
74
|
+
漏写r = r[r.length - 1]
|
|
75
|
+
是不是这里没有resolve, 造成整个request/host/dns的tcp无法关闭?,后台报错了
|
|
76
|
+
*/
|
|
77
|
+
resolve(null)
|
|
78
|
+
} else {
|
|
79
|
+
reject(r.msg)
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function setHostnameToStorage( id ){
|
|
86
|
+
//console.log(document.querySelector('select').value)
|
|
87
|
+
const v = document.getElementById( id ).value
|
|
88
|
+
localStorage.setItem( id, v )
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function getHostnameFromStorage( id ) {
|
|
92
|
+
return localStorage.getItem( id )
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function getFromValue(){
|
|
96
|
+
return document.getElementById('from').value
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function getToValue(){
|
|
100
|
+
return document.getElementById('to').value
|
|
101
|
+
}
|
|
102
|
+
/*********************************
|
|
103
|
+
* encrypt key below
|
|
104
|
+
*********************************/
|
|
105
|
+
|
|
106
|
+
/*
|
|
107
|
+
部署dom:
|
|
108
|
+
1. <input id="encKey" oninput="setEncKey()" />
|
|
109
|
+
部署dom事件:
|
|
110
|
+
*/
|
|
111
|
+
const encKey = "encKey"
|
|
112
|
+
|
|
113
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
114
|
+
console.log( "DOMContentLoaded" )
|
|
115
|
+
document.getElementById( encKey ).value = localStorage.getItem( encKey )
|
|
116
|
+
document.getElementById( encKey ).oninput = function () {
|
|
117
|
+
localStorage.setItem( encKey, document.getElementById( encKey ).value )
|
|
118
|
+
}
|
|
119
|
+
document.getElementById("interval").oninput = function() {
|
|
120
|
+
if( parseInt(this.value) )
|
|
121
|
+
localStorage.setItem("interval", this.value);
|
|
122
|
+
};
|
|
123
|
+
document.getElementById("interval").value = localStorage.getItem("interval") || 15000;
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
/*
|
|
127
|
+
typescript主要是补齐js的语法强度,需要更多语法,才能支持更强的逻辑表达
|
|
128
|
+
namespace/class/static/import
|
|
129
|
+
*/
|
|
130
|
+
function getEncKey(){
|
|
131
|
+
const v = document.getElementById( encKey ).value
|
|
132
|
+
if( v.length<10 ){
|
|
133
|
+
alert('密钥长度必须大于10')
|
|
134
|
+
}else{
|
|
135
|
+
return v
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function prepost_chat() {
|
|
140
|
+
if( !getEncKey() )
|
|
141
|
+
return false
|
|
142
|
+
for (const id of chatDomKeys) {
|
|
143
|
+
if( document.querySelector(`#${id}`).value =="unknown" )
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function prepost_mylog() {
|
|
150
|
+
if( !getEncKey() )
|
|
151
|
+
return false
|
|
152
|
+
for (const id of mylogDomKeys) {
|
|
153
|
+
if( document.querySelector(`#${id}`).value =="unknown" )
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function getInterval(){
|
|
160
|
+
return document.getElementById("interval").value;
|
|
161
|
+
}
|