-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdigicode.js
More file actions
52 lines (46 loc) · 978 Bytes
/
digicode.js
File metadata and controls
52 lines (46 loc) · 978 Bytes
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
/**
* digicode.js
*
* functions related to the management of the inputs (question, answer, deletion) for the digicode
*/
/*
* Implements the validation behavior of a digicode click zone
*/
function validatingBuffer(){
const answer = digicodeClickZone[digicodeClickZone.length-1];
const len = answer[1].length;
if(buffer == answer[0]){
return true;
}
for(let i = 0; i < len; i++){
if(buffer == answer[1][i]){
return true ;
}
}
buffer = "";
return false;
}
/**
* Implements the replacing behavior of a digicode click zone
* @param {String} digi
*/
function changingBuffer(digi){
buffer = digi;
}
/**
* Implements the adding behavior of a digicode click zone
* @param {String} digi
*/
function addingBuffer(digi){
buffer = buffer + digi;
}
/*
* Implements the deleting behavior of a digicode click zone
*/
function deletingBuffer(){
if(buffer.length == 0){
return;
}else{
buffer = buffer.substring(0, buffer.length-1);
}
}