Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
stamimy committed Jan 13, 2024
1 parent 371d958 commit 950baec
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions web-nfc.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

<script>

const employeeSN = { "11:c9:20:3e": "Bu Elsha", "11:c9:20:3f": "Pak Dito", "11:c9:20:40": "Mas Bonar", "11:c9:20:41": "Mbak Lita" };

scanButton.addEventListener("click", async () => {
console.log("User clicked scan button");
document.querySelector('#logz').textContent = "User clicked scan button";
Expand All @@ -11,19 +13,22 @@
const ndef = new NDEFReader();
await ndef.scan();
console.log("> Scan started");
document.querySelector('#logz').textContent = "> Scan started";
document.querySelector('#logz').textContent = "> Scanning..." + '\n';

ndef.addEventListener("readingerror", () => {
console.log("Argh! Cannot read data from the NFC tag. Try another one?");
document.querySelector('#logz').textContent = "Argh! Cannot read data from the NFC tag. Try another one?";
});

ndef.addEventListener("reading", ({ message, serialNumber }) => {
var employeeName = employeeSN[serialNumber];
document.querySelector('#logz').textContent += `> Welcome: ${employeeName}` + '\n';

console.log(`> Serial Number: ${serialNumber}`);
document.querySelector('#logz').textContent += `> Serial Number: ${serialNumber}`;
document.querySelector('#logz').textContent += `> Serial Number: ${serialNumber}` + '\n';

console.log(`> Records: (${message.records.length})`);
document.querySelector('#logz').textContent += `> Records: (${message.records.length})`;
document.querySelector('#logz').textContent += `> Records: (${message.records.length})` + '\n';
});
} catch (error) {
console.log("Argh! " + error);
Expand Down

0 comments on commit 950baec

Please sign in to comment.