-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigCommands.js
63 lines (54 loc) · 1.35 KB
/
configCommands.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
//ALL DATA SENT OUT FROM THE GUI TOO THE BOARD HERE
// to sanitize strings **********
function checkUserString(userString, lengthCheck, numberCheck = false) {
if (match(userString, "#") != null || match(userString, ",") != null) {
return 'error no # or comma';
}
if (userString.length >= lengthCheck) {
return 'error too long';
}
if (numberCheck) {
if(/^\d+$/.test(userString)){
return 'invalid value entered';
}
}
return null;
}
function checkPw() {
let sanitizer = checkUserString(pwInput.value(), 50);
if (sanitizer != null) {
pwInput.value(sanitizer);
return;
} else {
sendData("#pw," + pwInput.value());
}
}
function checkppKMValue() {
let sanitizer = checkUserString(ppKmInput.value(), 6, true);
if (sanitizer != null) {
if(statusTitle){
statusTitle.style.color = 'red';
statusTitle.textContent = sanitizer;
}
} else {
sendData("#ppKm," + ppKmInput.value());
}
}
function checkKMValue() {
let sanitizer = checkUserString(kmstandInput.value(), 6, true);
if (sanitizer != null) {
if(statusTitle){
statusTitle.style.color = 'red';
statusTitle.textContent = sanitizer;
}
} else {
sendData("#kmstand," + kmstandInput.value());
}
}
function resetCommand() {
sendData("#reset,");
disconnectBle();
}
function sendDebugData() {
sendData("#debug");
}