Fix merge conflict
This commit is contained in:
commit
c2d06c9036
@ -1,3 +1,4 @@
|
|||||||
|
/* jshint esversion: 6 */
|
||||||
import {
|
import {
|
||||||
Template
|
Template
|
||||||
} from 'meteor/templating';
|
} from 'meteor/templating';
|
||||||
@ -22,6 +23,18 @@ var workColors = {
|
|||||||
"other": "#852E6D"
|
"other": "#852E6D"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Creates variables for due dates
|
||||||
|
|
||||||
|
var ref = {
|
||||||
|
"1 Day": 1,
|
||||||
|
"2 Days": 2,
|
||||||
|
"1 Week": 7,
|
||||||
|
"1 Month": 30,
|
||||||
|
"Never": 0,
|
||||||
|
"Yes": true,
|
||||||
|
"No": false
|
||||||
|
};
|
||||||
|
|
||||||
// Reactive variables.
|
// Reactive variables.
|
||||||
Session.set("user",null);
|
Session.set("user",null);
|
||||||
Session.set("calendarClasses", null);
|
Session.set("calendarClasses", null);
|
||||||
@ -73,7 +86,9 @@ Template.registerHelper('myClasses', () => { // Gets all classes and respective
|
|||||||
var hide = Session.get("user").preferences.timeHide;
|
var hide = Session.get("user").preferences.timeHide;
|
||||||
|
|
||||||
for (var i = 0; i < courses.length; i++) { // For each user class.
|
for (var i = 0; i < courses.length; i++) { // For each user class.
|
||||||
found = classes.findOne({_id:courses[i]});
|
found = classes.findOne({
|
||||||
|
_id: courses[i]
|
||||||
|
});
|
||||||
found.subscribers = found.subscribers.length;
|
found.subscribers = found.subscribers.length;
|
||||||
found.mine = true;
|
found.mine = true;
|
||||||
if (found.admin === Meteor.userId()) { // If user owns this class.
|
if (found.admin === Meteor.userId()) { // If user owns this class.
|
||||||
@ -83,7 +98,9 @@ Template.registerHelper('myClasses', () => { // Gets all classes and respective
|
|||||||
if (classDisp.indexOf(courses[i]) !== -1) found.selected = true; // Filter selected.
|
if (classDisp.indexOf(courses[i]) !== -1) found.selected = true; // Filter selected.
|
||||||
array.push(found);
|
array.push(found);
|
||||||
|
|
||||||
var thisWork = work.find({class: courses[i]}).fetch();
|
var thisWork = work.find({
|
||||||
|
class: courses[i]
|
||||||
|
}).fetch();
|
||||||
|
|
||||||
if (classDisp.length !== 0 && classDisp.indexOf(found._id) === -1) { // Filter classes based on filter.
|
if (classDisp.length !== 0 && classDisp.indexOf(found._id) === -1) { // Filter classes based on filter.
|
||||||
array[i].thisClassWork = [];
|
array[i].thisClassWork = [];
|
||||||
@ -92,13 +109,14 @@ Template.registerHelper('myClasses', () => { // Gets all classes and respective
|
|||||||
|
|
||||||
for (var j = 0; j < thisWork.length; j++) { // For each work in class.
|
for (var j = 0; j < thisWork.length; j++) { // For each work in class.
|
||||||
if (hide !== 0) { // Time to hide isn't never.
|
if (hide !== 0) { // Time to hide isn't never.
|
||||||
var due = (moment(thisWork[j].dueDate))["_d"];
|
var due = (moment(thisWork[j].dueDate))._d;
|
||||||
var offset = (moment().subtract(hide,'days'))["_d"];
|
var offset = (moment().subtract(hide, 'days'))._d;
|
||||||
if (offset > due) { // If due is before hide days before today
|
if (offset > due) { // If due is before hide days before today
|
||||||
thisWork[j] = "no";
|
thisWork[j] = "no";
|
||||||
j = 0;
|
j = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(thisWork[j] !== "no" && Session.get("user").preferences.done) { // If done filter is true
|
if(thisWork[j] !== "no" && Session.get("user").preferences.done) { // If done filter is true
|
||||||
if(thisWork[j].done.indexOf(Meteor.userId()) !== -1) { // If user marked this work done.
|
if(thisWork[j].done.indexOf(Meteor.userId()) !== -1) { // If user marked this work done.
|
||||||
thisWork[j] = "no";
|
thisWork[j] = "no";
|
||||||
@ -109,7 +127,7 @@ Template.registerHelper('myClasses', () => { // Gets all classes and respective
|
|||||||
}
|
}
|
||||||
while (thisWork.indexOf("no") !== -1) thisWork.splice(thisWork.indexOf("no"), 1); // Splice all filtered works.
|
while (thisWork.indexOf("no") !== -1) thisWork.splice(thisWork.indexOf("no"), 1); // Splice all filtered works.
|
||||||
|
|
||||||
for(var j = 0; j < thisWork.length; j++) {
|
for (j = 0; j < thisWork.length; j++) {
|
||||||
thisWork[j].realDate = thisWork[j].dueDate;
|
thisWork[j].realDate = thisWork[j].dueDate;
|
||||||
thisWork[j].dueDate = moment(thisWork[j].dueDate).calendar(null, {
|
thisWork[j].dueDate = moment(thisWork[j].dueDate).calendar(null, {
|
||||||
sameDay: '[Today]',
|
sameDay: '[Today]',
|
||||||
@ -127,8 +145,8 @@ Template.registerHelper('myClasses', () => { // Gets all classes and respective
|
|||||||
}
|
}
|
||||||
thisWork[j].typeColor = workColors[thisWork[j].type];
|
thisWork[j].typeColor = workColors[thisWork[j].type];
|
||||||
|
|
||||||
thisWork[j].confirmationLength = thisWork[j].confirmations.length // Counts the number of confirmations and reports for a particular work.
|
thisWork[j].confirmationLength = thisWork[j].confirmations.length; // Counts the number of confirmations and reports for a particular work.
|
||||||
thisWork[j].reportLength = thisWork[j].reports.length
|
thisWork[j].reportLength = thisWork[j].reports.length;
|
||||||
|
|
||||||
var hoverHighlight = Session.get("classDispHover"); // Highlight/scale related class works on hover.
|
var hoverHighlight = Session.get("classDispHover"); // Highlight/scale related class works on hover.
|
||||||
if (hoverHighlight !== null && hoverHighlight === found._id) {
|
if (hoverHighlight !== null && hoverHighlight === found._id) {
|
||||||
@ -172,13 +190,11 @@ Template.main.helpers({
|
|||||||
defaultMode() { //Loads the default display mode for user.
|
defaultMode() { //Loads the default display mode for user.
|
||||||
if(load) {
|
if(load) {
|
||||||
Session.set("mode",Session.get("user").preferences.mode);
|
Session.set("mode",Session.get("user").preferences.mode);
|
||||||
load = false;
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
bgSrc() { // Returns background.
|
bgSrc() { // Returns background.
|
||||||
var pic = "Backgrounds/"+themeColors[Session.get("user").preferences.theme].background;
|
return "Backgrounds/"+ themeColors[Session.get("user").preferences.theme].background;
|
||||||
return pic;
|
|
||||||
},
|
},
|
||||||
menuStatus() { // Status of of menu sidebar.
|
menuStatus() { // Status of of menu sidebar.
|
||||||
if (Session.equals("sidebar", "menuContainer")) {
|
if (Session.equals("sidebar", "menuContainer")) {
|
||||||
@ -199,11 +215,8 @@ Template.main.helpers({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
modeStatus(status) { // Color status of display modes.
|
modeStatus(status) { // Color status of display modes.
|
||||||
if (Session.equals("mode",status)) {
|
if (!Session.equals("mode",status)) return;
|
||||||
return themeColors[Session.get("user").preferences.theme].highlightText;
|
return themeColors[Session.get("user").preferences.theme].highlightText;
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
currMode(name) { // Status of display mode.
|
currMode(name) { // Status of display mode.
|
||||||
var mode = Session.get("mode");
|
var mode = Session.get("mode");
|
||||||
@ -232,7 +245,9 @@ Template.main.helpers({
|
|||||||
var works = userClasses[i].thisClassWork;
|
var works = userClasses[i].thisClassWork;
|
||||||
for (var j = 0; j < works.length; j++) {
|
for (var j = 0; j < works.length; j++) {
|
||||||
var work = works[j];
|
var work = works[j];
|
||||||
var currClass = classes.findOne({_id: work.class})
|
var currClass = classes.findOne({
|
||||||
|
_id: work.class
|
||||||
|
});
|
||||||
var inRole = false;
|
var inRole = false;
|
||||||
|
|
||||||
if (Meteor.userId() === work.creator ||
|
if (Meteor.userId() === work.creator ||
|
||||||
@ -249,13 +264,15 @@ Template.main.helpers({
|
|||||||
borderColor: "#444",
|
borderColor: "#444",
|
||||||
startEditable: inRole,
|
startEditable: inRole,
|
||||||
className: "workevent " + work.class,
|
className: "workevent " + work.class,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
callback(events);
|
callback(events);
|
||||||
},
|
},
|
||||||
eventDrop: function(event, delta, revertFunc) { // When user drops from click-dragging.
|
eventDrop: function(event, delta, revertFunc) { // When user drops from click-dragging.
|
||||||
var current = work.findOne({_id:event.id});
|
var current = work.findOne({
|
||||||
|
_id: event.id
|
||||||
|
});
|
||||||
var date = event.start.format().split("-");
|
var date = event.start.format().split("-");
|
||||||
current.dueDate = new Date(date[0], parseInt(date[1]) - 1, date[2], 11, 59, 59);
|
current.dueDate = new Date(date[0], parseInt(date[1]) - 1, date[2], 11, 59, 59);
|
||||||
serverData = current;
|
serverData = current;
|
||||||
@ -263,7 +280,9 @@ Template.main.helpers({
|
|||||||
},
|
},
|
||||||
eventClick: function(event, jsEvent, view) { // On-click for work.
|
eventClick: function(event, jsEvent, view) { // On-click for work.
|
||||||
Session.set("newWork", false);
|
Session.set("newWork", false);
|
||||||
var thisWork = work.findOne({_id:event.id})
|
var thisWork = work.findOne({
|
||||||
|
_id: event.id
|
||||||
|
});
|
||||||
Session.set("currentWork", thisWork);
|
Session.set("currentWork", thisWork);
|
||||||
var thisReadWork = formReadable(thisWork);
|
var thisReadWork = formReadable(thisWork);
|
||||||
Session.set("currentReadableWork", thisReadWork);
|
Session.set("currentReadableWork", thisReadWork);
|
||||||
@ -286,7 +305,6 @@ Template.main.helpers({
|
|||||||
calColor() { // Sets the color of the calendar according to theme
|
calColor() { // Sets the color of the calendar according to theme
|
||||||
return "color:"+themeColors[Session.get("user").preferences.theme].calendar;
|
return "color:"+themeColors[Session.get("user").preferences.theme].calendar;
|
||||||
},
|
},
|
||||||
|
|
||||||
calCreWork() { // Display instructions for creating a work.
|
calCreWork() { // Display instructions for creating a work.
|
||||||
if (Session.get("calCreWork")) return true;
|
if (Session.get("calCreWork")) return true;
|
||||||
return false;
|
return false;
|
||||||
@ -358,7 +376,9 @@ Template.main.helpers({
|
|||||||
if (Session.get("newWork")) {
|
if (Session.get("newWork")) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
var currClass = classes.findOne({_id: Session.get("currentWork")["class"]})
|
var currClass = classes.findOne({
|
||||||
|
_id: Session.get("currentWork")["class"]
|
||||||
|
});
|
||||||
if (Meteor.userId() === Session.get("currentWork").creator ||
|
if (Meteor.userId() === Session.get("currentWork").creator ||
|
||||||
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
||||||
currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
|
currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
|
||||||
@ -370,7 +390,8 @@ Template.main.helpers({
|
|||||||
if (Session.get("refetchEvents")) {
|
if (Session.get("refetchEvents")) {
|
||||||
$("#fullcalendar").fullCalendar('refetchEvents');
|
$("#fullcalendar").fullCalendar('refetchEvents');
|
||||||
Session.set("refetchEvents", null);
|
Session.set("refetchEvents", null);
|
||||||
} }
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.main.events({
|
Template.main.events({
|
||||||
@ -421,10 +442,11 @@ Template.main.events({
|
|||||||
!event.target.parentNode.className.includes("workOptions") &&
|
!event.target.parentNode.className.includes("workOptions") &&
|
||||||
!event.target.parentNode.className.includes("prefOptions") &&
|
!event.target.parentNode.className.includes("prefOptions") &&
|
||||||
event.target.readOnly !== true) {
|
event.target.readOnly !== true) {
|
||||||
|
var radio;
|
||||||
if (Session.equals("sidebar", "optionsContainer") || Session.equals("sidebar", "both")) {
|
if (Session.equals("sidebar", "optionsContainer") || Session.equals("sidebar", "both")) {
|
||||||
var radio = "prefOptions";
|
radio = "prefOptions";
|
||||||
} else {
|
} else {
|
||||||
var radio = "workOptions";
|
radio = "workOptions";
|
||||||
}
|
}
|
||||||
for (var i = 0; i < document.getElementsByClassName(radio).length; i++) {
|
for (var i = 0; i < document.getElementsByClassName(radio).length; i++) {
|
||||||
try {
|
try {
|
||||||
@ -479,10 +501,11 @@ Template.main.events({
|
|||||||
Session.set("sidebar", null); // Closes all sidebars.
|
Session.set("sidebar", null); // Closes all sidebars.
|
||||||
},
|
},
|
||||||
'click .creWork' (event) { // Cick add work button.
|
'click .creWork' (event) { // Cick add work button.
|
||||||
|
var attr;
|
||||||
if (event.target.className !== "creWork") {
|
if (event.target.className !== "creWork") {
|
||||||
var attr = event.target.parentNode.getAttribute("classid");
|
attr = event.target.parentNode.getAttribute("classid");
|
||||||
} else {
|
} else {
|
||||||
var attr = event.target.getAttribute("classid");
|
attr = event.target.getAttribute("classid");
|
||||||
}
|
}
|
||||||
Session.set("newWork", true);
|
Session.set("newWork", true);
|
||||||
Session.set("currentReadableWork", // Default readable work.
|
Session.set("currentReadableWork", // Default readable work.
|
||||||
@ -493,7 +516,9 @@ Template.main.events({
|
|||||||
description: "Click here to edit...",
|
description: "Click here to edit...",
|
||||||
type: "Click here to edit..."
|
type: "Click here to edit..."
|
||||||
});
|
});
|
||||||
Session.set("currentWork",{class:attr});
|
Session.set("currentWork", {
|
||||||
|
class: attr
|
||||||
|
});
|
||||||
openDivFade(document.getElementsByClassName("overlay")[0]);
|
openDivFade(document.getElementsByClassName("overlay")[0]);
|
||||||
},
|
},
|
||||||
'click .workCard' (event) { // Display work information on work card click.
|
'click .workCard' (event) { // Display work information on work card click.
|
||||||
@ -502,26 +527,32 @@ Template.main.events({
|
|||||||
workid = event.target.getAttribute("workid");
|
workid = event.target.getAttribute("workid");
|
||||||
|
|
||||||
Session.set("newWork", false);
|
Session.set("newWork", false);
|
||||||
var thisWork = work.findOne({_id:workid});
|
var thisWork = work.findOne({
|
||||||
|
_id: workid
|
||||||
|
});
|
||||||
Session.set("currentWork", thisWork);
|
Session.set("currentWork", thisWork);
|
||||||
var thisReadWork = formReadable(thisWork);
|
var thisReadWork = formReadable(thisWork);
|
||||||
Session.set("currentReadableWork", thisReadWork);
|
Session.set("currentReadableWork", thisReadWork);
|
||||||
|
|
||||||
if (!Session.get("newWork") && !document.getElementById("optionsContainer").contains(event.target)) {
|
if (!Session.get("newWork") && !document.getElementById("optionsContainer").contains(event.target)) {
|
||||||
var currClass = classes.findOne({_id: Session.get("currentWork")["class"]});
|
var currClass = classes.findOne({
|
||||||
|
_id: Session.get("currentWork")["class"]
|
||||||
|
});
|
||||||
if (!(Meteor.userId() === Session.get("currentWork").creator || // If user has permission.
|
if (!(Meteor.userId() === Session.get("currentWork").creator || // If user has permission.
|
||||||
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
||||||
currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
|
currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
|
||||||
currClass.banned.indexOf(Meteor.userId()) !== -1)) {
|
currClass.banned.indexOf(Meteor.userId()) !== -1)) {
|
||||||
var inputs = $('#editWork .change').css("cursor", "default");
|
var inputs = $('#editWork .change').css("cursor", "default");
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
openDivFade(document.getElementsByClassName("overlay")[0]);
|
openDivFade(document.getElementsByClassName("overlay")[0]);
|
||||||
},
|
},
|
||||||
// HANDLING INPUT CHANGING
|
// HANDLING INPUT CHANGING
|
||||||
'click .change' (event) { // Click changable inputs. Creates an input where the span is.
|
'click .change' (event) { // Click changable inputs. Creates an input where the span is.
|
||||||
if (!Session.get("newWork") && !document.getElementById("optionsContainer").contains(event.target)) {
|
if (!Session.get("newWork") && !document.getElementById("optionsContainer").contains(event.target)) {
|
||||||
var currClass = classes.findOne({_id: Session.get("currentWork")["class"]});
|
var currClass = classes.findOne({
|
||||||
|
_id: Session.get("currentWork")["class"]
|
||||||
|
});
|
||||||
if (!(Meteor.userId() === Session.get("currentWork").creator || // If user has permission.
|
if (!(Meteor.userId() === Session.get("currentWork").creator || // If user has permission.
|
||||||
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
||||||
currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
|
currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
|
||||||
@ -582,7 +613,9 @@ Template.main.events({
|
|||||||
},
|
},
|
||||||
'click .radio' (event) { // Click dropdown input. Opens the dropdown menu.
|
'click .radio' (event) { // Click dropdown input. Opens the dropdown menu.
|
||||||
if (!Session.get("newWork") && !document.getElementById("optionsContainer").contains(event.target)) {
|
if (!Session.get("newWork") && !document.getElementById("optionsContainer").contains(event.target)) {
|
||||||
var currClass = classes.findOne({_id: Session.get("currentWork")["class"]});
|
var currClass = classes.findOne({
|
||||||
|
_id: Session.get("currentWork")["class"]
|
||||||
|
});
|
||||||
if (!(Meteor.userId() === Session.get("currentWork").creator ||
|
if (!(Meteor.userId() === Session.get("currentWork").creator ||
|
||||||
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
||||||
currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
|
currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
|
||||||
@ -591,10 +624,11 @@ Template.main.events({
|
|||||||
}
|
}
|
||||||
|
|
||||||
var op = event.target;
|
var op = event.target;
|
||||||
|
var radio;
|
||||||
if (Session.equals("sidebar", "optionsContainer") || Session.equals("sidebar", "both")) {
|
if (Session.equals("sidebar", "optionsContainer") || Session.equals("sidebar", "both")) {
|
||||||
var radio = "prefOptions";
|
radio = "prefOptions";
|
||||||
} else {
|
} else {
|
||||||
var radio = "workOptions";
|
radio = "workOptions";
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
for (var i = 0; i < document.getElementsByClassName(radio).length; i++) { // Close any previously open menus.
|
for (var i = 0; i < document.getElementsByClassName(radio).length; i++) { // Close any previously open menus.
|
||||||
@ -657,7 +691,9 @@ Template.main.events({
|
|||||||
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) {
|
||||||
var thisWork = work.findOne({_id:workId});
|
var thisWork = work.findOne({
|
||||||
|
_id: workId
|
||||||
|
});
|
||||||
Session.set("currentWork", thisWork);
|
Session.set("currentWork", thisWork);
|
||||||
var thisReadWork = formReadable(thisWork);
|
var thisReadWork = formReadable(thisWork);
|
||||||
Session.set("currentReadableWork", thisReadWork);
|
Session.set("currentReadableWork", thisReadWork);
|
||||||
@ -680,7 +716,7 @@ Template.main.events({
|
|||||||
sendData("deleteWork");
|
sendData("deleteWork");
|
||||||
closeDivFade(document.getElementsByClassName("overlay")[0]);
|
closeDivFade(document.getElementsByClassName("overlay")[0]);
|
||||||
},
|
},
|
||||||
'keyup #workComment' (event) { // Restrict length on comment.
|
'input #workComment' (event) { // Restrict length on comment.
|
||||||
var chars = 200 - 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 === 200) { // Don't display if nothing in comment.
|
if (chars === 200) { // Don't display if nothing in comment.
|
||||||
@ -689,19 +725,18 @@ Template.main.events({
|
|||||||
} else if (chars === 0) {
|
} else if (chars === 0) {
|
||||||
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: " + chars.toString());
|
Session.set("commentRestrict", chars.toString() + " characters left");
|
||||||
|
|
||||||
},
|
},
|
||||||
'click #markDone' () { // Click done button.
|
'click #markDone' () { // Click done button.
|
||||||
serverData = [Session.get("currentWork")._id, "done"]
|
serverData = [Session.get("currentWork")._id, "done"];
|
||||||
sendData("toggleWork");
|
sendData("toggleWork");
|
||||||
},
|
},
|
||||||
'click #markConfirm' () { // Click confirm button.
|
'click #markConfirm' () { // Click confirm button.
|
||||||
serverData = [Session.get("currentWork")._id, "confirmations"]
|
serverData = [Session.get("currentWork")._id, "confirmations"];
|
||||||
sendData("toggleWork");
|
sendData("toggleWork");
|
||||||
},
|
},
|
||||||
'click #markReport' () { // Click report button.
|
'click #markReport' () { // Click report button.
|
||||||
serverData = [Session.get("currentWork")._id, "reports"]
|
serverData = [Session.get("currentWork")._id, "reports"];
|
||||||
sendData("toggleWork");
|
sendData("toggleWork");
|
||||||
},
|
},
|
||||||
// CLASS FILTERS
|
// CLASS FILTERS
|
||||||
@ -715,17 +750,19 @@ Template.main.events({
|
|||||||
Session.set("sidebar", null);
|
Session.set("sidebar", null);
|
||||||
|
|
||||||
var date = calWorkDate.split("-");
|
var date = calWorkDate.split("-");
|
||||||
var date = new Date(date[0],parseInt(date[1])-1,date[2],11,59,59);
|
date = new Date(date[0], parseInt(date[1]) - 1, date[2], 11, 59, 59);
|
||||||
Session.set("newWork", true);
|
Session.set("newWork", true);
|
||||||
Session.set("currentReadableWork",
|
Session.set("currentReadableWork", {
|
||||||
{
|
|
||||||
name: "Name | Click here to edit...",
|
name: "Name | Click here to edit...",
|
||||||
class: classid,
|
class: classid,
|
||||||
dueDate: getReadableDate(date),
|
dueDate: getReadableDate(date),
|
||||||
description: "Click here to edit...",
|
description: "Click here to edit...",
|
||||||
type: "Click here to edit..."
|
type: "Click here to edit..."
|
||||||
});
|
});
|
||||||
Session.set("currentWork",{class:classid,dueDate:date});
|
Session.set("currentWork", {
|
||||||
|
class: classid,
|
||||||
|
dueDate: date
|
||||||
|
});
|
||||||
openDivFade(document.getElementsByClassName("overlay")[0]);
|
openDivFade(document.getElementsByClassName("overlay")[0]);
|
||||||
} else { // Normal clicking turns on filter.
|
} else { // Normal clicking turns on filter.
|
||||||
var array = Session.get("classDisp");
|
var array = Session.get("classDisp");
|
||||||
@ -741,10 +778,11 @@ Template.main.events({
|
|||||||
Session.set("classDisp", []);
|
Session.set("classDisp", []);
|
||||||
},
|
},
|
||||||
'mouseover .sideClass' (event) { // Highlight/scale filter on-hover.
|
'mouseover .sideClass' (event) { // Highlight/scale filter on-hover.
|
||||||
|
var div;
|
||||||
if (event.target.className !== "sideClass") {
|
if (event.target.className !== "sideClass") {
|
||||||
var div = event.target.parentNode;
|
div = event.target.parentNode;
|
||||||
} else {
|
} else {
|
||||||
var div = event.target;
|
div = event.target;
|
||||||
}
|
}
|
||||||
while (div.getAttribute("classid") === null) div = div.parentNode;
|
while (div.getAttribute("classid") === null) div = div.parentNode;
|
||||||
var classid = div.getAttribute("classid");
|
var classid = div.getAttribute("classid");
|
||||||
@ -778,7 +816,9 @@ function sendData(funcName) { // Call Meteor function, and do actions after func
|
|||||||
Meteor.call(funcName, serverData, function(err, result) {
|
Meteor.call(funcName, serverData, function(err, result) {
|
||||||
if (funcName === "toggleWork") {
|
if (funcName === "toggleWork") {
|
||||||
var workId = Session.get("currentWork")._id;
|
var workId = Session.get("currentWork")._id;
|
||||||
var thisWork = work.findOne({_id:workId});
|
var thisWork = work.findOne({
|
||||||
|
_id: workId
|
||||||
|
});
|
||||||
Session.set("currentWork", thisWork);
|
Session.set("currentWork", thisWork);
|
||||||
var thisReadWork = formReadable(thisWork);
|
var thisReadWork = formReadable(thisWork);
|
||||||
Session.set("currentReadableWork", thisReadWork);
|
Session.set("currentReadableWork", thisReadWork);
|
||||||
@ -789,10 +829,11 @@ function sendData(funcName) { // Call Meteor function, and do actions after func
|
|||||||
function closeInput(modifyingInput) { // Close a changeable input and change it back to span.
|
function closeInput(modifyingInput) { // Close a changeable input and change it back to span.
|
||||||
var input = document.getElementById(modifyingInput + "a");
|
var input = document.getElementById(modifyingInput + "a");
|
||||||
var span = document.getElementById(modifyingInput);
|
var span = document.getElementById(modifyingInput);
|
||||||
|
var color;
|
||||||
if (Session.equals("sidebar", "optionsContainer") || Session.equals("sidebar", "both")) {
|
if (Session.equals("sidebar", "optionsContainer") || Session.equals("sidebar", "both")) {
|
||||||
var color = "#000";
|
color = "#000";
|
||||||
} else {
|
} else {
|
||||||
var color = "#8C8C8C";
|
color = "#8C8C8C";
|
||||||
}
|
}
|
||||||
span.style.color = color;
|
span.style.color = color;
|
||||||
input.parentNode.removeChild(input);
|
input.parentNode.removeChild(input);
|
||||||
@ -883,7 +924,11 @@ function formReadable(input) { // Makes work information readable by users.
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < input.done.length; i++) { // Display users who marked as done.
|
for (var i = 0; i < input.done.length; i++) { // Display users who marked as done.
|
||||||
input.done[i] = {"user":Meteor.users.findOne({_id:input.done[i]}).profile.name};
|
input.done[i] = {
|
||||||
|
"user": Meteor.users.findOne({
|
||||||
|
_id: input.done[i]
|
||||||
|
}).profile.name
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.confirmations.indexOf(Meteor.userId()) !== -1) { // If user confirmed.
|
if (input.confirmations.indexOf(Meteor.userId()) !== -1) { // If user confirmed.
|
||||||
@ -906,8 +951,14 @@ function formReadable(input) { // Makes work information readable by users.
|
|||||||
if (!Session.get("newWork")) { // Don't display comments if user is creating work.
|
if (!Session.get("newWork")) { // Don't display comments if user is creating work.
|
||||||
for (var k = 0; k < comments.length; k++) {
|
for (var k = 0; k < comments.length; k++) {
|
||||||
var re = comments.length - k - 1;
|
var re = comments.length - k - 1;
|
||||||
resort[re] = {"comment":comments[k].comment,"date":null,"user":null};
|
resort[re] = {
|
||||||
resort[re].user = Meteor.users.findOne({_id:comments[k].user}).profile.name;
|
"comment": comments[k].comment,
|
||||||
|
"date": null,
|
||||||
|
"user": null
|
||||||
|
};
|
||||||
|
resort[re].user = Meteor.users.findOne({
|
||||||
|
_id: comments[k].user
|
||||||
|
}).profile.name;
|
||||||
resort[re].date = moment(comments[k].date).fromNow();
|
resort[re].date = moment(comments[k].date).fromNow();
|
||||||
}
|
}
|
||||||
input.comments = resort;
|
input.comments = resort;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
//meteor things
|
/* jshint esversion: 6 */
|
||||||
import {
|
import {
|
||||||
Meteor
|
Meteor
|
||||||
} from 'meteor/meteor';
|
} from 'meteor/meteor';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user