diff --git a/app.js b/app.js
index 10f51f8..eecd6dd 100644
--- a/app.js
+++ b/app.js
@@ -11,7 +11,7 @@ var express = require('express'),
passport = require('passport');
cookieParser = require('cookie-parser');
-mongoose.connect('mongodb://localhost/MakerSlot');
+mongoose.connect('mongodb://localhost/MakerSlot'); // every user gets their own local database?
var app = module.exports = express.createServer();
@@ -23,7 +23,7 @@ app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(cookieParser());
app.use(express.static(__dirname + '/public'));
-app.use(session({secret: 'weremakingawebsiteforseveral3dprinters', cookie:{}, saveUninitialized: false, resave: false}));
+app.use(session({secret: 'weremakingawebsiteforseveral3dprinters', cookie:{}, saveUninitialized: false, resave: false})); // hide the secret in the process.env?
app.use(passport.initialize());
app.use(passport.session());
app.use(app.router);
@@ -45,7 +45,7 @@ app.get('/deletePrint', routes.deletePrint)
//Forum routes
app.get('/forum', routes.dex)
-app.get('/getPosts', routes.getforumposts)
+app.get('/getPosts', routes.getforumposts) // most of your route names are camelcase (editForm) -- but this one's lowercase. Consistency!
app.post('/newPost', routes.newforumpost)
@@ -53,8 +53,7 @@ app.post('/newPost', routes.newforumpost)
app.get('/login', userroutes.login)
app.get('/logout', userroutes.logout)
app.get('/check', function(req,res){
- console.log("checking");
- console.log(req.session);
+ // get rid of debugging mechanisms before submitting code
res.send(req.user)
})
// Routes
@@ -74,6 +73,7 @@ app.post('/userCreate', passport.authenticate('local-signup',{
app.post('/submit', function(req,res){console.log("stahp")})
//Run verification code and import its important functions.
+// should this happen at the top? you use the "verification" variable earlier on.
var verification = require('./verification.js');
diff --git a/models/forumModel.js b/models/forumModel.js
index 72de967..f56ad61 100644
--- a/models/forumModel.js
+++ b/models/forumModel.js
@@ -1,6 +1,6 @@
var mongoose = require('mongoose');
-// Create a wiki page schema
+// Create a wiki page schema <-- make sure you update comments to match new context if you're reusing code :)
var forumSchema = mongoose.Schema({
user: String,
content: String,
diff --git a/models/printModel.js b/models/printModel.js
index 498e52a..b69b9d7 100644
--- a/models/printModel.js
+++ b/models/printModel.js
@@ -23,11 +23,11 @@ var printSchema = mongoose.Schema({
printMass: Number,
dateAndTime: String,
finish: String, //we need to add functionality to this
- duration: Number, //In minutes //and probably remove this
+ duration: Number, //In minutes //and probably remove this <- I think you should -- either this or finish time
ninjaApproval: Boolean,
printer: String,
problems: String
});
-module.exports = mongoose.model('print', printSchema);
\ No newline at end of file
+module.exports = mongoose.model('print', printSchema);
diff --git a/models/printerModel.js b/models/printerModel.js
index c379f9b..b2c4d6d 100644
--- a/models/printerModel.js
+++ b/models/printerModel.js
@@ -1,9 +1,9 @@
var mongoose = require('mongoose');
-// Create a wiki page schema
+// Create a wiki page schema <-- really, a wiki?
var printerSchema = mongoose.Schema({
name: String,
status: String
});
-module.exports = mongoose.model('printer', printerSchema);
\ No newline at end of file
+module.exports = mongoose.model('printer', printerSchema);
diff --git a/models/userModel.js b/models/userModel.js
index f3b2c7f..6e1f7c4 100644
--- a/models/userModel.js
+++ b/models/userModel.js
@@ -11,6 +11,7 @@ var userSchema = mongoose.Schema({
email: String
});
+// nice use of schema methods!
// methods ======================
// generating a hash
userSchema.methods.generateHash = function(password) {
@@ -22,4 +23,4 @@ userSchema.methods.validPassword = function(password) {
return bcrypt.compareSync(password, this.password);
};
-module.exports = mongoose.model('user', userSchema);
\ No newline at end of file
+module.exports = mongoose.model('user', userSchema);
diff --git a/package.json~ b/package.json~
deleted file mode 100644
index a5733f9..0000000
--- a/package.json~
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "name": "expressdemo",
- "version": "1.0.0",
- "description": "",
- "main": "index.js",
- "scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
- },
- "author": "",
- "license": "ISC",
- "dependencies": {
- "body-parser": "^1.14.2",
- "cookie-parser": "^1.4.1",
- "express": "^4.13.4",
- "express-handlebars": "^3.0.0",
- "morgan": "^1.6.1"
- }
-}
diff --git a/public/javascript/forum.js b/public/javascript/forum.js
index 2413cda..1237192 100644
--- a/public/javascript/forum.js
+++ b/public/javascript/forum.js
@@ -1,6 +1,9 @@
var forummodule = angular.module('forummodule', []);
+// I'm 100% ok with you using angular and 100% ok with you using straight-up jquery...
+// but I'm not ok with a combination of the two :/ Refactor to adhere to one design pattern?
-
+// I also can't tell how much of this file is in use -- looks like a good portion of it
+// is from the todo app.
function mainController($scope, $http) {
$scope.formData = {};
$scope.commentFormData = {};
diff --git a/public/javascript/home.js b/public/javascript/home.js
index cb84c80..dde9ff6 100644
--- a/public/javascript/home.js
+++ b/public/javascript/home.js
@@ -2,7 +2,10 @@ var onSuccess = function(data, status) {
console.log('added event');
window.location = "/schedule";
};
-
+// The clientside global scope includes *ALL* of your javascript files -- and you're
+// naming your onSuccess and onError callbacks the same thing in three different files.
+// Those functions WILL overlap -- you need to rename so they don't!
+
var onError = function(data, status) {
console.log("status", status);
console.log("error", data);
diff --git a/public/javascript/logs.js b/public/javascript/logs.js
index 6b1e388..ae609b5 100644
--- a/public/javascript/logs.js
+++ b/public/javascript/logs.js
@@ -7,7 +7,7 @@ var onSuccess = function(data, status) {
window.location = "/";
}
-var onSuccess2 = function(data, status) {
+var onSuccess2 = function(data, status) { // yep, your onSuccess functions will conflict -- this is a workaround, but could you pick a more semantic name?
window.location = "/";
}
diff --git a/public/javascript/main.js b/public/javascript/main.js
index 7159b26..4cc3498 100644
--- a/public/javascript/main.js
+++ b/public/javascript/main.js
@@ -1,7 +1,7 @@
//populates calendar, autofills form for edits
var onSuccess = function(data, status) {
$(document).ready(function(){
- $('input[value='+data.purpose+']').prop('checked',true);
+ $('input[value='+data.purpose+']').prop('checked',true);
$("#name").replaceWith('');
$("#email").replaceWith('');
$("#part").replaceWith('');
@@ -9,13 +9,13 @@ var onSuccess = function(data, status) {
$("#mass").replaceWith('');
$("#whenprint").replaceWith('');
$("#whendone").replaceWith('');
-
+
var hours = Math.floor(data.duration/60);
var minutes = data.duration%60;
-
+
$("input[name=hours]").replaceWith('')
$("input[name=minutes]").replaceWith('')
-
+
//change the data into something the program can use to find the html elements
if(data.ninjaApproval == true) {
var currentBoolean = "yes";
@@ -69,9 +69,9 @@ $(document).ready(function() {
height: 800,
firstDay: 1,
defaultView: 'agendaWeek'
-
+
})
-
+
var calendar = $('#calendar').fullCalendar('getCalendar');
calendar.on('dayClick', function(date, jsEvent, view) {
alert('clicked on ' + date.format());
@@ -98,7 +98,7 @@ $("#printFormEdit").submit(function(event) {
var hoursDur = $("input[name=hours]").val();
var minutesDur = $("input[name=minutes]").val();
var approved = $("input[name=approved]:checked").val();
- console.log(approved);
+ // remove debugging mechanisms!
var printer = $("input[name=printer]:checked").val();
var duration = parseInt(hoursDur)*60 + parseInt(minutesDur);
var problems = $("#problems").val();
@@ -132,6 +132,6 @@ function delPrint() {
$.get("deletePrint", {id: clicked})
.done(onSuccess4)
.error(onError);
- }
- }
+ }
+ }
}
diff --git a/routes/index.js b/routes/index.js
index fae67c8..b4b5ce6 100644
--- a/routes/index.js
+++ b/routes/index.js
@@ -1,11 +1,12 @@
-Print = require("../models/printModel")
-Forum = require("../models/forumModel")
-Announce = require("../models/announcementModel")
-Printer = require("../models/printerModel")
-Users = require("../models/userModel")
+// make sure you use `var`; be consistent w/ your semicolons (a linter could help)
+var Print = require("../models/printModel");
+var Forum = require("../models/forumModel");
+var Announce = require("../models/announcementModel");
+var Printer = require("../models/printerModel");
+var Users = require("../models/userModel");
var path = require('path'); //path allows the creation of paths (with /) from individual names
-routes = {}
+routes = {}
routes.index = function(req, res){
@@ -26,33 +27,31 @@ routes.getPrinters = function(req,res) {
//creates new printer and returns all printers
routes.newPrinter = function(req, res){
Users.findOne({name: req.user}, function (err, person) {
- if(err){
+ if (err) {
res.send(err)
};
- if(person.isNinja == true){
-
+ // be consistent w/ indentation & spacing -- fixed here, an issue throughout
+ if (person.isNinja == true) {
+ Printer.create({
+ name: req.body.name,
+ status: req.body.status
+ }, function(err, printers) {
+ if (err) {
+ res.send(err)
+ };
- Printer.create({
- name: req.body.name,
- status: req.body.status
- }, function(err, printers) {
+ Printer.find(function(err, printer) {
if (err) {
res.send(err)
};
-
- Printer.find(function(err, printer) {
- if (err) {
- res.send(err)
- };
res.json(printer);
- });
- }
- );
- }
-})
+ });
+ });
+ }
+ });
};
-//edit printer
+//edit printer
routes.editPrinter = function(req,res){
Printer.update({
_id : req.body.id},{$set:{
@@ -181,7 +180,7 @@ routes.editAnnouncement = function(req,res){
//deletes an announcement
routes.deleteAnnouncement = function(req,res){
//removes a print by id, then grabs all the remaining prints and returns them so they can be posted onto the calendar and it can be rerendered.
-
+
Users.findOne({name: req.user}, function (err, person) {
if(err){
res.send(err)
@@ -232,7 +231,7 @@ routes.newforumpost = function(req, res){
Forum.create({
content: req.body.content,
title: req.body.title,
- user: req.user
+ user: req.user
}, function(err, forum) {
if (err) {
res.send(err)
@@ -295,6 +294,7 @@ routes.editPrint = function(req,res){
//Updates a print through id, though that could be altered to whatever, probably even on-click, which we should see about doing.
//returns all the prints in the database including the edited one as well as the edited text alone.
Print.update({
+ // Is there a reason why you can't just $set:req.query? do you have to unpack in place like this?
_id : req.query.id},{$set:{name: req.query.name,
email: req.query.email,
part: req.query.part,
@@ -336,9 +336,7 @@ routes.getPrints = function(req,res){
res.send(err)
var events = [];
for (var i = 0;i -->