web beautify filter

This commit is contained in:
Yaman Qalieh 2016-10-03 23:13:05 -04:00
parent 196976cc9f
commit be716d982a

View File

@ -197,7 +197,9 @@ Template.registerHelper('myClasses', () => { // Gets all classes and respective
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].creator = Meteor.users.findOne({_id: thisWork[j].creator}).profile.name;
thisWork[j].creator = Meteor.users.findOne({
_id: thisWork[j].creator
}).profile.name;
var conf = thisWork[j].confirmations.length;
var repo = thisWork[j].reports.length;
var ratio = conf / repo;
@ -239,8 +241,7 @@ Template.registerHelper('commentLength', () => { // Returns characters left for
});
function startDragula() {
dragula([document.querySelector('#classesMode'), document.querySelector('#nonexistant')],
{
dragula([document.querySelector('#classesMode'), document.querySelector('#nonexistant')], {
moves: function(el, container, handle) {
// return handle.classList.contains("classInfo") || handle.classList.contains("mainClassName");
return _.intersection(["classInfo", "mainClassName", "mainClassHour", "mainClassTeacher"], handle.classList).length > 0;
@ -434,7 +435,9 @@ Template.main.helpers({
if (Session.get("newWork")) {
return defaultWork[value];
} else {
var thisWork = work.findOne({_id: Session.get("currentWorkId")});
var thisWork = work.findOne({
_id: Session.get("currentWorkId")
});
return formReadable(thisWork, value);
}
},
@ -785,11 +788,15 @@ Template.main.events({
var works = userClasses[i].thisClassWork;
for (var j = 0; j < works.length; j++) {
var work = works[j];
var workclass = classes.findOne({_id: work.class});
var workclass = classes.findOne({
_id: work.class
});
if (work.description == defaultWork.description) work.description = "";
if (work.dueDate == defaultWork.dueDate) continue;
if (work.name == defaultWork.name) work.name = "";
if (workclass === undefined) workclass = {name: "Personal"};
if (workclass === undefined) workclass = {
name: "Personal"
};
events.push([
workclass.name + ": " + work.name,
work.realDate.toLocaleDateString(),
@ -800,8 +807,13 @@ Template.main.events({
}
var JSONevents = JSON.stringify(events);
var CSVevents = Papa.unparse({fields: ["Subject", "Start Date", "Description", "All Day Event"], data: JSONevents});
var eventBlob = new Blob([CSVevents], {type: "data:text/csv;charset=utf-8"});
var CSVevents = Papa.unparse({
fields: ["Subject", "Start Date", "Description", "All Day Event"],
data: JSONevents
});
var eventBlob = new Blob([CSVevents], {
type: "data:text/csv;charset=utf-8"
});
saveAs(eventBlob, "hourglass.csv");
},
'keydown input' (event) { // Enter to close input.
@ -1070,11 +1082,16 @@ function toDate(date) { // Turns formatted date back to Date constructor.
function formReadable(input, val) { // Makes work information readable by users.
switch (val) {
case "typeColor": return input.typeColor = workColors[input.type];
case "name": return input.name;
case "dueDate": return getReadableDate(input.dueDate);
case "description": return input.description;
case "type": return input.type[0].toUpperCase() + input.type.slice(1);
case "typeColor":
return input.typeColor = workColors[input.type];
case "name":
return input.name;
case "dueDate":
return getReadableDate(input.dueDate);
case "description":
return input.description;
case "type":
return input.type[0].toUpperCase() + input.type.slice(1);
case "comments":
var comments = input.comments;
var resort = [];