Email Login
This commit is contained in:
@ -1,212 +1,247 @@
|
||||
var id;
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
|
||||
M.AutoInit();
|
||||
//initialize all modals
|
||||
$('.modal').modal({
|
||||
dismissible: false
|
||||
});
|
||||
|
||||
|
||||
$('.materialboxed').materialbox();
|
||||
$('.fixed-action-btn').floatingActionButton();
|
||||
//initialize all modals
|
||||
$('.modal').modal({
|
||||
dismissible: false
|
||||
});
|
||||
|
||||
|
||||
if ($(window).width() > 600) {
|
||||
//large
|
||||
$(".col").css("height", "100%");
|
||||
}
|
||||
else {
|
||||
//small
|
||||
$(".col").css("height", "50%");
|
||||
}
|
||||
|
||||
$("#modal1").modal("open");
|
||||
$('.materialboxed').materialbox();
|
||||
$('.fixed-action-btn').floatingActionButton();
|
||||
|
||||
|
||||
$(".btn-analyze").click(function() {
|
||||
if ($(window).width() > 600) {
|
||||
//large
|
||||
$(".col").css("height", "100%");
|
||||
} else {
|
||||
//small
|
||||
$(".col").css("height", "50%");
|
||||
}
|
||||
|
||||
$("#modal1").modal("open");
|
||||
|
||||
|
||||
$(".btn-analyze").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"
|
||||
};
|
||||
//AJAX
|
||||
|
||||
firebase.initializeApp(config);
|
||||
// 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"
|
||||
};
|
||||
|
||||
getAllShoppinglists();
|
||||
firebase.initializeApp(config);
|
||||
|
||||
updateUser();
|
||||
testSearch();
|
||||
|
||||
|
||||
|
||||
function movePurchases(text) {
|
||||
firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/dones",
|
||||
data:{
|
||||
idtoken: idtoken,
|
||||
sl_id: id,
|
||||
billcontent: text
|
||||
},
|
||||
success(result){
|
||||
console.log(result);
|
||||
window.location.href = "/dash/" + idtoken
|
||||
},
|
||||
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();
|
||||
getAllShoppinglists();
|
||||
});
|
||||
|
||||
$(document).on("click", ".btndash", function() {
|
||||
firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
||||
window.location.href = "/dash/" + idtoken
|
||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
||||
});
|
||||
updateUser();
|
||||
testSearch();
|
||||
|
||||
function analyzeUploaded() {
|
||||
|
||||
$("#modalEND").modal("open");
|
||||
|
||||
var img = document.getElementById("blah");
|
||||
|
||||
Tesseract.recognize(img).progress((progress) => {
|
||||
|
||||
if (progress.status == "recognizing text") {
|
||||
loading = true;
|
||||
}
|
||||
}).then((result) => {
|
||||
loading = false;
|
||||
console.log(result.text);
|
||||
movePurchases(result.text);
|
||||
$(".determinate").css("width", "0%");
|
||||
});
|
||||
}
|
||||
|
||||
setInterval(updateProgress(), 500);
|
||||
|
||||
function updateProgress(percent) {
|
||||
if(loading == true) {
|
||||
$(".determinate").css("width", progress.progress * 100 + "%");
|
||||
function movePurchases(text) {
|
||||
firebase.auth().onAuthStateChanged(function (user) {
|
||||
if (user) {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/dones",
|
||||
data: {
|
||||
idtoken: idtoken,
|
||||
sl_id: id,
|
||||
billcontent: text
|
||||
},
|
||||
success(result) {
|
||||
console.log(result);
|
||||
window.location.href = "/dash/" + idtoken
|
||||
},
|
||||
error(err) {
|
||||
console.error("Error: " + err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));
|
||||
} else {
|
||||
console.log("Check Auth error", user)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function updateUser() {
|
||||
firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/user",
|
||||
data:{
|
||||
idtoken: idtoken,
|
||||
message_id: "msgtest"
|
||||
},
|
||||
success(){
|
||||
console.log("USer updated");
|
||||
},
|
||||
error(err){
|
||||
console.error("Error: " + err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
||||
}
|
||||
|
||||
function testSearch() {
|
||||
console.log("dpne");
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
url: "/member",
|
||||
data: {
|
||||
sl_id: "PDADo1iJ",
|
||||
uid: "VZT25Xd3rLXEmGGUcrtocbJ9QBu2"
|
||||
},
|
||||
success(data) {
|
||||
console.log(data);
|
||||
},
|
||||
error(err) {
|
||||
console.error(err);
|
||||
}
|
||||
$(".test").click(function () {
|
||||
//movePurchases();
|
||||
getAllShoppinglists();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function getAllShoppinglists() {
|
||||
firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/myshoppinglists",
|
||||
data:{
|
||||
idtoken: idtoken,
|
||||
},
|
||||
success(data){
|
||||
|
||||
$(".preloader-wrapper").css("display", "none");
|
||||
for(let item of data) {
|
||||
$(".output").append("<a id='" + item.sl_id +"' class='collection-item'>" + item.name + "</a>")
|
||||
}
|
||||
|
||||
},
|
||||
error(err){
|
||||
console.error("Error: " + err);
|
||||
$(document).on("click", ".btndash", function () {
|
||||
firebase.auth().onAuthStateChanged(function (user) {
|
||||
if (user) {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||
window.location.href = "/dash/" + idtoken
|
||||
}).catch((error) => console.error("Get id token client error: ", error));
|
||||
} else {
|
||||
console.log("Check Auth error", user)
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("click", ".collection-item", function() {
|
||||
id = $(this).closest("a").attr("id");
|
||||
function analyzeUploaded() {
|
||||
|
||||
$(".active").removeClass("active");
|
||||
$("#modalEND").modal("open");
|
||||
|
||||
$(this).addClass("active");
|
||||
});
|
||||
var img = document.getElementById("blah");
|
||||
|
||||
$(".btncont").click(function() {
|
||||
run([{y:100}, {y:0}], $(".r1"));
|
||||
});
|
||||
Tesseract.recognize(img).progress((progress) => {
|
||||
|
||||
function run(v, elem){
|
||||
//Reverse the array
|
||||
var reversed = JSON.parse(JSON.stringify(v)).reverse();
|
||||
|
||||
$(v[0]).animate(v[1], {
|
||||
//The speed the element moves - lower is faster
|
||||
duration: 500,
|
||||
step: function(val) {
|
||||
//Adding the transform to your element
|
||||
elem.css("transform", `translateY(${val}%)`);
|
||||
if (progress.status == "recognizing text") {
|
||||
loading = true;
|
||||
}
|
||||
}).then((result) => {
|
||||
loading = false;
|
||||
console.log(result.text);
|
||||
movePurchases(result.text);
|
||||
$(".determinate").css("width", "0%");
|
||||
});
|
||||
}
|
||||
|
||||
setInterval(updateProgress(), 500);
|
||||
|
||||
function updateProgress(percent) {
|
||||
if (loading == true) {
|
||||
$(".determinate").css("width", progress.progress * 100 + "%");
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
$(".opt1").click(function() {
|
||||
run([{y:0}, {y:-100}], $(".r1"))
|
||||
}
|
||||
|
||||
run([{y:0}, {y:-100}], $(".r2"));
|
||||
//$("#modal2").modal("open");
|
||||
});
|
||||
function updateUser() {
|
||||
firebase.auth().onAuthStateChanged(function (user) {
|
||||
if (user) {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/user",
|
||||
data: {
|
||||
idtoken: idtoken,
|
||||
message_id: "msgtest"
|
||||
},
|
||||
success() {
|
||||
console.log("USer updated");
|
||||
},
|
||||
error(err) {
|
||||
console.error("Error: " + err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));
|
||||
} else {
|
||||
console.log("Check Auth error", user)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(".opt2").click(function() {
|
||||
// $('.row').animate({'margin-top': '-100%'}, 1000);
|
||||
});
|
||||
function testSearch() {
|
||||
console.log("dpne");
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
url: "/member",
|
||||
data: {
|
||||
sl_id: "PDADo1iJ",
|
||||
uid: "VZT25Xd3rLXEmGGUcrtocbJ9QBu2"
|
||||
},
|
||||
success(data) {
|
||||
console.log(data);
|
||||
},
|
||||
error(err) {
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function getAllShoppinglists() {
|
||||
firebase.auth().onAuthStateChanged(function (user) {
|
||||
if (user) {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/myshoppinglists",
|
||||
data: {
|
||||
idtoken: idtoken,
|
||||
},
|
||||
success(data) {
|
||||
|
||||
$(".preloader-wrapper").css("display", "none");
|
||||
for (let item of data) {
|
||||
$(".output").append("<a id='" + item.sl_id + "' class='collection-item'>" + item.name + "</a>")
|
||||
}
|
||||
|
||||
},
|
||||
error(err) {
|
||||
console.error("Error: " + err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));
|
||||
} else {
|
||||
console.log("Check Auth error", user)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).on("click", ".collection-item", function () {
|
||||
id = $(this).closest("a").attr("id");
|
||||
|
||||
$(".active").removeClass("active");
|
||||
|
||||
$(this).addClass("active");
|
||||
});
|
||||
|
||||
$(".btncont").click(function () {
|
||||
run([{
|
||||
y: 100
|
||||
}, {
|
||||
y: 0
|
||||
}], $(".r1"));
|
||||
});
|
||||
|
||||
function run(v, elem) {
|
||||
//Reverse the array
|
||||
var reversed = JSON.parse(JSON.stringify(v)).reverse();
|
||||
|
||||
$(v[0]).animate(v[1], {
|
||||
//The speed the element moves - lower is faster
|
||||
duration: 500,
|
||||
step: function (val) {
|
||||
//Adding the transform to your element
|
||||
elem.css("transform", `translateY(${val}%)`);
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
$(".opt1").click(function () {
|
||||
run([{
|
||||
y: 0
|
||||
}, {
|
||||
y: -100
|
||||
}], $(".r1"))
|
||||
|
||||
run([{
|
||||
y: 0
|
||||
}, {
|
||||
y: -100
|
||||
}], $(".r2"));
|
||||
//$("#modal2").modal("open");
|
||||
});
|
||||
|
||||
$(".opt2").click(function () {
|
||||
// $('.row').animate({'margin-top': '-100%'}, 1000);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@ -228,5 +263,4 @@ var loading = false;
|
||||
$(".determinate").css("width", "0%");
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
*/
|
Reference in New Issue
Block a user