logindex.js
2.68 KB
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
window.onload = function() {
window.onkeydown = function() {
if (event.code == "Backspace") {
var eles = document.getElementsByClassName("pwd_input");
for (var i = 0; i < eles.length; i++) {
if (eles[i] == document.activeElement) {
if (i == 0) {
break;
}
console.log(eles[i].value)
if (eles[i].value == "") {
eles[i - 1].value = "";
eles[i - 1].name = "";
eles[i - 1].focus();
}
break;
}
}
}
}
var eles = document.getElementsByClassName("pwd_input");
for (var i = 0; i < eles.length; i++) {
var ele = eles[i];
ele.onfocus = function() {
var str = this.id
var vv = str.substr(1, str.length);
var a = parseInt(vv);
if (this.name == "") {
jumHead(a);
} else if (this.name != "") {
jumEnd(a)
}
}
}
}
function jumHead(n) {
for (var j = 1; j < n; j++) {
var v1 = document.getElementById("p" + j);
if (v1.name == "") {
console.log(this)
v1.focus();
break;
}
}
}
function jumEnd(n) {
for (var j = n; j < 7; j++) {
var v1 = document.getElementById("p" + j);
if (j == 6) {
v1.focus();
break;
}
if (v1.value == "") {
v1.focus();
break;
}
}
}
function keypress(val) {
var ev = window.event;
var nowindex = val
var nextindex = val + 1;
if (nextindex == 7) {
var inputele = document.getElementById("p" + nowindex);
inputele.value = ev.key;
inputele.blur();
return;
}
var inputelenow = document.getElementById("p" + nowindex);
inputelenow.name = ev.key;
var inputele = document.getElementById("p" + nextindex);
inputele.focus();
}
function copyText() {
console.log("copyText");
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
console.log(ctx);
// ctx.rect(20,20,150,100);
// ctx.stroke();
var hh = 20;
for (var i = 0; i < 6; i++) {
var xx = 20 * i + hh;
ctx.rect(20 * i + 20, 10, 20, 20);
ctx.stroke();
}
}
function drawrect() {
console.log("drawrect");
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
ctx.fillrect(0, 0, 100, 100);
}
function jump(){
var roomId = 1008614;
var password = "123456";
var description = "123";
var create = { "request": "create", "room": roomId, "pin": password, "description": description};
this.init(1, create)
}