Fixed couldn't add work, and minor profile bug

This commit is contained in:
Kenneth Jao 2016-08-28 13:12:41 -04:00
parent 38eba83101
commit a15e588c92
2 changed files with 29 additions and 29 deletions

View File

@ -364,6 +364,7 @@ Template.main.helpers({
return "width:"+w.toString()+"px;height:"+h.toString()+"px;margin-left:"+-0.5*w.toString()+"px;margin-top:"+-0.5*h.toString()+"px";
},
commentDim() {
if(Session.get("newWork") || Session.get("newWork") === null) return;
var work = Session.get("currentWork");
if(work === null) return;
if(work.comments.length <= 3) return;
@ -482,10 +483,11 @@ Template.main.events({
if(getHomeworkFormData() === null) return;
Session.set("serverData",Session.get("currentWork"));
sendData("editWork");
document.getElementById("workComment").value = "";
}
Session.set("newWork",null);
Session.set("commentRestrict",null);
document.getElementById("workComment").value = "";
}
if (event.target.id !== sessval &&
@ -624,7 +626,7 @@ Template.main.events({
} catch (err) {}
openDivFade(document.getElementsByClassName(radio)[op.getAttribute("op")]);
},
'click .workOptions p' (event) {
'click .workOptionText' (event) {
var sessval = Session.get("modifying");
var p = event.target;
var opnum = parseInt(Session.get("radioDiv")) - parseInt(Session.get("radioOffset"));
@ -639,7 +641,7 @@ Template.main.events({
Session.set("radioDiv", null);
Session.set("radioOffset", null);
},
'click .prefOptions p' (event) {
'click .prefOptionText' (event) {
var sessval = Session.get("modifying");
var p = event.target;
var opnum = parseInt(Session.get("radioDiv")) - parseInt(Session.get("radioOffset"));
@ -920,6 +922,7 @@ function formReadable(input) {
input.type = input.type[0].toUpperCase() + input.type.slice(1);
var comments = input.comments;
var resort = [];
if(!Session.get("newWork")) {
for(var k = 0; k < comments.length; k++) {
var re = comments.length-k-1;
resort[re] = {"comment":comments[k].comment,"date":null,"user":null};
@ -934,5 +937,6 @@ function formReadable(input) {
});
}
input.comments = resort;
}
return input;
}

View File

@ -340,7 +340,7 @@ Template.profile.events({
} catch (err) {}
openDivFade(document.getElementsByClassName("profOptions")[op.getAttribute("op")]);
},
'click .profOptions p' (event) { // When someone selects "drop-down item"
'click .profOptionText' (event) { // When someone selects "drop-down item"
var sessval = Session.get("modifying");
var p = event.target;
var opnum = parseInt(Session.get("radioDiv")) - parseInt(Session.get("radioOffset"));
@ -610,20 +610,16 @@ function sendData(funcName) {
}
function getProfileData() {
var description = document.getElementById("motd").childNodes[0].nodeValue;
var school = document.getElementById("school").childNodes[0].nodeValue;
var profile = Meteor.user().profile;
profile.description = document.getElementById("motd").childNodes[0].nodeValue;
profile.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("\"", "");
profile.grade = parseInt(gradein.substring(gradein.length - 2, gradein));
profile.avatar = document.getElementById("profAvatar").style.backgroundImage.replace(")", "").replace("url(", "").replace("\"", "").replace("\"", "");
profile.banner = document.getElementById("profBanner").style.backgroundImage.replace(")", "").replace("url(", "").replace("\"", "").replace("\"", "");
profile.preferences = Meteor.user().profile.preferences;
return {
school: school,
grade: grade,
description: description,
avatar: avatar,
banner: banner
};
return profile;
}
function getCreateFormData() {