diff --git a/express-server/public/ocrscan/ocrscan.js b/express-server/public/ocrscan/ocrscan.js index 087fc116..8044f860 100644 --- a/express-server/public/ocrscan/ocrscan.js +++ b/express-server/public/ocrscan/ocrscan.js @@ -28,7 +28,7 @@ function movePurchases() { firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) { $.ajax({ type: "POST", - url: "/donepurchases", + url: "/dones", data:{ idtoken: idtoken, sl_id: "BplQ5lFU", @@ -47,11 +47,38 @@ function movePurchases() { $(".test").click(function() { movePurchases(); }); + +function analyzeUploaded() { + var img = document.getElementById("blah"); + + Tesseract.recognize(img).progress((progress) => { + + if (progress.status == "recognizing text") { + loading = true; + } + }).then((result) => { + loading = false; + $(".output").text(result.text); + $('#modal1').modal("open"); + movePurchases(); + $(".determinate").css("width", "0%"); + }); +} + +setInterval(updateProgress(), 500); + +function updateProgress(percent) { + if(loading == true) { + $(".determinate").css("width", progress.progress * 100 + "%"); + } + +} + }); var loading = false; -function analyze() { +/*function analyze() { var img = document.getElementById("canvas").toDataURL(); Tesseract.recognize(img).progress((progress) => { @@ -67,29 +94,4 @@ function analyze() { $(".determinate").css("width", "0%"); }); } - -function analyzeUploaded() { - var img = document.getElementById("blah"); - - Tesseract.recognize(img).progress((progress) => { - - if (progress.status == "recognizing text") { - loading = true; - } - }).then((result) => { - loading = false; - $(".output").text(result.text); - $('#modal1').modal("open"); - - $(".determinate").css("width", "0%"); - }); -} - -setInterval(updateProgress(), 500); - -function updateProgress(percent) { - if(loading == true) { - $(".determinate").css("width", progress.progress * 100 + "%"); - } - -} \ No newline at end of file +*/ diff --git a/express-server/routes/index.js b/express-server/routes/index.js index 0fe3e90b..54d06be2 100644 --- a/express-server/routes/index.js +++ b/express-server/routes/index.js @@ -428,4 +428,27 @@ router.get("/scan/", async (req, res,) => { res.render("ocrscan"); }); + +router.post("/dones", async function(req, res, next) { + console.log("/shoppinglist idtoken: ", req.body.idtoken) + var token = req.body.idtoken; + + var uid; + firebaseAdmin.auth().verifyIdToken(token) + .then(async function(decodedToken) { + uid = decodedToken.uid; + console.log("UID: ", uid); + console.log("So andere sachen: ", req.body.name, req.body.description); + try { + + res.status(200).send("Done"); + } + + catch(err) { + res.status(400).send(await err); + } + }).catch(function(error) { + console.log(error) + }); + }); module.exports = router; diff --git a/express-server/views/ocrscan.ejs b/express-server/views/ocrscan.ejs index 69a1083a..c7001087 100644 --- a/express-server/views/ocrscan.ejs +++ b/express-server/views/ocrscan.ejs @@ -36,6 +36,11 @@
+ +