2016-08-12 12:28:55 -04:00
|
|
|
|
import {
|
|
|
|
|
|
Template
|
|
|
|
|
|
} from 'meteor/templating';
|
2016-08-10 00:25:19 -04:00
|
|
|
|
|
2016-08-12 20:42:29 -04:00
|
|
|
|
|
|
|
|
|
|
Meteor.subscribe('schools');
|
|
|
|
|
|
Meteor.subscribe('classes');
|
|
|
|
|
|
Meteor.subscribe('work');
|
|
|
|
|
|
|
2016-08-12 12:28:55 -04:00
|
|
|
|
Session.set("profInputOpen", null);
|
|
|
|
|
|
Session.set("profClassTab", "manClass");
|
|
|
|
|
|
Session.set("modifying", null);
|
|
|
|
|
|
Session.set("radioDiv", null);
|
|
|
|
|
|
Session.set("notsearching", true);
|
|
|
|
|
|
Session.set("confirm", null);
|
|
|
|
|
|
Session.set("serverData", null);
|
2016-08-10 21:56:12 -04:00
|
|
|
|
Session.set("autocompleteDivs", null);
|
2016-08-12 12:28:55 -04:00
|
|
|
|
Session.set("confirmText", null);
|
2016-08-10 00:25:19 -04:00
|
|
|
|
|
2016-08-10 15:28:21 -04:00
|
|
|
|
var themeColors = {
|
2016-08-12 12:28:55 -04:00
|
|
|
|
"light": {
|
|
|
|
|
|
"header": "#EBEBEB",
|
|
|
|
|
|
"sidebar": "#65839A",
|
|
|
|
|
|
"statusIcons": "#33ADFF",
|
|
|
|
|
|
"highlightText": "#FF1A1A",
|
|
|
|
|
|
"cards": "#FEFEFE"
|
|
|
|
|
|
},
|
|
|
|
|
|
"dark": {
|
2016-08-10 15:28:21 -04:00
|
|
|
|
|
2016-08-12 12:28:55 -04:00
|
|
|
|
}
|
2016-08-10 15:28:21 -04:00
|
|
|
|
};
|
|
|
|
|
|
|
2016-08-10 00:25:19 -04:00
|
|
|
|
Template.profile.helpers({
|
2016-08-12 12:28:55 -04:00
|
|
|
|
classsettings: function() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
position: "bottom",
|
|
|
|
|
|
limit: 10,
|
|
|
|
|
|
rules: [{
|
|
|
|
|
|
token: '',
|
|
|
|
|
|
collection: classes,
|
|
|
|
|
|
field: "name",
|
|
|
|
|
|
template: Template.classDisplay,
|
|
|
|
|
|
filter: {
|
2016-08-12 16:12:03 -04:00
|
|
|
|
privacy: false,
|
2016-08-12 12:28:55 -04:00
|
|
|
|
status: true
|
|
|
|
|
|
}
|
|
|
|
|
|
}]
|
|
|
|
|
|
};
|
|
|
|
|
|
},
|
|
|
|
|
|
schoolcomplete() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
position: "bottom",
|
|
|
|
|
|
limit: 6,
|
|
|
|
|
|
rules: [{
|
|
|
|
|
|
token: '',
|
|
|
|
|
|
collection: schools,
|
|
|
|
|
|
field: 'name',
|
|
|
|
|
|
matchAll: true,
|
|
|
|
|
|
template: Template.schoollist
|
|
|
|
|
|
}]
|
|
|
|
|
|
};
|
|
|
|
|
|
},
|
|
|
|
|
|
teachercomplete() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
position: "bottom",
|
|
|
|
|
|
limit: 1,
|
|
|
|
|
|
rules: [{
|
|
|
|
|
|
token: '',
|
|
|
|
|
|
collection: classes,
|
|
|
|
|
|
field: 'teacher',
|
|
|
|
|
|
template: Template.teacherlist
|
|
|
|
|
|
}]
|
|
|
|
|
|
};
|
|
|
|
|
|
},
|
|
|
|
|
|
mainCenter() {
|
|
|
|
|
|
var width = window.innerWidth * 1600 / 1920 + 10;
|
|
|
|
|
|
return "width:" + width.toString() + "px;margin-left:" + -0.5 * width.toString() + "px";
|
|
|
|
|
|
},
|
|
|
|
|
|
mainHeight() {
|
|
|
|
|
|
return window.innerHeight.toString() + "px";
|
|
|
|
|
|
},
|
|
|
|
|
|
banner() {
|
|
|
|
|
|
var width = window.innerWidth * 1600 / 1920;
|
|
|
|
|
|
var height = width * 615 / 1600;
|
2016-08-13 20:52:47 -04:00
|
|
|
|
if (Meteor.user().profile.banner !== undefined) {
|
2016-08-12 12:28:55 -04:00
|
|
|
|
var banner = Meteor.user().profile.banner;
|
|
|
|
|
|
} else {
|
2016-08-12 18:27:03 -04:00
|
|
|
|
var banner = "Banners/defaultcover.jpg";
|
|
|
|
|
|
currentprofile = Meteor.user().profile;
|
|
|
|
|
|
currentprofile.banner = banner
|
|
|
|
|
|
Meteor.call("editProfile", currentprofile);
|
2016-08-12 12:28:55 -04:00
|
|
|
|
}
|
2016-08-12 18:27:03 -04:00
|
|
|
|
return "width:" + width.toString() + "px;height:" + height.toString() + "px;background-image:url(" + banner + ");background-size:" + width.toString() + "px " + height.toString() + "px";
|
2016-08-12 12:28:55 -04:00
|
|
|
|
},
|
|
|
|
|
|
avatar() {
|
|
|
|
|
|
var dim = window.innerWidth * 1600 / 1920 * 0.16;
|
2016-08-13 20:52:47 -04:00
|
|
|
|
if (Meteor.user().profile.avatar !== undefined) {
|
2016-08-13 09:02:04 -04:00
|
|
|
|
var pic = Meteor.user().profile.avatar + ".png";
|
2016-08-12 12:28:55 -04:00
|
|
|
|
} else {
|
2016-08-12 18:27:03 -04:00
|
|
|
|
var pic = "Avatars/" + (Math.floor(Math.random() * (11 - 1)) + 1).toString(); + ".png";
|
|
|
|
|
|
currentprofile = Meteor.user().profile;
|
|
|
|
|
|
currentprofile.avatar = pic
|
|
|
|
|
|
Meteor.call("editProfile", currentprofile);
|
2016-08-12 12:28:55 -04:00
|
|
|
|
}
|
|
|
|
|
|
return "background-image:url(" + pic + ");background-size:" + dim.toString() + "px " + dim.toString() + "px";
|
|
|
|
|
|
},
|
|
|
|
|
|
avatarDim() {
|
|
|
|
|
|
var dim = window.innerWidth * 1600 / 1920 * 0.16;
|
|
|
|
|
|
return "height:" + dim.toString() + "px;width:" + dim.toString() + "px;top:" + 0.43 * window.innerHeight.toString() + "px;";
|
|
|
|
|
|
},
|
|
|
|
|
|
username() {
|
|
|
|
|
|
return Meteor.user().profile.name;
|
|
|
|
|
|
},
|
|
|
|
|
|
motd() {
|
2016-08-12 18:27:03 -04:00
|
|
|
|
if (Meteor.user().profile.description) {
|
2016-08-12 12:28:55 -04:00
|
|
|
|
return Meteor.user().profile.description;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return "Say something about yourself!";
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
school() {
|
2016-08-12 18:27:03 -04:00
|
|
|
|
if (Meteor.user().profile.school) {
|
2016-08-12 12:28:55 -04:00
|
|
|
|
return Meteor.user().profile.school;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return "Click here to edit...";
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
grade() {
|
2016-08-12 18:27:03 -04:00
|
|
|
|
if (Meteor.user().profile.grade) {
|
2016-08-12 12:28:55 -04:00
|
|
|
|
return Meteor.user().profile.grade + "th";
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return "Click here to edit...";
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
classes() {
|
2016-08-12 17:07:12 -04:00
|
|
|
|
return classes.find(
|
|
|
|
|
|
{
|
|
|
|
|
|
status: {$eq: true},
|
|
|
|
|
|
privacy: {$eq: false}
|
|
|
|
|
|
},
|
|
|
|
|
|
{sort: {subscribers: -1 }},
|
|
|
|
|
|
{limit: 20}
|
|
|
|
|
|
).fetch();
|
2016-08-12 12:28:55 -04:00
|
|
|
|
},
|
|
|
|
|
|
profClassHeight() {
|
|
|
|
|
|
return 0.6 * window.innerHeight.toString() + "px";
|
|
|
|
|
|
},
|
|
|
|
|
|
classHolderHeight() {
|
|
|
|
|
|
return 0.26 * window.innerHeight.toString() + "px";
|
|
|
|
|
|
},
|
|
|
|
|
|
profClassTabColor(status) {
|
|
|
|
|
|
if (status === Session.get("profClassTab")) {
|
|
|
|
|
|
return themeColors[Cookie.get("theme")].highlightText;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
profClassTab(tab) {
|
|
|
|
|
|
if (tab === Session.get("profClassTab")) {
|
|
|
|
|
|
return true;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
notsearching() {
|
|
|
|
|
|
return Session.get("notsearching");
|
|
|
|
|
|
},
|
|
|
|
|
|
autocompleteClasses() {
|
|
|
|
|
|
return Session.get("autocompleteDivs");
|
|
|
|
|
|
},
|
2016-08-12 17:07:12 -04:00
|
|
|
|
myclasses() {
|
2016-08-12 12:28:55 -04:00
|
|
|
|
if (Meteor.user().profile.classes === undefined || Meteor.user().profile.classes.length === 0) {
|
|
|
|
|
|
return [];
|
|
|
|
|
|
} else {
|
2016-08-12 17:07:12 -04:00
|
|
|
|
var array = [];
|
|
|
|
|
|
var courses = Meteor.user().profile.classes;
|
|
|
|
|
|
for(var i = 0; i < courses.length; i++) {
|
|
|
|
|
|
array.push(classes.findOne({_id:courses[i]}));
|
|
|
|
|
|
}
|
|
|
|
|
|
return array;
|
2016-08-12 12:28:55 -04:00
|
|
|
|
}
|
2016-08-12 17:07:12 -04:00
|
|
|
|
},
|
2016-08-12 12:28:55 -04:00
|
|
|
|
notfound() {
|
|
|
|
|
|
return Session.get("notfound");
|
|
|
|
|
|
},
|
|
|
|
|
|
confirmText() {
|
|
|
|
|
|
return Session.get("confirmText");
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2016-08-10 00:25:19 -04:00
|
|
|
|
|
|
|
|
|
|
Template.profile.events({
|
2016-08-12 12:28:55 -04:00
|
|
|
|
'click profOptions p' (event) {
|
|
|
|
|
|
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 sessval = Session.get("modifying");
|
|
|
|
|
|
if (ele.id !== sessval && sessval !== null) closeInput(sessval);
|
2016-08-10 00:25:19 -04:00
|
|
|
|
|
2016-08-12 12:28:55 -04:00
|
|
|
|
Session.set("modifying", ele.id);
|
|
|
|
|
|
var dim = ele.getBoundingClientRect();
|
|
|
|
|
|
ele.style.display = "none";
|
|
|
|
|
|
var input = document.createElement("input");
|
2016-08-11 18:28:29 -04:00
|
|
|
|
|
2016-08-12 12:28:55 -04:00
|
|
|
|
if (ele.getAttribute("type") !== null) {
|
|
|
|
|
|
input.type = ele.getAttribute("type");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
input.type = "text";
|
|
|
|
|
|
}
|
|
|
|
|
|
input.value = ele.childNodes[0].nodeValue;
|
|
|
|
|
|
input.className = "changeInput";
|
|
|
|
|
|
input.style.height = 0.9 * dim.height.toString() + "px";
|
|
|
|
|
|
input.style.width = "70%";
|
|
|
|
|
|
input.style.padding = "0.1%";
|
|
|
|
|
|
input.id = ele.id + "a";
|
|
|
|
|
|
input.setAttribute("opc", ele.getAttribute("opc"));
|
|
|
|
|
|
ele.parentNode.appendChild(input);
|
|
|
|
|
|
if (ele.getAttribute("re") == "readonly") {
|
|
|
|
|
|
input.readOnly = true;
|
|
|
|
|
|
input.className += " op";
|
|
|
|
|
|
input.style.cursor = "pointer";
|
|
|
|
|
|
} else {
|
|
|
|
|
|
input.select();
|
|
|
|
|
|
}
|
|
|
|
|
|
input.focus();
|
|
|
|
|
|
if (ele.getAttribute("restrict") !== null) {
|
|
|
|
|
|
var span = document.createElement("span");
|
|
|
|
|
|
span.id = "restrict";
|
|
|
|
|
|
var num = parseInt(ele.getAttribute("restrict")) - input.value.length;
|
|
|
|
|
|
if (num <= 0) {
|
|
|
|
|
|
span.style.setProperty("color", "#FF1A1A", "important");
|
|
|
|
|
|
num = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
span.appendChild(document.createTextNode(num.toString() + " characters left"));
|
|
|
|
|
|
ele.parentNode.appendChild(span);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
'click' (event) {
|
|
|
|
|
|
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") &&
|
|
|
|
|
|
!Session.equals("radioDiv", null) &&
|
|
|
|
|
|
!event.target.parentNode.className.includes("profOptions") &&
|
|
|
|
|
|
event.target.readOnly !== true) {
|
|
|
|
|
|
var opnum = (parseInt(Session.get("radioDiv")) - parseInt(Session.get("radioOffset"))).toString();
|
|
|
|
|
|
for (var i = 0; i < document.getElementsByClassName("profOptions").length; i++) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
closeDivFade(document.getElementsByClassName("profOptions")[i]);
|
|
|
|
|
|
} catch (err) {}
|
|
|
|
|
|
}
|
|
|
|
|
|
Session.set("radioDiv", null);
|
|
|
|
|
|
Session.set("radioOffset", null);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
'keydown' (event) {
|
|
|
|
|
|
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) {
|
|
|
|
|
|
var op = event.target;
|
|
|
|
|
|
Session.set("radioDiv", op.getAttribute("op"));
|
|
|
|
|
|
Session.set("radioOffset", op.getAttribute("opc"));
|
|
|
|
|
|
try {
|
|
|
|
|
|
for (var i = 0; i < document.getElementsByClassName("profOptions").length; i++) {
|
|
|
|
|
|
var curr = document.getElementsByClassName("profOptions")[i];
|
|
|
|
|
|
if (Session.get("radioDiv") !== i.toString()) {
|
|
|
|
|
|
closeDivFade(document.getElementsByClassName("profOptions")[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (err) {}
|
|
|
|
|
|
openDivFade(document.getElementsByClassName("profOptions")[op.getAttribute("op")]);
|
|
|
|
|
|
},
|
|
|
|
|
|
'click .profOptions p' (event) {
|
|
|
|
|
|
var sessval = Session.get("modifying");
|
|
|
|
|
|
var p = event.target;
|
2016-08-13 18:58:54 -04:00
|
|
|
|
var opnum = parseInt(Session.get("radioDiv")) - parseInt(Session.get("radioOffset"));
|
2016-08-12 12:28:55 -04:00
|
|
|
|
var input = document.getElementsByClassName("op")[opnum];
|
|
|
|
|
|
input.value = p.childNodes[0].nodeValue;
|
|
|
|
|
|
try {
|
|
|
|
|
|
closeInput(sessval);
|
|
|
|
|
|
} catch (err) {}
|
2016-08-11 18:28:29 -04:00
|
|
|
|
|
2016-08-12 12:28:55 -04:00
|
|
|
|
closeDivFade(p.parentNode);
|
|
|
|
|
|
input.focus();
|
|
|
|
|
|
Session.set("radioDiv", null);
|
|
|
|
|
|
Session.set("radioOffset", null);
|
|
|
|
|
|
},
|
|
|
|
|
|
'click .addClass' () {
|
|
|
|
|
|
var functionHolder = document.getElementById("profClassInfoHolder");
|
|
|
|
|
|
closeDivFade(functionHolder);
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
|
Session.set("profClassTab", "addClass");
|
|
|
|
|
|
openDivFade(functionHolder);
|
|
|
|
|
|
}, 300);
|
|
|
|
|
|
},
|
2016-08-12 17:07:12 -04:00
|
|
|
|
'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);
|
2016-08-12 12:28:55 -04:00
|
|
|
|
},
|
|
|
|
|
|
'click .fa-search' () {
|
|
|
|
|
|
Session.set("searching", true);
|
|
|
|
|
|
},
|
|
|
|
|
|
'click .fa-times-thin' () {
|
|
|
|
|
|
Session.set("searching", false);
|
|
|
|
|
|
},
|
|
|
|
|
|
'keydown #profClassSearch' (event) {
|
|
|
|
|
|
if (event.target.value === "") {
|
|
|
|
|
|
Session.set("notsearching", true);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Session.set("notsearching", false);
|
|
|
|
|
|
}
|
|
|
|
|
|
Session.set("autocompleteDivs", null);
|
|
|
|
|
|
var divs = [];
|
|
|
|
|
|
try {
|
|
|
|
|
|
var items = document.getElementsByClassName("-autocomplete-container")[0].childNodes[3].childNodes;
|
|
|
|
|
|
if (items.length === 0) {
|
|
|
|
|
|
Session.set("notfound", true);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Session.set("notfound", false);
|
|
|
|
|
|
}
|
|
|
|
|
|
for (var i = 2; i < items.length; i += 3) {
|
|
|
|
|
|
var item = items[i].childNodes[3];
|
|
|
|
|
|
divs.push({
|
|
|
|
|
|
name: item.childNodes[1].childNodes[0].nodeValue,
|
|
|
|
|
|
teacher: item.childNodes[3].childNodes[0].nodeValue,
|
|
|
|
|
|
hour: item.childNodes[5].childNodes[0].nodeValue,
|
|
|
|
|
|
subscribers: item.childNodes[7].childNodes[0].nodeValue,
|
|
|
|
|
|
_id: item.getAttribute("classid")
|
|
|
|
|
|
});
|
|
|
|
|
|
Session.set("autocompleteDivs", divs);
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (err) {}
|
|
|
|
|
|
},
|
|
|
|
|
|
'click .classBox' (event) {
|
2016-08-12 17:07:12 -04:00
|
|
|
|
if (event.target.id === "label" || Session.get("profClassTab") === "manClass") return;
|
2016-08-12 12:28:55 -04:00
|
|
|
|
if (event.target.className !== "classBox") {
|
|
|
|
|
|
var attribute = event.target.parentNode.getAttribute("classid");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
var attribute = event.target.getAttribute("classid");
|
|
|
|
|
|
}
|
|
|
|
|
|
var data = [attribute, ""];
|
|
|
|
|
|
Session.set("serverData", data);
|
|
|
|
|
|
Session.set("confirm", "joinClass");
|
|
|
|
|
|
Session.set("confirmText", "Join class?");
|
2016-08-11 18:28:29 -04:00
|
|
|
|
|
2016-08-12 12:28:55 -04:00
|
|
|
|
openDivFade(document.getElementsByClassName("overlay")[0]);
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
|
document.getElementsByClassName("overlay")[0].style.opacity = "1";
|
|
|
|
|
|
}, 200);
|
|
|
|
|
|
},
|
|
|
|
|
|
'click .fa-check-circle-o' () {
|
|
|
|
|
|
sendData(Session.get("confirm"));
|
|
|
|
|
|
closeDivFade(document.getElementsByClassName("overlay")[0]);
|
2016-08-12 17:35:29 -04:00
|
|
|
|
if(Session.get("confirm") === "createClass") {
|
|
|
|
|
|
var form = document.getElementById("create");
|
|
|
|
|
|
for(var i = 0; i < form.length; i++) form[i].value = "";
|
|
|
|
|
|
}
|
2016-08-12 12:28:55 -04:00
|
|
|
|
Session.set("serverData", null);
|
|
|
|
|
|
Session.set("confirm", null);
|
|
|
|
|
|
},
|
|
|
|
|
|
'click .fa-times-circle-o' () {
|
|
|
|
|
|
closeDivFade(document.getElementsByClassName("overlay")[0]);
|
|
|
|
|
|
Session.set("serverData", null);
|
|
|
|
|
|
Session.set("confirm", null);
|
|
|
|
|
|
},
|
|
|
|
|
|
'click #save' () {
|
|
|
|
|
|
Session.set("serverData", getProfileData());
|
|
|
|
|
|
Session.set("confirm", "editProfile");
|
|
|
|
|
|
Session.set("confirmText", "Save new profile settings?");
|
|
|
|
|
|
|
|
|
|
|
|
openDivFade(document.getElementsByClassName("overlay")[0]);
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
|
document.getElementsByClassName("overlay")[0].style.opacity = "1";
|
|
|
|
|
|
}, 200);
|
|
|
|
|
|
},
|
|
|
|
|
|
'click #creSubmit' () {
|
|
|
|
|
|
var data = getCreateFormData();
|
|
|
|
|
|
if (data === null) return;
|
|
|
|
|
|
Session.set("serverData", data);
|
|
|
|
|
|
Session.set("confirm", "createClass");
|
|
|
|
|
|
Session.set("confirmText", "Submit request?");
|
|
|
|
|
|
|
|
|
|
|
|
openDivFade(document.getElementsByClassName("overlay")[0]);
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
|
document.getElementsByClassName("overlay")[0].style.opacity = "1";
|
|
|
|
|
|
}, 200);
|
|
|
|
|
|
},
|
|
|
|
|
|
'focus .op' (event) {
|
|
|
|
|
|
event.target.click();
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2016-08-10 00:25:19 -04:00
|
|
|
|
|
|
|
|
|
|
function openDivFade(div) {
|
2016-08-12 12:28:55 -04:00
|
|
|
|
if (div.className === "profOptions") {
|
|
|
|
|
|
div.style.display = "inline-block";
|
|
|
|
|
|
} else {
|
|
|
|
|
|
div.style.display = "block";
|
|
|
|
|
|
}
|
|
|
|
|
|
div.style.opacity = "0";
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
|
div.style.opacity = "1";
|
|
|
|
|
|
}, 100);
|
2016-08-10 00:25:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function closeDivFade(div) {
|
2016-08-12 12:28:55 -04:00
|
|
|
|
div.style.opacity = "0";
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
|
div.style.display = "none";
|
|
|
|
|
|
}, 100);
|
2016-08-10 00:25:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function closeInput(sessval) {
|
2016-08-12 12:28:55 -04:00
|
|
|
|
var input = document.getElementById(sessval + "a");
|
|
|
|
|
|
var span = document.getElementById(sessval);
|
|
|
|
|
|
input.parentNode.removeChild(input);
|
|
|
|
|
|
try {
|
|
|
|
|
|
var restrict = document.getElementById("restrict");
|
|
|
|
|
|
restrict.parentNode.removeChild(restrict);
|
|
|
|
|
|
} catch (err) {}
|
|
|
|
|
|
if (input.value === "") {
|
|
|
|
|
|
span.childNodes[0].nodeValue = "Click here to edit...";
|
|
|
|
|
|
} else {
|
|
|
|
|
|
span.childNodes[0].nodeValue = input.value;
|
|
|
|
|
|
}
|
|
|
|
|
|
span.style.display = "initial";
|
|
|
|
|
|
Session.set("modifying", null);
|
2016-08-12 18:27:03 -04:00
|
|
|
|
Session.set("serverData", getProfileData());
|
|
|
|
|
|
sendData("editProfile");
|
2016-08-10 00:25:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-08-10 21:56:12 -04:00
|
|
|
|
function sendData(funcName) {
|
2016-08-12 12:28:55 -04:00
|
|
|
|
Meteor.call(funcName, Session.get("serverData"));
|
2016-08-11 01:53:24 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getProfileData() {
|
2016-08-12 12:28:55 -04:00
|
|
|
|
var description = document.getElementById("motd").childNodes[0].nodeValue;
|
|
|
|
|
|
var school = document.getElementById("school").childNodes[0].nodeValue;
|
|
|
|
|
|
var gradein = document.getElementById("grade").childNodes[0].nodeValue;
|
|
|
|
|
|
var grade = parseInt(gradein.substring(gradein.length - 2, gradein));
|
|
|
|
|
|
var avatar = document.getElementById("profAvatar").style.backgroundImage.replace(")", "").replace("url(", "").replace("\"", "").replace("\"", "");
|
|
|
|
|
|
var banner = document.getElementById("profBanner").style.backgroundImage.replace(")", "").replace("url(", "").replace("\"", "").replace("\"", "");
|
2016-08-11 18:28:29 -04:00
|
|
|
|
|
2016-08-12 12:28:55 -04:00
|
|
|
|
return {
|
|
|
|
|
|
school: school,
|
|
|
|
|
|
grade: grade,
|
|
|
|
|
|
description: description,
|
|
|
|
|
|
avatar: avatar,
|
|
|
|
|
|
banner: banner
|
|
|
|
|
|
};
|
2016-08-11 18:28:29 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getCreateFormData() {
|
2016-08-12 12:28:55 -04:00
|
|
|
|
var stop;
|
|
|
|
|
|
var form = document.getElementsByClassName("creInput");
|
|
|
|
|
|
for (var i = 0; i < form.length; i++) {
|
|
|
|
|
|
if (form[i].value === "") {
|
|
|
|
|
|
form[i].focus();
|
|
|
|
|
|
form[i].placeholder = "Missing field";
|
|
|
|
|
|
form[i].className += " formInvalid";
|
|
|
|
|
|
stop = true;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
form[i].className = form[i].className.replace(" formInvalid", "");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (stop) return null;
|
2016-08-11 18:28:29 -04:00
|
|
|
|
|
2016-08-12 12:28:55 -04:00
|
|
|
|
var school = form[0].value;
|
|
|
|
|
|
var hour = form[1].value;
|
|
|
|
|
|
var teacher = form[2].value;
|
|
|
|
|
|
var name = form[3].value;
|
2016-08-12 15:55:35 -04:00
|
|
|
|
if (form[4].value == "Public") {
|
2016-08-12 12:28:55 -04:00
|
|
|
|
var privacy = false;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
var privacy = true;
|
|
|
|
|
|
}
|
2016-08-12 15:55:35 -04:00
|
|
|
|
var category = form[5].value.toLowerCase();
|
2016-08-12 12:28:55 -04:00
|
|
|
|
return {
|
|
|
|
|
|
school: school,
|
|
|
|
|
|
hour: hour,
|
|
|
|
|
|
teacher: teacher,
|
|
|
|
|
|
name: name,
|
|
|
|
|
|
privacy: privacy,
|
|
|
|
|
|
category: category,
|
|
|
|
|
|
status: false,
|
|
|
|
|
|
code: ""
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|