-
Notifications
You must be signed in to change notification settings - Fork 0
/
editor_extra_post.js
45 lines (32 loc) · 1.41 KB
/
editor_extra_post.js
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
function call_draw()
{
Module.ccall('draw', null, [], []);
}
function canvas_resize()
{
canvas.width = document.body.offsetWidth;
canvas.height = window.innerHeight;
}
window.addEventListener('paste', function (e)
{
if(e.clipboardData != false) {
//console.log(e.clipboardData.getData('Text'));
let chars = e.clipboardData.getData('Text').split('');
// console.log(chars);
for (var i = 0; i < chars.length; i++) {
Module.ccall('paste_char', // name of C function
'number', // return type
['string'], // argument types
[chars[i]]);
}
call_draw();
}
}, false);
window.addEventListener("keypress", function(/*e*/) { call_draw(); /*e.preventDefault();*/ return false });
window.addEventListener("keydown", function(/*e*/) { call_draw(); /*e.preventDefault();*/ return false });
window.addEventListener("keyup", function(/*e*/) { call_draw(); /*e.preventDefault();*/ return false });
window.addEventListener("click", function(/*e*/) { call_draw(); /*e.preventDefault();*/ return false });
window.addEventListener("mousemove", function(/*e*/) { call_draw(); /*e.preventDefault();*/ return false });
document.addEventListener("scroll", function(/*e*/) { call_draw(); /*e.preventDefault();*/ return false });
document.addEventListener("scrollend", function(/*e*/) { call_draw(); /*e.preventDefault();*/ return false });
window.addEventListener("resize", function(/*e*/) { canvas_resize(); return false });