Added actual button, and bug fixes
This commit is contained in:
parent
c52e477eee
commit
db2c32956a
@ -65,16 +65,18 @@
|
|||||||
<p class="prefOptionText">Calendar</p>
|
<p class="prefOptionText">Calendar</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div>
|
<div>
|
||||||
<div class="inputRadio">
|
<div class="inputRadioPref">
|
||||||
<span class="prefTitle">Default Mode:</span>
|
<span class="prefTitle">Hide Homework:</span><br>
|
||||||
<span class="change radio" opc="2" op="2" re="readonly" id="prefBg">{{pref 'background'}}</span>
|
<span class="change radio" opc="2" op="2" re="readonly" id="prefHide">{{pref 'timeHide'}}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="prefOptions" style="background-color:{{divColor 'header'}}">
|
<div class="prefOptions" style="background-color:{{divColor 'header'}}">
|
||||||
<p class="prefOptionText">White</p>
|
<p class="prefOptionText">A Day</p>
|
||||||
<p class="prefOptionText">Black</p>
|
<p class="prefOptionText">A Week</p>
|
||||||
|
<p class="prefOptionText">A Month</p>
|
||||||
|
<p class="prefOptionText">Never</p>
|
||||||
</div>
|
</div>
|
||||||
</div> -->
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<img id="bg" src={{bgSrc}}>
|
<img id="bg" src={{bgSrc}}>
|
||||||
|
|||||||
@ -47,9 +47,16 @@ var workColors = {
|
|||||||
|
|
||||||
var defaults = {
|
var defaults = {
|
||||||
"theme":"light",
|
"theme":"light",
|
||||||
"mode":"classes"
|
"mode":"classes",
|
||||||
"timeHide":7
|
"timeHide":"A Day"
|
||||||
}
|
};
|
||||||
|
|
||||||
|
var ref = {
|
||||||
|
"A Day":1,
|
||||||
|
"A Week":7,
|
||||||
|
"A Month":30,
|
||||||
|
"Never":0
|
||||||
|
};
|
||||||
|
|
||||||
// Reactive variables.
|
// Reactive variables.
|
||||||
Session.set("calendarclasses", null);
|
Session.set("calendarclasses", null);
|
||||||
@ -93,7 +100,7 @@ Template.registerHelper('myClasses', () => {
|
|||||||
var array = [];
|
var array = [];
|
||||||
var courses = Meteor.user().profile.classes;
|
var courses = Meteor.user().profile.classes;
|
||||||
var classDisp = Session.get("classDisp");
|
var classDisp = Session.get("classDisp");
|
||||||
var hide = Meteor.user().profile.preferences.timeHide;
|
var hide = ref[Meteor.user().profile.preferences.timeHide];
|
||||||
for(var i = 0; i < courses.length; i++) {
|
for(var i = 0; i < courses.length; i++) {
|
||||||
found = classes.findOne({_id:courses[i]});
|
found = classes.findOne({_id:courses[i]});
|
||||||
found.subscribers = found.subscribers.length/17;
|
found.subscribers = found.subscribers.length/17;
|
||||||
@ -112,16 +119,19 @@ Template.registerHelper('myClasses', () => {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var j = 0; j < thisWork.length; j++) {
|
for(var j = 0; j < thisWork.length; j++) {
|
||||||
if(hide !== 0) {
|
if(hide !== 0) {
|
||||||
var cont = false;
|
var due = (moment(thisWork[j].dueDate))["_d"];
|
||||||
var today = moment().subtract(hide,'days').format();
|
var today = (moment().subtract(hide,'days'))["_d"];
|
||||||
if(today > thisWork[j].dueDate) {
|
if(today > due) {
|
||||||
cont = true;
|
thisWork[j] = "no";
|
||||||
continue;
|
j = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(cont) continue;
|
}
|
||||||
|
while(thisWork.indexOf("no") !== -1) thisWork.splice(thisWork.indexOf("no"),1);
|
||||||
|
|
||||||
|
for(var j = 0; j < thisWork.length; j++) {
|
||||||
thisWork[j].dueDate = moment(thisWork[j].dueDate).calendar(null, {
|
thisWork[j].dueDate = moment(thisWork[j].dueDate).calendar(null, {
|
||||||
sameDay: '[Today]',
|
sameDay: '[Today]',
|
||||||
nextDay: '[Tomorrow]',
|
nextDay: '[Tomorrow]',
|
||||||
@ -195,6 +205,7 @@ Template.main.helpers({
|
|||||||
},
|
},
|
||||||
currMode(name) {
|
currMode(name) {
|
||||||
var mode = Session.get("mode");
|
var mode = Session.get("mode");
|
||||||
|
console.log(mode);
|
||||||
if (name === mode) {
|
if (name === mode) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -215,10 +226,19 @@ Template.main.helpers({
|
|||||||
var events = [];
|
var events = [];
|
||||||
var cursor = work.find({class: {$in: Session.get("calendarclasses")}});
|
var cursor = work.find({class: {$in: Session.get("calendarclasses")}});
|
||||||
var classDisp = Session.get("classDisp");
|
var classDisp = Session.get("classDisp");
|
||||||
|
var hide = ref[Meteor.user().profile.preferences.timeHide];
|
||||||
cursor.forEach(function(current) {
|
cursor.forEach(function(current) {
|
||||||
var disp = true;
|
var disp = true;
|
||||||
if(classDisp.length !== 0 && classDisp.indexOf(current.class) === -1) disp = false;
|
if(classDisp.length !== 0 && classDisp.indexOf(current.class) === -1) disp = false;
|
||||||
|
|
||||||
|
if(hide !== 0) {
|
||||||
|
var due = (moment(current.dueDate))["_d"];
|
||||||
|
var today = (moment().subtract(hide,'days'))["_d"];
|
||||||
|
if(today > due) {
|
||||||
|
disp = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var inRole = false;
|
var inRole = false;
|
||||||
if(Meteor.userId() === current.creator ||
|
if(Meteor.userId() === current.creator ||
|
||||||
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
||||||
@ -357,14 +377,16 @@ Template.main.helpers({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
pref(val) {
|
pref(val) {
|
||||||
if(Meteor.user().profile.preferences === null) {
|
if(Object.keys(Meteor.user().profile.preferences).length !== Object.keys(defaults).length) {
|
||||||
var array = Meteor.user().profile;
|
var array = Meteor.user().profile;
|
||||||
array.preferences = defaults;
|
array.preferences = defaults;
|
||||||
Session.set("serverData",array);
|
Session.set("serverData",array);
|
||||||
sendData("editProfile");
|
sendData("editProfile");
|
||||||
|
if(val === 'timeHide') return defaults[val];
|
||||||
return defaults[val].charAt(0).toUpperCase() + defaults[val].slice(1);
|
return defaults[val].charAt(0).toUpperCase() + defaults[val].slice(1);
|
||||||
} else {
|
} else {
|
||||||
var preferences = Meteor.user().profile.preferences;
|
var preferences = Meteor.user().profile.preferences;
|
||||||
|
if(val === 'timeHide') return preferences[val];
|
||||||
return preferences[val].charAt(0).toUpperCase() + preferences[val].slice(1);
|
return preferences[val].charAt(0).toUpperCase() + preferences[val].slice(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -806,7 +828,8 @@ function getPreferencesData() {
|
|||||||
var profile = Meteor.user().profile;
|
var profile = Meteor.user().profile;
|
||||||
var options = {
|
var options = {
|
||||||
"theme":document.getElementById("prefTheme").childNodes[0].nodeValue.toLowerCase(),
|
"theme":document.getElementById("prefTheme").childNodes[0].nodeValue.toLowerCase(),
|
||||||
"mode":document.getElementById("prefMode").childNodes[0].nodeValue.toLowerCase()
|
"mode":document.getElementById("prefMode").childNodes[0].nodeValue.toLowerCase(),
|
||||||
|
"timeHide":document.getElementById("prefHide").childNodes[0].nodeValue
|
||||||
};
|
};
|
||||||
profile.preferences = options;
|
profile.preferences = options;
|
||||||
return profile;
|
return profile;
|
||||||
@ -832,29 +855,3 @@ function formReadable(input) {
|
|||||||
input.type = input.type[0].toUpperCase() + input.type.slice(1);
|
input.type = input.type[0].toUpperCase() + input.type.slice(1);
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeColor(hex, amt) {
|
|
||||||
|
|
||||||
hex = hex.slice(1);
|
|
||||||
var num = parseInt(hex,16);
|
|
||||||
var r = (num >> 16) + amt;
|
|
||||||
|
|
||||||
if (r > 255) r = 255;
|
|
||||||
else if (r < 0) r = 0;
|
|
||||||
|
|
||||||
var b = ((num >> 8) & 0x00FF) + amt;
|
|
||||||
|
|
||||||
if (b > 255) b = 255;
|
|
||||||
else if (b < 0) b = 0;
|
|
||||||
|
|
||||||
var g = (num & 0x0000FF) + amt;
|
|
||||||
|
|
||||||
if (g > 255) g = 255;
|
|
||||||
else if (g < 0) g = 0;
|
|
||||||
|
|
||||||
var final = (g | (b << 8) | (r << 16)).toString(16);
|
|
||||||
|
|
||||||
// Adds preceeding zeros
|
|
||||||
while (final.length < 6) {final = "0" + final};
|
|
||||||
return "#" + final;
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user