done purchases remove, ocr scan, read image
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
$(document).ready(function() {
|
||||
|
||||
//initialize all modals
|
||||
$('.modal').modal();
|
||||
$('.materialboxed').materialbox();
|
||||
|
||||
$(".btnanalyze").click(function() {
|
||||
analyze();
|
||||
analyzeUploaded();
|
||||
});
|
||||
});
|
||||
|
||||
@ -27,6 +27,23 @@ function analyze() {
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -34,4 +51,43 @@ function updateProgress(percent) {
|
||||
$(".determinate").css("width", progress.progress * 100 + "%");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//AJAX
|
||||
|
||||
// Initialize Firebase
|
||||
var config = {
|
||||
apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
|
||||
authDomain: "test-667ca.firebaseapp.com",
|
||||
databaseURL: "https://test-667ca.firebaseio.com",
|
||||
projectId: "test-667ca",
|
||||
storageBucket: "test-667ca.appspot.com",
|
||||
messagingSenderId: "221332577314"
|
||||
};
|
||||
|
||||
firebase.initializeApp(config);
|
||||
|
||||
function movePurchases() {
|
||||
firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/donepurchases",
|
||||
data:{
|
||||
idtoken: idtoken,
|
||||
sl_id: "BplQ5lFU",
|
||||
billcontent: "fsfs"
|
||||
},
|
||||
success(result){
|
||||
console.log(result);
|
||||
},
|
||||
error(err){
|
||||
console.error("Error: " + err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
||||
}
|
||||
|
||||
$(".test").click(function() {
|
||||
movePurchases();
|
||||
})
|
Reference in New Issue
Block a user