Fixed comments

This commit is contained in:
Kenneth Jao 2016-09-02 00:34:40 -04:00
parent fabe20ddfe
commit 7eebae2b9f
3 changed files with 8 additions and 9 deletions

View File

@ -802,7 +802,7 @@ input, textarea {
#comment { #comment {
width: 105%; width: 105%;
position: relative; position: relative;
overflow-y: scroll; overflow-y: auto;
} }
.commentBox { .commentBox {

View File

@ -676,6 +676,7 @@ Template.main.events({
var input = document.getElementById('workComment'); var input = document.getElementById('workComment');
comment = input.value; comment = input.value;
input.value = ""; input.value = "";
Session.set("commentRestrict",null);
if (comment !== "") { if (comment !== "") {
document.getElementById('workComment').value = ""; document.getElementById('workComment').value = "";
Meteor.call('addComment', [comment, workId], function(err,result) { Meteor.call('addComment', [comment, workId], function(err,result) {
@ -702,18 +703,16 @@ Template.main.events({
sendData("deleteWork"); sendData("deleteWork");
closeDivFade(document.getElementsByClassName("overlay")[0]); closeDivFade(document.getElementsByClassName("overlay")[0]);
}, },
'keydown #workComment' (event) { // Restrict length on comment. 'keyup #workComment' (event) { // Restrict length on comment.
var chars = event.target.value.length; var chars = 200-event.target.value.length;
document.getElementById("commentRestrict").style.color = "#7E7E7E"; document.getElementById("commentRestrict").style.color = "#7E7E7E";
if(chars === 0) { // Don't display if nothing in comment. if(chars === 200) { // Don't display if nothing in comment.
Session.set("commentRestrict",""); Session.set("commentRestrict","");
return; return;
} } else if(chars === 0) {
if(chars === 200) {
document.getElementById("commentRestrict").style.color = "#FF1A1A"; // Make text red if 0 characters left. document.getElementById("commentRestrict").style.color = "#FF1A1A"; // Make text red if 0 characters left.
} }
Session.set("commentRestrict", "Characters left: " + (200-chars).toString()); Session.set("commentRestrict", "Characters left: " + chars.toString());
}, },
'click #markDone' () { // Click done button. 'click #markDone' () { // Click done button.

View File

@ -392,7 +392,7 @@ Meteor.methods({
var foundsubs = currentclass.subscribers; var foundsubs = currentclass.subscribers;
if (typeof comment === "string" && comment.length <= 200 && if (typeof comment === "string" && comment.length <= 200 &&
_.contains(foundsubs, Meteor.userId()) && _.contains(foundsubs, Meteor.userId()) &&
_.contains(currentclass.banned, Meteor.userId())) { !_.contains(currentclass.banned, Meteor.userId())) {
var commentInfo = { var commentInfo = {
"comment": input[0], "comment": input[0],
"user": user, "user": user,