diff --git a/app.js b/app.js index a0257d733ec9ee11cba67f30586837adcbd8f2ad..107df178e767010696e211a3f31a1f0fef223375 100644 --- a/app.js +++ b/app.js @@ -163,15 +163,7 @@ function renderData() { const key = keys[i]; const val = datas[key]; - let buttons = []; - for (let i = 0; i < Object.keys(qr).length; i++) { - const k = Object.keys(qr)[i]; - if (qr[k]) { - buttons.push(k); - } - } - - html += `<tr><td>${key}</td><td>${val}</td><td>${buttons}</td></tr>`; + html += `<tr><td>${key}</td><td>${val.count}</td><td>${val.buttons}</td></tr>`; } html += "</table>"; @@ -287,8 +279,19 @@ function tick() { "#FF3B58", ); - datas[code.data] ||= 0; - datas[code.data] += 1; + if (!datas[code.data]) { + let buttons = []; + for (let i = 0; i < Object.keys(qr).length; i++) { + const k = Object.keys(qr)[i]; + if (qr[k]) { + buttons.push(k); + } + } + + datas[code.data] = { count: 1, buttons }; + } else { + datas[code.data].count += 1; + } renderData(); }