This commit is contained in:
Arav-Agarwal 2016-08-25 22:56:10 -04:00
parent f0fa84c47a
commit aced6645a1

View File

@ -231,14 +231,7 @@ Template.profile.helpers({
}); });
Template.profile.events({ Template.profile.events({
'click profOptions p' (event) { 'click .change' (event) { // Allows changes to profile values
var p = event.target;
p.parentNode.parentNode.childNodes[1].value = p.childNodes[0].nodeValue;
closeDivFade(p.parentNode);
Session.set("radioDiv", null);
Session.set("radioOffset", null);
},
'click .change' (event) {
var ele = event.target; var ele = event.target;
var sessval = Session.get("modifying"); var sessval = Session.get("modifying");
if (ele.id !== sessval && sessval !== null) closeInput(sessval); if (ele.id !== sessval && sessval !== null) closeInput(sessval);
@ -281,7 +274,7 @@ Template.profile.events({
ele.parentNode.appendChild(span); ele.parentNode.appendChild(span);
} }
}, },
'click' (event) { 'click' (event) { // Whenever a click happens
var sessval = Session.get("modifying"); var sessval = Session.get("modifying");
if (event.target.id !== sessval && if (event.target.id !== sessval &&
event.target.id !== sessval + "a" && event.target.id !== sessval + "a" &&
@ -321,7 +314,7 @@ Template.profile.events({
document.getElementById("joinPrivClass").style.marginBottom = "-10%"; document.getElementById("joinPrivClass").style.marginBottom = "-10%";
} }
}, },
'keydown' (event) { 'keydown' (event) { // Whenever one key is pressed (for character restrictions)
var sessval = Session.get("modifying"); var sessval = Session.get("modifying");
if (event.keyCode == 13) { if (event.keyCode == 13) {
try { try {
@ -348,7 +341,7 @@ Template.profile.events({
} }
} }
}, },
'click .radio' (event) { 'click .radio' (event) { // Click on an input that has a drop-down menu
var op = event.target; var op = event.target;
Session.set("radioDiv", op.getAttribute("op")); Session.set("radioDiv", op.getAttribute("op"));
Session.set("radioOffset", op.getAttribute("opc")); Session.set("radioOffset", op.getAttribute("opc"));
@ -362,7 +355,7 @@ Template.profile.events({
} catch (err) {} } catch (err) {}
openDivFade(document.getElementsByClassName("profOptions")[op.getAttribute("op")]); openDivFade(document.getElementsByClassName("profOptions")[op.getAttribute("op")]);
}, },
'click .profOptions p' (event) { 'click .profOptions p' (event) { // When someone selects "drop-down item"
var sessval = Session.get("modifying"); var sessval = Session.get("modifying");
var p = event.target; var p = event.target;
var opnum = parseInt(Session.get("radioDiv")) - parseInt(Session.get("radioOffset")); var opnum = parseInt(Session.get("radioDiv")) - parseInt(Session.get("radioOffset"));
@ -401,13 +394,7 @@ Template.profile.events({
openDivFade(functionHolder);         openDivFade(functionHolder);        
}, 300);     }, 300);    
}, },
'click .fa-search' () { 'keyup #profClassSearch' (event) { // Auto-complete updater
Session.set("searching", true);
},
'click .fa-times-thin' () {
Session.set("searching", false);
},
'keyup #profClassSearch' (event) {
if (event.target.value.length === 0) { if (event.target.value.length === 0) {
Session.set("notsearching", true); Session.set("notsearching", true);
} else { } else {
@ -436,7 +423,7 @@ Template.profile.events({
} }
} catch (err) {} } catch (err) {}
}, },
'click .classBox' (event) { 'click .classBox' (event) { // When you click on a box that holds class
if (event.target.id === "label" || if (event.target.id === "label" ||
Session.get("profClassTab") === "manClass" || Session.get("profClassTab") === "manClass" ||
event.target.className.includes("fa-times")) return; event.target.className.includes("fa-times")) return;
@ -456,7 +443,7 @@ Template.profile.events({
document.getElementsByClassName("overlay")[0].style.opacity = "1"; document.getElementsByClassName("overlay")[0].style.opacity = "1";
}, 200); }, 200);
}, },
'click .fa-check-circle-o' () { 'click .fa-check-circle-o' () { // Confirmation Button
sendData(Session.get("confirm")); sendData(Session.get("confirm"));
closeDivFade(document.getElementsByClassName("overlay")[0]); closeDivFade(document.getElementsByClassName("overlay")[0]);
if(Session.get("confirm") === "createClass") { if(Session.get("confirm") === "createClass") {
@ -466,12 +453,12 @@ Template.profile.events({
Session.set("serverData", null); Session.set("serverData", null);
Session.set("confirm", null); Session.set("confirm", null);
}, },
'click .fa-times-circle-o' () { 'click .fa-times-circle-o' () { // Deny Button
closeDivFade(document.getElementsByClassName("overlay")[0]); closeDivFade(document.getElementsByClassName("overlay")[0]);
Session.set("serverData", null); Session.set("serverData", null);
Session.set("confirm", null); Session.set("confirm", null);
}, },
'click #creSubmit' () { 'click #creSubmit' () { //Submits form data for class
var data = getCreateFormData(); var data = getCreateFormData();
if (data === null) return; if (data === null) return;
Session.set("serverData", data); Session.set("serverData", data);
@ -480,10 +467,10 @@ Template.profile.events({
openDivFade(document.getElementsByClassName("overlay")[0]); openDivFade(document.getElementsByClassName("overlay")[0]);
}, },
'focus .op' (event) { 'focus .op' (event) { // Browser Casework
event.target.click(); event.target.click();
}, },
'click .owned' (event) { 'click .owned' (event) { // When you click your own class
if (event.target.id === "label") return; if (event.target.id === "label") return;
if (!event.target.className.includes("owned")) { if (!event.target.className.includes("owned")) {
var attribute = event.target.parentNode.getAttribute("classid"); var attribute = event.target.parentNode.getAttribute("classid");
@ -493,7 +480,7 @@ Template.profile.events({
Session.set("selectClassId",attribute); Session.set("selectClassId",attribute);
document.getElementById("createdClasses").style.marginRight = "0"; document.getElementById("createdClasses").style.marginRight = "0";
}, },
'click .userAdder .fa-plus' (event) { 'click .userAdder .fa-plus' (event) { // Gives/Removes User Privileges
var input = event.target.parentNode.childNodes[3]; var input = event.target.parentNode.childNodes[3];
input.placeholder = "1234@abc.xyz"; input.placeholder = "1234@abc.xyz";
input.className.replace(" formInvalid",""); input.className.replace(" formInvalid","");
@ -514,7 +501,7 @@ Template.profile.events({
sendData("trackUserInClass"); sendData("trackUserInClass");
}, },
'click .classBox .fa-times' (event) { 'click .classBox .fa-times' (event) { // Leaves a class
var box = event.target.parentNode; var box = event.target.parentNode;
var classid = box.getAttribute("classid"); var classid = box.getAttribute("classid");
Session.set("serverData", box.getAttribute("classid")); Session.set("serverData", box.getAttribute("classid"));
@ -522,7 +509,7 @@ Template.profile.events({
Session.set("confirmText", "Leave this class?"); Session.set("confirmText", "Leave this class?");
openDivFade(document.getElementsByClassName("overlay")[0]); openDivFade(document.getElementsByClassName("overlay")[0]);
}, },
'click .userBox .fa-times' (event) { 'click .userBox .fa-times' (event) { // Removes user from permissions
var box = event.target.parentNode; var box = event.target.parentNode;
Session.set("serverData", [ Session.set("serverData", [
box.getAttribute("userid"), box.getAttribute("userid"),
@ -531,7 +518,7 @@ Template.profile.events({
]) ])
sendData("untrackUserInClass"); sendData("untrackUserInClass");
}, },
'click #copy' () { 'click #copy' () { //Copies googlee-classroom style code
if(document.getElementById("code").value === "None") return; if(document.getElementById("code").value === "None") return;
document.getElementById("code").select(); document.getElementById("code").select();
document.execCommand("copy"); document.execCommand("copy");
@ -553,7 +540,7 @@ Template.profile.events({
event.target.parentNode.appendChild(input); event.target.parentNode.appendChild(input);
event.target.parentNode.appendChild(i); event.target.parentNode.appendChild(i);
}, },
'click .fa-exchange' (event) { 'click .fa-exchange' (event) { //Changes class admin upon confirmation
var input = event.target.parentNode.childNodes[3]; var input = event.target.parentNode.childNodes[3];
input.placeholder = "1234@abc.xyz"; input.placeholder = "1234@abc.xyz";
input.className.replace(" formInvalid",""); input.className.replace(" formInvalid","");
@ -572,14 +559,14 @@ Template.profile.events({
openDivFade(document.getElementsByClassName("overlay")[0]) openDivFade(document.getElementsByClassName("overlay")[0])
document.getElementById("createdClasses").style.marginRight = "-40%"; document.getElementById("createdClasses").style.marginRight = "-40%";
}, },
'click #private' (event) { 'click #private' (event) { // Joins private class
Session.set("privateClass",true); Session.set("privateClass",true);
var input = document.getElementById("privateCode"); var input = document.getElementById("privateCode");
input.className = ""; input.className = "";
input.placeholder = "Enter code here..."; input.placeholder = "Enter code here...";
document.getElementById("joinPrivClass").style.marginBottom = "0"; document.getElementById("joinPrivClass").style.marginBottom = "0";
}, },
'click #privSubmit' () { 'click #privSubmit' () { // Submits private class code
var input = document.getElementById("privateCode"); var input = document.getElementById("privateCode");
var code = input.value; var code = input.value;
input.value = ""; input.value = "";