Skip to content

Commit

Permalink
v 1.5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
avicohen89 committed Jun 3, 2017
1 parent e0fe4e3 commit c930733
Show file tree
Hide file tree
Showing 11 changed files with 662 additions and 105 deletions.
1 change: 1 addition & 0 deletions src/admin_page/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<!--Loaded a personal script to combine API's as well as page design and logic initate-->
<script src="config.js"></script>
<script src="script.js"></script>
<link rel='stylesheet' href='style.css' />
<!--END of Loaded a personal script to combine API's as well as page design and logic initate-->

</head>
Expand Down
124 changes: 56 additions & 68 deletions src/admin_page/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,17 @@ let db_rendering = function()
admin_req = admin_req.ref("admin");
admin_req.once('value').then(function(snapshot)
{
if(snapshot.val().localeCompare(firebase.auth().currentUser.email)==0)
if(firebase.auth().currentUser.email == snapshot.val() + "@gmail.com" )
{
is_admin=1;
let move_mail = function()
{
let new_email = document.getElementById("email").value;
let admin_req = firebase.database();
admin_req = admin_req.ref("admin");
admin_req.set(new_email);
};

let form_obj = document.createElement("FORM");
form_obj.id = "form";
form_obj.autocomplete = "false";
form_obj.acceptCharset = "UTF-8";
form_obj.onsubmit = move_mail;

let email = document.createElement("INPUT");
email.setAttribute("type", "email");
email.name = "email";
email.required = "true";
email.autocomplete = "false";
email.form = form_obj;
email.id = "email";

let btn = document.createElement("button");
btn.form = form_obj;
btn.formNoValidate = false; // validate data
btn.type = "submit";
btn.name = "submit";
btn.innerHTML = "Make that e-mail admin!";

form_obj.appendChild(document.createTextNode("Move admin to another e-mail: "));
form_obj.appendChild(email);
form_obj.appendChild(btn);
document.body.appendChild(document.createElement("br"));
document.body.appendChild(form_obj);

let change_colors_btn = document.createElement("button");
change_colors_btn.type = "button";
change_colors_btn.innerHTML = "Manage users";
change_colors_btn.addEventListener("click",function()
{
window.location = "../user_creator/user_creator.html";
window.location = "../manage_users/manage_users.html";
});
document.getElementById("row0").appendChild(change_colors_btn);
}
Expand All @@ -72,7 +39,7 @@ let db_rendering = function()
snapshot.forEach(function(childSnapshot)
{
let email = childSnapshot.val().substring(1,childSnapshot.val().length);
if(is_admin==1 || email.localeCompare(firebase.auth().currentUser.email) == 0)
if(is_admin==1 || firebase.auth().currentUser.email == email + "@gmail.com" )
{
let status = "";
if(childSnapshot.val().charAt(0) == '0')
Expand Down Expand Up @@ -151,43 +118,64 @@ let Add_new = function()
admin_req = admin_req.ref("admin");
admin_req.once('value').then(function(snapshot)
{
if(snapshot.val().localeCompare(firebase.auth().currentUser.email)==0)
if(firebase.auth().currentUser.email == snapshot.val() + "@gmail.com" )
{
is_admin = 1;
}
//if(page.charAt(page.length-1) == '/') // HTML LINK breaker, decrepted
// page = page.substr(0,page.length-1);
let page_unicoded = page.replace(/[^\x20-\x7E]+/g, '');
if(page.localeCompare(page_unicoded) != 0) // meaning page had some special unicoded characters!
page = page.replace(/\D/g,''); // strips all non-numbers from page-id, leading to verifiable string
let storesRef = rootRef.child('Facebook/' + page);
storesRef.set("0" + firebase.auth().currentUser.email);
let row = document.getElementById("table").insertRow(document.getElementById("table").childElementCount);
row.id = document.getElementById("table").childElementCount;
let cell1 = row.insertCell(0);
let cell2 = row.insertCell(1);
let cell3 = row.insertCell(2);
cell1.innerHTML = "<a href='https://www.facebook.com/" +page+ "'>" + page + "</a>";
let status = "Pending";
if(is_admin == 1)
let autoapprove = 0;
firebase.database().ref("Auto_approve").once('value', function(snapshot)
{
let aprvbtn = document.createElement('input');
aprvbtn.type = "button";
aprvbtn.style.backgroundColor = "orange";
aprvbtn.setAttribute("onClick","approve("+ '"' + page+ '"'+"," + document.getElementById("table").childElementCount +");");
aprvbtn.value = status;
cell2.appendChild(aprvbtn);
}
else
snapshot.forEach(function(ChildSnapshot)
{

if(ChildSnapshot.key+"@gmail.com" == firebase.auth().currentUser.email)
autoapprove = ChildSnapshot.val();
});
}).then(function()
{
cell2.innerHTML = status.fontcolor("red");
}
cell3.innerHTML = firebase.auth().currentUser.email;
let cell4 = document.createElement('input');
cell4.type = "button";
cell4.setAttribute("onClick","del("+ '"' + page+ '"'+","+ document.getElementById("table").childElementCount +");");
cell4.value = "Delete";
row.insertCell(3).appendChild(cell4);
//if(page.charAt(page.length-1) == '/') // HTML LINK breaker, decrepted
// page = page.substr(0,page.length-1);
let page_unicoded = page.replace(/[^\x20-\x7E]+/g, '');
if(page.localeCompare(page_unicoded) != 0) // meaning page had some special unicoded characters!
page = page.replace(/\D/g,''); // strips all non-numbers from page-id, leading to verifiable string
let storesRef = rootRef.child('Facebook/' + page);
storesRef.set(autoapprove + firebase.auth().currentUser.email.substring(0,firebase.auth().currentUser.email.indexOf("@")));
let row = document.getElementById("table").insertRow(document.getElementById("table").childElementCount);
row.id = document.getElementById("table").childElementCount;
let cell1 = row.insertCell(0);
let cell2 = row.insertCell(1);
let cell3 = row.insertCell(2);
cell1.innerHTML = "<a href='https://www.facebook.com/" +page+ "'>" + page + "</a>";
let status = "Pending";
if(autoapprove == 1)
{
let approved_status = "approved";
cell2.innerHTML = approved_status.fontcolor("green");
}
else
{
if(is_admin == 1)
{
let aprvbtn = document.createElement('input');
aprvbtn.type = "button";
aprvbtn.style.backgroundColor = "orange";
aprvbtn.setAttribute("onClick","approve("+ '"' + page+ '"'+"," + document.getElementById("table").childElementCount +");");
aprvbtn.value = status;
cell2.appendChild(aprvbtn);
}
else
{
cell2.innerHTML = status.fontcolor("red");
}
}
cell3.innerHTML = firebase.auth().currentUser.email.substring(0,firebase.auth().currentUser.email.indexOf("@"));
let cell4 = document.createElement('input');
cell4.type = "button";
cell4.setAttribute("onClick","del("+ '"' + page+ '"'+","+ document.getElementById("table").childElementCount +");");
cell4.value = "Delete";
row.insertCell(3).appendChild(cell4);
});

});
}

Expand Down
10 changes: 10 additions & 0 deletions src/admin_page/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
table, th, td {
border: 1px solid black;
}
table {
width: 100%;
}

th {
height: 50px;
}
39 changes: 26 additions & 13 deletions src/create_user/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ $( document ).ready(function()
let send_data = function()
{
let email = document.getElementById("email").value;
email+="@gmail.com";
let pw = document.getElementById("password").value;
let pw2 = document.getElementById("password2").value;
let colors = document.getElementById("colors").style.backgroundColor.split(',');
let nickname = document.getElementById("name").value;
let r = parseInt(colors[0].substring(4)).toString(16) + "";
let g = parseInt(colors[1]).toString(16)+ "";
let b = parseInt(colors[2]).toString(16)+ "";
Expand All @@ -36,25 +36,25 @@ let send_data = function()
admin_req.once('value').then(function(snapshot)
{

if(snapshot.val().localeCompare(firebase.auth().currentUser.email)==0)
if(firebase.auth().currentUser.email == snapshot.val() + "@gmail.com" )
{
let backup = firebase.auth().currentUser;
firebase.auth().createUserWithEmailAndPassword(email, pw).catch(function(error)
firebase.auth().createUserWithEmailAndPassword(email+"@gmail.com", pw).catch(function(error)
{
//alert("Failed due to an error");
// storesRef.remove();
//return false;
alert(error);
}).then(function()
{
let storesRef = firebase.database().ref().child('Users/' + email.replace('.', ""));
storesRef.set(email+"@"+color_string);
firebase.database().ref().child("Crds/" + email.replace('.', "" ) ).set(pw);
alert("Success! moving to main page");
let storesRef = firebase.database().ref().child('Users/' + email);
storesRef.set(color_string);
firebase.database().ref().child("Names/" + email).set(nickname);
firebase.database().ref().child("Crds/" + email).set(pw);
firebase.database().ref().child("Auto_approve/" + email).set(0);
firebase.auth().signInWithEmailAndPassword(admin_email, admin_pw).catch(function(error)
{
console.log(error.message);
}).then(function()
{
alert("Success! moving to main page");
window.location = "../index.html";
return false;
});
Expand All @@ -69,7 +69,7 @@ let send_data = function()
{
snapshot.forEach(function(childSnapshot)
{
if(childSnapshot.key.replace('.',"") == firebase.auth().currentUser.email.replace('.',""))
if(firebase.auth().currentUser.email == snapshot.val() + "@gmail.com" )
{
admin_email += firebase.auth().currentUser.email;
admin_pw += childSnapshot.val();
Expand Down Expand Up @@ -103,7 +103,6 @@ let build_HTML = function()
form_obj.acceptCharset = "UTF-8"; // utilizes english-only with special characters incl @
form_obj.onsubmit = send_data;


let email = document.createElement("INPUT");
email.setAttribute("type", "input");
email.name = "email";
Expand All @@ -112,11 +111,25 @@ let build_HTML = function()
email.form = form_obj;
email.id = "email";
email.setAttribute("pattern","[a-zA-Z0-9!#$%^*_|]{0,100}");


form_obj.appendChild(document.createTextNode("Username: "));
form_obj.appendChild(email);

let name = document.createElement("INPUT");
name.setAttribute("type", "input");
name.name = "name";
name.required = "true";
name.autocomplete = "true";
name.form = form_obj;
name.id = "name";

form_obj.appendChild(document.createElement("br"));
form_obj.appendChild(document.createTextNode("nickname (required): "));
form_obj.appendChild(name);



let pw = document.createElement("INPUT");
pw.setAttribute("type","password");
pw.name = "password";
Expand Down
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<!--Full Calendar API and jquery API loading files-->

<<link rel='stylesheet' href='libs/fullcalendar/fullcalendar.css' /> <!--Calendar design file-->
<link rel='stylesheet' href='libs/fullcalendar/fullcalendar.css' />
<script src='libs/fullcalendar/lib/jquery.min.js'></script>
<script src='libs/fullcalendar/lib/moment.min.js'></script>
<script src='libs/fullcalendar/fullcalendar.js'></script>
Expand Down
19 changes: 19 additions & 0 deletions src/manage_users/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var config_module= (function ()
{

let config =
{
apiKey: "AIzaSyBU9GCk3-4FVsBJp2Etpy2pmU2TTgR7U6c",
authDomain: "test-9d3f7.firebaseapp.com",
databaseURL: "https://test-9d3f7.firebaseio.com",
storageBucket: "test-9d3f7.appspot.com",
messagingSenderId: "692751540092"
}; // API keys configuration
let config_firebase = function()
{
firebase.initializeApp(config);// sending API key to server for verification
};

return { config_firebase, };
}());
config_module.config_firebase();
29 changes: 29 additions & 0 deletions src/manage_users/manage_users.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<!--jquery loading file-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<!--END of jquery loading file-->

<!--jsoncolor loading file-->
<script src="../libs/jsoncolor/jscolor.min.js"></script>
<!--END of jsoncolor loading file-->

<!--Google Firebase API loading files-->
<script src="https://www.gstatic.com/firebasejs/3.7.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.7.1/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.7.1/firebase-database.js"></script>
<!--END of Google Firebase API loading files-->

<!--Loaded a personal script to combine API's as well as page design and logic initate-->
<script src="config.js"></script>
<script src="script.js"></script>
<link rel='stylesheet' href='style.css' />
<!--END of Loaded a personal script to combine API's as well as page design and logic initate-->

</head>

<body>

</body>
</html>
Loading

0 comments on commit c930733

Please sign in to comment.