using ajax for submission

This commit is contained in:
2018-08-31 19:15:00 -07:00
parent f4de43ba68
commit aa57b26a8b
10 changed files with 180 additions and 47 deletions
-25
View File
@@ -28,31 +28,6 @@ module.exports = class Cards {
return this.all().then(cards =>
cards.find(c => parseInt(c.number, 10) === parseInt(number, 10))
)
// console.log(':', JSON.stringify(number.toString().trim()))
// const scanned = parseInt(
// number
// .toString('hex')
// .trim() // Remove any whiespace or newlines
// .replace('\u0003', '') // Remove "end of text" character
// .replace('\u0002', '') // Remove "start of text" character
// .substring(3) // Strip off con
// .slice(0, -2), // Strip off checksum
// 16
// )
// this.log('Scanned card:', scanned)
// return this.readCardsFromSDCard().then(cards => {
// const card = cards.find(c => parseInt(c.number) === scanned)
// if (card) {
// const name = card.name.split(' ')[0]
// this.log(`Welcome in ${name}!`, scanned)
// this.openDoor()
// } else {
// this.log('Card is invalid:', scanned)
// }
// })
}
static sortByName(cards) {
+1 -1
View File
@@ -7,7 +7,7 @@ module.exports = class Logs {
static all() {
return new Promise((resolve, reject) => {
fs.readFile(LOGS_PATH, (err, data) => {
if (err) return reject(err)
if (err) return resolve(JSON.parse("[]"))
resolve(JSON.parse(data))
})
})