serverData make global variable

This commit is contained in:
Yaman Qalieh 2016-08-29 21:02:02 -04:00
parent 9356b4b04c
commit cb8c9025f4
3 changed files with 42 additions and 44 deletions

View File

@ -43,7 +43,6 @@ Session.set("newWork",null);
Session.set("currentWork",null);
Session.set("currentReadableWork",null);
Session.set("modifying",null);
Session.set("serverData",null);
Session.set("noclass",null);
Session.set("calCreWork",null);
Session.set("calWorkDate",null);
@ -51,7 +50,7 @@ Session.set("classDisp",[]);
Session.set("classDispHover",null);
Session.set("commentRestrict",null);
Template.registerHelper('divColor', (div) => { // Reactive color changing based on preferences. Colors stored in Session.get("themeColors").
Template.registerHelper('divColor', (div) => { // Reactive color changing based on preferences. Colors stored in themeColors.
return themeColors[Meteor.user().profile.preferences.theme][div];
});
@ -150,7 +149,7 @@ Template.registerHelper('pref', (val) => {
if(Object.keys(Meteor.user().profile.preferences).length !== Object.keys(defaults).length) {
var array = Meteor.user().profile;
array.preferences = defaults;
Session.set("serverData",array);
serverData = array;
sendData("editProfile");
if(val === 'timeHide' || val === 'done') return defaults[val];
return defaults[val].charAt(0).toUpperCase() + defaults[val].slice(1);
@ -281,7 +280,7 @@ Template.main.helpers({
var current = work.findOne({_id:event.id});
var date = event.start.format().split("-");
current.dueDate = new Date(date[0],parseInt(date[1])-1,date[2],11,59,59);
Session.set("serverData",current);
serverData = current;
sendData("editWork");
},
eventClick: function(event, jsEvent, view) {
@ -472,14 +471,14 @@ Template.main.events({
closeDivFade(document.getElementsByClassName("overlay")[0]);
if(!Session.get("newWork")) {
if(getHomeworkFormData() === null) return;
Session.set("serverData",Session.get("currentWork"));
serverData = Session.get("currentWork");
sendData("editWork");
document.getElementById("workComment").value = "";
}
Session.set("newWork",null);
Session.set("currentWork",null);
Session.set("currentReadableWork",null);
$('.req').css("color","")
$('.req').css("color","");
Session.set("commentRestrict",null);
}
@ -675,7 +674,7 @@ Template.main.events({
},
'click #workSubmit' () {
if(getHomeworkFormData() === null) return;
Session.set("serverData",Session.get("currentWork"));
serverData = Session.get("currentWork");
if(Session.get("newWork")) {
sendData("createWork");
} else {
@ -778,15 +777,15 @@ Template.main.events({
Session.set("commentRestrict", "Characters left: " + (200-chars).toString());
},
'click #markDone' () {
Session.set("serverData", [Session.get("currentWork")._id, "done"])
serverData = [Session.get("currentWork")._id, "done"]
sendData("toggleWork");
},
'click #markConfirm' () {
Session.set("serverData", [Session.get("currentWork")._id, "confirmations"])
serverData = [Session.get("currentWork")._id, "confirmations"]
sendData("toggleWork");
},
'click #markReport' () {
Session.set("serverData", [Session.get("currentWork")._id, "reports"])
serverData = [Session.get("currentWork")._id, "reports"]
sendData("toggleWork");
}
});
@ -807,7 +806,7 @@ function closeDivFade(div) {
}
function sendData(funcName) {
Meteor.call(funcName, Session.get("serverData") , function(err,result) {
Meteor.call(funcName, serverData , function(err,result) {
if((funcName === "editWork" || funcName === "createWork") && Session.get("mode") === "calendar") {
$("#fullcalendar").fullCalendar( 'refetchEvents' );
} else if(funcName === "toggleWork") {
@ -845,11 +844,11 @@ function closeInput(sessval) {
Session.set("modifying", null);
if(Session.equals("sidebar","optionsContainer") || Session.equals("sidebar","both")) {
Session.set("serverData",getPreferencesData());
serverData = getPreferencesData();
sendData("editProfile");
} else if(!Session.get("newWork")) {
if(getHomeworkFormData() === null) return;
Session.set("serverData",Session.get("currentWork"));
serverData = Session.get("currentWork");
sendData("editWork");
}
}

View File

@ -4,12 +4,10 @@
// Sets up global variables
Session.set("profInputOpen", null);
Session.set("profClassTab", "manClass");
Session.set("modifying", null);
Session.set("notsearching", true);
Session.set("confirm", null);
Session.set("serverData", null);
Session.set("autocompleteDivs", null);
Session.set("confirmText", null);
Session.set("selectedClass",null);
@ -419,7 +417,7 @@ Template.profile.events({
var attribute = event.target.getAttribute("classid");
}
var data = [attribute, ""];
Session.set("serverData", data);
serverData = data;
Session.set("confirm", "joinClass");
Session.set("confirmText", "Join class?");
@ -435,18 +433,18 @@ Template.profile.events({
var form = document.getElementById("create");
for(var i = 0; i < form.length; i++) form[i].value = "";
}
Session.set("serverData", null);
serverData = null;
Session.set("confirm", null);
},
'click .fa-times-circle-o' () { // Deny Button
closeDivFade(document.getElementsByClassName("overlay")[0]);
Session.set("serverData", null);
serverData = null;
Session.set("confirm", null);
},
'click #creSubmit' () { //Submits form data for class
var data = getCreateFormData();
if (data === null) return;
Session.set("serverData", data);
serverData = data;
Session.set("confirm", "createClass");
Session.set("confirmText", "Submit request?");
@ -478,29 +476,29 @@ Template.profile.events({
return;
}
var user = Meteor.users.findOne({"services.google.email":value});
Session.set("serverData", [
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");
Session.set("serverData", 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;
Session.set("serverData", [
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
@ -509,7 +507,7 @@ Template.profile.events({
document.execCommand("copy");
},
'click #deleteClass' () {
Session.set("serverData",document.getElementById("createdClasses").getAttribute("classid"));
serverData = document.getElementById("createdClasses").getAttribute("classid");
Session.set("confirm", "deleteClass");
Session.set("confirmText", "Delete this class?");
openDivFade(document.getElementsByClassName("overlay")[0]);
@ -538,7 +536,7 @@ Template.profile.events({
return;
}
var user = Meteor.users.findOne({"services.google.email":value});
Session.set("serverData", [user._id,classid]);
serverData = [user._id,classid];
Session.set("confirm","changeAdmin");
Session.set("confirmText", "Are you really sure?");
openDivFade(document.getElementsByClassName("overlay")[0])
@ -555,7 +553,7 @@ Template.profile.events({
var input = document.getElementById("privateCode");
var code = input.value;
input.value = "";
Session.set("serverData", code);
serverData = code;
Meteor.call("joinPrivateClass", code, function(error, result) {
if(result) {
document.getElementById("joinPrivClass").style.marginBottom = "-10%";
@ -597,12 +595,12 @@ function closeInput(sessval) {
}
span.style.display = "initial";
Session.set("modifying", null);
Session.set("serverData", getProfileData());
serverData = getProfileData();
sendData("editProfile");
}
function sendData(funcName) {
Meteor.call(funcName, Session.get("serverData"));
Meteor.call(funcName, serverData);
}
function getProfileData() {

View File

@ -26,3 +26,4 @@ themeColors = {
}
};
serverData = null;