This commit is contained in:
Kenneth Jao 2016-10-01 17:27:02 -04:00
commit b5a4351bc2
4 changed files with 171 additions and 141 deletions

View File

@ -39,3 +39,5 @@ harrison:papa-parse
pfafman:filesaver pfafman:filesaver
flemay:less-autoprefixer flemay:less-autoprefixer
natestrauser:select2 natestrauser:select2
juliancwirko:s-alert
juliancwirko:s-alert-stackslide

View File

@ -59,6 +59,8 @@ iron:middleware-stack@1.1.0
iron:router@1.0.13 iron:router@1.0.13
iron:url@1.0.11 iron:url@1.0.11
jquery@1.11.9 jquery@1.11.9
juliancwirko:s-alert@3.2.0
juliancwirko:s-alert-stackslide@3.1.3
lai:collection-extensions@0.2.1_1 lai:collection-extensions@0.2.1_1
launch-screen@1.0.12 launch-screen@1.0.12
less@2.7.5 less@2.7.5

View File

@ -1,4 +1,5 @@
<template name="profile"> <template name="profile">
{{> sAlert}}
<div class="noScroll"> <div class="noScroll">
<div id="mainpage{{userProfile}}"><h2>Main Page</h2></div> <div id="mainpage{{userProfile}}"><h2>Main Page</h2></div>
<div id="logout2" onclick='document.getElementById("login-buttons-logout").click();'><h2>Logout</h2></div> <div id="logout2" onclick='document.getElementById("login-buttons-logout").click();'><h2>Logout</h2></div>

View File

