@@ -0,0 +1,153 @@


console.log("hello");

if($('#majorAddToHotbar')){

$('#majorAddToHotbar').on('click',function(e){
console.log("Clicked add major to hotbar.");
e.preventDefault();
//do some verification
// /:type/:id/:contentname
var temporaryInfo = {
type: 'major',
contentid: $('#contentid').html(),
contentname: $('#contentname').html()
};
$.ajax({
url: 'http://localhost:8080/account/addhotbarelement',
type: 'post',
dataType: 'json',
data: temporaryInfo,
cache:false,
async: true,
success: function(data){
console.log("Async call has returned.")
//callback methods go right here
if(data.error){
//$('#profileMessage').text(data);
alert(data.error);
}else if(data.success){
//$('#profileMessage').text(data);
location.reload();
//alert(data.success);
}else {
//$('#profileMessage').text("Something else.");
alert("Something else.");
}
}
});
});
};

if($('#addNewCourseForm')){

$('#addNewCourseFormSubmit').on('click',function(e){
console.log("Clicked add new course.");
e.preventDefault();
//do some verification
// /:type/:id/:contentname
var temporaryInfo = {
majorid: $('#contentid').html(),
courseidentificationcode: $('#addNewCourseFormIdCode').val(),
coursename: $('#addNewCourseFormCourseName').val()
};
$.ajax({
url: 'http://localhost:8080/course/addnewcourse',
type: 'post',
dataType: 'json',
data: temporaryInfo,
cache:false,
async: true,
success: function(data){
console.log("Async call has returned.")
//callback methods go right here
if(data.error){
//$('#profileMessage').text(data);
alert(data.error);
}else if(data.success){
//$('#profileMessage').text(data);
location.reload();
//alert(data.success);
}else {
//$('#profileMessage').text("Something else.");
alert("Something else.");
}
}
});
});
};



if($('#addNewCourseFormOpen')){

$('#addNewCourseFormOpen').on('click',function(e){
console.log("Clicked show.");
e.preventDefault();
//do some verification
$('#addNewCourseForm').show();
});
};

if($('#addNewCourseFormCancel')){

$('#addNewCourseFormCancel').on('click',function(e){
console.log("Clicked cancel.");
e.preventDefault();
//do some verification
$('#addNewCourseForm').hide();
});
};


/*$('#updateProfileForm').submit(function(e){
console.log("Clicked submit profile information.");
e.preventDefault();
//do some verification
$.ajax({
url: 'http://localhost:8080/account/updateprofile',
type: 'post',
dataType: 'json',
data: $(this).serialize(),
cache:false,
async: true,
success: function(data){
console.log("Async call has returned.")
//callback methods go right here
if(data.data=="error"){
$('#profileMessage').text("Error. Try again.");
}else if(data.data=="success"){
$('#profileMessage').text("Profile information updated.");
}else {
$('#profileMessage').text("Something else.");
}
}
});
});*/

/*$('#updateUsernameForm').submit(function(e){
console.log("Clicked submit username information.");
e.preventDefault();
//do some verification
$.ajax({
url: 'http://localhost:8080/account/updateusername',
type: 'post',
dataType: 'json',
data: $(this).serialize(),
cache:false,
async: true,
success: function(data){
console.log("Async call has returned.")
//callback methods go right here
if(data.data=="error"){
$('#usernameMessage').text("Error. Try again.");
}else if(data.data=="success"){
$('#usernameMessage').text("Username information updated.");
}else {
$('#usernameMessage').text("Something else.");
}
}
});
});*/
@@ -1,7 +1,10 @@
body {
/*padding: 50px;*/
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
overflow-y: scroll;

}

