Skip to content

Commit

Permalink
Minified login page scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Signior-X committed Jun 19, 2020
1 parent d380056 commit be50e1a
Showing 1 changed file with 2 additions and 192 deletions.
194 changes: 2 additions & 192 deletions functions/views/login.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -45,198 +45,8 @@
<!-- <script>var md=new Remarkable;function viewMobileSite(){window.location.href="/mobile"}document.addEventListener("DOMContentLoaded",function(){window.signInEmail="anonymousNotSigned";window.currentNote="",window.editor={id:"",title:"",description:""},console.log("anonymousNotSigned"),firebase.database().ref("anonymousNotSigned").orderByChild("timestamp").on("value",function(e){var o=[];e.forEach(function(e){var n=e.key,t=e.val();o.push({childKey:n,childData:t})}),o.reverse(),window.notesData={};var n=document.getElementById("note-family");if(n.innerHTML="",noteFamilyString="",o.forEach(function(e){var o=e.childKey,n=e.childData;noteFamilyString+='<div id="'+o+'" class="note-row hoverable" onclick=doOnNoteClick(this) ><div class="note-title">'+n.title+'</div><div class="note-date">'+n.date+"</div></div>",window.notesData[o]={description:n.description,title:n.title}}),n.innerHTML=noteFamilyString,window.currentNote)try{document.getElementById(window.currentNote).classList.add("is--active"),document.getElementById(window.currentNote).classList.remove("hoverable")}catch(e){console.log("Ignore this error, comes at time of delete",e.toString)}}),signInToGoogle=(()=>{console.log("Sign In to Google!");var e=new firebase.auth.GoogleAuthProvider;firebase.auth().signInWithPopup(e).then(function(e){console.log("success, check now!"),console.log(e.user);var o=new XMLHttpRequest;o.addEventListener("error",function(e){console.log("Failed"),console.log(e.toString())}),o.addEventListener("load",function(e){1==JSON.parse(e.srcElement.response).success?console.log("Sign In Success!"):console.log("Failed to sign In"),location.reload()}),o.open("POST","/set",!0),o.setRequestHeader("Content-Type","application/json"),o.send(JSON.stringify({userEmail:e.user.email,userDisplayName:e.user.displayName}))}).catch(function(e){console.log(e),console.log("Failed to do")})}),$("#sign-in-anonymous").click(function(){var e=new XMLHttpRequest;e.addEventListener("error",function(e){console.log("Failed"),console.log(e.toString())}),e.addEventListener("load",function(e){1==JSON.parse(e.srcElement.response).success?console.log("Sign In Success!"):console.log("Failed to sign In"),location.reload()}),e.open("POST","/set",!0),e.setRequestHeader("Content-Type","application/json"),e.send(JSON.stringify({userEmail:"anonymousUserPriyam",userDisplayName:"Priyam"}))})});</script>
<script></script> -->

