aboutsummaryrefslogtreecommitdiffstats
path: root/tests/html/bluetooth/bluetooth_functions.js
blob: b0f73c79c0aa0804950bedea57b9fbc0d6a23017 (plain) (blame)
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
function clear() {
    document.getElementById("log").textContent = "";
}

function log(line) {
    document.getElementById("log").textContent += timeStamp() + line + '\n';
}

function asciiToDecimal(bytestr) {
    var result = [];
    for(i = 0; i < bytestr.length; i++) {
        result[i] = bytestr.charCodeAt(i) ;
    }
    return result;
}

function populate(testCases){
    for(i = 0; i < testCases.length; ++i) {
        var btn = document.createElement('button');
        btn.setAttribute('onclick','onButtonClick(' + i + ')');
        btn.innerHTML = 'Test '+ (i+1);
        document.getElementById('buttons').appendChild(btn);
    }
}

function timeStamp() {
    var date = new Date;
    var hours = date.getHours();
    var minutes = "0" + date.getMinutes();
    var seconds = "0" + date.getSeconds();
    return hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2) + ' ';
}