-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
64 lines (51 loc) · 1.85 KB
/
test.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
window.onload = function() {
var temp_title = ' Pixelsuft WebTK Example!';
if (!window.py_title) {
window.py_title = async function(new_title) {
document.title = new_title;
}
window.py_print = async function(new_title) {
console.log(new_title);
}
window.py_stop = async function(new_title) {
window.close();
}
window.py_screen = async function(new_title) {
// Blah Blah Blah
}
window.py_fetch = async function(new_title) {
// Blah Blah Blah
}
}
function title_change() {
temp_title = temp_title.substr(1) + temp_title[0];
if (temp_title[0] == ' ')
return title_change();
py_title(temp_title).then(function() {
setTimeout(title_change, temp_title[0] == 'P' ? 3000 : 500);
});
}
document.addEventListener('keydown', function(e) {
if (e.keyCode == 27 || e.keyCode == 81) // ESCape or Q
py_stop();
});
document.getElementById('button0').addEventListener('click', function(e) {
py_screen().then(function(e) {
document.getElementById('screen0').src = e[0];
});
});
document.getElementById('button1').addEventListener('click', function(e) {
py_fetch().then(function(e) {
console.log(e, e.followers);
document.getElementById('text0').textContent = `Pixelsuft: ${e.fws} followers, ${e.fwg} following, ${e.rps} repositories`;
});
});
document.addEventListener('contextmenu', function(e) {
e.preventDefault();
});
document.getElementById('screen0').addEventListener('dragstart', function(e) {
e.preventDefault();
});
title_change();
py_print('Hello', 'world');
}