forked from domdfcoding/circuitpython-mfrc522
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtag_read_HID_exemple.html
More file actions
103 lines (101 loc) · 2.89 KB
/
tag_read_HID_exemple.html
File metadata and controls
103 lines (101 loc) · 2.89 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
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
<style media="screen">
@font-face {
font-family: SourceSansVariable;
font-weight: 100 800;
src: url(_fonts/SourceSans3VF-Roman.ttf.woff2) format("woff2");
}
* { margin:0; padding: 0; }
html { font-size: 100%; /* 1rem = 1em = 16px */}
body {
line-height: 120%;
/* deco */
background-color: #f0f0f0;
color: #333;
font-family: SourceSansVariable;
font-weight: 100;
box-sizing: border-box;
padding: 0 1rem;
transition: all 600ms ease-in-out;
overflow: hidden;
}
section {
height: calc(100vh - 2rem);
margin: 1rem 0;
display: flex;
justify-content: center;
align-items: center;
font-size: 10rem;
font-weight: 800;
}
#s_0 {
background-color: red;
}
#s_1 {
background-color: yellow;
}
#s_2 {
background-color: pink;
}
#s_3 {
background-color: fuchsia;
}
</style>
</head>
<body>
<section id="s_0">1</section>
<section id="s_1">2</section>
<section id="s_2">3</section>
<section id="s_3">4</section>
<script>
const liste = ["88:4:60:7d","88:4:5d:1a","88:4:fd:a","88:4:c6:93"];
let table = [];
let tag = [];
let oldTag = [];
//let index = 0;
window.addEventListener("keydown", (event) => {
if (event.key !== undefined) {
//console.log("reçu: ",event.code);
switch (event.code) {
case "Enter": // fin du tag
if (oldTag.toString() !== tag.toString()) {
console.log("tag :",tag.join(":"));
oldTag = tag.join(":");
action(); // déplace le body pour montrer la section correspondante
} else {
console.log("même tag");
}
// vide tag;
tag = [];
break;
case "KeyM": // fin du chiffre
tag.push(parseInt(table.join("")).toString(16));
// vide table
table = [];
//index++;
break;
default:
// remove "Digit" in the string and push in the array
//console.log("code:",event.code,"key:", event.key)
table.push(event.code.replace(/Digit/gm, ""));
}
}
});
function action() {
// teste le tag encours dans la liste
liste.forEach((item, i) => {
if (item == oldTag) {
console.log(i);
// déplace le body (margin-top)
document.body.style.marginTop = `calc(-${i*100}vh + ${i}rem)`;
}
});
}
</script>
</body>
</html>