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">
{{> sAlert}}
<div class="noScroll">
<div id="mainpage{{userProfile}}"><h2>Main Page</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...";
},
classes() { // Loads all of the possible classes ( Limit of twenty shown ) ( Sorts by class size )
var array = classes.find(
{
status: {$eq: true},
privacy: {$eq: false},
_id: {$nin: Meteor.user().profile.classes}
var array = classes.find({
status: {
$eq: true
},
{sort: {subscribers: -1 }},
{limit: 20}
).fetch();
privacy: {
$eq: false
},
_id: {
$nin: Meteor.user().profile.classes
}
}, {
sort: {
subscribers: -1
}
}, {
limit: 20
}).fetch();
for (var i = 0; i < array.length; i++) {
array[i].subscribers = array[i].subscribers.length;
@ -214,7 +222,7 @@ Template.profile.events({
var functionHolder = document.getElementById("profClassInfoHolder");
closeDivFade(functionHolder);
var div = document.getElementById("profClasses");
div.style.height = "50%"
div.style.height = "50%";
setTimeout(function() {            
Session.set("profClassTab", "addClass");
div.style.height = "90%";          
@ -226,7 +234,7 @@ Template.profile.events({
var functionHolder = document.getElementById("profClassInfoHolder");
closeDivFade(functionHolder);
var div = document.getElementById("profClasses");
div.style.height = "50%"     
div.style.height = "50%";     
setTimeout(function() {            
Session.set("profClassTab", "manClass"); 
div.style.height = "90%";           
@ -238,7 +246,7 @@ Template.profile.events({
var functionHolder = document.getElementById("profClassInfoHolder");        
closeDivFade(functionHolder);
var div = document.getElementById("profClasses");
div.style.height = "50%"
div.style.height = "50%";
setTimeout(function() {
Session.set("profClassTab", "creClass");
div.style.height = "90%";
@ -274,14 +282,18 @@ Template.profile.events({
}
Session.set("selectedClass", null);
var usertype = ["moderators", "banned"];
var array = classes.findOne({_id:attribute});
var array = classes.findOne({
_id: attribute
});
for (var i = 0; i < usertype.length; i++) {
var users = array[usertype[i]];
array[usertype[i]] = [];
for (var j = 0; j < users.length; j++) {
var detailusers = {};
var user = Meteor.users.findOne({_id:users[j]});
var user = Meteor.users.findOne({
_id: users[j]
});
detailusers._id = user._id;
detailusers.email = user.services.google.email;
detailusers.name = user.profile.name;
@ -357,7 +369,9 @@ Template.profile.events({
input.placeholder = "Not a valid user";
return;
}
var user = Meteor.users.findOne({"services.google.email":value});
var user = Meteor.users.findOne({
"services.google.email": value
});
serverData = [
user._id,
classid,
@ -405,7 +419,9 @@ Template.profile.events({
input.placeholder = "Not a valid user";
return;
}
var user = Meteor.users.findOne({"services.google.email":value});
var user = Meteor.users.findOne({
"services.google.email": value
});
serverData = [user._id, classid];
confirm = "changeAdmin";
Session.set("confirmText", "Are you really sure?");
@ -601,14 +617,18 @@ function sendData(funcName) {
Meteor.call(funcName, serverData, function(err, result) {
if (funcName === "trackUserInClass") {
var selectedClass = Session.get("selectedClass");
var array = classes.findOne({_id:selectedClass._id});
var array = classes.findOne({
_id: selectedClass._id
});
var usertype = ["moderators", "banned"];
for (var i = 0; i < usertype.length; i++) {
var users = array[usertype[i]];
array[usertype[i]] = [];
for (var j = 0; j < users.length; j++) {
var detailusers = {};
var user = Meteor.users.findOne({_id:users[j]});
var user = Meteor.users.findOne({
_id: users[j]
});
detailusers._id = user._id;
detailusers.email = user.services.google.email;
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.
var user = Meteor.users.findOne({"services.google.email":email});
var user = Meteor.users.findOne({
"services.google.email": email
});
if (user === undefined) {
return true;
} else {
if(classes.findOne({_id:classid}).subscribers)
if (classes.findOne({
_id: classid
}).subscribers)
return false;
}
}