-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileSaver.js
More file actions
66 lines (62 loc) · 1.78 KB
/
FileSaver.js
File metadata and controls
66 lines (62 loc) · 1.78 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
var rfid;
var input="";
var output;
var key="";
function xor(n,m){
var ans=new Array(n.length);
for(var i=0;i<ans.length;i++){
ans[i]=String.fromCharCode(n.charCodeAt(i)^m.charCodeAt(i%m.length));
}
ans=ans.join("");
return ans;
}
function show(){
input=document.getElementById("message").value;
if(input!==""&&key!==""){
output=xor(input,key);
document.getElementById("message").value=output;
document.getElementById("hint").innerHTML = "Success!Your text is converted successfully.";
}
else{
document.getElementById("hint").innerHTML = "Error!Please try again!";
}
}
function buzzer_music(m) {
var musicNotes = {};
musicNotes.notes = [];
musicNotes.tempos = [];
if (m[0].notes.length > 1) {
for (var i = 0; i < m.length; i++) {
if (Array.isArray(m[i].notes)) {
var cn = musicNotes.notes.concat(m[i].notes);
musicNotes.notes = cn;
} else {
musicNotes.notes.push(m[i].notes);
}
if (Array.isArray(m[i].tempos)) {
var ct = musicNotes.tempos.concat(m[i].tempos);
musicNotes.tempos = ct;
} else {
musicNotes.tempos.push(m[i].tempos);
}
}
} else {
musicNotes.notes = [m[0].notes];
musicNotes.tempos = [m[0].tempos];
}
return musicNotes;
}
boardReady({device: 'a4kQK'}, function (board) {
board.systemReset();
board.samplingInterval = 250;
buzzer = getBuzzer(board, 9);
rfid = getRFID(board);
rfid.read();
rfid.on("enter",function(_uid){
if(key===""){
key=_uid;
document.getElementById("hint").innerHTML = "Card detected,please enter your text.";
buzzer.play(buzzer_music([ {notes:"C7",tempos:"8"}]).notes ,buzzer_music([ {notes:"C7",tempos:"8"}]).tempos );
}
});
});