mirror of
https://github.com/bodyrep/DemoApp.git
synced 2025-12-06 06:01:48 +00:00
fixed search and filters
This commit is contained in:
5
.idea/copyright/profiles_settings.xml
generated
5
.idea/copyright/profiles_settings.xml
generated
@@ -1,5 +0,0 @@
|
||||
<component name="CopyrightManager">
|
||||
<settings default="">
|
||||
<module2copyright />
|
||||
</settings>
|
||||
</component>
|
||||
9
.idea/libraries/sass_stdlib.xml
generated
9
.idea/libraries/sass_stdlib.xml
generated
@@ -1,9 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="sass-stdlib">
|
||||
<CLASSES />
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="file://$APPLICATION_HOME_DIR$/plugins/sass/lib/stubs/sass_functions.scss" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
5
.idea/scopes/scope_settings.xml
generated
5
.idea/scopes/scope_settings.xml
generated
@@ -1,5 +0,0 @@
|
||||
<component name="DependencyValidationManager">
|
||||
<state>
|
||||
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
|
||||
</state>
|
||||
</component>
|
||||
6
app.js
6
app.js
@@ -20,6 +20,7 @@ app.configure(function(){
|
||||
app.use(express.bodyParser());
|
||||
app.use(express.methodOverride());
|
||||
app.use(express.cookieParser('my secret string'));
|
||||
app.use(express.favicon());
|
||||
app.use(express.session({
|
||||
secret: 'my secret string',
|
||||
maxAge: 3600000,
|
||||
@@ -33,8 +34,8 @@ app.configure(function(){
|
||||
next();
|
||||
});
|
||||
app.set('port', 3000);
|
||||
app.use(app.router);
|
||||
app.use(express.static(__dirname + '/public'));
|
||||
app.use(app.router);
|
||||
});
|
||||
|
||||
app.configure('development', function(){
|
||||
@@ -53,6 +54,9 @@ require('./routes/session')(app);
|
||||
require('./routes/workouts')(app);
|
||||
require('./routes/admin')(app);
|
||||
require('./routes/api')(app);
|
||||
// This must be last
|
||||
require('./routes/404')(app);
|
||||
|
||||
|
||||
http.createServer(app).listen(app.get("port"), function(){
|
||||
console.log ("Server listening on port " + app.get("port"));
|
||||
|
||||
@@ -8,6 +8,8 @@ $(document).ready(function() {
|
||||
$('.datepicker').datepicker('setDate', new Date());
|
||||
//$('.datepicker').datepicker("hide");
|
||||
|
||||
//jsut everything work better
|
||||
$.ajax({async:false});
|
||||
|
||||
jQuery.extend({
|
||||
getValues: function(url) {
|
||||
@@ -114,29 +116,68 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
|
||||
$("ul#exercises").sortable({
|
||||
items: "> li",
|
||||
cancel: ':input, button' ,
|
||||
placeholder: "ui-state-highlight",
|
||||
revert: true,
|
||||
start: function(e, ui){
|
||||
ui.placeholder.height(ui.item.height());
|
||||
},
|
||||
stop: function(event, ui) {
|
||||
$('#newworkout').trigger('sortupdate');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//$('#newworkout').trigger('sortupdate');
|
||||
$("#Leftpane").delegate("button.recent-link", "click",function () {
|
||||
var id = $(this).attr('value');
|
||||
$('div#Rightpane').empty().load("/workouts/"+ id + "/recent/", function(){
|
||||
$("button").button();
|
||||
});
|
||||
$('div#Leftpane').empty().load("/users/"+ id + "/sidebar", function(){
|
||||
$("button").button();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$("#Leftpane").delegate("button.newex-link", "click",function () {
|
||||
var id = $(this).attr('value');
|
||||
$('div#Rightpane').empty().load(id);
|
||||
$('div#Leftpane').empty().load("/workouts/filters", function(){
|
||||
PopulateExerciseList(originalExerciselist);
|
||||
$("ul#exercises").sortable({
|
||||
items: "> li",
|
||||
cancel: ':input, button' ,
|
||||
placeholder: "ui-state-highlight",
|
||||
revert: true,
|
||||
start: function(e, ui){
|
||||
ui.placeholder.height(ui.item.height());
|
||||
},
|
||||
stop: function(event, ui) {
|
||||
$('#newworkout').trigger('sortupdate');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
$("button").button();
|
||||
});
|
||||
|
||||
$("#top").delegate("button.home-link", "click",function() {
|
||||
//$("#top").delegate("button.home-link", "click",function () {
|
||||
// window.location = this.id;
|
||||
|
||||
$("button.map-link").click(function () {
|
||||
console.log('mapclick');
|
||||
var id = $(this).attr('value');
|
||||
console.log(id);
|
||||
$('div#Rightpane').empty().load(id, function(){
|
||||
PopulateExerciseList(originalExerciselist);
|
||||
$('div#Rightpane').empty().load("/workouts/"+ id + "/recent/", function(){
|
||||
$("button").button();
|
||||
});
|
||||
$('div#Leftpane').empty().load("/users/"+ id + "/sidebar", function(){
|
||||
$("button").button();
|
||||
});
|
||||
});
|
||||
|
||||
$("#Rightpane").delegate("a", "click",function() {
|
||||
console.log("yup yup" + $(this).attr('href'));
|
||||
var id = $(this).attr('href');
|
||||
$('div#Rightpane').empty().load(id , function(){
|
||||
$("button").button();
|
||||
});
|
||||
// Stop regular handling of "click" in IE (and some others)
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#Leftpane").delegate("button.map-link", "click",function () {
|
||||
var id = $(this).attr('value');
|
||||
$('div#Rightpane').empty().load(id);
|
||||
$("button").button();
|
||||
});
|
||||
|
||||
$(document).on('click', '.addthisExercise',(function() {
|
||||
@@ -157,9 +198,28 @@ $(document).ready(function() {
|
||||
//filteredExerciseArray = filterarray(originalExerciselist);
|
||||
//PopulateExerciseList(arr);
|
||||
|
||||
$(document).on('click', '.filter',(function (){
|
||||
var keyREGEX= "";
|
||||
if ($(".filter:checked").length > 0)
|
||||
$(document).on('click', '.filter', function(){
|
||||
filterarray();
|
||||
});
|
||||
|
||||
$(document).on('keyup', '#searchbox', function(){
|
||||
filterarray();
|
||||
});
|
||||
|
||||
|
||||
|
||||
function filterarray(){
|
||||
console.time('Filter');
|
||||
|
||||
var searchstring = $("#searchbox").val();
|
||||
var keyREGEX= "";
|
||||
|
||||
if(jQuery.trim(searchstring).length > 0)
|
||||
{
|
||||
keyREGEX += '('+ searchstring +')';
|
||||
}
|
||||
|
||||
if ($(".filter:checked").length > 0)
|
||||
{
|
||||
// any one is checked
|
||||
var len = $('.filter').length;
|
||||
@@ -172,31 +232,43 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
//keyREGEX += "'";
|
||||
keyREGEX = keyREGEX.replace(")(", ")|(");
|
||||
} else {
|
||||
// none is checked
|
||||
keyREGEX = '(none is checked)';
|
||||
keyREGEX = keyREGEX.replace(/\)\(/g, ")|(");
|
||||
}
|
||||
|
||||
console.log("Regex= " + keyREGEX);
|
||||
filteredExerciseArray = filterarray(originalExerciselist, keyREGEX);
|
||||
PopulateExerciseList(filteredExerciseArray);
|
||||
//filteredExerciseArray = filterarray(originalExerciselist, keyREGEX);
|
||||
//PopulateExerciseList(filteredExerciseArray);
|
||||
|
||||
$("#exerciselist li").each(function(){
|
||||
//var keywordarray = $(this).data('keywords');
|
||||
var keyworddata = $(this).data('keywords').toString();
|
||||
if(jQuery.trim(searchstring).length > 0) {
|
||||
if ( ($(this).text().search(new RegExp(keyREGEX,'i')) > -1) && (keyworddata.search(new RegExp(keyREGEX,'ig')) > -1) ) {
|
||||
console.log("search" + $(this).text() + " " + keyREGEX);
|
||||
$(this).show();
|
||||
console.log('thisshow1 ' + $(this).text() + ' ' + keyworddata.search(new RegExp(keyREGEX,'ig')) );
|
||||
} else {
|
||||
console.log('thishide1 ' + $(this).text() + ' ' + keyworddata.search(new RegExp(keyREGEX,'ig')));
|
||||
$(this).hide();
|
||||
}
|
||||
}
|
||||
else if (keyworddata.search(new RegExp(keyREGEX,'ig')) > -1)
|
||||
{
|
||||
console.log('thisshow ' + $(this).text() + ' ' + keyworddata + ' ' + keyworddata.search(new RegExp(keyREGEX,'ig')));
|
||||
$(this).show();
|
||||
}
|
||||
else {
|
||||
console.log('thishide ' + $(this).text() + ' ' + keyworddata + ' ' + keyworddata.search(new RegExp(keyREGEX,'ig')));
|
||||
$(this).hide();
|
||||
}
|
||||
});
|
||||
|
||||
console.timeEnd('Filter');
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function filterarray(input, regex){
|
||||
console.log('passed regex' + regex);
|
||||
var keyRE=new RegExp(regex);
|
||||
var arr = jQuery.grep(input, function(n, i){
|
||||
return keyRE.test(n.keywords);
|
||||
// return $.grep(n.keywords, function (item, i) {
|
||||
// return keyRE.test(item);
|
||||
// });
|
||||
});
|
||||
console.log("arr " + arr.length);
|
||||
return arr;
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
// Pseudocode for 1RM calcs
|
||||
@@ -226,10 +298,11 @@ function PopulateExerciseList(exerciselist) {
|
||||
var newExerciselist = $('<div></div>');
|
||||
$.each(exerciselist, function (i, item) {
|
||||
//console.log("Exercisename = " + item.name);
|
||||
var newElem = $('<li>'+item.name + ' - ' + item.description + ' - ' + item.keywords +'<button type="button" class="addthisExercise">+</li>');
|
||||
var newElem = $('<li>'+item.name + ' - ' + item.description + '<button type="button" class="addthisExercise">+</li>');
|
||||
$(newElem).data('name', item.name);
|
||||
$(newElem).data('exid', item._id);
|
||||
$(newElem).data('musclearray', item.musclearray);
|
||||
$(newElem).data('keywords', item.keywords);
|
||||
//$(newElem).data('musclearrayMod', item.musclearrayMod);
|
||||
$(newElem).data('datafields', item.datafields);
|
||||
newExerciselist.append(newElem);
|
||||
|
||||
@@ -24,6 +24,12 @@ list-style-type: none;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#userphoto {
|
||||
width: 160px;
|
||||
height: 160px;
|
||||
background-color: #99B2FF;
|
||||
}
|
||||
|
||||
#exerciselist {
|
||||
width : 500px;
|
||||
height : 400px;
|
||||
|
||||
@@ -8,6 +8,7 @@ var isAdmin = require('./middleware/is_admin');
|
||||
|
||||
module.exports = function(app) {
|
||||
app.get('/', loggedIn, isAdmin, function(req, res){
|
||||
res.render('index', { title: 'Express' });
|
||||
//res.render('index', { title: 'Express' });
|
||||
res.redirect('/users/' + req.session.user.username);
|
||||
});
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* User Routes
|
||||
*/
|
||||
|
||||
var async = require('async');
|
||||
var User = require('../data/models/user');
|
||||
var notLoggedIn = require('./middleware/not_logged_in');
|
||||
var loggedIn = require('./middleware/logged_in');
|
||||
@@ -9,35 +9,38 @@ var loadUser = require('./middleware/load_user');
|
||||
var isAdmin = require('./middleware/is_admin');
|
||||
var restrictUserToSelf = require('./middleware/restrict_user_to_self');
|
||||
var maxUsersPerPage = 5;
|
||||
var maxWorkoutsPerPage = 5;
|
||||
var Workout = require('../data/models/workout');
|
||||
|
||||
module.exports = function(app) {
|
||||
|
||||
|
||||
app.get('/users', loggedIn, isAdmin, function(req, res, next){
|
||||
var page = req.query.page && parseInt(req.query.page, 10) || 0;
|
||||
res.redirect('/users/' + req.session.user.username);
|
||||
// var page = req.query.page && parseInt(req.query.page, 10) || 0;
|
||||
|
||||
User.count(function(err, count) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
var lastPage = (page + 1) * maxUsersPerPage >= count;
|
||||
// User.count(function(err, count) {
|
||||
// if (err) {
|
||||
// return next(err);
|
||||
// }
|
||||
// var lastPage = (page + 1) * maxUsersPerPage >= count;
|
||||
|
||||
User.find({})
|
||||
.sort('name')
|
||||
.skip(page * maxUsersPerPage)
|
||||
.limit(maxUsersPerPage)
|
||||
.exec(function(err, users) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
res.render('users/index', {
|
||||
title: 'Users',
|
||||
users: users,
|
||||
page: page,
|
||||
lastPage: lastPage
|
||||
});
|
||||
});
|
||||
});
|
||||
// User.find({})
|
||||
// .sort('name')
|
||||
// .skip(page * maxUsersPerPage)
|
||||
// .limit(maxUsersPerPage)
|
||||
// .exec(function(err, users) {
|
||||
// if (err) {
|
||||
// return next(err);
|
||||
// }
|
||||
// res.render('users/index', {
|
||||
// title: 'Users',
|
||||
// users: users,
|
||||
// page: page,
|
||||
// lastPage: lastPage
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
});
|
||||
|
||||
app.get('/users/new', notLoggedIn, function(req, res) {
|
||||
@@ -45,10 +48,43 @@ module.exports = function(app) {
|
||||
});
|
||||
|
||||
app.get('/users/:name', loadUser, function(req, res, next){
|
||||
req.user.recentworkouts(function(err, workouts) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
// req.user.recentworkouts(function(err, workouts) {
|
||||
// if (err) {
|
||||
// return next(err);
|
||||
// }
|
||||
|
||||
var page = req.query.page && parseInt(req.query.page, 10) || 0;
|
||||
async.parallel([
|
||||
|
||||
function(next) {
|
||||
Workout.count(next);
|
||||
},
|
||||
|
||||
function(next) {
|
||||
Workout.find({})
|
||||
//.sort('title', 1)
|
||||
.populate('elements.exerciseID')
|
||||
.skip(page * maxWorkoutsPerPage)
|
||||
.limit(maxWorkoutsPerPage)
|
||||
.exec(next);
|
||||
console.log("exercise search finsihed");
|
||||
}
|
||||
],
|
||||
|
||||
// callback from async
|
||||
function(err, results) {
|
||||
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
var count = results[0];
|
||||
var workouts = results[1];
|
||||
|
||||
var lastPage = (page + 1) * maxWorkoutsPerPage >= count;
|
||||
|
||||
|
||||
|
||||
res.render('users/profile', {
|
||||
title: 'User profile',
|
||||
user: req.user,
|
||||
@@ -58,6 +94,15 @@ module.exports = function(app) {
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/users/:name/sidebar', loadUser, function(req, res, next){
|
||||
res.render('users/sidebar', {
|
||||
user: req.user,
|
||||
requested: req.params.name
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
app.post('/users', notLoggedIn, function(req, res, next) {
|
||||
User.create(req.body, function(err) {
|
||||
if (err) {
|
||||
|
||||
@@ -17,7 +17,11 @@ var Moment = require('moment');
|
||||
|
||||
module.exports = function(app) {
|
||||
|
||||
app.get('/workouts/recent', loggedIn, function(req, res, next){
|
||||
app.get('/workouts', loggedIn, function(req, res) {
|
||||
res.redirect('/users/' + req.session.user.username);
|
||||
});
|
||||
|
||||
app.get('/workouts/:id/recent', loggedIn, function(req, res, next){
|
||||
var page = req.query.page && parseInt(req.query.page, 10) || 0;
|
||||
async.parallel([
|
||||
|
||||
@@ -28,6 +32,7 @@ module.exports = function(app) {
|
||||
function(next) {
|
||||
Workout.find({})
|
||||
//.sort('title', 1)
|
||||
.populate('elements.exerciseID')
|
||||
.skip(page * maxWorkoutsPerPage)
|
||||
.limit(maxWorkoutsPerPage)
|
||||
.exec(next);
|
||||
@@ -46,9 +51,10 @@ module.exports = function(app) {
|
||||
|
||||
var lastPage = (page + 1) * maxWorkoutsPerPage >= count;
|
||||
|
||||
console.log("workouts- " + JSON.stringify(workouts));
|
||||
|
||||
res.render('workouts/recent', {
|
||||
title: 'workouts',
|
||||
workouts: workouts,
|
||||
recentworkouts: workouts,
|
||||
page: page,
|
||||
lastPage: lastPage
|
||||
});
|
||||
@@ -61,24 +67,26 @@ module.exports = function(app) {
|
||||
res.render('workouts/new', {title: "New workout"});
|
||||
});
|
||||
|
||||
app.get('/workouts/:name/recent', loadUser, function(req, res, next){
|
||||
req.user.recentworkouts(function(err, workouts) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
res.render('workouts/recent', {
|
||||
//user: req.user,
|
||||
//requested: req.params.name,
|
||||
recentworkouts: workouts
|
||||
});
|
||||
});
|
||||
app.get('/workouts/filters', loggedIn, function(req, res) {
|
||||
res.render('workouts/filters');
|
||||
});
|
||||
|
||||
// app.get('/workouts/:name/recent', loadUser, function(req, res, next){
|
||||
// req.user.recentworkouts(function(err, workouts) {
|
||||
// if (err) {
|
||||
// return next(err);
|
||||
// }
|
||||
// res.render('workouts/recent', {
|
||||
// //user: req.user,
|
||||
// //requested: req.params.name,
|
||||
// recentworkouts: workouts
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
app.get('/workouts/:_id', loggedIn, loadWorkout, function(req, res, next){
|
||||
console.log("time" + Moment.utc(req.workout.workoutDate).format("ddd, hA"));
|
||||
var output = MuscleArray(req.workout);
|
||||
console.log('output - ' + JSON.stringify(output));
|
||||
|
||||
console.log('output - ' + JSON.stringify(output));
|
||||
res.render('workouts/workout', {title: req.workout.title,
|
||||
workout: req.workout,
|
||||
workouttime: Moment.utc(req.workout.workoutDate).format("ddd, hA")
|
||||
|
||||
@@ -1,71 +1,68 @@
|
||||
extends ../layout
|
||||
|
||||
block additionalscripts
|
||||
script(src='/javascripts/newexercisevalidation.js')
|
||||
|
||||
block content
|
||||
h1 Edit Exercise<p></p>
|
||||
|
||||
form(id="newexercise", method="POST", action="/admin/exercises/" + encodeURIComponent(exercise._id))
|
||||
ul
|
||||
li
|
||||
label(for="name") Exercise Name<br />
|
||||
input#name(name="name", value= exercise.name, oldvalue= exercise.name)
|
||||
input#_id(name="_id", value= exercise._id, type='hidden')
|
||||
|
||||
li
|
||||
label(for="type") Exercise Type<br />
|
||||
|
||||
//- first a little prep
|
||||
- freeweights = ('freeweights'==exercise.type) ? 'selected' : null;
|
||||
- machine = ('machine'==exercise.type) ? 'selected' : null;
|
||||
- bodyweight = ('bodyweight'==exercise.type) ? 'selected' : null;
|
||||
- kettlebells = ('kettelbells'==exercise.type) ? 'selected' : null;
|
||||
- cardio = ('cardio'==exercise.type) ? 'selected' : null;
|
||||
|
||||
select#type(name="type")
|
||||
option(value='notselected') Select One
|
||||
option(value='freeweights', selected=freeweights) Free Weights
|
||||
option(value='machine', selected=machine) Exercise Machine
|
||||
option(value='bodyweight', selected=bodyweight) Bodyweight
|
||||
option(value='kettlebells', selected=kettlebells) Kettlebells
|
||||
option(value='cardio', selected=cardio) Cardio
|
||||
|
||||
li
|
||||
label(for="type") Exercise Description<br />
|
||||
input#description(name="description", value= exercise.description)
|
||||
li
|
||||
label(for="type") Exercise Difficulty<br />
|
||||
input#difficulty(name="difficulty", value= exercise.difficulty)
|
||||
i = 0
|
||||
- for (i ; i < 10; ++i) {
|
||||
marray = "musclearray[" + i + "]"
|
||||
li
|
||||
label(for="type") Muscle data #{i}
|
||||
input(name= marray, class="musclearray", id= marray, value= exercise.musclearray[i])
|
||||
- }
|
||||
li
|
||||
keywordlist = [ 'Free Weights', 'Exercise Machine', 'Bodyweight', 'Kettlebells', 'Cardio']
|
||||
label(for="type") Keywords<br />
|
||||
select#type(name="keywords", multiple="multiple")
|
||||
- for keyword in keywordlist
|
||||
option(selected=exercise.keywords.indexOf(keyword) != -1) #{keyword}
|
||||
script(src='/javascripts/newexercisevalidation.js')
|
||||
|
||||
|
||||
li
|
||||
label(for="type") Alternatives<br />
|
||||
li
|
||||
datafieldlist = ['Reps','Weight','Time','Distance']
|
||||
label(for="datafields") Datafields<br />
|
||||
select#type(name="datafields", multiple="multiple")
|
||||
- for datafield in datafieldlist
|
||||
option(selected=exercise.datafields.indexOf(datafield) != -1) #{datafield}
|
||||
li
|
||||
input(type="submit", value="Save Changes")
|
||||
h1 Edit Exercise<p></p>
|
||||
|
||||
p
|
||||
a(href="/admin") Admin Index
|
||||
p
|
||||
a(href="/admin/users") Admin Users
|
||||
p
|
||||
a(href="/admin/exercises") Admin Exercises
|
||||
form(id="newexercise", method="POST", action="/admin/exercises/" + encodeURIComponent(exercise._id))
|
||||
ul
|
||||
li
|
||||
label(for="name") Exercise Name<br />
|
||||
input#name(name="name", value= exercise.name, oldvalue= exercise.name)
|
||||
input#_id(name="_id", value= exercise._id, type='hidden')
|
||||
|
||||
li
|
||||
label(for="type") Exercise Type<br />
|
||||
|
||||
//- first a little prep
|
||||
- freeweights = ('freeweights'==exercise.type) ? 'selected' : null;
|
||||
- machine = ('machine'==exercise.type) ? 'selected' : null;
|
||||
- bodyweight = ('bodyweight'==exercise.type) ? 'selected' : null;
|
||||
- kettlebells = ('kettelbells'==exercise.type) ? 'selected' : null;
|
||||
- cardio = ('cardio'==exercise.type) ? 'selected' : null;
|
||||
|
||||
select#type(name="type")
|
||||
option(value='notselected') Select One
|
||||
option(value='freeweights', selected=freeweights) Free Weights
|
||||
option(value='machine', selected=machine) Exercise Machine
|
||||
option(value='bodyweight', selected=bodyweight) Bodyweight
|
||||
option(value='kettlebells', selected=kettlebells) Kettlebells
|
||||
option(value='cardio', selected=cardio) Cardio
|
||||
|
||||
li
|
||||
label(for="type") Exercise Description<br />
|
||||
input#description(name="description", value= exercise.description)
|
||||
li
|
||||
label(for="type") Exercise Difficulty<br />
|
||||
input#difficulty(name="difficulty", value= exercise.difficulty)
|
||||
i = 0
|
||||
- for (i ; i < 10; ++i) {
|
||||
marray = "musclearray[" + i + "]"
|
||||
li
|
||||
label(for="type") Muscle data #{i}
|
||||
input(name= marray, class="musclearray", id= marray, value= exercise.musclearray[i])
|
||||
- }
|
||||
li
|
||||
keywordlist = [ 'Free Weights', 'Exercise Machine', 'Bodyweight', 'Kettlebells', 'Cardio']
|
||||
label(for="type") Keywords<br />
|
||||
select#type(name="keywords", multiple="multiple")
|
||||
- for keyword in keywordlist
|
||||
option(selected=exercise.keywords.indexOf(keyword) != -1) #{keyword}
|
||||
|
||||
|
||||
li
|
||||
label(for="type") Alternatives<br />
|
||||
li
|
||||
datafieldlist = ['Reps','Weight','Time','Distance']
|
||||
label(for="datafields") Datafields<br />
|
||||
select#type(name="datafields", multiple="multiple")
|
||||
- for datafield in datafieldlist
|
||||
option(selected=exercise.datafields.indexOf(datafield) != -1) #{datafield}
|
||||
li
|
||||
input(type="submit", value="Save Changes")
|
||||
|
||||
p
|
||||
a(href="/admin") Admin Index
|
||||
p
|
||||
a(href="/admin/users") Admin Users
|
||||
p
|
||||
a(href="/admin/exercises") Admin Exercises
|
||||
@@ -1,21 +1,18 @@
|
||||
extends ../layout
|
||||
h1 Bodyrep
|
||||
p Exercise Admin
|
||||
|
||||
block content
|
||||
h1 Bodyrep
|
||||
p Exercise Admin
|
||||
p
|
||||
a(href="/users") List Users
|
||||
p
|
||||
a(href="/workouts") List workouts
|
||||
p
|
||||
a(href="/admin") Admin Index
|
||||
p
|
||||
a(href="/admin/users") Admin Users
|
||||
p
|
||||
a(href="/admin/exercises") Admin Exercises
|
||||
p
|
||||
a(href="/admin/exercises/new") Add Exercise
|
||||
hr
|
||||
|
||||
p
|
||||
a(href="/users") List Users
|
||||
p
|
||||
a(href="/workouts") List workouts
|
||||
p
|
||||
a(href="/admin") Admin Index
|
||||
p
|
||||
a(href="/admin/users") Admin Users
|
||||
p
|
||||
a(href="/admin/exercises") Admin Exercises
|
||||
p
|
||||
a(href="/admin/exercises/new") Add Exercise
|
||||
hr
|
||||
|
||||
p= exercise
|
||||
p= exercise
|
||||
@@ -1,37 +1,28 @@
|
||||
extends ../layout
|
||||
h1 Bodyrep
|
||||
p Exercise Admin
|
||||
|
||||
block content
|
||||
h1 Bodyrep
|
||||
p Exercise Admin
|
||||
p
|
||||
a(href="/admin/users") Admin Users
|
||||
p
|
||||
a(href="/admin/exercises") Admin Exercises
|
||||
p
|
||||
a(href="/admin/exercises/new") Add Exercise
|
||||
hr
|
||||
|
||||
p
|
||||
a(href="/users") List Users
|
||||
p
|
||||
a(href="/workouts") List workouts
|
||||
p
|
||||
a(href="/admin") Admin Index
|
||||
p
|
||||
a(href="/admin/users") Admin Users
|
||||
p
|
||||
a(href="/admin/exercises") Admin Exercises
|
||||
p
|
||||
a(href="/admin/exercises/new") Add Exercise
|
||||
hr
|
||||
ul
|
||||
- exercises.forEach(function(exercise) {
|
||||
li
|
||||
a(href="/admin/exercises/" + encodeURIComponent(exercise._id))= exercise.name
|
||||
form(action="/admin/exercises/" + encodeURIComponent(exercise._id), method="POST")
|
||||
input(name="_method", type="hidden", value="DELETE")
|
||||
input(type="submit", value="Delete")
|
||||
- });
|
||||
|
||||
ul
|
||||
- exercises.forEach(function(exercise) {
|
||||
li
|
||||
a(href="/admin/exercises/" + encodeURIComponent(exercise._id))= exercise.name
|
||||
form(action="/admin/exercises/" + encodeURIComponent(exercise._id), method="POST")
|
||||
input(name="_method", type="hidden", value="DELETE")
|
||||
input(type="submit", value="Delete")
|
||||
- });
|
||||
- if (page > 0) {
|
||||
a(href="?page=" + (page - 1)) Previous
|
||||
|
||||
- }
|
||||
|
||||
- if (page > 0) {
|
||||
a(href="?page=" + (page - 1)) Previous
|
||||
|
||||
- }
|
||||
|
||||
- if (! lastPage) {
|
||||
a(href="?page=" + (page + 1)) Next
|
||||
- }
|
||||
- if (! lastPage) {
|
||||
a(href="?page=" + (page + 1)) Next
|
||||
- }
|
||||
@@ -4,12 +4,6 @@
|
||||
h1 Bodyrep
|
||||
p Admin Index
|
||||
|
||||
p
|
||||
a(href="/users") List Users
|
||||
p
|
||||
a(href="/workouts") List workouts
|
||||
p
|
||||
a(href="/admin") Admin Index
|
||||
p
|
||||
a(href="/admin/users") Admin Users
|
||||
p
|
||||
|
||||
@@ -1,45 +1,42 @@
|
||||
extends ../layout
|
||||
script(src='/javascripts/newexercisevalidation.js')
|
||||
|
||||
block additionalscripts
|
||||
script(src='/javascripts/newexercisevalidation.js')
|
||||
|
||||
block content
|
||||
h1 New Exercise<p></p>
|
||||
h1 New Exercise<p></p>
|
||||
|
||||
form(id="newexercise", method="POST", action="/admin/exercises/new")
|
||||
ul
|
||||
li
|
||||
label(for="name") Exercise Name<br />
|
||||
input#name(name="name")
|
||||
li
|
||||
label(for="type") Exercise Description<br />
|
||||
input#description(name="description", class="needsnumber")
|
||||
li
|
||||
label(for="type") Exercise Difficulty<br />
|
||||
input#difficulty(name="difficulty")
|
||||
i = 0
|
||||
- for (i ; i < 10; ++i) {
|
||||
marray = "musclearray[" + i + "]"
|
||||
li
|
||||
label(for="type") Muscle data #{i}
|
||||
input(name= marray, class="musclearray", id= marray)
|
||||
- }
|
||||
li
|
||||
label(for="type") Keywords<br />
|
||||
select#type(name="keywords", multiple="multiple")
|
||||
option(value='Free Weights') Free Weights
|
||||
option(value='Exercise Machine') Exercise Machines
|
||||
option(value='Bodyweight') Bodyweight
|
||||
option(value='Kettlebells') Kettlebells
|
||||
option(value='Cardio') Cardio
|
||||
li
|
||||
label(for="type") Alternatives<br />
|
||||
li
|
||||
label(for="datafields") Datafields<br />
|
||||
select#type(name="datafields", multiple="multiple")
|
||||
option(value='Reps') Reps
|
||||
option(value='Weight') Weight
|
||||
option(value='Time') Time
|
||||
option(value='Distance') Distance
|
||||
li
|
||||
input(type="submit", value="Create")
|
||||
form(id="newexercise", method="POST", action="/admin/exercises/new")
|
||||
ul
|
||||
li
|
||||
label(for="name") Exercise Name<br />
|
||||
input#name(name="name")
|
||||
li
|
||||
label(for="type") Exercise Description<br />
|
||||
input#description(name="description", class="needsnumber")
|
||||
li
|
||||
label(for="type") Exercise Difficulty<br />
|
||||
input#difficulty(name="difficulty")
|
||||
i = 0
|
||||
- for (i ; i < 10; ++i) {
|
||||
marray = "musclearray[" + i + "]"
|
||||
li
|
||||
label(for="type") Muscle data #{i}
|
||||
input(name= marray, class="musclearray", id= marray)
|
||||
- }
|
||||
li
|
||||
label(for="type") Keywords<br />
|
||||
select#type(name="keywords", multiple="multiple")
|
||||
option(value='Free Weights') Free Weights
|
||||
option(value='Exercise Machine') Exercise Machines
|
||||
option(value='Bodyweight') Bodyweight
|
||||
option(value='Kettlebells') Kettlebells
|
||||
option(value='Cardio') Cardio
|
||||
li
|
||||
label(for="type") Alternatives<br />
|
||||
li
|
||||
label(for="datafields") Datafields<br />
|
||||
select#type(name="datafields", multiple="multiple")
|
||||
option(value='Reps') Reps
|
||||
option(value='Weight') Weight
|
||||
option(value='Time') Time
|
||||
option(value='Distance') Distance
|
||||
li
|
||||
input(type="submit", value="Create")
|
||||
@@ -1,36 +1,27 @@
|
||||
extends ../layout
|
||||
h1 Bodyrep
|
||||
p User Admin
|
||||
|
||||
block content
|
||||
h1 Bodyrep
|
||||
p User Admin
|
||||
p
|
||||
a(href="/admin/users") Admin Users
|
||||
p
|
||||
a(href="/admin/exercises") Admin Exercises
|
||||
|
||||
p
|
||||
a(href="/users") List Users
|
||||
p
|
||||
a(href="/workouts") List workouts
|
||||
p
|
||||
a(href="/admin") Admin Index
|
||||
p
|
||||
a(href="/admin/users") Admin Users
|
||||
p
|
||||
a(href="/admin/exercises") Admin Exercises
|
||||
hr
|
||||
|
||||
hr
|
||||
ul
|
||||
- users.forEach(function(user) {
|
||||
li
|
||||
a(href="/users/" + encodeURIComponent(user.username))= user.name
|
||||
form(action="/admin/users/" + encodeURIComponent(user._id), method="POST")
|
||||
input(name="_method", type="hidden", value="DELETE")
|
||||
input(type="submit", value="Delete")
|
||||
- });
|
||||
|
||||
ul
|
||||
- users.forEach(function(user) {
|
||||
li
|
||||
a(href="/users/" + encodeURIComponent(user.username))= user.name
|
||||
form(action="/admin/users/" + encodeURIComponent(user._id), method="POST")
|
||||
input(name="_method", type="hidden", value="DELETE")
|
||||
input(type="submit", value="Delete")
|
||||
- });
|
||||
- if (page > 0) {
|
||||
a(href="?page=" + (page - 1)) Previous
|
||||
|
||||
- }
|
||||
|
||||
- if (page > 0) {
|
||||
a(href="?page=" + (page - 1)) Previous
|
||||
|
||||
- }
|
||||
|
||||
- if (! lastPage) {
|
||||
a(href="?page=" + (page + 1)) Next
|
||||
- }
|
||||
- if (! lastPage) {
|
||||
a(href="?page=" + (page + 1)) Next
|
||||
- }
|
||||
@@ -1,6 +1,7 @@
|
||||
script(src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js')
|
||||
script(src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js')
|
||||
script(src='http://jzaefferer.github.com/jquery-validation/jquery.validate.js')
|
||||
|
||||
script(src='/javascripts/scripts.js')
|
||||
|
||||
//script(src='/javascripts/livevalidation_standalone.compressed.js')
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
div#top
|
||||
|
||||
- if (session.user)
|
||||
p
|
||||
|
||||
span
|
||||
b UserName
|
||||
b UserName
|
||||
span= session.user.name
|
||||
button.home-link(value= encodeURIComponent(session.user.name)) Home
|
||||
span
|
||||
b  UserID
|
||||
span= session.user._id
|
||||
b  UserID
|
||||
span= session.user._id
|
||||
form(method="POST", action="/session")
|
||||
input(type="hidden", name="_method", value="DELETE")
|
||||
input(type="submit", value="Log out")
|
||||
|
||||
@@ -5,25 +5,8 @@ extends ../layout
|
||||
block content
|
||||
|
||||
div#Leftpane
|
||||
h2= user.name
|
||||
|
||||
- if (session.user)
|
||||
- if (session.user.name === requested)
|
||||
h2 Private View
|
||||
div
|
||||
button.map-link(value="/workouts/" + encodeURIComponent(session.user.name) + "/recent") Recent workouts
|
||||
div
|
||||
button.map-link(value="/workouts/new") Create new workout
|
||||
|
||||
- else
|
||||
h2 Public View
|
||||
|
||||
- if (session.user)
|
||||
- if (session.user.is_admin === true)
|
||||
div
|
||||
button.map-link(value="/admin") Goto Admin Page
|
||||
include ./sidebar
|
||||
|
||||
div#Rightpane
|
||||
|
||||
include ../workouts/recent
|
||||
|
||||
|
||||
@@ -1,27 +1,5 @@
|
||||
//extends ../layout
|
||||
//block content
|
||||
h1 New workout
|
||||
|
||||
h3 Exercises (dynamically loaded from database)
|
||||
ul#exerciselist
|
||||
li Unpopulated
|
||||
|
||||
div#filters
|
||||
h3 Filters
|
||||
label Free Weights
|
||||
input.filter(type="checkbox", checked=true, value="Free Weights")
|
||||
label Bodyweight
|
||||
input.filter(type="checkbox", checked=true, value="Bodyweight")
|
||||
label Exercise Machines
|
||||
input.filter(type="checkbox", checked=true, value='Exercise Machine')
|
||||
label Kettlebells
|
||||
input.filter(type="checkbox", checked=true, value='Kettlebells')
|
||||
label Cardio
|
||||
input.filter(type="checkbox", checked=true, value='Cardio')
|
||||
|
||||
//button#addExercise(type="button") Add Exercise
|
||||
hr
|
||||
|
||||
form#newworkout(method="POST", action="/workouts")
|
||||
ul
|
||||
li
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
h3 Recent workouts:
|
||||
ul
|
||||
- recentworkouts.forEach(function(workout) {
|
||||
li
|
||||
a.map-link(href="/workouts/" + encodeURIComponent(workout._id))= workout._id
|
||||
- });
|
||||
|
||||
- recentworkouts.forEach(function(workout) {
|
||||
li
|
||||
a.map-link(href="/workouts/" + encodeURIComponent(workout._id))= workout._id
|
||||
each element in workout.elements
|
||||
li= element.exerciseID.name
|
||||
ol
|
||||
each split in element.splits
|
||||
li Reps: #{split.reps} Weight: #{split.weight}
|
||||
- });
|
||||
@@ -1,35 +1,9 @@
|
||||
extends ../layout
|
||||
h1= workout.title
|
||||
|
||||
|
||||
block content
|
||||
h1= workout.title
|
||||
|
||||
div!= workout.body
|
||||
|
||||
hr
|
||||
|
||||
p
|
||||
span Workout ID:
|
||||
|
||||
a(href="/workouts/" + encodeURIComponent(workout._id))= workout._id
|
||||
div= workout
|
||||
ul
|
||||
li Time: #{workouttime}
|
||||
each element in workout.elements
|
||||
li= element.exerciseID
|
||||
ul
|
||||
each split in element.splits
|
||||
li Reps: #{split.reps} Weight: #{split.weight}
|
||||
|
||||
- if (session.user)
|
||||
- if (session.user.is_admin === true)
|
||||
form(action="/workouts/" + encodeURIComponent(workout._id), method="POST")
|
||||
input(name="_method", type="hidden", value="DELETE")
|
||||
input(type="submit", value="Delete")
|
||||
p
|
||||
a(href="/workouts") List workouts
|
||||
- else
|
||||
- if (session.user._id == workout.userID)
|
||||
form(action="/workouts/" + encodeURIComponent(workout._id), method="POST")
|
||||
input(name="_method", type="hidden", value="DELETE")
|
||||
input(type="submit", value="Delete")
|
||||
ul
|
||||
li Time: #{workouttime}
|
||||
each element in workout.elements
|
||||
li= element.exerciseID
|
||||
ul
|
||||
each split in element.splits
|
||||
li Reps: #{split.reps} Weight: #{split.weight}
|
||||
|
||||
Reference in New Issue
Block a user