diff --git a/hourglass/client/profile/profile.css b/hourglass/client/profile/profile.css
index 675136d..552fa3b 100644
--- a/hourglass/client/profile/profile.css
+++ b/hourglass/client/profile/profile.css
@@ -568,7 +568,7 @@
-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
+ transition: background-color 0.4s ease;
}
#changeAdmin span:hover {
@@ -602,9 +602,56 @@
-webkit-transition: color 0.4s ease;
-moz-transition: color 0.4s ease;
-ms-transition: color 0.4s ease;
- transition: color 0.4s ease
+ transition: color 0.4s ease;
}
.fa-exchange:hover {
color: #CC4444;
+}
+
+#joinPrivClass {
+ width: 18%;
+ margin-bottom: -10%;
+ padding: 1.5%;
+ padding-bottom: 2%;
+
+ border-top: 5px solid #852E6D;
+ box-shadow: -2px 0px 5px 1px #444;
+
+ position: absolute;
+ right: 5%;
+ bottom: 0;
+
+ -webkit-transition: margin 0.4s ease;
+ -moz-transition: margin 0.4s ease;
+ -ms-transition: margin 0.4s ease;
+ transition: margin 0.4s ease;
+}
+
+#joinPrivClass h3 {
+ font-weight: 400;
+ font-size: 150%;
+ margin-bottom: 3%;
+}
+
+#privateCode {
+ font-size: 130%;
+ padding: 1%;
+}
+
+#privSubmit {
+ font-size: 120%;
+ margin-left: 5%;
+ padding: 3%;
+ background-color: rgba(0,0,0,0.2);
+ cursor: pointer;
+
+ -webkit-transition: background-color 0.2s ease;
+ -moz-transition: background-color 0.2s ease;
+ -ms-transition: background-color 0.2s ease;
+ transition: background-color 0.2s ease;
+}
+
+#privSubmit:hover {
+ background-color: rgba(0,0,0,0.1);
}
\ No newline at end of file
diff --git a/hourglass/client/profile/profile.html b/hourglass/client/profile/profile.html
index a0f7bae..73d0865 100644
--- a/hourglass/client/profile/profile.html
+++ b/hourglass/client/profile/profile.html
@@ -185,6 +185,12 @@
Delete Class
+
+
+
Enter Code:
+
+ Submit
+
diff --git a/hourglass/client/profile/profile.js b/hourglass/client/profile/profile.js
index b3e62ac..522ceb6 100644
--- a/hourglass/client/profile/profile.js
+++ b/hourglass/client/profile/profile.js
@@ -195,7 +195,7 @@ Template.profile.helpers({
return Session.get("confirmText");
},
selectedClass(val) {
- if(Session.get("selectedClass") === null) return;
+ if(Session.get("selectClassId") === null) return;
var usertype = ["moderators","banned"];
var attribute = Session.get("selectClassId");
var array = classes.findOne({_id:attribute});
@@ -314,6 +314,11 @@ Template.profile.events({
div.removeChild(div.childNodes[3]);
div.removeChild(div.childNodes[3]);
}
+ if(Session.get("privateClass") &&
+ !document.getElementById("joinPrivClass").contains(event.target)) {
+ Session.set("privateClass",false);
+ document.getElementById("joinPrivClass").style.marginBottom = "-10%";
+ }
},
'keydown' (event) {
var sessval = Session.get("modifying");
@@ -554,6 +559,27 @@ Template.profile.events({
Session.set("confirmText", "Are you really sure?");
openDivFade(document.getElementsByClassName("overlay")[0])
document.getElementById("createdClasses").style.marginRight = "-40%";
+ },
+ 'click #private' (event) {
+ Session.set("privateClass",true);
+ var input = document.getElementById("privateCode");
+ input.className = "";
+ input.placeholder = "Enter code here...";
+ document.getElementById("joinPrivClass").style.marginBottom = "0";
+ },
+ 'click #privSubmit' () {
+ var input = document.getElementById("privateCode");
+ var code = input.value;
+ input.value = "";
+ Session.set("serverData", code);
+ Meteor.call("joinPrivateClass", code, function(error, result) {
+ if(result) {
+ document.getElementById("joinPrivClass").style.marginBottom = "-10%";
+ } else {
+ input.className = "formInvalid";
+ input.placeholder = "Invalid code.";
+ }
+ });
}
});
diff --git a/hourglass/server/main.js b/hourglass/server/main.js
index d5c9a21..f8d5910 100644
--- a/hourglass/server/main.js
+++ b/hourglass/server/main.js
@@ -422,15 +422,16 @@ Meteor.methods({
}
},
'joinPrivateClass': function(input) {
- input.status = true;
- input.privacy = true;
- var found = classes.findOne(input);
- current = Meteor.user().profile;
- if (found !== undefined && input.code !== undefined &&
+ var found = classes.findOne({status: true, privacy: true, code:input});
+ var current = Meteor.user().profile;
+ if (found !== undefined && input !== undefined &&
current.classes.indexOf(found._id) === -1) {
classes.update({_id: found._id}, {$set: {subscribers: found.subscribers.concat(Meteor.userId())}});
- current.concat(found._id);
+ current.classes = current.classes.concat(found._id);
Meteor.users.update({_id: Meteor.userId()}, {$set: {profile: current}});
+ return true;
+ } else {
+ return false;
}
},
'leaveClass': function(change) {