comments for profile, and small changes
This commit is contained in:
parent
cd72662cb6
commit
535ee70bbd
@ -6,6 +6,7 @@ import './main.html';
|
||||
|
||||
var load = true;
|
||||
var calCreWork = null;
|
||||
var calWorkDate = null;
|
||||
|
||||
var openValues = {
|
||||
"menu": "-25%",
|
||||
@ -43,17 +44,16 @@ var ref = {
|
||||
};
|
||||
|
||||
// Reactive variables.
|
||||
Session.set("calendarClasses", null); //
|
||||
Session.set("sidebar", null);
|
||||
Session.set("newWork",null);
|
||||
Session.set("currentWork",null);
|
||||
Session.set("currentReadableWork",null);
|
||||
Session.set("modifying",null);
|
||||
Session.set("noclass",null);
|
||||
Session.set("calWorkDate",null);
|
||||
Session.set("classDisp",[]);
|
||||
Session.set("classDispHover",null);
|
||||
Session.set("commentRestrict",null);
|
||||
Session.set("calendarClasses", null);
|
||||
Session.set("sidebar", null); // Status of sidebar
|
||||
Session.set("newWork",null); // If user creating new work.
|
||||
Session.set("currentWork",null); // Stores current selected work info.
|
||||
Session.set("currentReadableWork",null); // Stores readable selected work info.
|
||||
Session.set("modifying",null); // Stores current open input.
|
||||
Session.set("noclass",null); // If user does not have classes.
|
||||
Session.set("classDisp",[]); // Stores current filter for classes.
|
||||
Session.set("classDispHover",null); // Stores current hovered filter.
|
||||
Session.set("commentRestrict",null); // Stores text for comment character restriction.
|
||||
|
||||
Template.registerHelper('divColor', (div) => { // Reactive color changing based on preferences. Colors stored in themeColors.
|
||||
return themeColors[Meteor.user().profile.preferences.theme][div];
|
||||
@ -286,7 +286,7 @@ Template.main.helpers({
|
||||
dayClick: function(date, jsEvent, view) { // On-click for each day.
|
||||
if(jsEvent.target.className.includes("fc-past")) return;
|
||||
calCreWork = true;
|
||||
Session.set("calWorkDate",date.format());
|
||||
calWorkDate = date.format();
|
||||
Session.set("sidebar","menuContainer");
|
||||
}
|
||||
};
|
||||
@ -725,7 +725,7 @@ Template.main.events({
|
||||
calCreWork = null;
|
||||
Session.set("sidebar",null);
|
||||
|
||||
var date = Session.get("calWorkDate").split("-");
|
||||
var date = calWorkDate.split("-");
|
||||
var date = new Date(date[0],parseInt(date[1])-1,date[2],11,59,59);
|
||||
Session.set("newWork", true);
|
||||
Session.set("currentReadableWork",
|
||||
@ -796,6 +796,7 @@ function sendData(funcName) { // Call Meteor function, and do actions after func
|
||||
} else if(funcName === "editProfile") {
|
||||
$("#fullcalendar").fullCalendar( 'refetchEvents' );
|
||||
}
|
||||
console.log(err,result);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@
|
||||
|
||||
{{#if profClassTab "addClass"}}
|
||||
<i class="fa fa-search" aria-hidden="true"></i>
|
||||
{{> inputAutocomplete id="profClassSearch" settings=classsettings placeholder="Search..."}}
|
||||
{{> inputAutocomplete id="profClassSearch" settings=classSettings placeholder="Search..."}}
|
||||
<h4 id="private">Join Private Class</h4>
|
||||
<div id="label" class="classBox">
|
||||
<span class="name classText">Class Name</span>
|
||||
@ -101,7 +101,7 @@
|
||||
<div id="formContainer">
|
||||
<div class="formDiv">
|
||||
<p class="profTitle">School:</p>
|
||||
{{> inputAutocomplete settings=schoolcomplete class="form-control creInput" type="text" name="school" placeholder="Example: International Academy" }}
|
||||
{{> inputAutocomplete settings=schoolComplete class="form-control creInput" type="text" name="school" placeholder="Example: International Academy" }}
|
||||
</div>
|
||||
<div class="formDiv">
|
||||
<p class="profTitle">Hour:</p>
|
||||
@ -109,7 +109,7 @@
|
||||
</div>
|
||||
<div class="formDiv">
|
||||
<p class="profTitle">Teacher:</p>
|
||||
{{> inputAutocomplete settings=teachercomplete class="form-control creInput" type="text" name="teacher" placeholder="Example: Woods" }}
|
||||
{{> inputAutocomplete settings=teacherComplete class="form-control creInput" type="text" name="teacher" placeholder="Example: Woods" }}
|
||||
</div>
|
||||
<div class="formDiv">
|
||||
<p class="profTitle">Class Name:</p>
|
||||
|
||||
@ -2,22 +2,22 @@
|
||||
Template
|
||||
} from 'meteor/templating';
|
||||
|
||||
confirm = null; // Sets function to execute after confirmation click.
|
||||
|
||||
// Sets up global variables
|
||||
|
||||
Session.set("profClassTab", "manClass");
|
||||
Session.set("modifying", null);
|
||||
Session.set("notsearching", true);
|
||||
Session.set("confirm", null);
|
||||
Session.set("autocompleteDivs", null);
|
||||
Session.set("confirmText", null);
|
||||
Session.set("selectedClass",null);
|
||||
Session.set("selectClassId",null);
|
||||
Session.set("code",null);
|
||||
Session.set("noclass",null);
|
||||
Session.set("notfound",null);
|
||||
Session.set("profClassTab", "manClass"); // Set default classes card mode to 'Manage Classes.'
|
||||
Session.set("modifying", null); // Stores current open input.
|
||||
Session.set("notsearching", true); // If user is searching in search box.
|
||||
Session.set("autocompleteDivs", null); // Stores returned autocomplete results.
|
||||
Session.set("confirmText", null); // Stores text for different confirmation functions.
|
||||
Session.set("selectClassId",null); // Stores selected owned class ID.
|
||||
Session.set("code",null); // If owned class has a code.
|
||||
Session.set("noclass",null); // If user doesn't have classes.
|
||||
Session.set("notfound",null); // If no results for autocomplete.
|
||||
|
||||
Template.profile.helpers({
|
||||
classsettings: function() {
|
||||
classSettings() { // Returns autocomplete array for classes.
|
||||
return {
|
||||
position: "bottom",
|
||||
limit: 10,
|
||||
@ -33,7 +33,7 @@ Template.profile.helpers({
|
||||
}]
|
||||
};
|
||||
},
|
||||
schoolcomplete() {
|
||||
schoolComplete() { // Returns autocomplete array for schools.
|
||||
return {
|
||||
position: "bottom",
|
||||
limit: 6,
|
||||
@ -46,7 +46,7 @@ Template.profile.helpers({
|
||||
}]
|
||||
};
|
||||
},
|
||||
teachercomplete() {
|
||||
teacherComplete() { // Returns autocomplete array for teachers.
|
||||
return {
|
||||
position: "bottom",
|
||||
limit: 1,
|
||||
@ -58,11 +58,11 @@ Template.profile.helpers({
|
||||
}]
|
||||
};
|
||||
},
|
||||
mainCenter() { // Centers main container
|
||||
mainCenter() { // Centers main div container.
|
||||
var width = window.innerWidth * 1600 / 1920 + 10;
|
||||
return "width:" + width.toString() + "px;margin-left:" + -0.5 * width.toString() + "px";
|
||||
},
|
||||
mainHeight() {
|
||||
mainHeight() { // Returns height of screen for div.
|
||||
return window.innerHeight.toString() + "px";
|
||||
},
|
||||
banner() { // Styles the banner
|
||||
@ -92,7 +92,7 @@ Template.profile.helpers({
|
||||
}
|
||||
return "background-image:url(" + pic + ");background-size:" + dim.toString() + "px " + dim.toString() + "px";
|
||||
},
|
||||
avatarDim() { //Dimensions the avatar
|
||||
avatarDim() { // Dimensions of the avatar
|
||||
var dim = window.innerWidth * 1600 / 1920 * 0.16;
|
||||
return "height:" + dim.toString() + "px;width:" + dim.toString() + "px;top:" + 0.43 * window.innerHeight.toString() + "px;";
|
||||
},
|
||||
@ -147,7 +147,7 @@ Template.profile.helpers({
|
||||
classHolderHeight() { // Dimensions the container for the classes
|
||||
return 0.26 * window.innerHeight.toString() + "px";
|
||||
},
|
||||
profClassTabColor(status) { // Change this [Supposed to show the current mode that's selected via color]
|
||||
profClassTabColor(status) { // Change this [Supposed to show the current mode that's selected via color]
|
||||
if (status === Session.get("profClassTab")) {
|
||||
return Session.get("themeColors")[Meteor.user().profile.preferences.theme].highlightText;
|
||||
} else {
|
||||
@ -167,16 +167,16 @@ Template.profile.helpers({
|
||||
autocompleteClasses() { // Returns current auto-completes for classes
|
||||
return Session.get("autocompleteDivs");
|
||||
},
|
||||
notfound() {
|
||||
notfound() { // Returns if autocomplete has no results.
|
||||
return Session.get("notfound");
|
||||
},
|
||||
noclass() {
|
||||
noclass() { // Returns if user has classes.
|
||||
return Session.get("noclass");
|
||||
},
|
||||
confirmText() {
|
||||
confirmText() { // Returns respective text for different confirm functions.
|
||||
return Session.get("confirmText");
|
||||
},
|
||||
selectedClass(val) {
|
||||
selectedClass(val) { // Returns values for selectedClass
|
||||
if(Session.get("selectClassId") === null) return;
|
||||
var usertype = ["moderators","banned"];
|
||||
var attribute = Session.get("selectClassId");
|
||||
@ -204,19 +204,237 @@ Template.profile.helpers({
|
||||
}
|
||||
return array[val];
|
||||
},
|
||||
code() {
|
||||
code() { // Returns if selected class has code.
|
||||
return Session.get("code");
|
||||
},
|
||||
userHolder() {
|
||||
userHolder() { // Returns height of user holders for moderators/banned.
|
||||
return 0.15 * window.innerHeight.toString() + "px";
|
||||
}
|
||||
});
|
||||
|
||||
Template.profile.events({
|
||||
'click .change' (event) { // Allows changes to profile values
|
||||
'click' (event) { // Whenever a click happens
|
||||
var modifyingInput = Session.get("modifying");
|
||||
if (event.target.id !== modifyingInput &&
|
||||
event.target.id !== modifyingInput + "a" &&
|
||||
!Session.equals("modifying", null) &&
|
||||
!event.target.parentNode.className.includes("profOptions")) {
|
||||
closeInput(modifyingInput);
|
||||
}
|
||||
if (!event.target.className.includes("radio") &&
|
||||
!event.target.parentNode.className.includes("profOptions") &&
|
||||
event.target.readOnly !== true) {
|
||||
for (var i = 0; i < document.getElementsByClassName("profOptions").length; i++) {
|
||||
try {
|
||||
closeDivFade(document.getElementsByClassName("profOptions")[i]);
|
||||
} catch (err) {}
|
||||
}
|
||||
}
|
||||
if(!document.getElementById("createdClasses").contains(event.target) &&
|
||||
Session.get("code") !== null &&
|
||||
!event.target.className.includes("fa-times-circle-o")) {
|
||||
document.getElementById("createdClasses").style.marginRight = "-40%";
|
||||
}
|
||||
if(Session.get("changeAdmin") &&
|
||||
!document.getElementById("changeAdmin").contains(event.target)) {
|
||||
Session.set("changeAdmin",false);
|
||||
var div = document.getElementById("changeAdmin");
|
||||
div.removeChild(div.childNodes[3]);
|
||||
div.removeChild(div.childNodes[3]);
|
||||
}
|
||||
if(Session.get("privateClass") &&
|
||||
!document.getElementById("joinPrivClass").contains(event.target)) {
|
||||
Session.set("privateClass",false);
|
||||
document.getElementById("joinPrivClass").style.marginBottom = "-10%";
|
||||
}
|
||||
},
|
||||
// MAIN BUTTONS
|
||||
'click .addClass' () {
|
||||
var functionHolder = document.getElementById("profClassInfoHolder");
|
||||
closeDivFade(functionHolder);
|
||||
setTimeout(function() {
|
||||
Session.set("profClassTab", "addClass");
|
||||
openDivFade(functionHolder);
|
||||
}, 300);
|
||||
},
|
||||
'click .manageClass' () {
|
||||
var functionHolder = document.getElementById("profClassInfoHolder");
|
||||
closeDivFade(functionHolder);
|
||||
setTimeout(function() {
|
||||
Session.set("profClassTab", "manClass");
|
||||
openDivFade(functionHolder);
|
||||
}, 300);
|
||||
},
|
||||
'click .createClass' () {
|
||||
var functionHolder = document.getElementById("profClassInfoHolder");
|
||||
closeDivFade(functionHolder);
|
||||
setTimeout(function() {
|
||||
Session.set("profClassTab", "creClass");
|
||||
openDivFade(functionHolder);
|
||||
}, 300);
|
||||
},
|
||||
'click .classBox' (event) { // When you click on a box that holds class
|
||||
if (event.target.id === "label" ||
|
||||
Session.get("profClassTab") === "manClass" ||
|
||||
event.target.className.includes("fa-times")) return;
|
||||
|
||||
if (event.target.className !== "classBox") {
|
||||
var attribute = event.target.parentNode.getAttribute("classid");
|
||||
} else {
|
||||
var attribute = event.target.getAttribute("classid");
|
||||
}
|
||||
var data = [attribute, ""];
|
||||
serverData = data;
|
||||
confirm = "joinClass";
|
||||
Session.set("confirmText", "Join class?");
|
||||
|
||||
openDivFade(document.getElementsByClassName("overlay")[0]);
|
||||
setTimeout(function() {
|
||||
document.getElementsByClassName("overlay")[0].style.opacity = "1";
|
||||
}, 200);
|
||||
},
|
||||
'click .owned' (event) { // When you click your own class
|
||||
if (event.target.id === "label") return;
|
||||
if (!event.target.className.includes("owned")) {
|
||||
var attribute = event.target.parentNode.getAttribute("classid");
|
||||
} else {
|
||||
var attribute = event.target.getAttribute("classid");
|
||||
}
|
||||
Session.set("selectClassId",attribute);
|
||||
document.getElementById("createdClasses").style.marginRight = "0";
|
||||
},
|
||||
'click .classBox .fa-times' (event) { // Leaves a class
|
||||
var box = event.target.parentNode;
|
||||
var classid = box.getAttribute("classid");
|
||||
serverData = box.getAttribute("classid");
|
||||
confirm = "leaveClass";
|
||||
Session.set("confirmText", "Leave this class?");
|
||||
openDivFade(document.getElementsByClassName("overlay")[0]);
|
||||
},
|
||||
'click #creSubmit' () { //Submits form data for class
|
||||
var data = getCreateFormData();
|
||||
if (data === null) return;
|
||||
serverData = data;
|
||||
confirm = "createClass";
|
||||
Session.set("confirmText", "Submit request?");
|
||||
|
||||
openDivFade(document.getElementsByClassName("overlay")[0]);
|
||||
},
|
||||
'click #private' (event) { // Joins private class
|
||||
Session.set("privateClass",true);
|
||||
var input = document.getElementById("privateCode");
|
||||
input.className = "";
|
||||
input.placeholder = "Enter code here...";
|
||||
document.getElementById("joinPrivClass").style.marginBottom = "0";
|
||||
},
|
||||
'click #privSubmit' () { // Submits private class code
|
||||
var input = document.getElementById("privateCode");
|
||||
var code = input.value;
|
||||
input.value = "";
|
||||
serverData = code;
|
||||
Meteor.call("joinPrivateClass", code, function(error, result) {
|
||||
if(result) {
|
||||
document.getElementById("joinPrivClass").style.marginBottom = "-10%";
|
||||
} else {
|
||||
input.className = "formInvalid";
|
||||
input.placeholder = "Invalid code.";
|
||||
}
|
||||
});
|
||||
},
|
||||
// OWNED CLASS BUTTONS=
|
||||
'click #copy' () { // Copies code for private classes.
|
||||
if(document.getElementById("code").value === "None") return;
|
||||
document.getElementById("code").select();
|
||||
document.execCommand("copy");
|
||||
},
|
||||
'click .userAdder .fa-plus' (event) { // Gives/Removes user privileges
|
||||
var input = event.target.parentNode.childNodes[3];
|
||||
input.placeholder = "1234@abc.xyz";
|
||||
input.className.replace(" formInvalid","");
|
||||
var value = input.value;
|
||||
var classid = document.getElementById("createdClasses").getAttribute("classid");
|
||||
input.value = "";
|
||||
if(checkUser(value,classid)) {
|
||||
input.className += " formInvalid";
|
||||
input.placeholder = "Not a valid user";
|
||||
return;
|
||||
}
|
||||
var user = Meteor.users.findOne({"services.google.email":value});
|
||||
serverData = [
|
||||
user._id,
|
||||
classid,
|
||||
event.target.parentNode.childNodes[1].childNodes[0].nodeValue.replace(":","").toLowerCase(),
|
||||
true
|
||||
];
|
||||
sendData("trackUserInClass");
|
||||
},
|
||||
'click .userBox .fa-times' (event) { // Removes user from permissions
|
||||
var box = event.target.parentNode;
|
||||
serverData = [
|
||||
box.getAttribute("userid"),
|
||||
document.getElementById("createdClasses").getAttribute("classid"),
|
||||
box.parentNode.parentNode.childNodes[1].childNodes[1].childNodes[0].nodeValue.replace(":","").toLowerCase(),
|
||||
false
|
||||
];
|
||||
sendData("trackUserInClass");
|
||||
},
|
||||
'click #deleteClass' () {
|
||||
serverData = document.getElementById("createdClasses").getAttribute("classid");
|
||||
confirm = "deleteClass";
|
||||
Session.set("confirmText", "Delete this class?");
|
||||
openDivFade(document.getElementsByClassName("overlay")[0]);
|
||||
},
|
||||
'click #changeAdmin span' (event) { // Click to give ownership of class.
|
||||
if(Session.get("changeAdmin")) return;
|
||||
Session.set("changeAdmin",true);
|
||||
var input = document.createElement("input");
|
||||
input.placeholder = "1234@abc.xyz";
|
||||
var i = document.createElement("i");
|
||||
i.className = "fa fa-exchange";
|
||||
i.setAttribute("aria-hidden","true");
|
||||
event.target.parentNode.appendChild(input);
|
||||
event.target.parentNode.appendChild(i);
|
||||
},
|
||||
'click .fa-exchange' (event) { //Changes class admin upon confirmation
|
||||
var input = event.target.parentNode.childNodes[3];
|
||||
input.placeholder = "1234@abc.xyz";
|
||||
input.className.replace(" formInvalid","");
|
||||
var value = input.value;
|
||||
var classid = document.getElementById("createdClasses").getAttribute("classid");
|
||||
input.value = "";
|
||||
if(checkUser(value,classid)) {
|
||||
input.className += " formInvalid";
|
||||
input.placeholder = "Not a valid user";
|
||||
return;
|
||||
}
|
||||
var user = Meteor.users.findOne({"services.google.email":value});
|
||||
serverData = [user._id,classid];
|
||||
confirm = "changeAdmin";
|
||||
Session.set("confirmText", "Are you really sure?");
|
||||
openDivFade(document.getElementsByClassName("overlay")[0])
|
||||
document.getElementById("createdClasses").style.marginRight = "-40%";
|
||||
},
|
||||
// OVERLAY BUTTONS
|
||||
'click .fa-check-circle-o' () { // Confirmation Button
|
||||
sendData(confirm);
|
||||
closeDivFade(document.getElementsByClassName("overlay")[0]);
|
||||
if(confirm === "createClass") {
|
||||
var form = document.getElementById("create");
|
||||
for(var i = 0; i < form.length; i++) form[i].value = "";
|
||||
}
|
||||
serverData = null;
|
||||
confirm = null;
|
||||
},
|
||||
'click .fa-times-circle-o' () { // Deny Button
|
||||
closeDivFade(document.getElementsByClassName("overlay")[0]);
|
||||
serverData = null;
|
||||
confirm = null;
|
||||
},
|
||||
// INPUT HANDLING
|
||||
'click .change' (event) { // Click changable inputs. Creates an input where the span is.
|
||||
var ele = event.target;
|
||||
var sessval = Session.get("modifying");
|
||||
if (ele.id !== sessval && sessval !== null) closeInput(sessval);
|
||||
var modifyingInput = Session.get("modifying");
|
||||
if (ele.id !== modifyingInput && modifyingInput !== null) closeInput(modifyingInput);
|
||||
|
||||
Session.set("modifying", ele.id);
|
||||
var dim = ele.getBoundingClientRect();
|
||||
@ -256,70 +474,7 @@ Template.profile.events({
|
||||
ele.parentNode.appendChild(span);
|
||||
}
|
||||
},
|
||||
'click' (event) { // Whenever a click happens
|
||||
var sessval = Session.get("modifying");
|
||||
if (event.target.id !== sessval &&
|
||||
event.target.id !== sessval + "a" &&
|
||||
!Session.equals("modifying", null) &&
|
||||
!event.target.parentNode.className.includes("profOptions")) {
|
||||
closeInput(sessval);
|
||||
}
|
||||
if (!event.target.className.includes("radio") &&
|
||||
!event.target.parentNode.className.includes("profOptions") &&
|
||||
event.target.readOnly !== true) {
|
||||
for (var i = 0; i < document.getElementsByClassName("profOptions").length; i++) {
|
||||
try {
|
||||
closeDivFade(document.getElementsByClassName("profOptions")[i]);
|
||||
} catch (err) {}
|
||||
}
|
||||
}
|
||||
if(!document.getElementById("createdClasses").contains(event.target) &&
|
||||
Session.get("code") !== null &&
|
||||
!event.target.className.includes("fa-times-circle-o")) {
|
||||
document.getElementById("createdClasses").style.marginRight = "-40%";
|
||||
setTimeout(function() { Session.set("selectedClass", null); }, 300);
|
||||
}
|
||||
if(Session.get("changeAdmin") &&
|
||||
!document.getElementById("changeAdmin").contains(event.target)) {
|
||||
Session.set("changeAdmin",false);
|
||||
var div = document.getElementById("changeAdmin");
|
||||
div.removeChild(div.childNodes[3]);
|
||||
div.removeChild(div.childNodes[3]);
|
||||
}
|
||||
if(Session.get("privateClass") &&
|
||||
!document.getElementById("joinPrivClass").contains(event.target)) {
|
||||
Session.set("privateClass",false);
|
||||
document.getElementById("joinPrivClass").style.marginBottom = "-10%";
|
||||
}
|
||||
},
|
||||
'keydown' (event) { // Whenever one key is pressed (for character restrictions)
|
||||
var sessval = Session.get("modifying");
|
||||
if (event.keyCode == 13) {
|
||||
try {
|
||||
closeInput(sessval);
|
||||
} catch (err) {}
|
||||
}
|
||||
if (sessval !== null && event.keyCode !== 13) {
|
||||
var restrict = document.getElementById(sessval).getAttribute("restrict");
|
||||
if (restrict !== null) {
|
||||
var num = parseInt(restrict) - event.target.value.length;
|
||||
var restext = document.getElementById("restrict");
|
||||
if (num === 1) {
|
||||
restext.childNodes[0].nodeValue = num.toString() + " character left";
|
||||
restext.style.setProperty("color", "#999", "important");
|
||||
} else if (num <= 0) {
|
||||
var input = document.getElementById(sessval + "a");
|
||||
input.value = input.value.substring(0, parseInt(restrict));
|
||||
restext.childNodes[0].nodeValue = "0 characters left";
|
||||
restext.style.setProperty("color", "#FF1A1A", "important");
|
||||
} else {
|
||||
restext.childNodes[0].nodeValue = num.toString() + " characters left";
|
||||
restext.style.setProperty("color", "#999", "important");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'click .radio' (event) { // Click on an input that has a drop-down menu
|
||||
'click .radio' (event) { // Click dropdown input. Opens the dropdown menu.
|
||||
var op = event.target;
|
||||
try {
|
||||
for (var i = 0; i < document.getElementsByClassName("profOptions").length; i++) {
|
||||
@ -337,8 +492,35 @@ Template.profile.events({
|
||||
openDivFade(op.parentNode.parentNode.childNodes[3]);
|
||||
}
|
||||
},
|
||||
'click .profOptionText' (event) { // When someone selects "drop-down item"
|
||||
var sessval = Session.get("modifying");
|
||||
'keydown' (event) { // Restricts characters for certain inputs.
|
||||
var modifyingInput = Session.get("modifying");
|
||||
if (event.keyCode == 13) {
|
||||
try {
|
||||
closeInput(modifyingInput);
|
||||
} catch (err) {}
|
||||
}
|
||||
if (modifyingInput !== null && event.keyCode !== 13) {
|
||||
var restrict = document.getElementById(modifyingInput).getAttribute("restrict");
|
||||
if (restrict !== null) {
|
||||
var num = parseInt(restrict) - event.target.value.length;
|
||||
var restext = document.getElementById("restrict");
|
||||
if (num === 1) {
|
||||
restext.childNodes[0].nodeValue = num.toString() + " character left";
|
||||
restext.style.setProperty("color", "#999", "important");
|
||||
} else if (num <= 0) {
|
||||
var input = document.getElementById(modifyingInput + "a");
|
||||
input.value = input.value.substring(0, parseInt(restrict));
|
||||
restext.childNodes[0].nodeValue = "0 characters left";
|
||||
restext.style.setProperty("color", "#FF1A1A", "important");
|
||||
} else {
|
||||
restext.childNodes[0].nodeValue = num.toString() + " characters left";
|
||||
restext.style.setProperty("color", "#999", "important");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'click .profOptionText' (event) { // Click each profile option setting.
|
||||
var modifyingInput = Session.get("modifying");
|
||||
var p = event.target;
|
||||
if(p.className.includes("cre")) {
|
||||
var input = p.parentNode.parentNode.childNodes[3]
|
||||
@ -347,36 +529,13 @@ Template.profile.events({
|
||||
}
|
||||
input.value = p.childNodes[0].nodeValue;
|
||||
try {
|
||||
closeInput(sessval);
|
||||
closeInput(modifyingInput);
|
||||
} catch (err) {}
|
||||
|
||||
closeDivFade(p.parentNode);
|
||||
input.focus();
|
||||
},
|
||||
'click .addClass' () {
|
||||
var functionHolder = document.getElementById("profClassInfoHolder");
|
||||
closeDivFade(functionHolder);
|
||||
setTimeout(function() {
|
||||
Session.set("profClassTab", "addClass");
|
||||
openDivFade(functionHolder);
|
||||
}, 300);
|
||||
},
|
||||
'click .manageClass' () {
|
||||
var functionHolder = document.getElementById("profClassInfoHolder");
|
||||
closeDivFade(functionHolder);
|
||||
setTimeout(function() {
|
||||
Session.set("profClassTab", "manClass");
|
||||
openDivFade(functionHolder);
|
||||
}, 300);
|
||||
},
|
||||
'click .createClass' () {
|
||||
var functionHolder = document.getElementById("profClassInfoHolder");
|
||||
closeDivFade(functionHolder);
|
||||
setTimeout(function() {
|
||||
Session.set("profClassTab", "creClass");
|
||||
openDivFade(functionHolder);
|
||||
}, 300);
|
||||
},
|
||||
// AUTOCOMPLETE HANDLING
|
||||
'keyup #profClassSearch' (event) { // Auto-complete updater
|
||||
if (event.target.value.length === 0) {
|
||||
Session.set("notsearching", true);
|
||||
@ -387,12 +546,12 @@ Template.profile.events({
|
||||
var divs = [];
|
||||
try {
|
||||
var items = document.getElementsByClassName("-autocomplete-container")[0].childNodes[3].childNodes;
|
||||
if (items.length === 0) {
|
||||
if (items.length === 0) { // If no results.
|
||||
Session.set("notfound", true);
|
||||
} else {
|
||||
Session.set("notfound", false);
|
||||
}
|
||||
for (var i = 2; i < items.length; i += 3) {
|
||||
for (var i = 2; i < items.length; i += 3) { // Iterate through autocomplete div.
|
||||
var item = items[i].childNodes[3];
|
||||
if(Meteor.user().profile.classes.indexOf(item.getAttribute("classid")) !== -1) continue;
|
||||
divs.push({
|
||||
@ -406,163 +565,9 @@ Template.profile.events({
|
||||
}
|
||||
} catch (err) {}
|
||||
},
|
||||
'click .classBox' (event) { // When you click on a box that holds class
|
||||
if (event.target.id === "label" ||
|
||||
Session.get("profClassTab") === "manClass" ||
|
||||
event.target.className.includes("fa-times")) return;
|
||||
|
||||
if (event.target.className !== "classBox") {
|
||||
var attribute = event.target.parentNode.getAttribute("classid");
|
||||
} else {
|
||||
var attribute = event.target.getAttribute("classid");
|
||||
}
|
||||
var data = [attribute, ""];
|
||||
serverData = data;
|
||||
Session.set("confirm", "joinClass");
|
||||
Session.set("confirmText", "Join class?");
|
||||
|
||||
openDivFade(document.getElementsByClassName("overlay")[0]);
|
||||
setTimeout(function() {
|
||||
document.getElementsByClassName("overlay")[0].style.opacity = "1";
|
||||
}, 200);
|
||||
},
|
||||
'click .fa-check-circle-o' () { // Confirmation Button
|
||||
sendData(Session.get("confirm"));
|
||||
closeDivFade(document.getElementsByClassName("overlay")[0]);
|
||||
if(Session.get("confirm") === "createClass") {
|
||||
var form = document.getElementById("create");
|
||||
for(var i = 0; i < form.length; i++) form[i].value = "";
|
||||
}
|
||||
serverData = null;
|
||||
Session.set("confirm", null);
|
||||
},
|
||||
'click .fa-times-circle-o' () { // Deny Button
|
||||
closeDivFade(document.getElementsByClassName("overlay")[0]);
|
||||
serverData = null;
|
||||
Session.set("confirm", null);
|
||||
},
|
||||
'click #creSubmit' () { //Submits form data for class
|
||||
var data = getCreateFormData();
|
||||
if (data === null) return;
|
||||
serverData = data;
|
||||
Session.set("confirm", "createClass");
|
||||
Session.set("confirmText", "Submit request?");
|
||||
|
||||
openDivFade(document.getElementsByClassName("overlay")[0]);
|
||||
},
|
||||
'focus .op' (event) { // Browser Casework
|
||||
'focus .op' (event) { // Selects input for next tabbing.
|
||||
event.target.click();
|
||||
},
|
||||
'click .owned' (event) { // When you click your own class
|
||||
if (event.target.id === "label") return;
|
||||
if (!event.target.className.includes("owned")) {
|
||||
var attribute = event.target.parentNode.getAttribute("classid");
|
||||
} else {
|
||||
var attribute = event.target.getAttribute("classid");
|
||||
}
|
||||
Session.set("selectClassId",attribute);
|
||||
document.getElementById("createdClasses").style.marginRight = "0";
|
||||
},
|
||||
'click .userAdder .fa-plus' (event) { // Gives/Removes User Privileges
|
||||
var input = event.target.parentNode.childNodes[3];
|
||||
input.placeholder = "1234@abc.xyz";
|
||||
input.className.replace(" formInvalid","");
|
||||
var value = input.value;
|
||||
var classid = document.getElementById("createdClasses").getAttribute("classid");
|
||||
input.value = "";
|
||||
if(checkUser(value,classid)) {
|
||||
input.className += " formInvalid";
|
||||
input.placeholder = "Not a valid user";
|
||||
return;
|
||||
}
|
||||
var user = Meteor.users.findOne({"services.google.email":value});
|
||||
serverData = [
|
||||
user._id,
|
||||
classid,
|
||||
event.target.parentNode.childNodes[1].childNodes[0].nodeValue.replace(":","").toLowerCase()
|
||||
];
|
||||
sendData("trackUserInClass");
|
||||
|
||||
},
|
||||
'click .classBox .fa-times' (event) { // Leaves a class
|
||||
var box = event.target.parentNode;
|
||||
var classid = box.getAttribute("classid");
|
||||
serverData = box.getAttribute("classid");
|
||||
Session.set("confirm","leaveClass");
|
||||
Session.set("confirmText", "Leave this class?");
|
||||
openDivFade(document.getElementsByClassName("overlay")[0]);
|
||||
},
|
||||
'click .userBox .fa-times' (event) { // Removes user from permissions
|
||||
var box = event.target.parentNode;
|
||||
serverData = [
|
||||
box.getAttribute("userid"),
|
||||
document.getElementById("createdClasses").getAttribute("classid"),
|
||||
box.parentNode.parentNode.childNodes[1].childNodes[1].childNodes[0].nodeValue.replace(":","").toLowerCase()
|
||||
];
|
||||
sendData("untrackUserInClass");
|
||||
},
|
||||
'click #copy' () { //Copies googlee-classroom style code
|
||||
if(document.getElementById("code").value === "None") return;
|
||||
document.getElementById("code").select();
|
||||
document.execCommand("copy");
|
||||
},
|
||||
'click #deleteClass' () {
|
||||
serverData = document.getElementById("createdClasses").getAttribute("classid");
|
||||
Session.set("confirm", "deleteClass");
|
||||
Session.set("confirmText", "Delete this class?");
|
||||
openDivFade(document.getElementsByClassName("overlay")[0]);
|
||||
},
|
||||
'click #changeAdmin span' (event) {
|
||||
if(Session.get("changeAdmin")) return;
|
||||
Session.set("changeAdmin",true);
|
||||
var input = document.createElement("input");
|
||||
input.placeholder = "1234@abc.xyz";
|
||||
var i = document.createElement("i");
|
||||
i.className = "fa fa-exchange";
|
||||
i.setAttribute("aria-hidden","true");
|
||||
event.target.parentNode.appendChild(input);
|
||||
event.target.parentNode.appendChild(i);
|
||||
},
|
||||
'click .fa-exchange' (event) { //Changes class admin upon confirmation
|
||||
var input = event.target.parentNode.childNodes[3];
|
||||
input.placeholder = "1234@abc.xyz";
|
||||
input.className.replace(" formInvalid","");
|
||||
var value = input.value;
|
||||
var classid = document.getElementById("createdClasses").getAttribute("classid");
|
||||
input.value = "";
|
||||
if(checkUser(value,classid)) {
|
||||
input.className += " formInvalid";
|
||||
input.placeholder = "Not a valid user";
|
||||
return;
|
||||
}
|
||||
var user = Meteor.users.findOne({"services.google.email":value});
|
||||
serverData = [user._id,classid];
|
||||
Session.set("confirm","changeAdmin");
|
||||
Session.set("confirmText", "Are you really sure?");
|
||||
openDivFade(document.getElementsByClassName("overlay")[0])
|
||||
document.getElementById("createdClasses").style.marginRight = "-40%";
|
||||
},
|
||||
'click #private' (event) { // Joins private class
|
||||
Session.set("privateClass",true);
|
||||
var input = document.getElementById("privateCode");
|
||||
input.className = "";
|
||||
input.placeholder = "Enter code here...";
|
||||
document.getElementById("joinPrivClass").style.marginBottom = "0";
|
||||
},
|
||||
'click #privSubmit' () { // Submits private class code
|
||||
var input = document.getElementById("privateCode");
|
||||
var code = input.value;
|
||||
input.value = "";
|
||||
serverData = code;
|
||||
Meteor.call("joinPrivateClass", code, function(error, result) {
|
||||
if(result) {
|
||||
document.getElementById("joinPrivClass").style.marginBottom = "-10%";
|
||||
} else {
|
||||
input.className = "formInvalid";
|
||||
input.placeholder = "Invalid code.";
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function openDivFade(div) {
|
||||
@ -580,9 +585,9 @@ function closeDivFade(div) {
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function closeInput(sessval) {
|
||||
var input = document.getElementById(sessval + "a");
|
||||
var span = document.getElementById(sessval);
|
||||
function closeInput(modifyingInput) { // Closes current modifying input.
|
||||
var input = document.getElementById(modifyingInput + "a");
|
||||
var span = document.getElementById(modifyingInput);
|
||||
input.parentNode.removeChild(input);
|
||||
try {
|
||||
var restrict = document.getElementById("restrict");
|
||||
@ -603,7 +608,7 @@ function sendData(funcName) {
|
||||
Meteor.call(funcName, serverData);
|
||||
}
|
||||
|
||||
function getProfileData() {
|
||||
function getProfileData() { // Gets all data related to profile.
|
||||
var profile = Meteor.user().profile;
|
||||
profile.description = document.getElementById("motd").childNodes[0].nodeValue;
|
||||
profile.school = document.getElementById("school").childNodes[0].nodeValue;
|
||||
@ -620,10 +625,10 @@ function getProfileData() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
function getCreateFormData() {
|
||||
function getCreateFormData() { // Gets create class form data, and returns null.
|
||||
var stop;
|
||||
var form = document.getElementsByClassName("creInput");
|
||||
for (var i = 0; i < form.length; i++) {
|
||||
for (var i = 0; i < form.length; i++) { // Checks for missing/invalid fields.
|
||||
if(i === 1 || i === 2) continue;
|
||||
if (form[i].value === "") {
|
||||
form[i].focus();
|
||||
@ -658,7 +663,7 @@ function getCreateFormData() {
|
||||
};
|
||||
}
|
||||
|
||||
function checkUser(email,classid) {
|
||||
function checkUser(email,classid) { // Checks if user email exists.
|
||||
var user = Meteor.users.findOne({"services.google.email":email});
|
||||
if(user === undefined) {
|
||||
return true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user