diff --git a/express-server/public/ocrscan/ocrscan.js b/express-server/public/ocrscan/ocrscan.js index cef46cf1..72f58f3e 100644 --- a/express-server/public/ocrscan/ocrscan.js +++ b/express-server/public/ocrscan/ocrscan.js @@ -6,6 +6,41 @@ $(document).ready(function() { $(".btnanalyze").click(function() { analyzeUploaded(); }); + + +//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)}}); +} }); var loading = false; @@ -54,39 +89,6 @@ function updateProgress(percent) { } -//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();