This commit is contained in:
peli 2020-06-24 08:41:40 -07:00
Родитель 29e0739249
Коммит 0da2a2de39
3 изменённых файлов: 27 добавлений и 31 удалений

Просмотреть файл

@ -33,17 +33,8 @@
<script src="/dist/jacdac.umd.js"></script>
<script>
const logDiv = document.getElementById("log");
const devicesDiv = document.getElementById("devices");
function log(msg) {
const line = document.createElement("div");
line.innerText = "" + msg;
logDiv.insertBefore(line, logDiv.firstElementChild);
if (logDiv.childElementCount > 100)
logDiv.lastElementChild.remove();
}
async function sniff() {
log('starting')
let bus;
@ -53,8 +44,7 @@
bus.on('deviceconnect', d => {
devicesDiv.innerText = bus.devices().map(d => d.toString()).join(', ')
});
bus.on('packetreceive', pkt => {
bus.on('packetreceive', pkt => {
const decoded = jacdac.decodePacketData(pkt);
console.debug(jacdac.printPacket(pkt))
if (decoded)
@ -69,6 +59,15 @@
const connect = document.getElementById("connect");
connect.onclick = sniff;
function log(msg) {
const logDiv = document.getElementById("log");
const line = document.createElement("div");
line.innerText = "" + msg;
logDiv.insertBefore(line, logDiv.firstElementChild);
if (logDiv.childElementCount > 100)
logDiv.lastElementChild.remove();
}
</script>
</body>

Просмотреть файл

@ -27,16 +27,6 @@
<script src="/dist/jacdac.umd.js"></script>
<script>
function log(msg) {
const logDiv = document.getElementById("log");
const line = document.createElement("div");
line.innerText = "" + msg;
logDiv.insertBefore(line, logDiv.firstElementChild);
if (logDiv.childElementCount > 100)
logDiv.lastElementChild.remove();
}
async function sniff() {
log('starting')
let bus;
@ -52,6 +42,15 @@
const connect = document.getElementById("connect");
connect.onclick = sniff;
function log(msg) {
const logDiv = document.getElementById("log");
const line = document.createElement("div");
line.innerText = "" + msg;
logDiv.insertBefore(line, logDiv.firstElementChild);
if (logDiv.childElementCount > 100)
logDiv.lastElementChild.remove();
}
</script>
</body>

Просмотреть файл

@ -33,17 +33,7 @@
<script src="/dist/jacdac.umd.js"></script>
<script>
const logDiv = document.getElementById("log");
const devicesDiv = document.getElementById("devices");
function log(msg) {
const line = document.createElement("div");
line.innerText = "" + msg;
logDiv.insertBefore(line, logDiv.firstElementChild);
if (logDiv.childElementCount > 100)
logDiv.lastElementChild.remove();
}
async function sniff() {
log('starting')
let bus;
@ -75,6 +65,14 @@
const connect = document.getElementById("connect");
connect.onclick = sniff;
function log(msg) {
const logDiv = document.getElementById("log");
const line = document.createElement("div");
line.innerText = "" + msg;
logDiv.insertBefore(line, logDiv.firstElementChild);
if (logDiv.childElementCount > 100)
logDiv.lastElementChild.remove();
}
</script>
</body>