diff --git a/hourglass/client/main/main.css b/hourglass/client/main/main.css
index 083284b..a88953b 100644
--- a/hourglass/client/main/main.css
+++ b/hourglass/client/main/main.css
@@ -131,7 +131,7 @@ input, textarea {
.fa-bars, .fa-cog {
font-size: 200%;
height: 100%;
- padding: 0.6%;
+ padding: 0.65%;
padding-right: 0.8%;
float: left;
@@ -166,7 +166,6 @@ input, textarea {
}
#logout {
- width: initial;
padding: 1%;
background-color: rgba(0,0,0,0.05);
diff --git a/hourglass/client/main/main.js b/hourglass/client/main/main.js
index da9b446..d97ad46 100644
--- a/hourglass/client/main/main.js
+++ b/hourglass/client/main/main.js
@@ -46,6 +46,7 @@ Session.set("modifying",null);
Session.set("radioDiv",null);
Session.set("radioOffset",null);
Session.set("serverData",null);
+Session.set("noclass",null);
Template.registerHelper('divColor', (div) => {
return themeColors[Cookie.get("theme")][div];
@@ -62,13 +63,14 @@ Template.registerHelper('overlayDim', (part) => {
Template.registerHelper('myClasses', () => {
if (Meteor.user().profile.classes === undefined || Meteor.user().profile.classes.length === 0) {
+ Session.set("noclass",true);
return [];
} else {
var array = [];
var courses = Meteor.user().profile.classes;
for(var i = 0; i < courses.length; i++) {
found = classes.findOne({_id:courses[i]});
-
+ found.subscribers = found.subscribers.length;
if(found.admin === Meteor.userId()) found.box = " owned";
array.push(found);
@@ -80,6 +82,7 @@ Template.registerHelper('myClasses', () => {
}
array[i].thisClassWork = thisWork;
}
+ Session.set("noclass",false);
return array;
}
});
diff --git a/hourglass/client/profile/profile.css b/hourglass/client/profile/profile.css
index 414ebcf..675136d 100644
--- a/hourglass/client/profile/profile.css
+++ b/hourglass/client/profile/profile.css
@@ -210,7 +210,7 @@
animation: expand .7s ease 1;
}
-#profClassSearch .-autocomplete-container {
+.-autocomplete-container {
display: none;
}
@@ -278,6 +278,25 @@
background-color: rgba(0,0,0,0.1);
}
+#private {
+ margin: 3% 35% 0 4%;
+ padding: 1.5%;
+
+ background-color: rgba(0,0,0,0.2);
+
+ float: right;
+ cursor: pointer;
+
+ -webkit-transition: background-color 0.4s ease;
+ -moz-transition: background-color 0.4s ease;
+ -ms-transition: background-color 0.4s ease;
+ transition: background-color 0.4s ease;
+}
+
+#private:hover {
+ background-color: rgba(0,0,0,0.1);
+}
+
.owned {
background-color: #27646D;
@@ -327,8 +346,7 @@
margin-left: 5% !important;
margin-right: 5% !important;
margin-bottom: 0 !important;
- position: relative;
-
+ position: relative;
}
.formDiv {
@@ -346,9 +364,10 @@
margin: 0 !important;
}
-.-autocomplete-container {
+.formDiv .-autocomplete-container {
margin: 0 0 0 0 !important;
position: absolute;
+ display: inherit !important;
}
#creSubmit {
diff --git a/hourglass/client/profile/profile.html b/hourglass/client/profile/profile.html
index 4affb4c..a0f7bae 100644
--- a/hourglass/client/profile/profile.html
+++ b/hourglass/client/profile/profile.html
@@ -59,12 +59,16 @@
{{#each myClasses}}
{{> classDisplay}}
{{/each}}
+ {{#if noclass}}
+
No results found...
+ {{/if}}
{{/if}}
{{#if profClassTab "addClass"}}
{{> inputAutocomplete id="profClassSearch" settings=classsettings placeholder="Search..."}}
+ Join Private Class
Class Name
Teacher
@@ -76,12 +80,15 @@
{{#each classes}}
{{> classDisplay}}
{{/each}}
+ {{#if noclass}}
+
No results found...
+ {{/if}}
{{else}}
{{#each autocompleteClasses}}
{{> classDisplay}}
{{/each}}
{{#if notfound}}
- No results found...
+ No results found...
{{/if}}
{{/if}}
diff --git a/hourglass/client/profile/profile.js b/hourglass/client/profile/profile.js
index 9ab182b..78c4f40 100644
--- a/hourglass/client/profile/profile.js
+++ b/hourglass/client/profile/profile.js
@@ -2,7 +2,6 @@ import {
Template
} from 'meteor/templating';
-
Meteor.subscribe('schools');
Meteor.subscribe('classes');
Meteor.subscribe('work');
@@ -19,6 +18,8 @@ Session.set("confirmText", null);
Session.set("selectedClass",null);
Session.set("selectClassId",null);
Session.set("code",null);
+Session.set("noclass",null);
+Session.set("notfound",null);
var themeColors = {
"light": {
@@ -103,7 +104,6 @@ Template.profile.helpers({
pic = Meteor.user().profile.avatar;
} else {
pic = "Avatars/" + (Math.floor(Math.random() * (11 - 1)) + 1).toString() + ".png";
- console.log(pic);
currentprofile = Meteor.user().profile;
currentprofile.avatar = pic;
Meteor.call("editProfile", currentprofile);
@@ -139,7 +139,7 @@ Template.profile.helpers({
}
},
classes() {
- return classes.find(
+ var array = classes.find(
{
status: {$eq: true},
privacy: {$eq: false},
@@ -148,6 +148,16 @@ Template.profile.helpers({
{sort: {subscribers: -1 }},
{limit: 20}
).fetch();
+
+ for(var i = 0; i < array.length; i++) {
+ array[i].subscribers = array[i].subscribers.length;
+ }
+ if(array.length === 0) {
+ Session.set("noclass",true);
+ } else {
+ Session.set("noclass",false);
+ }
+ return array;
},
profClassHeight() {
return 0.6 * window.innerHeight.toString() + "px";
@@ -178,6 +188,9 @@ Template.profile.helpers({
notfound() {
return Session.get("notfound");
},
+ noclass() {
+ return Session.get("noclass");
+ },
confirmText() {
return Session.get("confirmText");
},
@@ -387,8 +400,8 @@ Template.profile.events({
'click .fa-times-thin' () {
Session.set("searching", false);
},
- 'keydown #profClassSearch' (event) {
- if (event.target.value === "") {
+ 'keyup #profClassSearch' (event) {
+ if (event.target.value.length === 0) {
Session.set("notsearching", true);
} else {
Session.set("notsearching", false);
@@ -409,7 +422,7 @@ Template.profile.events({
name: item.childNodes[1].childNodes[0].nodeValue,
teacher: item.childNodes[3].childNodes[0].nodeValue,
hour: item.childNodes[5].childNodes[0].nodeValue,
- subscribers: item.childNodes[7].childNodes[0].nodeValue,
+ subscribers: item.childNodes[7].childNodes[0].nodeValue.length/17,
_id: item.getAttribute("classid")
});
Session.set("autocompleteDivs", divs);
@@ -475,16 +488,17 @@ Template.profile.events({
input.placeholder = "1234@abc.xyz";
input.className.replace(" formInvalid","");
var value = input.value;
+ var classid = document.getElementById("createdClasses").getAttribute("classid");
input.value = "";
- if(checkUser(value)) {
+ if(checkUser(value,classid)) {
input.className += " formInvalid";
input.placeholder = "Not a valid user";
return;
}
- var user = Meteor.users.findOne({"services.google.email":input.value});
+ var user = Meteor.users.findOne({"services.google.email":value});
Session.set("serverData", [
user._id,
- document.getElementById("createdClasses").getAttribute("classid"),
+ classid,
event.target.parentNode.childNodes[1].childNodes[0].nodeValue.replace(":","").toLowerCase()
]);
sendData("trackUserInClass");
@@ -526,12 +540,19 @@ Template.profile.events({
input.placeholder = "1234@abc.xyz";
input.className.replace(" formInvalid","");
var value = input.value;
+ var classid = document.getElementById("createdClasses").getAttribute("classid");
input.value = "";
- if(checkUser(value)) {
+ if(checkUser(value,classid)) {
input.className += " formInvalid";
input.placeholder = "Not a valid user";
return;
}
+ var user = Meteor.users.findOne({"services.google.email":value});
+ Session.set("serverData", [user._id,classid]);
+ Session.set("confirm","changeAdmin");
+ Session.set("confirmText", "Are you really sure?");
+ openDivFade(document.getElementsByClassName("overlay")[0])
+ document.getElementById("createdClasses").style.marginRight = "-40%";
}
});
@@ -632,11 +653,12 @@ function getCreateFormData() {
};
}
-function checkUser(email) {
+function checkUser(email,classid) {
var user = Meteor.users.findOne({"services.google.email":email});
if(user === undefined) {
return true;
} else {
+ if(classes.findOne({_id:classid}).subscribers)
return false;
}
}
\ No newline at end of file