merge
This commit is contained in:
commit
8205a253e7
@ -88,10 +88,10 @@
|
|||||||
font-size: 3.5vh;
|
font-size: 3.5vh;
|
||||||
width: 12vw;
|
width: 12vw;
|
||||||
margin-top: 4vh;
|
margin-top: 4vh;
|
||||||
/* margin-left: 16vw; */
|
margin-left: 5vw;
|
||||||
padding: 1vh;
|
padding: 1vh;
|
||||||
|
background-color: #27A127;
|
||||||
|
|
||||||
border: 1px solid #FCF0F0;
|
|
||||||
-moz-border-radius: 4px;
|
-moz-border-radius: 4px;
|
||||||
-webkit-border-radius: 4px;
|
-webkit-border-radius: 4px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
@ -106,7 +106,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.loginButtons:hover {
|
.loginButtons:hover {
|
||||||
background-color: rgba(0,0,0,0.2);
|
background-color: #239023;
|
||||||
}
|
}
|
||||||
|
|
||||||
#loginContainer {
|
#loginContainer {
|
||||||
@ -114,7 +114,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#demoButton {
|
#demoButton {
|
||||||
margin-left: 11vw;
|
border: 1px solid #FCF0F0;
|
||||||
|
background-color: rgba(0,0,0,0);
|
||||||
|
margin-left: 4vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
#demoButton:hover {
|
||||||
|
background-color: rgba(255,255,255,0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#version {
|
#version {
|
||||||
|
|||||||
@ -18,9 +18,9 @@
|
|||||||
<h1>Everything in</h1>
|
<h1>Everything in</h1>
|
||||||
<h2>One Place.</h2>
|
<h2>One Place.</h2>
|
||||||
<h5><b>We</b> handle the organization, <b>you</b> handle the work.</h5>
|
<h5><b>We</b> handle the organization, <b>you</b> handle the work.</h5>
|
||||||
<div id="loginContainer" >
|
<div id="loginContainer">
|
||||||
<div class="loginButtons" onclick="document.getElementById('login-buttons-google').click()">Sign in!</div>
|
<div class="loginButtons" onclick="document.getElementById('login-buttons-google').click()">Sign in!</div>
|
||||||
<div class="loginButtons" id="demoButton">Demo</div>
|
<div class="loginButtons" id="demoButton" onclick="Session.set('demo',true);">Demo</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -33,10 +33,12 @@ Session.set("confirmText", ""); // Stores text for confirmations.
|
|||||||
// On render actions
|
// On render actions
|
||||||
|
|
||||||
Meteor.autorun(function () { // Disconnect checking
|
Meteor.autorun(function () { // Disconnect checking
|
||||||
|
if (Session.get("demo")) return;
|
||||||
if (Meteor.status().status !== "connected" && Meteor.status().status !== "connecting" && !disconnect) {
|
if (Meteor.status().status !== "connected" && Meteor.status().status !== "connecting" && !disconnect) {
|
||||||
disconnect = true;
|
disconnect = true;
|
||||||
var div = document.createElement("div");
|
var div = document.createElement("div");
|
||||||
div.id = "disconnect";
|
div.id = "disconnect";
|
||||||
|
div.style.color = "#FFF";
|
||||||
var h = document.createElement("h3");
|
var h = document.createElement("h3");
|
||||||
h.appendChild(document.createTextNode("Uh Oh. We can't reach you right now!"));
|
h.appendChild(document.createTextNode("Uh Oh. We can't reach you right now!"));
|
||||||
var h2 = document.createElement("h4");
|
var h2 = document.createElement("h4");
|
||||||
@ -75,10 +77,98 @@ Template.login.rendered = function() {
|
|||||||
Accounts._loginButtonsSession.set('dropdownVisible', true);
|
Accounts._loginButtonsSession.set('dropdownVisible', true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function randInt(min,max) {
|
||||||
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||||
|
}
|
||||||
|
|
||||||
Template.main.created = function() {
|
Template.main.created = function() {
|
||||||
Session.set("mode", Session.get("user").preferences.mode);
|
Session.set("mode", Session.get("user").preferences.mode);
|
||||||
Session.set("myWork", []);
|
Session.set("myWork", []);
|
||||||
Session.set("filterWork", []);
|
Session.set("filterWork", []);
|
||||||
|
if(Session.get("demo")) {
|
||||||
|
var classes = ["Biology", "Math", "Literature", "History"];
|
||||||
|
var names = ["Worksheet", "Problems", "Notes"];
|
||||||
|
var counter = 0;
|
||||||
|
for(var i = 0; i < classes.length; i++) {
|
||||||
|
for(var j = 0; j < randInt(1,3); j++) {
|
||||||
|
var nameInt = randInt(0,2);
|
||||||
|
var item = {
|
||||||
|
_id: counter.toString(),
|
||||||
|
class: classes[i],
|
||||||
|
dueDate: moment().endOf('day').add(randInt(1,5), "day").subtract(12, "hours").toDate(),
|
||||||
|
type: "normal",
|
||||||
|
name: names[nameInt] + ((nameInt === 0) ? " #"+randInt(1,8) : (nameInt === 1) ? " #"+randInt(1,9) + "-" + randInt(20,34) : " pg. "+randInt(90,120)+"-"+randInt(130,140)),
|
||||||
|
confirmationLength: randInt(1,10),
|
||||||
|
reportLength: randInt(0,6),
|
||||||
|
done: []
|
||||||
|
};
|
||||||
|
updateWork(counter.toString(), item, "added");
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateWork(counter.toString(), {
|
||||||
|
_id: counter.toString(),
|
||||||
|
class: "Math",
|
||||||
|
dueDate: moment().endOf('day').add(randInt(1,5), "day").subtract(12, "hours").toDate(),
|
||||||
|
type: "test",
|
||||||
|
name: "Math Test 3.1",
|
||||||
|
confirmationLength: randInt(1,10),
|
||||||
|
reportLength: randInt(0,6),
|
||||||
|
done: []
|
||||||
|
}, "added");
|
||||||
|
updateWork((counter+1).toString(), {
|
||||||
|
_id: (counter+1).toString(),
|
||||||
|
class: "Literature",
|
||||||
|
dueDate: moment().endOf('day').add(randInt(1,5), "day").subtract(12, "hours").toDate(),
|
||||||
|
type: "project",
|
||||||
|
name: "Poem Commentary",
|
||||||
|
confirmationLength: randInt(1,10),
|
||||||
|
reportLength: randInt(0,6),
|
||||||
|
done: []
|
||||||
|
}, "added");
|
||||||
|
updateWork((counter+2).toString(), {
|
||||||
|
_id: (counter+2).toString(),
|
||||||
|
class: "Biology",
|
||||||
|
dueDate: moment().endOf('day').add(randInt(1,5), "day").subtract(12, "hours").toDate(),
|
||||||
|
type: "quiz",
|
||||||
|
name: "Cell Respiration",
|
||||||
|
confirmationLength: randInt(1,10),
|
||||||
|
reportLength: randInt(0,6),
|
||||||
|
done: []
|
||||||
|
}, "added");
|
||||||
|
updateWork((counter+3).toString(), {
|
||||||
|
_id: (counter+3).toString(),
|
||||||
|
class: "Personal",
|
||||||
|
dueDate: moment().endOf('day').add(randInt(1,5), "day").subtract(12, "hours").toDate(),
|
||||||
|
type: "other",
|
||||||
|
name: "Clean Room",
|
||||||
|
confirmationLength: 1,
|
||||||
|
reportLength: 0,
|
||||||
|
done: []
|
||||||
|
}, "added");
|
||||||
|
|
||||||
|
var array = [];
|
||||||
|
var classes = ["Personal", "History", "Math", "Biology", "Literature"];
|
||||||
|
var prefix = ["Mr.", "Dr.", "Ms.", "Mrs."];
|
||||||
|
for(var i = 0; i < classes.length; i++) {
|
||||||
|
array.push({
|
||||||
|
box: " owned",
|
||||||
|
hour: (i === 0) ? "" : "A"+(i).toString(),
|
||||||
|
mine: false,
|
||||||
|
name: classes[i],
|
||||||
|
status: true,
|
||||||
|
category: (i === 0) ? "Personal" : "class",
|
||||||
|
selected: "rgba(0,0,0,0)",
|
||||||
|
subscribers: randInt(7,20),
|
||||||
|
_id: classes[i],
|
||||||
|
teacher: prefix[randInt(0,3)] + " Bot",
|
||||||
|
teachershort: "Bot"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Session.set("myClasses", array);
|
||||||
|
filterWork();
|
||||||
|
}
|
||||||
|
|
||||||
Session.set("classInfo", null);
|
Session.set("classInfo", null);
|
||||||
$(document).on('keyup', (e) => {
|
$(document).on('keyup', (e) => {
|
||||||
if(event.keyCode === 27 && $(".overlay").css("display") !== "none") {
|
if(event.keyCode === 27 && $(".overlay").css("display") !== "none") {
|
||||||
@ -86,7 +176,6 @@ Template.main.created = function() {
|
|||||||
Session.set("currentWork", null);
|
Session.set("currentWork", null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
work.find().observeChanges({
|
work.find().observeChanges({
|
||||||
added: function (id, fields) {
|
added: function (id, fields) {
|
||||||
updateWork(id, fields, "added");
|
updateWork(id, fields, "added");
|
||||||
@ -117,6 +206,8 @@ Template.main.rendered = function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
document.getElementsByTagName("body")[0].style.color = Session.get("user").preferences.theme.textColor;
|
document.getElementsByTagName("body")[0].style.color = Session.get("user").preferences.theme.textColor;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Template.classesMode.rendered = function() {
|
Template.classesMode.rendered = function() {
|
||||||
@ -187,7 +278,7 @@ Template.registerHelper('overlayDim', (part) => { // Gets size of the overlay co
|
|||||||
|
|
||||||
Template.registerHelper('myClasses', () => { // Gets all classes and respective works.
|
Template.registerHelper('myClasses', () => { // Gets all classes and respective works.
|
||||||
var myClasses = Session.get("user").classes;
|
var myClasses = Session.get("user").classes;
|
||||||
getClasses(myClasses);
|
if(!Session.get("demo")) getClasses(myClasses);
|
||||||
return Session.get("myClasses");
|
return Session.get("myClasses");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -236,6 +327,7 @@ Template.registerHelper('work', (value) => {// Returns the specified work value.
|
|||||||
if(Session.get("newWork")) {
|
if(Session.get("newWork")) {
|
||||||
switch(value) {
|
switch(value) {
|
||||||
case "class":
|
case "class":
|
||||||
|
if(Session.get("demo")) return thisWork["class"];
|
||||||
var id = thisWork["class"];
|
var id = thisWork["class"];
|
||||||
if(!id) return;
|
if(!id) return;
|
||||||
return (id === Meteor.userId()) ? "Personal" : classes.findOne({_id: id}).name;
|
return (id === Meteor.userId()) ? "Personal" : classes.findOne({_id: id}).name;
|
||||||
@ -258,6 +350,7 @@ Template.registerHelper('work', (value) => {// Returns the specified work value.
|
|||||||
case "name":
|
case "name":
|
||||||
return input.name;
|
return input.name;
|
||||||
case "class":
|
case "class":
|
||||||
|
if(Session.get("demo")) return thisWork["class"];
|
||||||
var id = input["class"];
|
var id = input["class"];
|
||||||
return (id === Meteor.userId()) ? "Personal" : classes.findOne({_id: id}).name;
|
return (id === Meteor.userId()) ? "Personal" : classes.findOne({_id: id}).name;
|
||||||
case "dueDate":
|
case "dueDate":
|
||||||
@ -304,35 +397,53 @@ Template.registerHelper('work', (value) => {// Returns the specified work value.
|
|||||||
return input.done;
|
return input.done;
|
||||||
case "doneCol":
|
case "doneCol":
|
||||||
if (Session.get("newWork")) return "";
|
if (Session.get("newWork")) return "";
|
||||||
if (!_.contains(input.done, Meteor.userId())) return "";
|
if (Session.get("demo")) {
|
||||||
|
if (input.done.length === 0) return "";
|
||||||
|
} else {
|
||||||
|
if (!_.contains(input.done, Meteor.userId())) return "";
|
||||||
|
}
|
||||||
return "#27A127";
|
return "#27A127";
|
||||||
case "doneText":
|
case "doneText":
|
||||||
if (Session.get("newWork")) return "";
|
if (Session.get("newWork")) return "";
|
||||||
if (!_.contains(input.done, Meteor.userId())) return "Mark done";
|
if (Session.get("demo")) {
|
||||||
|
if(input.done.length === 0) return "Mark done";
|
||||||
|
} else {
|
||||||
|
if (!_.contains(input.done, Meteor.userId())) return "Mark done";
|
||||||
|
}
|
||||||
return "Done!";
|
return "Done!";
|
||||||
case "doneIcon":
|
case "doneIcon":
|
||||||
if (Session.get("newWork")) return "";
|
if (Session.get("newWork")) return "";
|
||||||
if (!_.contains(input.done, Meteor.userId())) return "fa-square-o";
|
if(Session.get("demo")) {
|
||||||
|
if(input.done.length === 0) return "fa-square-o";
|
||||||
|
} else {
|
||||||
|
if (!_.contains(input.done, Meteor.userId())) return "fa-square-o";
|
||||||
|
}
|
||||||
return "fa-check-square-o";
|
return "fa-check-square-o";
|
||||||
case "userConfirm":
|
case "userConfirm":
|
||||||
|
if(Session.get("demo")) return "#27A127";
|
||||||
if (!_.contains(input.confirmations, Meteor.userId())) return (Meteor.Device.isPhone() || Meteor.Device.isTablet()) ? "rgb(101,101,101)" : "";
|
if (!_.contains(input.confirmations, Meteor.userId())) return (Meteor.Device.isPhone() || Meteor.Device.isTablet()) ? "rgb(101,101,101)" : "";
|
||||||
return "#27A127";
|
return "#27A127";
|
||||||
case "confirmations":
|
case "confirmations":
|
||||||
|
if(Session.get("demo")) return input.confirmationLength;
|
||||||
return input.confirmations.length;
|
return input.confirmations.length;
|
||||||
case "userReport":
|
case "userReport":
|
||||||
|
if(Session.get("demo")) return "";
|
||||||
if (!_.contains(input.reports, Meteor.userId())) return (Meteor.Device.isPhone() || Meteor.Device.isTablet()) ? "rgb(101,101,101)" : "";
|
if (!_.contains(input.reports, Meteor.userId())) return (Meteor.Device.isPhone() || Meteor.Device.isTablet()) ? "rgb(101,101,101)" : "";
|
||||||
return "#FF1A1A";
|
return "#FF1A1A";
|
||||||
case "reports":
|
case "reports":
|
||||||
|
if(Session.get("demo")) return input.reportLength;
|
||||||
return input.reports.length;
|
return input.reports.length;
|
||||||
case "email":
|
case "email":
|
||||||
return Meteor.users.findOne({
|
return Meteor.users.findOne({
|
||||||
_id: input.creator
|
_id: input.creator
|
||||||
}).services.google.email;
|
}).services.google.email;
|
||||||
case "avatar":
|
case "avatar":
|
||||||
|
if(Session.get("demo")) return "Logos/ColoredLogo.png";
|
||||||
return Meteor.users.findOne({
|
return Meteor.users.findOne({
|
||||||
_id: input.creator
|
_id: input.creator
|
||||||
}).services.google.picture;
|
}).services.google.picture;
|
||||||
case "creator":
|
case "creator":
|
||||||
|
if(Session.get("demo")) return "A. Robot";
|
||||||
return Meteor.users.findOne({
|
return Meteor.users.findOne({
|
||||||
_id: input.creator
|
_id: input.creator
|
||||||
}).profile.name;
|
}).profile.name;
|
||||||
@ -363,6 +474,7 @@ Template.main.helpers({
|
|||||||
return " - " + Session.get("user").school;
|
return " - " + Session.get("user").school;
|
||||||
},
|
},
|
||||||
avatar() { // Returns avatar.
|
avatar() { // Returns avatar.
|
||||||
|
if(Session.get("demo")) return "Logos/ColoredLogo.png";
|
||||||
try {
|
try {
|
||||||
return Meteor.user().services.google.picture;
|
return Meteor.user().services.google.picture;
|
||||||
} catch(err) {}
|
} catch(err) {}
|
||||||
@ -403,9 +515,15 @@ Template.main.helpers({
|
|||||||
eventLimit: 3,
|
eventLimit: 3,
|
||||||
events: Session.get("calendarEvents"),
|
events: Session.get("calendarEvents"),
|
||||||
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({
|
if(Session.get("demo")) {
|
||||||
_id: event.id
|
var current = Session.get("myWork").filter(function(obj) {
|
||||||
});
|
return obj._id === event.id;
|
||||||
|
})[0];
|
||||||
|
} else {
|
||||||
|
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);
|
||||||
if(Date.parse(new Date()) > Date.parse(current.dueDate)) {
|
if(Date.parse(new Date()) > Date.parse(current.dueDate)) {
|
||||||
@ -417,7 +535,13 @@ 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);
|
||||||
Session.set("currentWork", work.findOne({_id: event.id}));
|
if(Session.get("demo")) {
|
||||||
|
Session.set("currentWork", Session.get("myWork").filter(function(obj) {
|
||||||
|
return obj._id === event.id;
|
||||||
|
})[0]);
|
||||||
|
} else {
|
||||||
|
Session.set("currentWork", work.findOne({_id: event.id}));
|
||||||
|
}
|
||||||
$(".overlay").velocity("fadeIn", 150);
|
$(".overlay").velocity("fadeIn", 150);
|
||||||
$("#comment").slimScroll({
|
$("#comment").slimScroll({
|
||||||
width: '100%',
|
width: '100%',
|
||||||
@ -426,8 +550,15 @@ Template.main.helpers({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
eventMouseover: function(event, jsEvent, view) {
|
eventMouseover: function(event, jsEvent, view) {
|
||||||
var classid = work.findOne({_id: event.id})["class"];
|
if(Session.get("demo")) {
|
||||||
var className = (classid === Meteor.userId()) ? "Personal" : classes.findOne({_id: classid}).name;
|
var className = Session.get("myWork").filter(function(obj) {
|
||||||
|
return obj._id === event.id;
|
||||||
|
})[0].class;
|
||||||
|
} else {
|
||||||
|
var classid = work.findOne({_id: event.id})["class"];
|
||||||
|
var className = (classid === Meteor.userId()) ? "Personal" : classes.findOne({_id: classid}).name;
|
||||||
|
}
|
||||||
|
|
||||||
var span = this.children[0].children[0];
|
var span = this.children[0].children[0];
|
||||||
$(span).velocity("stop");
|
$(span).velocity("stop");
|
||||||
$(span).velocity({opacity:0}, 50, function() {
|
$(span).velocity({opacity:0}, 50, function() {
|
||||||
@ -437,7 +568,13 @@ Template.main.helpers({
|
|||||||
this.style.boxShadow = "inset 0 0 0 99999px rgba(255,255,255,0.2)";
|
this.style.boxShadow = "inset 0 0 0 99999px rgba(255,255,255,0.2)";
|
||||||
},
|
},
|
||||||
eventMouseout: function(event, jsEvent, view) {
|
eventMouseout: function(event, jsEvent, view) {
|
||||||
var workName = work.findOne({_id: event.id}).name;
|
if(Session.get("demo")) {
|
||||||
|
var workName = Session.get("myWork").filter(function(obj) {
|
||||||
|
return obj._id === event.id;
|
||||||
|
})[0].name;
|
||||||
|
} else {
|
||||||
|
var workName = work.findOne({_id: event.id}).name;
|
||||||
|
}
|
||||||
var span = this.children[0].children[0];
|
var span = this.children[0].children[0];
|
||||||
$(span).velocity("stop");
|
$(span).velocity("stop");
|
||||||
$(span).velocity({opacity:0}, 50, function() {
|
$(span).velocity({opacity:0}, 50, function() {
|
||||||
@ -483,6 +620,7 @@ Template.main.helpers({
|
|||||||
return Session.get("newWork");
|
return Session.get("newWork");
|
||||||
},
|
},
|
||||||
inRole() { // Checks correct permissions.
|
inRole() { // Checks correct permissions.
|
||||||
|
if(Session.get("demo")) return true;
|
||||||
if(Session.equals("currentWork",null)) return;
|
if(Session.equals("currentWork",null)) return;
|
||||||
try {
|
try {
|
||||||
var thisWork = work.findOne({
|
var thisWork = work.findOne({
|
||||||
@ -558,6 +696,14 @@ Template.main.events({
|
|||||||
toggleToSidebar("option");
|
toggleToSidebar("option");
|
||||||
},
|
},
|
||||||
'click .fa-question' (event) { // Click requests button.
|
'click .fa-question' (event) { // Click requests button.
|
||||||
|
if (Session.get("demo")) {
|
||||||
|
sAlert.error("Not available in demo!", {
|
||||||
|
effect: 'stackslide',
|
||||||
|
position: 'top',
|
||||||
|
timeout: 2000
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
toggleToSidebar("requests");
|
toggleToSidebar("requests");
|
||||||
},
|
},
|
||||||
'click .creWork' (event) { // Cick add work button.
|
'click .creWork' (event) { // Cick add work button.
|
||||||
@ -596,9 +742,15 @@ Template.main.events({
|
|||||||
'click .workCard' (event) { // Display work information on work card click.
|
'click .workCard' (event) { // Display work information on work card click.
|
||||||
if(event.target.className.indexOf("fa") !== -1) return;
|
if(event.target.className.indexOf("fa") !== -1) return;
|
||||||
var workid = event.target.getAttribute("workid");
|
var workid = event.target.getAttribute("workid");
|
||||||
var thisWork = work.findOne({
|
if(Session.get("demo")) {
|
||||||
_id: workid
|
var thisWork = Session.get("myWork").filter(function(obj) {
|
||||||
});
|
return obj._id === workid;
|
||||||
|
})[0];
|
||||||
|
} else {
|
||||||
|
var thisWork = work.findOne({
|
||||||
|
_id: workid
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Session.set("newWork", false);
|
Session.set("newWork", false);
|
||||||
Session.set("currentWork", thisWork);
|
Session.set("currentWork", thisWork);
|
||||||
@ -799,6 +951,14 @@ Template.main.events({
|
|||||||
},
|
},
|
||||||
// WORK OVERLAY BUTTONS
|
// WORK OVERLAY BUTTONS
|
||||||
'click #commentSubmit' (event) { // Click to submit a comment.
|
'click #commentSubmit' (event) { // Click to submit a comment.
|
||||||
|
if (Session.get("demo")) {
|
||||||
|
sAlert.error("Not available in demo!", {
|
||||||
|
effect: 'stackslide',
|
||||||
|
position: 'top',
|
||||||
|
timeout: 2000
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
workId = Session.get("currentWork")._id;
|
workId = Session.get("currentWork")._id;
|
||||||
var input = document.getElementById('workComment');
|
var input = document.getElementById('workComment');
|
||||||
comment = input.value;
|
comment = input.value;
|
||||||
@ -844,24 +1004,46 @@ Template.main.events({
|
|||||||
sendData("toggleWork");
|
sendData("toggleWork");
|
||||||
},
|
},
|
||||||
'click #markConfirm' () { // Click confirm button.
|
'click #markConfirm' () { // Click confirm button.
|
||||||
|
if (Session.get("demo")) {
|
||||||
|
sAlert.error("Not available in demo!", {
|
||||||
|
effect: 'stackslide',
|
||||||
|
position: 'top',
|
||||||
|
timeout: 2000
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
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.
|
||||||
|
if (Session.get("demo")) {
|
||||||
|
sAlert.error("Not available in demo!", {
|
||||||
|
effect: 'stackslide',
|
||||||
|
position: 'top',
|
||||||
|
timeout: 2000
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
serverData = [Session.get("currentWork")._id, "reports"];
|
serverData = [Session.get("currentWork")._id, "reports"];
|
||||||
sendData("toggleWork");
|
sendData("toggleWork");
|
||||||
},
|
},
|
||||||
'click .cWorkBottom .fa-thumbs-up' (event) {
|
'click .cWorkBottom .fa-thumbs-up' (event) {
|
||||||
|
if (Session.get("demo")) return;
|
||||||
serverData = [event.target.parentNode.parentNode.parentNode.parentNode.getAttribute("workid"), "confirmations"];
|
serverData = [event.target.parentNode.parentNode.parentNode.parentNode.getAttribute("workid"), "confirmations"];
|
||||||
sendData("toggleWork");
|
sendData("toggleWork");
|
||||||
},
|
},
|
||||||
'click .cWorkBottom .fa-exclamation-triangle' (event) {
|
'click .cWorkBottom .fa-exclamation-triangle' (event) {
|
||||||
|
if (Session.get("demo")) return;
|
||||||
serverData = [event.target.parentNode.parentNode.parentNode.parentNode.getAttribute("workid"), "reports"];
|
serverData = [event.target.parentNode.parentNode.parentNode.parentNode.getAttribute("workid"), "reports"];
|
||||||
sendData("toggleWork");
|
sendData("toggleWork");
|
||||||
},
|
},
|
||||||
'click #signout' () {
|
'click #signout' () {
|
||||||
$(".noScroll").velocity("fadeOut", 50);
|
$(".noScroll").velocity("fadeOut", 50);
|
||||||
Session.set('sidebarMode','');
|
Session.set('sidebarMode','');
|
||||||
|
if (Session.get("demo")) {
|
||||||
|
Session.set("demo", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
document.getElementById('login-buttons-logout').click();
|
document.getElementById('login-buttons-logout').click();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -897,35 +1079,62 @@ toggleOptionMenu = function(toggle, menu) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sendData = function(funcName) { // Call Meteor function, and do actions after function is completed depending on function.
|
sendData = function(funcName) { // Call Meteor function, and do actions after function is completed depending on function.
|
||||||
if(funcName === "editWork" || funcName === "createWork") {
|
if(Session.get("demo")) {
|
||||||
for(var key in serverData) {
|
var allWork = Session.get("myWork").concat(Session.get("filterWork"));
|
||||||
if(serverData[key] === true) serverData[key] = "";
|
if(funcName === "editProfile") {
|
||||||
}
|
Session.set("user", serverData);
|
||||||
|
} else if(funcName === "editWork") {
|
||||||
}
|
updateWork(serverData._id, serverData, "changed");
|
||||||
if(funcName === "editWork") workChanger = true;
|
} else if(funcName === "createWork") {
|
||||||
if(funcName === "editProfile") filterWork();
|
serverData._id = allWork.length;
|
||||||
Meteor.call(funcName, serverData, function(error, result) {
|
serverData.done = [];
|
||||||
if(funcName === "createWork") Session.set("currentWork", null);
|
serverData.confirmationLength = 1;
|
||||||
serverData = null;
|
serverData.reportLength = 0;
|
||||||
if (error !== undefined) {
|
updateWork(serverData._id, serverData, "added");
|
||||||
console.log(funcName);
|
} else if(funcName === "toggleWork") {
|
||||||
console.log(error);
|
var toggle = allWork.filter(function(obj) {
|
||||||
sAlert.error(error.error[1] || error.message, {
|
return serverData[0] === obj._id;
|
||||||
effect: 'stackslide',
|
})[0];
|
||||||
position: 'top'
|
if(toggle.done.length === 0) {
|
||||||
});
|
toggle.done = ["yes"];
|
||||||
} else {
|
} else {
|
||||||
if(funcName === "createClass") {
|
toggle.done = [];
|
||||||
var inputs = document.getElementsByClassName("creInput");
|
|
||||||
for(var i = 0; i < inputs.length; i++) {
|
|
||||||
inputs[i].value = "";
|
|
||||||
}
|
|
||||||
toggleToMode("manageClass");
|
|
||||||
}
|
}
|
||||||
|
updateWork(serverData[0], toggle, "changed");
|
||||||
|
} else if(funcName === "deleteWork") {
|
||||||
|
updateWork(serverData, null, "remove")
|
||||||
}
|
}
|
||||||
document.getElementsByTagName("body")[0].style.color = Session.get("user").preferences.theme.textColor;
|
filterWork();
|
||||||
});
|
} else {
|
||||||
|
if(funcName === "editWork" || funcName === "createWork") {
|
||||||
|
for(var key in serverData) {
|
||||||
|
if(serverData[key] === true) serverData[key] = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(funcName === "editWork") workChanger = true;
|
||||||
|
if(funcName === "editProfile") filterWork();
|
||||||
|
Meteor.call(funcName, serverData, function(error, result) {
|
||||||
|
if(funcName === "createWork") Session.set("currentWork", null);
|
||||||
|
serverData = null;
|
||||||
|
if (error !== undefined) {
|
||||||
|
console.log(funcName);
|
||||||
|
console.log(error);
|
||||||
|
sAlert.error(error.error[1] || error.message, {
|
||||||
|
effect: 'stackslide',
|
||||||
|
position: 'top'
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if(funcName === "createClass") {
|
||||||
|
var inputs = document.getElementsByClassName("creInput");
|
||||||
|
for(var i = 0; i < inputs.length; i++) {
|
||||||
|
inputs[i].value = "";
|
||||||
|
}
|
||||||
|
toggleToMode("manageClass");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
document.getElementsByTagName("body")[0].style.color = Session.get("user").preferences.theme.textColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeInput() { // Close a changeable input and change it back to span.
|
function closeInput() { // Close a changeable input and change it back to span.
|
||||||
@ -1078,21 +1287,30 @@ updateWork = function(id, fields, type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var workObj;
|
var workObj;
|
||||||
|
if(Session.get("demo")) {
|
||||||
if(type === "added") {
|
workObj = fields;
|
||||||
workObj = Object.assign({}, fields, {_id: id})
|
} else {
|
||||||
} else if(type === "changed") {
|
if(type === "added") {
|
||||||
workObj = work.findOne({_id: id});
|
workObj = Object.assign({}, fields, {_id: id});
|
||||||
|
} else if(type === "changed") {
|
||||||
|
workObj = work.findOne({_id: id});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Meteor.users.findOne({_id: workObj.creator}) === undefined) return;
|
if(!Session.get("demo")) {
|
||||||
if(Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) && !_.contains(Session.get("user").classes, workObj["class"])) return;
|
if(Meteor.users.findOne({_id: workObj.creator}) === undefined) return;
|
||||||
|
if(Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) && !_.contains(Session.get("user").classes, workObj["class"])) return;
|
||||||
|
}
|
||||||
|
|
||||||
workObj.classid = workObj.class;
|
workObj.classid = workObj.class;
|
||||||
|
|
||||||
workObj.shortname = (workObj.name.length <= 20) ? workObj.name : workObj.name.substring(0,20) + "...";
|
workObj.shortname = (workObj.name.length <= 20) ? workObj.name : workObj.name.substring(0,20) + "...";
|
||||||
workObj.className = (workObj.classid === Meteor.userId()) ? "Personal" : classes.findOne({_id: workObj.classid}).name;
|
if(Session.get("demo")) {
|
||||||
|
workObj.className = workObj.class;
|
||||||
|
} else {
|
||||||
|
workObj.className = (workObj.classid === Meteor.userId()) ? "Personal" : classes.findOne({_id: workObj.classid}).name;
|
||||||
|
}
|
||||||
|
|
||||||
workObj.dateWord = (!(Meteor.Device.isPhone() || Meteor.Device.isTablet())) ?
|
workObj.dateWord = (!(Meteor.Device.isPhone() || Meteor.Device.isTablet())) ?
|
||||||
moment(workObj.dueDate).calendar(null, {
|
moment(workObj.dueDate).calendar(null, {
|
||||||
sameDay: '[Today]',
|
sameDay: '[Today]',
|
||||||
@ -1119,17 +1337,26 @@ updateWork = function(id, fields, type) {
|
|||||||
workObj.cardDate = "400";
|
workObj.cardDate = "400";
|
||||||
}
|
}
|
||||||
|
|
||||||
workObj.confirmationLength = workObj.confirmations.length; // Counts the number of confirmations and reports for a particular work.
|
if(Session.get("demo")) {
|
||||||
workObj.reportLength = workObj.reports.length;
|
workObj.confirmed = "#27A127";
|
||||||
workObj.confirmed = (_.contains(workObj.confirmations, Meteor.userId())) ? "#27A127" : "";
|
workObj.reported = "";
|
||||||
workObj.reported = (_.contains(workObj.reports, Meteor.userId())) ? "#FF1A1A" : "";
|
} else {
|
||||||
|
workObj.confirmationLength = workObj.confirmations.length; // Counts the number of confirmations and reports for a particular work.
|
||||||
|
workObj.reportLength = workObj.reports.length;
|
||||||
|
workObj.confirmed = (_.contains(workObj.confirmations, Meteor.userId())) ? "#27A127" : "";
|
||||||
|
workObj.reported = (_.contains(workObj.reports, Meteor.userId())) ? "#FF1A1A" : "";
|
||||||
|
}
|
||||||
|
|
||||||
workObj.typeColor = workColors[workObj.type];
|
workObj.typeColor = workColors[workObj.type];
|
||||||
|
|
||||||
workObj.creatorname = Meteor.users.findOne({
|
if(Session.get("demo")) {
|
||||||
_id: workObj.creator
|
workObj.creatorname = "A. Robot";
|
||||||
}).profile.name;
|
} else {
|
||||||
|
workObj.creatorname = Meteor.users.findOne({
|
||||||
|
_id: workObj.creator
|
||||||
|
}).profile.name;
|
||||||
|
}
|
||||||
|
|
||||||
var normalColor = Session.get("user").preferences.theme.text;
|
var normalColor = Session.get("user").preferences.theme.text;
|
||||||
// Ratio color handling
|
// Ratio color handling
|
||||||
/*var conf = workObj.confirmations.length;
|
/*var conf = workObj.confirmations.length;
|
||||||
@ -1172,7 +1399,6 @@ updateWork = function(id, fields, type) {
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Session.set("myWork", myWork);
|
Session.set("myWork", myWork);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1189,7 +1415,11 @@ filterWork = function() {
|
|||||||
var notInClassFilter = classDisp.length !== 0 && !_.contains(classDisp, workObj.classid);
|
var notInClassFilter = classDisp.length !== 0 && !_.contains(classDisp, workObj.classid);
|
||||||
var notInTypeFilter = typeFilter.length !== 0 && !_.contains(typeFilter, workObj.type);
|
var notInTypeFilter = typeFilter.length !== 0 && !_.contains(typeFilter, workObj.type);
|
||||||
var pastHideDate = hideTime !== 0 && (moment().subtract(hideTime, 'days'))._d > (moment(workObj.dueDate))._d;
|
var pastHideDate = hideTime !== 0 && (moment().subtract(hideTime, 'days'))._d > (moment(workObj.dueDate))._d;
|
||||||
var markedDone = Session.get("user").preferences.done && !(Meteor.Device.isPhone() || Meteor.Device.isTablet()) && _.contains(workObj.done, Meteor.userId());
|
if(Session.get("demo")) {
|
||||||
|
var markedDone = Session.get("user").preferences.done && workObj.done.length !== 0;
|
||||||
|
} else {
|
||||||
|
var markedDone = Session.get("user").preferences.done && !(Meteor.Device.isPhone() || Meteor.Device.isTablet()) && _.contains(workObj.done, Meteor.userId());
|
||||||
|
}
|
||||||
var reported = false; // Temp, working on reporting.
|
var reported = false; // Temp, working on reporting.
|
||||||
//var reported = (workObj.reportLength / (workObj.reportLength + workObj.confirmationLength)) > 0.7; // Over 70% are reports
|
//var reported = (workObj.reportLength / (workObj.reportLength + workObj.confirmationLength)) > 0.7; // Over 70% are reports
|
||||||
|
|
||||||
@ -1199,6 +1429,7 @@ filterWork = function() {
|
|||||||
displayWork.push(workObj);
|
displayWork.push(workObj);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Session.set("myWork", displayWork.sort(function(a,b) { // Display work.
|
Session.set("myWork", displayWork.sort(function(a,b) { // Display work.
|
||||||
if(Date.parse(a.dueDate) === Date.parse(b.dueDate)) {
|
if(Date.parse(a.dueDate) === Date.parse(b.dueDate)) {
|
||||||
var x = a.name.toLowerCase();
|
var x = a.name.toLowerCase();
|
||||||
@ -1219,10 +1450,17 @@ function calendarEvents() {
|
|||||||
var myWork = Session.get("myWork");
|
var myWork = Session.get("myWork");
|
||||||
for(var i = 0; i < myWork.length; i++) {
|
for(var i = 0; i < myWork.length; i++) {
|
||||||
var work = myWork[i];
|
var work = myWork[i];
|
||||||
var currClass = classes.findOne({ _id: work.classid});
|
if(Session.get("demo")) {
|
||||||
|
var currClass = Session.get("myClasses").filter(function(obj) {
|
||||||
|
return obj.name === work.class;
|
||||||
|
})[0];
|
||||||
|
} else {
|
||||||
|
var currClass = classes.findOne({ _id: work.classid});
|
||||||
|
}
|
||||||
var inRole = false;
|
var inRole = false;
|
||||||
|
|
||||||
if (work.class === Meteor.userId() ||
|
if (Session.get("demo") ||
|
||||||
|
work.class === Meteor.userId() ||
|
||||||
Meteor.userId() === work.creator ||
|
Meteor.userId() === work.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 ||
|
||||||
|
|||||||
@ -168,10 +168,26 @@ Template.sidebarOptionPlate.events({
|
|||||||
},
|
},
|
||||||
'click .addClass' () { // Click classes mode button.
|
'click .addClass' () { // Click classes mode button.
|
||||||
if (Session.equals("settingMode", "addClass")) return;
|
if (Session.equals("settingMode", "addClass")) return;
|
||||||
|
if (Session.get("demo")) {
|
||||||
|
sAlert.error("Not available in demo!", {
|
||||||
|
effect: 'stackslide',
|
||||||
|
position: 'top',
|
||||||
|
timeout: 2000
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
toggleToMode("addClass");
|
toggleToMode("addClass");
|
||||||
},
|
},
|
||||||
'click .createClass' () { // Click classes mode button.
|
'click .createClass' () { // Click classes mode button.
|
||||||
if (Session.equals("settingMode", "createClass")) return;
|
if (Session.equals("settingMode", "createClass")) return;
|
||||||
|
if (Session.get("demo")) {
|
||||||
|
sAlert.error("Not available in demo!", {
|
||||||
|
effect: 'stackslide',
|
||||||
|
position: 'top',
|
||||||
|
timeout: 2000
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
toggleToMode("createClass");
|
toggleToMode("createClass");
|
||||||
},
|
},
|
||||||
'click #settingMode' () {
|
'click #settingMode' () {
|
||||||
@ -204,11 +220,18 @@ Template.sidebarCreatePlate.events({
|
|||||||
});
|
});
|
||||||
|
|
||||||
Template.registerHelper("classInfo", (info) => {
|
Template.registerHelper("classInfo", (info) => {
|
||||||
var thisClass = classes.findOne({
|
if(Session.get("demo")) {
|
||||||
_id: Session.get("classInfo")
|
if(Session.equals("classInfo", "Personal")) var isYou = true;
|
||||||
});
|
var thisClass = Session.get("myClasses").filter(function(obj) {
|
||||||
if (thisClass === undefined) return;
|
return obj.name === Session.get("classInfo");
|
||||||
var isYou = Session.equals("classInfo", Meteor.userId());
|
})[0];
|
||||||
|
} else {
|
||||||
|
var thisClass = classes.findOne({
|
||||||
|
_id: Session.get("classInfo")
|
||||||
|
});
|
||||||
|
if (thisClass === undefined) return;
|
||||||
|
var isYou = Session.equals("classInfo", Meteor.userId());
|
||||||
|
}
|
||||||
switch (info) {
|
switch (info) {
|
||||||
case "name":
|
case "name":
|
||||||
return (isYou) ? "Personal" : thisClass.name;
|
return (isYou) ? "Personal" : thisClass.name;
|
||||||
@ -221,6 +244,7 @@ Template.registerHelper("classInfo", (info) => {
|
|||||||
case "privacy":
|
case "privacy":
|
||||||
return (isYou) ? true : thisClass.privacy;
|
return (isYou) ? true : thisClass.privacy;
|
||||||
case "admin":
|
case "admin":
|
||||||
|
if(Session.get("demo")) return "A. Robot";
|
||||||
return Meteor.users.findOne({
|
return Meteor.users.findOne({
|
||||||
_id: (isYou) ? Meteor.userId() : thisClass.admin
|
_id: (isYou) ? Meteor.userId() : thisClass.admin
|
||||||
});
|
});
|
||||||
@ -300,6 +324,14 @@ Template.manageClass.events({
|
|||||||
},
|
},
|
||||||
'click #classInfoModeWrapper span:last-child' () {
|
'click #classInfoModeWrapper span:last-child' () {
|
||||||
if (Session.equals("classInfoMode", "users")) return;
|
if (Session.equals("classInfoMode", "users")) return;
|
||||||
|
if (Session.get("demo")) {
|
||||||
|
sAlert.error("Not available in demo!", {
|
||||||
|
effect: 'stackslide',
|
||||||
|
position: 'top',
|
||||||
|
timeout: 2000
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
toggleToClassInfoMode("users");
|
toggleToClassInfoMode("users");
|
||||||
},
|
},
|
||||||
'click .infoCard .fa-pencil-square-o' () {
|
'click .infoCard .fa-pencil-square-o' () {
|
||||||
|
|||||||
@ -10,6 +10,8 @@ Router.route('/', {
|
|||||||
waitOn: function() {
|
waitOn: function() {
|
||||||
if(!Meteor.userId()) {
|
if(!Meteor.userId()) {
|
||||||
return;
|
return;
|
||||||
|
} else if(Session.get("demo")) {
|
||||||
|
return ["HIIII"];
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
Meteor.subscribe('classes', this.params._id),
|
Meteor.subscribe('classes', this.params._id),
|
||||||
@ -22,6 +24,33 @@ Router.route('/', {
|
|||||||
];
|
];
|
||||||
},
|
},
|
||||||
action: function() {
|
action: function() {
|
||||||
|
if(Session.get("demo")) {
|
||||||
|
Session.set("user", {
|
||||||
|
"school":"Robot Academy",
|
||||||
|
"grade":"2018",
|
||||||
|
"classes": ["History", "Math", "Biology", "Literature"],
|
||||||
|
"preferences": {
|
||||||
|
"theme": {
|
||||||
|
"background":"NeonBlue.jpg",
|
||||||
|
"mainColor":"#1D1C23",
|
||||||
|
"secondaryColor":"#1F212F",
|
||||||
|
"sidebarColor":"#312E32",
|
||||||
|
"userDropdownColor":"#2E312B",
|
||||||
|
"iconHighlight":"#70E6E6",
|
||||||
|
"modeHighlight":"#70E6E6",
|
||||||
|
"classCardColor":"#32363C",
|
||||||
|
"textColor":"#FCF0F0"
|
||||||
|
},
|
||||||
|
"mode": "classes",
|
||||||
|
"timeHide":0,
|
||||||
|
"done": true,
|
||||||
|
"hideReport": true},
|
||||||
|
"name": "A. Robot",
|
||||||
|
"complete": true
|
||||||
|
});
|
||||||
|
this.render("main");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!Meteor.userId() || !completeProfile()) {
|
if (!Meteor.userId() || !completeProfile()) {
|
||||||
this.redirect('/login');
|
this.redirect('/login');
|
||||||
} else {
|
} else {
|
||||||
@ -42,6 +71,9 @@ Router.route('/', {
|
|||||||
|
|
||||||
Router.route('/login', {
|
Router.route('/login', {
|
||||||
action: function() {
|
action: function() {
|
||||||
|
if(Session.get("demo")) {
|
||||||
|
this.redirect('/');
|
||||||
|
}
|
||||||
if (!Meteor.userId()) {
|
if (!Meteor.userId()) {
|
||||||
if(Meteor.Device.isPhone()) {
|
if(Meteor.Device.isPhone()) {
|
||||||
this.render("mLogin");
|
this.render("mLogin");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user