.log {
display: inline-block;
vertical-align:top;
@@ -110,25 +113,24 @@ a {
margin-right:20px;
}

.loginLinksLineHeight{
line-height:30px;
}

.loginLinks:link{
line-height: 30px;
color: #321CA3;
text-decoration: none;
}
.loginLinks:visited{
line-height: 30px;
text-decoration: none;
color: #321CA3;
}

.loginLinks:hover{
line-height: 30px;
text-decoration: none;
color: #5D49C4;
}
.loginLinks:active{
line-height: 30px;
text-decoration: none;
color: #321CA3;
}
@@ -160,8 +162,7 @@ a {

.loginContainer{
margin: 0 auto;
margin-top: 15px;
width:450px;
width: 600px;
}
.colorRed{
color: red;
@@ -232,12 +233,15 @@ a {
border-top-color: LightGray;
border-left-color: LightGray;
border-radius: 4px;
text-decoration:none;
}
.hotbarButtons:focus{
outline: none;
text-decoration:none;
}
.hotbarButtons:hover{
/*color: #5D49C4;*/
text-decoration:none;
color: #6E6E6E;
}

@@ -260,4 +264,74 @@ a {

.btn-info{
color:#262626;
}

.contentContainer{
margin: 0 auto;
margin-top:20px;
width: 600px;
background-color: white;
}

.coolBorder{
border: 1px solid black;
border-color: rgba(100,100,100,1);
border-width: 1px 1px 1px 1px;
border-radius: 10px;
padding-left:30px;
padding-right:30px;
padding-top:30px;
padding-bottom:30px;
margin-bottom:20px;
margin-top:20px;

box-shadow: 0px 0px 20px #888888;
}

.squareBorder{
border: 1px solid black;
border-color: rgba(100,100,100,1);
border-width: 1px 1px 1px 1px;
padding-left:15px;
padding-right:15px;
padding-top:15px;
padding-bottom:15px;
margin-top:10px;

}

.breadcrumbsContainer{
margin-bottom:10px;
}



.identificationDiv{
width:150px;
}

.coursenameDiv{
}

.courseButton{
margin-bottom:5px;
margin-top:5px;
}

.inline{
display: inline-block;
}

.accountHotElement{
margin-top:4px;
margin-bottom:4px;
}

.submitcancelbuttons{
width:100px;
margin-right:10px;
}

.centerContent{
text-align: center;
}
@@ -63,6 +63,43 @@ module.exports = function(passport){
});
});

router.post('/addhotbarelement', isNotAuthenticated, function(req,res){
// ability to remove hotbar elements, should probably be async
// ability to change (username), (pw), email, fullname... might be a good idea to have it async
// function (fullname, email, username, id, callback)
//console.log("/addhotbarelement router was accessed");
//console.log("type: "+req.params.type);
//console.log("id: "+req.params.id);
//console.log("/addhotbarelement req.params: "+JSON.stringify(req.params));

//accountManager.removeHotbarElement = function (userid,type,elementid, callback) {
//return res.redirect('/account');
//console.log("/addhotbarelement, req.body: "+JSON.stringify(req.body));
//console.log("/addhotbarelement, req.body: "+req.body.type);
//console.log("/addhotbarelement, req.body: "+req.body.contentid);
//console.log("/addhotbarelement, req.body: "+req.body.contentname);
/*req.on('data', function(data)
{
console.log("/addhotbarelement route data: "+JSON.stringify(data))
});
return res.json({swag:"swag"});*/
// accountManager.addhotbarelement = function (userid,type,contentid,contentname, callback)
accountManager.addHotbarElement(req.user.id, req.body.type, req.body.contentid, req.body.contentname, function(err,result){
//console.log("/addhotbarelement... before if else");
if(err){
req.session.changesuccessmessage = "There was an error adding to hotbar. Try again.";
console.log("/addhotbarelement, err: "+err);
return res.json({error: req.session.changesuccessmessage});
}
else{
console.log("/addhotbarelement, insert success");
req.session.changesuccessmessage = "The hotbar element was successfully added.";
return res.json({success: req.session.changesuccessmessage});
}
//console.log("/addhotbarelement... after if else");
});
});

router.post('/updateprofile', isNotAuthenticated, function(req,res){
// ability to remove hotbar elements, should probably be async
// ability to change (username), (pw), email, fullname... might be a good idea to have it async
@@ -2,28 +2,53 @@

var courseManager = require('../lib/managers/course-manager');
var router = require('express').Router();
var isAuthenticated = require('../lib/isAuthenticated');
//var isAuthenticated = require('../lib/isAuthenticated');

router.get('/', function (req, res) {
// render summary metadatalist
summaryManager.getSummaryMetaData(req.body.courseId, function (err, result) {
// render summary metadata table with results
// handle error
res.render('course', { title: 'Courses', summaryMeta:result });
module.exports = function(passport){

router.get('/', function (req, res) {
// render summary metadatalist
summaryManager.getSummaryMetaData(req.body.courseId, function (err, result) {
// render summary metadata table with results
// handle error
res.render('course', { title: 'Courses', summaryMeta:result });
});
});

router.post('/', function (req, res) {
if(!req.isAuthenticated()){
res.redirect('/');
}
var courseName = req.body.name;
var courseCode = req.body.identificationCode;
var majorId = req.body.majorId;
courseManager.createCourse(courseName, courseCode, majorId, function (err, result) {
if(!err) {
res.send(result)
} else {
res.send(err)
}
});
});
});

router.post('/', isAuthenticated, function (req, res) {
var courseName = req.body.name;
var courseCode = req.body.identificationCode;
var majorId = req.body.majorId;
courseManager.createCourse(courseName, courseCode, majorId, function (err, result) {
if(!err) {
res.send(result)
} else {
res.send(err)
router.post('/addnewcourse', function (req, res) {
if(!req.isAuthenticated()){
console.log('/addnewcourse, user is not authenticated.');
return res.json({error: 'You are not authenticated.'});
}
var courseName = req.body.coursename;
var courseCode = req.body.courseidentificationcode;
var majorId = req.body.majorid;
courseManager.createCourse(courseName, courseCode, majorId, function (err, result) {
if(err) {
console.log('/addnewcourse, err: '+err);
return res.json({error: "There was an error."});
} else {
console.log('/addnewcourse, success');
return res.json({success: 'Course has been successfully added.'});
}
});
});
});
return router;

module.exports = router;
};
@@ -4,24 +4,59 @@ var courseManager = require('../lib/managers/course-manager');
var majorManager = require('../lib/managers/major-manager');
var router = require('express').Router();

router.get('/', function (req, res) {
// async request
courseManager.getCourseByMajor(req.body.majorId, function (err, result) {
// return courses asyncly
// handle error
var isNotAuthenticated = function (req, res, next) {
'use strict';
if (req.isAuthenticated()){
return next();

}
res.redirect('/');
};

module.exports = function(passport){

router.get('/:id', function (req, res) {
majorManager.getMajorByIdArnar(req.params.id, function(err,result){
if(err){
console.log("/major/:id get, err: "+err);
res.render('placeholder-major',{message:'There was an error.'});
}else{
var majorBreadcrumbs = result.rows[0];

// async request
//console.log('/major/:id :id is: '+req.params.id);
courseManager.getCoursesByMajorIdArnar(req.params.id, function (err, result) {
if(err){
console.log("/major/:id get, err: "+err);
res.render('placeholder-major', {message: 'There was an error.'});
}else{
console.log('/major/:id get, result.rows: '+JSON.stringify(result.rows));
console.log('get /major/:id, breadCrumbs: '+JSON.stringify(majorBreadcrumbs));
res.render('placeholder-major', {message:null, result:result.rows, breadcrumbs: majorBreadcrumbs});
}
// return courses asyncly
// handle error
});
}
})
});
});

router.post('/', isAuthenticated, function (req, res) {
var majorName = req.body.name;
var dptmtId = req.body.departmentId;
majorManager.createMajor(majorName, dptmtId, function (err, result) {
if(!err) {
res.send(result)
} else {
res.send(err)
router.post('/addnewmajor', function (req, res) {
if(!req.isAuthenticated()){
console.log('/addnewmajor, user is not authenticated.');
return res.json({error: 'You are not authenticated.'});
}
var majorName = req.body.majorname;
var departmentId = req.body.departmentid;
majorManager.createMajor(majorName, departmentId, function (err, result) {
if(err) {
console.log('/addnewmajor, err: '+err);
return res.json({error: "There was an error."});
} else {
console.log('/addnewmajor, success');
return res.json({success: 'Major has been successfully created.'});
}
});
});
});

module.exports = router;
return router;
};
@@ -1,6 +1,8 @@
extends layout
extends placeholder-layout

block content
h1= message
h2= error.status
p= message
br
p= error.status
br
pre #{error.stack}
@@ -2,15 +2,11 @@ extends placeholder-layout

block content
div.fullWidth
div.accountContainer.loginContainer
div.loginContainer.coolBorder
// user info
div
br
div
if changesuccessmessage
span(id="changesuccessmessage").colorRed=changesuccessmessage
else
br
if changesuccessmessage
span(id="changesuccessmessage").colorRed=changesuccessmessage
form(id="updateProfileForm" method="post" action='/account/updateprofile')
fieldset.form-group
label(for="fullname") Full name:
@@ -51,41 +47,23 @@ block content
div.verticalAlignment.fullWidth
label My courses:
div.verticalAlignment.fullWidth
div.fullWidth
div(onClick="location.href='/course?id=23';").btn.btn-info.hotElementWidth.leftContent .Línuleg Algebra
div(onClick="location.href='/account/removehotbarelement/course/23';").btn.btn-danger.hotRemoveWidth Remove
div.fullWidth
div(onClick="location.href='/course?id=23';").btn.btn-info.hotElementWidth.leftContent .Línuleg Algebra
div(onClick="location.href='/account/removehotbarelement/course/23';").btn.btn-danger.hotRemoveWidth Remove
each element in hotbarelements.courses
div.fullWidth
div(onClick="location.href='/"+element.type+"?id="+element.elementid+"';").btn.btn-info.hotElementWidth.leftContent=element.contentname
div(onClick="location.href='/account/removehotbarelement/"+element.type+"/"+element.elementid+"';").btn.btn-danger.hotRemoveWidth Remove
div.fullWidth.accountHotElement
a(href='/'+element.type+'/'+element.elementid).btn.btn-info.hotElementWidth.leftContent=element.contentname
a(href='/account/removehotbarelement/'+element.type+'/'+element.elementid).btn.btn-danger.hotRemoveWidth Remove
br
label My majors:
//div.fullWidth My majors:
div.verticalAlignment.fullWidth
div.fullWidth
div(onClick="location.href='/course?id=23';").btn.btn-info.hotElementWidth.leftContent .Línuleg Algebra
div(onClick="location.href='/account/removehotbarelement/course/23';").btn.btn-danger.hotRemoveWidth Remove
div.fullWidth
div(onClick="location.href='/course?id=23';").btn.btn-info.hotElementWidth.leftContent .Línuleg Algebra
div(onClick="location.href='/account/removehotbarelement/course/23';").btn.btn-danger.hotRemoveWidth Remove
each element in hotbarelements.majors
div.fullWidth
div(onClick="location.href='/"+element.type+"?id="+element.elementid+"';").btn.btn-info.hotElementWidth.leftContent=element.contentname
div(onClick="location.href='/account/removehotbarelement/"+element.type+"/"+element.elementid+"';").btn.btn-danger.hotRemoveWidth Remove
div.fullWidth.accountHotElement
a(href='/'+element.type+'/'+element.elementid).btn.btn-info.hotElementWidth.leftContent=element.contentname
a(href='/account/removehotbarelement/'+element.type+'/'+element.elementid).btn.btn-danger.hotRemoveWidth Remove
br
label My summaries:
div.verticalAlignment.fullWidth
div.fullWidth
div(onClick="location.href='/course?id=23';").btn.btn-info.hotElementWidth.leftContent .Línuleg Algebra
div(onClick="location.href='/account/removehotbarelement/course/23';").btn.btn-danger.hotRemoveWidth Remove
div.fullWidth
div(onClick="location.href='/course?id=23';").btn.btn-info.hotElementWidth.leftContent .Línuleg Algebra
div(onClick="location.href='/account/removehotbarelement/course/23';").btn.btn-danger.hotRemoveWidth Remove
each element in hotbarelements.summaries
div.fullWidth
div(onClick="location.href='/"+element.type+"?id="+element.elementid+"';").btn.btn-info.hotElementWidth.leftContent=element.contentname
div(onClick="location.href='/account/removehotbarelement/"+element.type+"/"+element.elementid+"';").btn.btn-danger.hotRemoveWidth Remove
div.fullWidth.accountHotElement
a(href='/'+element.type+'/'+element.elementid).btn.btn-info.hotElementWidth.leftContent=element.contentname
a(href='/account/removehotbarelement/'+element.type+'/'+element.elementid).btn.btn-danger.hotRemoveWidth Remove
script(src="/javascripts/frontend-account.js")
@@ -25,34 +25,34 @@ html(lang="is")
div.verticalMiddleContent.accountDiv.rightContent2
div
if !session.passport||!session.passport.user
a(href='/login').loginLinks Login
a(href='/login').loginLinks.loginLinksLineHeight Login
b |
a(href='/signup').loginLinks Signup
a(href='/signup').loginLinks.loginLinksLineHeight Signup
b |
a(href='/facebook-login')
img(src='/images/login-with-facebook.png' style='width:135px;height:30px;')
else
a(href='/account').loginLinks=user.fullname
a(href='/account').loginLinks.loginLinksLineHeight=user.fullname
b |
a(href='/logout').loginLinks Logout
a(href='/logout').loginLinks.loginLinksLineHeight Logout
// Hotbar
if session.passport
if session.passport.user
div.fullWidth.hotBarDiv
div.hotbarLabels My Courses:
button(onClick="location.href='/course?id=23';").hotbarButtons .Línuleg Algebra
button(onClick="location.href='/course?id=24';").hotbarButtons .Tölvunarfræði 1
//button(onClick="location.href='/course?id=23';").hotbarButtons .Línuleg Algebra
//button(onClick="location.href='/course?id=24';").hotbarButtons .Tölvunarfræði 1
each course in hotbarelements.courses
button(onClick="location.href='/course?id="+course.elementid+"';").hotbarButtons=course.contentname
a(href='/course/'+course.elementid).hotbarButtons.verticalMiddleContent=course.contentname
div.hotbarLabels My majors:
button(onClick="location.href='/major?id=4';").hotbarButtons .Tölvunarfræði
//button(onClick="location.href='/major?id=4';").hotbarButtons .Tölvunarfræði
each major in hotbarelements.majors
button(onClick="location.href='/major?id="+major.elementid+"';").hotbarButtons=major.contentname
a(href='/major/'+major.elementid).hotbarButtons.verticalMiddleContent=major.contentname
div.hotbarLabels My summaries:
button(onClick="location.href='/summary?id=4';").hotbarButtons .Línuleg Algebra
button(onClick="location.href='/summary?id=5';").hotbarButtons .Tölvunarfræði 1
//button(onClick="location.href='/summary?id=4';").hotbarButtons .Línuleg Algebra
//button(onClick="location.href='/summary?id=5';").hotbarButtons .Tölvunarfræði 1
each summary in hotbarelements.summaries
button(onClick="location.href='/summary?id="+summary.elementid+"';").hotbarButtons=summary.contentname
a(href='/summary/'+summary.elementid).hotbarButtons.verticalMiddleContent=summary.contentname
// lower border for header
div.headerBorder
main
@@ -2,7 +2,7 @@ extends placeholder-layout

block content
div.fullWidth
div.loginContainer
div.loginContainer.coolBorder
span Provide your login information.
br
br
@@ -15,7 +15,6 @@ block content
input(id="password" type="password" name="password" placeholder="Password" required).form-control
div
input(type="submit").form-control.btn-success.active
br
if (message != "")
div
span= message
@@ -0,0 +1,51 @@
extends placeholder-layout

block content
//major container
div.fullWidth
div.contentContainer
// breadcrumbs container
div.breadcrumbsContainer.mainHeader.verticalMiddleContent
div
div(style="display:none;")
p(id="contentid")=breadcrumbs.majorid
p(id="contentname")=breadcrumbs.majorname
span
a(href='/school/'+breadcrumbs.schoolid).loginLinks=breadcrumbs.schoolname
b=" > "
a(href='/department/'+breadcrumbs.departmentid).loginLinks=breadcrumbs.departmentname
b=" > "
a(href='/major/'+breadcrumbs.majorid).loginLinks=breadcrumbs.majorname
div.coolBorder
if user
div.fullWidth.centerContent
a(id="majorAddToHotbar").btn.btn-success.fullWidth Add major to hotbar
if result.length==0
p There are no courses yet.
else
each course in result
// a course
a(href='/course/'+course.courseid).btn.btn-info.courseButton.fullWidth.leftContent
div.identificationDiv.inline=course.identificationcode+" : "
div.coursenameDiv.inline=course.coursename
if user
a(id="addNewCourseFormOpen").btn.btn-success.courseButton.fullWidth.centerContent Add new course to this major
div(id="addNewCourseForm" href='javascript:void(0)' style="display:none;").squareBorder
form
fieldset.form-group
label(for="addNewCourseFormIdCode") Course identification code:
input(id="addNewCourseFormIdCode" type="text" name="addNewCourseFormIdCode" placeholder="Course identification code" required).form-control
fieldset.form-group
label(for="addNewCourseFormCourseName") Course name:
input(id="addNewCourseFormCourseName" type="text" name="addNewCourseFormCourseName" placeholder="Course name" required).form-control
div.horizontalAlignment
a(id="addNewCourseFormSubmit" href='javascript:void(0)').form-control.btn-success.active.submitcancelbuttons Submit
a(id="addNewCourseFormCancel" href='javascript:void(0)').form-control.btn-danger.active.submitcancelbuttons Cancel
else
a(href="/login").btn.btn-success.fullWidth Login to add new courses!

// container for the comment module
div.coolBorder Here is the chat module


script(src="/javascripts/frontend-major.js")
@@ -2,7 +2,7 @@ extends placeholder-layout

block content
div.fullWidth
div.loginContainer
div.loginContainer.coolBorder
span Provide your signup information.
br
br
@@ -26,11 +26,9 @@ block content
label(for="fullname") Full name:
input(id="fullname" type="text" name="fullname" placeholder="Full name" required).form-control
input(type="submit").form-control.btn-success.active
br
div
if (message != "")
span(id="message")= message
else
span(id="message")
if (message != "")
span(id="message")= message
else
span(id="message")

script(src="/javascripts/frontend-signup.js")