-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_index.html
182 lines (178 loc) · 7.25 KB
/
test_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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
<title>js-util Test</title>
<link rel="stylesheet" type="text/css" href="base.css">
<script src="https://cdn.bootcss.com/vConsole/3.2.2/vconsole.min.js"></script>
<script type="text/javascript" src="common/date.js"></script>
<script type="text/javascript" src="common/env.js"></script>
<script type="text/javascript" src="common/hex_grid_map.js"></script>
<script type="text/javascript" src="common/list.js"></script>
<script type="text/javascript" src="common/lock.js"></script>
<script type="text/javascript" src="common/memory.js"></script>
<script type="text/javascript" src="common/promise.js"></script>
<script type="text/javascript" src="common/random.js"></script>
<script type="text/javascript" src="common/string.js"></script>
<script type="text/javascript" src="common/misc.js"></script>
<script type="text/javascript" src="DOM/dom.js"></script>
<script type="text/javascript" src="DOM/keybutton_state.js"></script>
<script type="text/javascript" src="DOM/keyboard.js"></script>
<script type="text/javascript" src="DOM/mouse.js"></script>
<script type="text/javascript" src="DOM/touch.js"></script>
<script type="text/javascript" src="DOM/dom_async.js"></script>
<script type="text/javascript" src="DOM/layout_xml.js"></script>
<script type="text/javascript" src="DOM/websocket_client.js"></script>
</head>
<body>
<div id="div1" style="border: 1px solid; height: 33%; overflow: auto;"></div>
<div id="div2" style="border: 1px solid; height: 33%; overflow: auto;"></div>
<div id="div3" style="border: 1px solid; height: 30%; overflow: auto;"></div>
</body>
<script type="text/javascript">
async function main() {
// 移动端加载调试工具
if (js_util.Common.host_browser_env() === js_util.Common.HOST_BROWSER_ENV.MOBILE) {
if (VConsole) {
new VConsole();
}
}
// console.log(`lineNo: ${js_util.Common.lineNo()}`);
/*
let divArr = [
document.getElementById("div1"),
document.getElementById("div2")
];
let console_div = document.getElementById("div3");
for (let i = 0; i < divArr.length; ++i) {
const div = divArr[i];
div.addEventListener("touchstart", function (e) {
div.innerText += `touchstart,,, touches_length: ${e.touches.length}, target_length: ${e.targetTouches.length}, changed_length: ${e.changedTouches.length}\n`;
div.scrollTop = div.scrollHeight;
let s = '';
for (const touch of e.touches) {
s += `start touch id: ${touch.identifier}, movement: `;
let state = js_util.DOM.TouchGlobalListener.key_state(touch.identifier);
s += `(${state.data.movementX}, ${state.data.movementY})\n`;
}
s += '--------\n'
console_div.innerText += s;
console_div.scrollTop = console_div.scrollHeight;
});
div.addEventListener("touchmove", function (e) {
let s = '';
for (const touch of e.targetTouches) {
s += `move touch id: ${touch.identifier}, movement: `;
let state = js_util.DOM.TouchGlobalListener.key_state(touch.identifier);
s += `(${state.data.movementX}, ${state.data.movementY})\n`;
}
s += '--------\n'
div.innerText += s;
div.scrollTop = div.scrollHeight;
s = '';
for (const touch of e.touches) {
s += `move touch id: ${touch.identifier}, movement: `;
let state = js_util.DOM.TouchGlobalListener.key_state(touch.identifier);
s += `(${state.data.movementX}, ${state.data.movementY})\n`;
}
s += '--------\n'
console_div.innerText += s;
console_div.scrollTop = console_div.scrollHeight;
});
}
*/
// Test execute env
//console.log(`host env: ${js_util.Common.host_env()}, ${js_util.Common.host_env_string()}, \
//${js_util.Common.host_browser_env()}, ${js_util.Common.host_browser_env_string()}`);
// // Test Lock
// let lockmgr = new js_util.Common.LockManager();
// let guard = lockmgr.new_guard();
// await guard.lock("xxxx");
// setTimeout(async () => {
// let guard = lockmgr.new_guard();
// await guard.lock("xxxx");
// console.log("end2");
// guard.unlock();
// }, 1000);
// await js_util.Common.promise_sleep(2000);
// guard.unlock();
// console.log("end1");
// // Test layout from XML
// let ajax = js_util.DOM.ajax_open("get", "http://39.100.213.153/small_game_client/static_resource/layout.xml");
// let result = await js_util.DOM.ajax_send(ajax, null, 3000);
// if (!result) {
// console.log("ajax error");
// return;
// }
// let layout = new js_util.DOM.LayoutXML();
// layout.parse_from_xml_node(result.responseXML.firstChild);
// let dom = layout.dom_from_xml_tag_name("#login_dialog");
// document.body.appendChild(dom);
// // Test WebsocketClient
// let ws_client = new js_util.DOM.WebSocketClient();
// result = await ws_client.connect("ws://60.204.155.222:51101/");
// if (!result) {
// console.log("ws client connect error");
// return;
// }
// let session = new js_util.DOM.WebSocketClientSession();
// session.replace_socket(ws_client);
// session.onclose = () => {
// console.log("ws_client disconnect....");
// };
// console.log("ws client connect success");
// // Test Keyboard Event
// document.addEventListener('keydown', function (e) {
// const key_state = js_util.DOM.KeyboardGlobalListener.key_state(e.code);
// const presist_timelen = key_state.press_timestamp - key_state.press_start_timestamp;
// let elapsed_timelen = key_state.press_start_timestamp - key_state.release_timestamp;
// if (key_state.press_total_times === 1) {
// elapsed_timelen = 0;
// }
// console.log(`keydown: ${key_state.pressed}, presist_timelen: ${presist_timelen}, elapsed_timelen: ${elapsed_timelen}`);
// });
// document.addEventListener('keyup', function (e) {
// const key_state = js_util.DOM.KeyboardGlobalListener.key_state(e.code);
// const presist_timelen = key_state.release_timestamp - key_state.press_start_timestamp;
// console.log(`keyup: ${key_state.pressed}, presist_timelen: ${presist_timelen}`);
// });
// // Test Mouse
// document.addEventListener('dblclick', function (e) {
// const state = js_util.DOM.MouseGlobalListener.key_state(e.button);
// console.log('dblclick');
// console.log(state);
// });
// window.addEventListener('mousemove', function (e) {
// const oldX = js_util.DOM.MouseGlobalListener.data.clientX;
// const oldY = js_util.DOM.MouseGlobalListener.data.clientY;
// console.log(`old: (${oldX}, ${oldY}), e: (${e.clientX}, ${e.clientY})`);
// }, true);
// // Test Worker
// const worker_url = js_util.DOM.fn_to_worker_url(async function () {
// self.addEventListener('message', function (e) {
// postMessage(e.data);
// });
// self.addEventListener('error', function (e) {
// });
// const script_root_path = 'http://39.100.213.153/small_game_client/';
// importScripts(script_root_path + 'js-util/DOM/websocket_client.js');
// let ws_client = new js_util.DOM.WebSocketClient();
// result = await ws_client.connect("ws://60.204.155.222:51101/");
// if (!result) {
// return;
// }
// postMessage("connect success");
// });
// let worker = new Worker(worker_url, { name: 'net_worker' });
// worker.addEventListener('message', function (e) {
// console.log(e.data);
// });
// worker.addEventListener('error', function (e) {
// console.log(e);
// });
// worker.postMessage("zhiyinnitaimei");
};
main();
</script>
</html>