<script>
var md = new Remarkable({
html: true,
xhtmlOut: true
});
document.addEventListener('DOMContentLoaded', function () {
// Taken from desktop part
window.signInEmail = 'anonymousNotSigned';
const signInUserEmail = 'anonymousNotSigned';
window.currentNote = '';
window.editor = { id: '', title: '', description: '' };
console.log(signInUserEmail);
// Now call the data extract for only once so as to get the list of datas
firebase.database().ref(signInUserEmail).orderByChild('timestamp').on('value', function (snapshot) {
//console.log(snapshot);
var descNoteList = [];
snapshot.forEach(function (childSnapshot) {
var childKey = childSnapshot.key;
var childData = childSnapshot.val();
//console.log("childkey", childKey);
//console.log("childData", childData);
// ...
descNoteList.push({ childKey: childKey, childData: childData });
});
// Reverse the array
descNoteList.reverse();
// Empty the notes data
window.notesData = {};
var noteFamily = document.getElementById('note-family');
noteFamily.innerHTML = '';
noteFamilyString = '';
descNoteList.forEach(function (childSnapshot) {
var childKey = childSnapshot.childKey;
var childData = childSnapshot.childData;
noteFamilyString += '<div id="' + childKey + '" class="note-row hoverable" onclick=doOnNoteClick(this) >'
+ '<div class="note-title">' + childData.title + '</div>'
+ '<div class="note-date">' + childData.date + '</div>'
+ '</div>';
// Only storing notes description in it
window.notesData[childKey] = { description: childData.description, title: childData.title };
});
noteFamily.innerHTML = noteFamilyString;
// make the current note active if present
if (window.currentNote) {
try {
document.getElementById(window.currentNote).classList.add('is--active');
document.getElementById(window.currentNote).classList.remove('hoverable');
} catch (e) {
console.log("Ignore this error, comes at time of delete", e.toString)
}
}
addNotefunction = (title, description) => {
//Start the add note function
console.log("Add Note");
var options = { month: 'short', day: 'numeric' };
var today = new Date();
// console.log(today.toLocaleDateString("en-US", options));
var newNote = {
title: title,
description: description,
date: today.toLocaleDateString("en-US", options),
timestamp: firebase.database.ServerValue.TIMESTAMP
}
// Get a key for a new Post.
var newPostKey = firebase.database().ref(signInUserEmail).push().key;
console.log(newPostKey);
// Now this is going to be the current value which we are editing
window.currentNote = newPostKey;
// Write the new post's data simultaneously in the posts list and the user's post list.
var updates = {};
updates[newPostKey] = newNote;
return firebase.database().ref(signInUserEmail).update(updates);
}
updateNotefunction = (noteId, title, description) => {
//Start the update note function
console.log("Update Note");
var options = { month: 'short', day: 'numeric' };
var today = new Date();
// console.log(today.toLocaleDateString("en-US", options));
var newNote = {
title: title,
description: description,
date: today.toLocaleDateString("en-US", options),
timestamp: firebase.database.ServerValue.TIMESTAMP
}
// Write the new post's data simultaneously in the posts list and the user's post list.
var updates = {};
updates[noteId] = newNote;
return firebase.database().ref(signInUserEmail).update(updates);
}
deleteNotefunction = (noteId) => {
return firebase.database().ref(signInUserEmail).child(noteId).remove();
}
});
//list(family);
// Here the firebase is correctly defined purely!
//console.log(firebase.database.ServerValue.TIMESTAMP);
// Removed the ones not needed here
signInToGoogle = () => {
// Start the sign in Activity!
console.log("Sign In to Google!");
// Google sign in
var provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(provider).then(function (result) {
// console.log(result.user.email);
console.log("success, check now!");
// console.log(result.user.displayName);
// console.log(result);
// console.log(result.user);
// console.log(result.user_id_token);
console.log(result.user);
// Add the cookie so that this can be also cleared whether to check wheather user is sign in or not
var xhttp = new XMLHttpRequest();
xhttp.addEventListener("error", function (evt) {
console.log("Failed");
console.log(evt.toString());
});
xhttp.addEventListener("load", function (evt) {
// console.log(evt);
// console.log(evt.srcElement);
// console.log(evt.srcElement.response);
if (JSON.parse(evt.srcElement.response)['success'] == 1) {
console.log("Sign In Success!");
} else {
console.log("Failed to sign In");
}
location.reload();
});
// Defining parameters
xhttp.open("POST", "/set", true);
//Send the proper header information along with the request
xhttp.setRequestHeader("Content-Type", "application/json"); // Necessary for POST
xhttp.send(JSON.stringify({ userEmail: result.user.email, userDisplayName: result.user.displayName }));
}).catch(function (err) {
console.log(err);
console.log("Failed to do");
});
}
});
function viewMobileSite() {
window.location.href = "/mobile";
}
// Add this sccript before the body to make this work
</script>
<!-- Script just after body -->
<script>var md=new Remarkable({html:!0,xhtmlOut:!0});function viewMobileSite(){window.location.href="/mobile"}document.addEventListener("DOMContentLoaded",function(){window.signInEmail="anonymousNotSigned";window.currentNote="",window.editor={id:"",title:"",description:""},console.log("anonymousNotSigned"),firebase.database().ref("anonymousNotSigned").orderByChild("timestamp").on("value",function(e){var o=[];e.forEach(function(e){var t=e.key,n=e.val();o.push({childKey:t,childData:n})}),o.reverse(),window.notesData={};var t=document.getElementById("note-family");if(t.innerHTML="",noteFamilyString="",o.forEach(function(e){var o=e.childKey,t=e.childData;noteFamilyString+='<div id="'+o+'" class="note-row hoverable" onclick=doOnNoteClick(this) ><div class="note-title">'+t.title+'</div><div class="note-date">'+t.date+"</div></div>",window.notesData[o]={description:t.description,title:t.title}}),t.innerHTML=noteFamilyString,window.currentNote)try{document.getElementById(window.currentNote).classList.add("is--active"),document.getElementById(window.currentNote).classList.remove("hoverable")}catch(e){console.log("Ignore this error, comes at time of delete",e.toString)}addNotefunction=((e,o)=>{console.log("Add Note");var t={title:e,description:o,date:(new Date).toLocaleDateString("en-US",{month:"short",day:"numeric"}),timestamp:firebase.database.ServerValue.TIMESTAMP},n=firebase.database().ref("anonymousNotSigned").push().key;console.log(n),window.currentNote=n;var i={};return i[n]=t,firebase.database().ref("anonymousNotSigned").update(i)}),updateNotefunction=((e,o,t)=>{console.log("Update Note");var n={title:o,description:t,date:(new Date).toLocaleDateString("en-US",{month:"short",day:"numeric"}),timestamp:firebase.database.ServerValue.TIMESTAMP},i={};return i[e]=n,firebase.database().ref("anonymousNotSigned").update(i)}),deleteNotefunction=(e=>firebase.database().ref("anonymousNotSigned").child(e).remove())}),signInToGoogle=(()=>{console.log("Sign In to Google!");var e=new firebase.auth.GoogleAuthProvider;firebase.auth().signInWithPopup(e).then(function(e){console.log("success, check now!"),console.log(e.user);var o=new XMLHttpRequest;o.addEventListener("error",function(e){console.log("Failed"),console.log(e.toString())}),o.addEventListener("load",function(e){1==JSON.parse(e.srcElement.response).success?console.log("Sign In Success!"):console.log("Failed to sign In"),location.reload()}),o.open("POST","/set",!0),o.setRequestHeader("Content-Type","application/json"),o.send(JSON.stringify({userEmail:e.user.email,userDisplayName:e.user.displayName}))}).catch(function(e){console.log(e),console.log("Failed to do")})})});</script>

<div id="main">
<div id="top-nav">
Expand Down

0 comments on commit be50e1a

Please sign in to comment.