diff --git a/app.js b/app.js index 68221fb..48c91ff 100644 --- a/app.js +++ b/app.js @@ -1,13 +1,13 @@ -var express = require('express'); -var session = require('express-session'); +var express = require('express'); +var session = require('express-session'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); var morgan = require('morgan'); -var app = express(); -var port = process.env.PORT || 3000; +var app = express(); +var port = process.env.PORT || 3000; var passport = require('passport'); -var flash = require('connect-flash'); +var flash = require('connect-flash'); require('./config/passport')(passport); app.use('/public', express.static('public')); @@ -17,17 +17,17 @@ app.use('/node_modules', express.static('node_modules')); app.use(morgan('dev')); app.use(cookieParser()); app.use(bodyParser.urlencoded({ - extended: true + extended: true })); app.use(bodyParser.json()); app.set('view engine', 'ejs'); app.use(session({ - secret: 'vocabuilder', - resave: true, - saveUninitialized: true -} )); + secret: 'vocabuilder', + resave: true, + saveUninitialized: true +})); app.use(passport.initialize()); app.use(passport.session()); app.use(flash()); diff --git a/app/review.js b/app/review.js index 29026af..6547588 100644 --- a/app/review.js +++ b/app/review.js @@ -1,9 +1,21 @@ module.exports = function(req, res) { remword = function(userid, wordid) { - connection.query("UPDATE ?? SET progress = progress + 1, daterev = ADDDATE(daterev, 2*progress) WHERE id = ?", - [userid, wordid], function(err, rows) { - if (err) throw err; - }); + if (word.numDontRem < 2) { + connection.query("UPDATE ?? SET progress = progress + 1, daterev = ADDDATE(daterev, 2*progress) WHERE id = ?", + [userid, wordid], function(err, rows) { + if (err) throw err; + }); + } + } + + // a function that does not set a new revision date, for testing purposes + remword2 = function(userid, word) { + if (word.numDontRem < 2) { + connection.query("UPDATE ?? SET progress = progress + 1 WHERE id = ?", + [userid, word.id], function(err, rows) { + if (err) throw err; + }); + } } }; var mysql = require('mysql'); diff --git a/app/routes.js b/app/routes.js index 066011c..c459c4f 100644 --- a/app/routes.js +++ b/app/routes.js @@ -136,7 +136,7 @@ module.exports = function(app, passport) { }); app.post('/remword', function(req, res) { - remword(req.user.id, req.body.id); + remword2(req.user.id, req.body); }); app.get('/logout', function(req, res) { diff --git a/app/word-list.js b/app/word-list.js index c7dff8f..0f81a2d 100644 --- a/app/word-list.js +++ b/app/word-list.js @@ -11,8 +11,9 @@ module.exports = function(req, res) { mm = tomorrow.getMonth()+1; yyyy = tomorrow.getFullYear(); tomorrow = yyyy + '-' + mm + '-' + dd; + // review date is set to today for testing purpose connection.query("INSERT INTO ?? ( word, phonetic, meaning, progress, dateadded, daterev, datecomp ) values (?,?,?,?,?,?,?)", - [userid, word, phonetic, meaning, 0, today, tomorrow, "1000-1-1"], function(err, rows) { + [userid, word, phonetic, meaning, 0, today, today, "1000-1-1"], function(err, rows) { if (err) throw err; }); } @@ -40,7 +41,8 @@ module.exports = function(req, res) { } getRevWordList = function(userid, callback) { - connection.query("SELECT * FROM ?? WHERE DATE_FORMAT(daterev, '%Y-%m-%d') <= CURDATE()", + connection.query("SELECT * FROM ?? WHERE DATE_FORMAT(daterev, '%Y-%m-%d') <= CURDATE() \ + and progress < 10", [userid], function(err, rows){ if (err) throw err; return callback(null, rows); diff --git a/config/database.js b/config/database.js index 301bcab..a322469 100644 --- a/config/database.js +++ b/config/database.js @@ -1,10 +1,10 @@ // config/database.js module.exports = { - 'connection': { - 'host': 'localhost', - 'user': 'root', - 'password': 'root' - }, - 'database': 'vocabuilder', - 'users_table': 'users' -}; + 'connection': { + 'host': 'localhost', + 'user': 'root', + 'password': 'root' + }, + 'database': 'vocabuilder', + 'users_table': 'users' +}; \ No newline at end of file diff --git a/config/passport.js b/config/passport.js index 943ae3b..08ea435 100644 --- a/config/passport.js +++ b/config/passport.js @@ -42,8 +42,7 @@ module.exports = function(passport) { password: bcrypt.hashSync(password, null, null), }; var insertQuery = "INSERT INTO users ( username, password, firstname, lastname, email ) values (?,?,?,?,?)"; - connection.query(insertQuery, [newUserMysql.username, newUserMysql.password - , req.body.firstname, req.body.lastname, req.body.email], function(err, rows) { + connection.query(insertQuery, [newUserMysql.username, newUserMysql.password, req.body.firstname, req.body.lastname, req.body.email], function(err, rows) { newUserMysql.id = rows.insertId; console.log(rows.insertId); var tablename = rows.insertId; @@ -51,8 +50,8 @@ module.exports = function(passport) { word VARCHAR(30), phonetic VARCHAR(10), meaning VARCHAR(255), \ progress TINYINT, dateadded DATE, daterev DATE, datecomp DATE, \ UNIQUE INDEX `id_UNIQUE` (`id` ASC))', [tablename], function(err, rows) { - if (err) throw err; - }); + if (err) throw err; + }); return done(null, newUserMysql); }); } @@ -86,4 +85,4 @@ module.exports = function(passport) { }); }) ); -}; +}; \ No newline at end of file diff --git a/public/css/styles.css b/public/css/styles.css index 008a98b..9c7b77e 100644 --- a/public/css/styles.css +++ b/public/css/styles.css @@ -1,39 +1,52 @@ .btn-primary { background-color: #5B9BD5 !important; } + .top-buffer-20 { - margin-top:20px; + margin-top: 20px; } + .top-buffer-50 { - margin-top:50px; + margin-top: 50px; } + .table-borderless td, .table-borderless th { - border: none; + border: none; } + .form-inline input { - margin-left: 10px; + margin-left: 10px; } + .form-inline * { margin-bottom: 10px; } + .navbar-custom { - background-color: #5B9BD5; + background-color: #5B9BD5; } + /* change the brand and text color */ -.navbar-custom .navbar-brand, -.navbar-custom .navbar-text { - color: rgba(255,255,255,.8); + +.navbar-custom .navbar-brand, .navbar-custom .navbar-text { + color: rgba(255, 255, 255, .8); } + /* change the link color */ + .navbar-custom .navbar-nav .nav-link { - color: rgba(255,255,255,.5); + color: rgba(255, 255, 255, .5); } + /* change the color of active or hovered links */ -.navbar-custom .nav-item.active .nav-link, -.navbar-custom .nav-item:hover .nav-link { - color: #ffffff; + +.navbar-custom .nav-item.active .nav-link, .navbar-custom .nav-item:hover .nav-link { + color: #ffffff; +} + +.form-control { + width: 100%; } -.form-control { width: 100%; } .modal-error { background-color: #F2DEDE !important; @@ -56,4 +69,4 @@ width: 50%; float: left; padding: 1%; -} +} \ No newline at end of file diff --git a/views/modals/profile.ejs b/views/modals/profile.ejs index ed9d121..a63ba0a 100644 --- a/views/modals/profile.ejs +++ b/views/modals/profile.ejs @@ -91,4 +91,4 @@ - + \ No newline at end of file diff --git a/views/partials/head.ejs b/views/partials/head.ejs index f2ebaa9..de98a50 100644 --- a/views/partials/head.ejs +++ b/views/partials/head.ejs @@ -4,4 +4,6 @@ -