run code filter

This commit is contained in:
Yaman Qalieh 2016-10-01 16:09:58 -04:00
parent 2797423008
commit 18c784fab3
2 changed files with 165 additions and 140 deletions

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;
@ -214,7 +222,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 +234,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 +246,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 +282,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 +369,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 +419,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 +617,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 +709,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;
} }
} }