ocr update
This commit is contained in:
		@@ -28,7 +28,7 @@ function movePurchases() {
 | 
				
			|||||||
    firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
 | 
					    firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
 | 
				
			||||||
        $.ajax({
 | 
					        $.ajax({
 | 
				
			||||||
            type: "POST",
 | 
					            type: "POST",
 | 
				
			||||||
            url: "/donepurchases",
 | 
					            url: "/dones",
 | 
				
			||||||
            data:{
 | 
					            data:{
 | 
				
			||||||
                idtoken: idtoken,
 | 
					                idtoken: idtoken,
 | 
				
			||||||
                sl_id: "BplQ5lFU",
 | 
					                sl_id: "BplQ5lFU",
 | 
				
			||||||
@@ -47,11 +47,38 @@ function movePurchases() {
 | 
				
			|||||||
$(".test").click(function() {
 | 
					$(".test").click(function() {
 | 
				
			||||||
    movePurchases();
 | 
					    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;
 | 
					var loading = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function analyze() {
 | 
					/*function analyze() {
 | 
				
			||||||
    var img = document.getElementById("canvas").toDataURL();
 | 
					    var img = document.getElementById("canvas").toDataURL();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Tesseract.recognize(img).progress((progress) => {
 | 
					    Tesseract.recognize(img).progress((progress) => {
 | 
				
			||||||
@@ -67,29 +94,4 @@ function analyze() {
 | 
				
			|||||||
        $(".determinate").css("width", "0%");
 | 
					        $(".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 + "%");
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -428,4 +428,27 @@ router.get("/scan/", async (req, res,) => {
 | 
				
			|||||||
  res.render("ocrscan");
 | 
					  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;
 | 
					module.exports = router;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,6 +36,11 @@
 | 
				
			|||||||
    <div class="progress grey lighten-1">
 | 
					    <div class="progress grey lighten-1">
 | 
				
			||||||
        <div class="determinate green accent-4" style="width: 0%"></div>
 | 
					        <div class="determinate green accent-4" style="width: 0%"></div>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <ul class="collection with-header">
 | 
				
			||||||
 | 
					        <li class="collection-header"><h4>Choose List</h4></li>
 | 
				
			||||||
 | 
					        <li class="collection-item"><div>Test<a class="secondary-content"><i class="material-icons">send</i></a></div></li>
 | 
				
			||||||
 | 
					      </ul>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user