@ -99,15 +99,23 @@ Template.profile.helpers({
return "Click here to edit..."; return "Click here to edit...";
}, },
classes() { // Loads all of the possible classes ( Limit of twenty shown ) ( Sorts by class size ) classes() { // Loads all of the possible classes ( Limit of twenty shown ) ( Sorts by class size )
var array = classes.find( var array = classes.find({
{ status: {
status: {$eq: true}, $eq: true
privacy: {$eq: false},
_id: {$nin: Meteor.user().profile.classes}
}, },
{sort: {subscribers: -1 }}, privacy: {
{limit: 20} $eq: false
).fetch(); },
_id: {
$nin: Meteor.user().profile.classes
}
}, {
sort: {
subscribers: -1
}
}, {
limit: 20
}).fetch();
for (var i = 0; i < array.length; i++) { for (var i = 0; i < array.length; i++) {
array[i].subscribers = array[i].subscribers.length; array[i].subscribers = array[i].subscribers.length;
@ -204,7 +212,8 @@ Template.profile.events({
// MAIN BUTTONS // MAIN BUTTONS
'click #mainpage' () { 'click #mainpage' () {
if (!Meteor.userId() || _.contains([null, undefined, ""], Meteor.user().profile.school)) { if (!Meteor.userId() || _.contains([null, undefined, ""], Meteor.user().profile.school)) {
alert("Please fill in your profile!"); sAlert.closeAll();
sAlert.error('Please fill in your profile!', {effect: 'stackslide', position: 'top'});
} else { } else {
window.location = '/'; window.location = '/';
} }
@ -214,7 +223,7 @@ Template.profile.events({
var functionHolder = document.getElementById("profClassInfoHolder"); var functionHolder = document.getElementById("profClassInfoHolder");
closeDivFade(functionHolder); closeDivFade(functionHolder);
var div = document.getElementById("profClasses"); var div = document.getElementById("profClasses");
div.style.height = "50%" div.style.height = "50%";
setTimeout(function() {             setTimeout(function() {            
Session.set("profClassTab", "addClass"); Session.set("profClassTab", "addClass");
div.style.height = "90%";           div.style.height = "90%";          
@ -226,7 +235,7 @@ Template.profile.events({
var functionHolder = document.getElementById("profClassInfoHolder"); var functionHolder = document.getElementById("profClassInfoHolder");
closeDivFade(functionHolder); closeDivFade(functionHolder);
var div = document.getElementById("profClasses"); var div = document.getElementById("profClasses");
div.style.height = "50%"      div.style.height = "50%";     
setTimeout(function() {             setTimeout(function() {            
Session.set("profClassTab", "manClass");  Session.set("profClassTab", "manClass"); 
div.style.height = "90%";            div.style.height = "90%";           
@ -238,7 +247,7 @@ Template.profile.events({
var functionHolder = document.getElementById("profClassInfoHolder");         var functionHolder = document.getElementById("profClassInfoHolder");        
closeDivFade(functionHolder); closeDivFade(functionHolder);
var div = document.getElementById("profClasses"); var div = document.getElementById("profClasses");
div.style.height = "50%" div.style.height = "50%";
setTimeout(function() { setTimeout(function() {
Session.set("profClassTab", "creClass"); Session.set("profClassTab", "creClass");
div.style.height = "90%"; div.style.height = "90%";
@ -274,14 +283,18 @@ Template.profile.events({
} }
Session.set("selectedClass", null); Session.set("selectedClass", null);
var usertype = ["moderators", "banned"]; var usertype = ["moderators", "banned"];
var array = classes.findOne({_id:attribute}); var array = classes.findOne({
_id: attribute
});
for (var i = 0; i < usertype.length; i++) { for (var i = 0; i < usertype.length; i++) {
var users = array[usertype[i]]; var users = array[usertype[i]];
array[usertype[i]] = []; array[usertype[i]] = [];
for (var j = 0; j < users.length; j++) { for (var j = 0; j < users.length; j++) {
var detailusers = {}; var detailusers = {};
var user = Meteor.users.findOne({_id:users[j]}); var user = Meteor.users.findOne({
_id: users[j]
});
detailusers._id = user._id; detailusers._id = user._id;
detailusers.email = user.services.google.email; detailusers.email = user.services.google.email;
detailusers.name = user.profile.name; detailusers.name = user.profile.name;
@ -357,7 +370,9 @@ Template.profile.events({
input.placeholder = "Not a valid user"; input.placeholder = "Not a valid user";
return; return;
} }
var user = Meteor.users.findOne({"services.google.email":value}); var user = Meteor.users.findOne({
"services.google.email": value
});
serverData = [ serverData = [
user._id, user._id,
classid, classid,
@ -405,7 +420,9 @@ Template.profile.events({
input.placeholder = "Not a valid user"; input.placeholder = "Not a valid user";
return; return;
} }
var user = Meteor.users.findOne({"services.google.email":value}); var user = Meteor.users.findOne({
"services.google.email": value
});
serverData = [user._id, classid]; serverData = [user._id, classid];
confirm = "changeAdmin"; confirm = "changeAdmin";
Session.set("confirmText", "Are you really sure?"); Session.set("confirmText", "Are you really sure?");
@ -601,14 +618,18 @@ function sendData(funcName) {
Meteor.call(funcName, serverData, function(err, result) { Meteor.call(funcName, serverData, function(err, result) {
if (funcName === "trackUserInClass") { if (funcName === "trackUserInClass") {
var selectedClass = Session.get("selectedClass"); var selectedClass = Session.get("selectedClass");
var array = classes.findOne({_id:selectedClass._id}); var array = classes.findOne({
_id: selectedClass._id
});
var usertype = ["moderators", "banned"]; var usertype = ["moderators", "banned"];
for (var i = 0; i < usertype.length; i++) { for (var i = 0; i < usertype.length; i++) {
var users = array[usertype[i]]; var users = array[usertype[i]];
array[usertype[i]] = []; array[usertype[i]] = [];
for (var j = 0; j < users.length; j++) { for (var j = 0; j < users.length; j++) {
var detailusers = {}; var detailusers = {};
var user = Meteor.users.findOne({_id:users[j]}); var user = Meteor.users.findOne({
_id: users[j]
});
detailusers._id = user._id; detailusers._id = user._id;
detailusers.email = user.services.google.email; detailusers.email = user.services.google.email;
detailusers.name = user.profile.name; detailusers.name = user.profile.name;
@ -689,11 +710,15 @@ function getCreateFormData() { // Gets create class form data, and returns null.
} }
function checkUser(email, classid) { // Checks if user email exists. function checkUser(email, classid) { // Checks if user email exists.
var user = Meteor.users.findOne({"services.google.email":email}); var user = Meteor.users.findOne({
"services.google.email": email
});
if (user === undefined) { if (user === undefined) {
return true; return true;
} else { } else {
if(classes.findOne({_id:classid}).subscribers) if (classes.findOne({
_id: classid
}).subscribers)
return false; return false;
} }
} }