diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 1a552d3..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -DemoApp \ No newline at end of file diff --git a/.idea/DemoApp.iml b/.idea/DemoApp.iml deleted file mode 100644 index 12d959d..0000000 --- a/.idea/DemoApp.iml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/.idea/dictionaries/fbleagh.xml b/.idea/dictionaries/fbleagh.xml deleted file mode 100644 index ab0dc3a..0000000 --- a/.idea/dictionaries/fbleagh.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index 7c62b52..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 81d02b4..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 6933c1e..0000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml deleted file mode 100644 index 6ea6fae..0000000 --- a/.idea/jsLibraryMappings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/.idea/libraries/sass_stdlib.xml b/.idea/libraries/sass_stdlib.xml deleted file mode 100644 index 8962a7d..0000000 --- a/.idea/libraries/sass_stdlib.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 008d8ad..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - jar:file:\C:\Program Files (x86)\JetBrains\WebStorm 5.0.4\lib\webide.jar!\resources\html5-schema\html5.rnc - - - - diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index cff7dfd..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml deleted file mode 100644 index 0d5175c..0000000 --- a/.idea/scopes/scope_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index ab55cf1..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 6478b1f..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,358 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SASS/SCSS - - - Spelling - - - XSLT - - - - - XSLT - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1359841287134 - 1359841287134 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/public/javascripts/scripts.js b/public/javascripts/scripts.js index 2758cc7..6e2585a 100644 --- a/public/javascripts/scripts.js +++ b/public/javascripts/scripts.js @@ -1,13 +1,49 @@ $(document).ready(function() { //makes buttons buttons $("button").button(); - //makes datepickers - $( ".datepicker" ).datepicker(); - $('.datepicker').datepicker('setDate', new Date()); + //just everything works better when synchro $.ajax({async:false}); - + +// $.widget( "ui.timespinner", $.ui.spinner, { +// options: { +// // seconds +// step: 60 * 1000, +// // hours +// page: 60, +// culture: "en-US", +// spin : function(event, ui) { +// console.log("SPINN!"); +// return false; +// }, +// change: function( event, ui ) { +// console.log("change!"); +// return false; +// } +// } + // _parse: function( value ) { + // if ( typeof value === "string" ) { + // // already a timestamp + // if ( Number( value ) == value ) { + // return Number( value ); + // } + // return +Globalize.parseDate( value ); + // } + // return value; + // }, + // _format: function( value ) { + // return Globalize.format( new Date(value), "t" ); + // } + // }); + + + // $( "#culture" ).change(function() { + // var current = $( "#spinner" ).timespinner( "value" ); + // Globalize.culture( $(this).val() ); + // $( "#spinner" ).timespinner( "value", current ); + // }); + // }); jQuery.extend({ getValues: function(url) { @@ -81,7 +117,7 @@ $(document).ready(function() { }); $(document).on('click', '.addSet',(function() { - var newElem = $('
  • '); + var newElem = $('
  • '); $(this).siblings('ul.sets').append(newElem); $("button").button(); $("ul.sets").sortable({ @@ -108,40 +144,7 @@ $(document).ready(function() { - $("#newworkout").bind('sortupdate', function(event, ui) { - $('#exercises > li').each(function(){ - var itemindex= $(this).index(); - $(this).find('input, select').each(function() { - var newname = $(this).attr('name').replace(/elements\[[0-9]*\]/,'elements[' + itemindex + ']'); - $(this).attr('name', newname); - }); - $(this).find('ul li').each(function(){ - var itemindex2= $(this).index(); - $(this).children('input').each(function(){ - var newname2 = $(this).attr('name').replace(/\[splits\]\[[0-9]*\]/,'[splits][' + itemindex2 + ']'); - newname2 = newname2.replace(/elements\[[0-9]*\]/,'elements[' + itemindex + ']'); - $(this).attr('name', newname2); - }); - - $(this).children('label').each(function(){ - var newname2 = 'Set '+ (itemindex2 + 1 ) + ''; - $(this).html(newname2); - }); - - //Only show delete if more than 1 set - if ( $(this).siblings('.set').length > 0 ) { - $(this).children('.delete').show(); - } else { - $(this).children('.delete').hide(); - } - - }); - - - - }); - }); @@ -162,7 +165,52 @@ $(document).ready(function() { $("#Leftpane").delegate("button.newex-link", "click",function () { var id = $(this).attr('value'); - $('div#Rightpane').empty().load(id); + $('div#Rightpane').empty().load(id, function(){ + //$( "#timespinner" ).timespinner(); + //makes datepickers + $( ".datepicker" ).datepicker(); + $('.datepicker').datepicker('setDate', new Date()); + + $("#newworkout").bind('sortupdate', function(event, ui) { + console.log('sortupdate called'); + $('#exercises > li').each(function(){ + var itemindex= $(this).index(); + $(this).find('input, select').each(function() { + var newname = $(this).attr('name').replace(/elements\[[0-9]*\]/,'elements[' + itemindex + ']'); + $(this).attr('name', newname); + }); + $(this).find('ul li').each(function(){ + var itemindex2= $(this).index(); + + $(this).children('input').each(function(){ + var newname2 = $(this).attr('name').replace(/\[splits\]\[[0-9]*\]/,'[splits][' + itemindex2 + ']'); + newname2 = newname2.replace(/elements\[[0-9]*\]/,'elements[' + itemindex + ']'); + $(this).attr('name', newname2); + }); + + // $(this).children('label').each(function(){ + // var newname2 = 'Set '+ (itemindex2 + 1 ) + ''; + // $(this).html(newname2); + // }); + + //Only show delete if more than 1 set + if ( $(this).siblings('.set').length > 0 ) { + $(this).children('.delete').show(); + } else { + $(this).children('.delete').hide(); + } + + }); + + + + }); + }); + + + + }); + $('div#Leftpane').empty().load("/workouts/filters", function(){ $('span.SVGBODYFilter').empty().load("/images/BlankBody.svg", function(){ //$("button").button(); @@ -193,6 +241,7 @@ $(document).ready(function() { $("button").button(); $('span.SVGBODY').empty().load("/images/BlankBody.svg", function(){ }); + LoadBodyHistory(); }); $('div#Leftpane').empty().load("/users/"+ id + "/sidebar", function(){ $("button").button(); @@ -203,7 +252,9 @@ $(document).ready(function() { var id = $(this).attr('href'); $('div#Rightpane').empty().load(id , function(){ $("button").button(); + LoadBodyHistory(); }); + return false; }); @@ -212,12 +263,13 @@ $(document).ready(function() { $('div#Rightpane').empty().load(id , function(){ $("button").button(); $( ".buttonset" ).buttonset(); + }); }); $(document).on('click', '.addthisExercise',(function() { - var newElem = $('
  • '); + var newElem = $('
  • '); $(newElem).data('musclearray', $(this).closest('li').data('musclearray')); $(newElem).data('musclearrayMod', $(this).closest('li').data('musclearrayMod')); $(newElem).appendTo('ul#exercises'); diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index e4f8a9c..0cf8cfc 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -39,6 +39,9 @@ li.floatleft { float: left; } +.workoutentry { + width: 250px; +} #Leftpane { display: block; @@ -52,7 +55,7 @@ li.floatleft { display: block; float: left; overflow: hidden; - width: 80%; + wxxxidth: 80%; } #userphoto { diff --git a/routes/admin.js b/routes/admin.js index fe0e3a2..4a98f02 100644 --- a/routes/admin.js +++ b/routes/admin.js @@ -17,7 +17,7 @@ module.exports = function(app) { app.get('/admin', loggedIn, isAdmin, function(req, res){ res.render('admin/index', { title: 'Admin' }); - }); +}); app.get('/admin/users', loggedIn, isAdmin, function(req, res, next){ var page = req.query.page && parseInt(req.query.page, 10) || 0; @@ -130,9 +130,13 @@ app.get('/admin/exercises', loggedIn, isAdmin, function(req, res, next){ }); app.post('/admin/exercises/:_id', function(req, res, next){ + console.log("Upsert data " + JSON.stringify(req.body)); var exercise = req.body; + console.log("Upsert exercise " + JSON.stringify(exercise)); var docid = req.body._id; + console.log("DOCID " + docid); delete exercise["_id"]; + console.log("Upsert document " + JSON.stringify(exercise)); Exercise.findByIdAndUpdate(docid, exercise, {upsert: false}, function(err) { if (err) { if (err.code === 11000) { @@ -150,9 +154,6 @@ app.get('/admin/exercises', loggedIn, isAdmin, function(req, res, next){ } res.redirect('/admin/exercises'); }); - - - }); diff --git a/routes/users.js b/routes/users.js index 3d91f9e..2f48ea8 100644 --- a/routes/users.js +++ b/routes/users.js @@ -11,6 +11,7 @@ var restrictUserToSelf = require('./middleware/restrict_user_to_self'); var maxUsersPerPage = 5; var maxWorkoutsPerPage = 5; var Workout = require('../data/models/workout'); +var Moment = require('moment'); module.exports = function(app) { @@ -78,8 +79,12 @@ module.exports = function(app) { var workouts = results[1]; var lastPage = (page + 1) * maxWorkoutsPerPage >= count; - - + workouts.forEach(function (thisworkout) { + console.log("thisworkouts " + JSON.stringify(thisworkout)); + thisworkout.PrettyDate = Moment.utc(thisworkout.workoutDate).format("ddd, hA"); + console.log("time" + Moment.utc(thisworkout.workoutDate).format("ddd, hA")); + console.log("thisworkouts " + JSON.stringify(thisworkout.PrettyDate)); + }); res.render('users/profile', { title: 'User profile', diff --git a/routes/workouts.js b/routes/workouts.js index f934093..96f6450 100644 --- a/routes/workouts.js +++ b/routes/workouts.js @@ -52,6 +52,15 @@ module.exports = function(app) { var lastPage = (page + 1) * maxWorkoutsPerPage >= count; console.log("workouts- " + JSON.stringify(workouts)); + //console.log("time" + Moment.utc(req.workout.workoutDate).format("ddd, hA")); + //foreach + //json[0].workoutDate + workouts.forEach(function (thisworkout) { + console.log("thisworkouts " + JSON.stringify(thisworkout)); + thisworkout.PrettyDate = Moment.utc(thisworkout.workoutDate).format("ddd, hA"); + console.log("time" + Moment.utc(thisworkout.workoutDate).format("ddd, hA")); + console.log("thisworkouts " + JSON.stringify(thisworkout.PrettyDate)); + }); res.render('workouts/recent', { recentworkouts: workouts, diff --git a/views/scripts.jade b/views/scripts.jade index c693a03..11deb1a 100644 --- a/views/scripts.jade +++ b/views/scripts.jade @@ -2,6 +2,9 @@ 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/jquery.svg.min.js') +script(src='/javascripts/globalize.js') +script(src='/javascripts/cultures/globalize.culture.en-US.js') + script(src='/javascripts/scripts.js') //script(src='/javascripts/livevalidation_standalone.compressed.js') diff --git a/views/session/user.jade b/views/session/user.jade index a77eaa1..e6e2187 100644 --- a/views/session/user.jade +++ b/views/session/user.jade @@ -1,11 +1,11 @@ div#top - if (session.user) - + span b UserName  span= session.user.name - button.home-link(value= encodeURIComponent(session.user.name)) Home + button.home-link(value= encodeURIComponent(session.user.username)) Home span b  UserID  span= session.user._id diff --git a/views/users/sidebar.jade b/views/users/sidebar.jade index 795f3d0..ba6de7c 100644 --- a/views/users/sidebar.jade +++ b/views/users/sidebar.jade @@ -6,11 +6,11 @@ h2= user.name - if (session.user.username === requested) h2 Private View div - button.recent-link(value= encodeURIComponent(session.user.name) ) Recent workouts + button.recent-link(value= encodeURIComponent(session.user.username) ) Recent workouts div button.newex-link(value="/workouts/new") Create new workout div - button.map-link(value="/users/admin/edit") Edit User + button.map-link(value="/users/" + encodeURIComponent(session.user.username) + "/edit") Edit User div button Placeholder2 - else diff --git a/views/workouts/new.jade b/views/workouts/new.jade index 56d4d64..7bce28e 100644 --- a/views/workouts/new.jade +++ b/views/workouts/new.jade @@ -1,19 +1,18 @@ -h1 New workout +h1 New workouty form#newworkout(method="POST", action="/workouts") ul li label(for="title", value="UserID") UserID - input#title(name="userID", value=session.user._id) + input#title(name="userID", value=session.user.name) li label(for="datepicker", value="Date") workoutDate input.datepicker(name="workoutDate") li label(for="timepicker", value="Time") workoutTime - select(name="workoutTime") - option(value='0100') 1 AM - option(value='0130') 1:30 AM - option(value='0200') 2 AM + input#timespinner(name="workoutTime", value="08:30 PM" ) + + ul#exercises diff --git a/views/workouts/recent.jade b/views/workouts/recent.jade index dbb97ee..80ba453 100644 --- a/views/workouts/recent.jade +++ b/views/workouts/recent.jade @@ -3,7 +3,7 @@ h3 Recent workouts: - recentworkouts.forEach(function(workout) { li.floatleft span(class="floatleft workoutentry") - a(class="map-link", href="/workouts/" + encodeURIComponent(workout._id))= workout._id + a(class="map-link", href="/workouts/" + encodeURIComponent(workout._id))= workout.PrettyDate each element in workout.elements p(class="workoutelement", data-musclearray=element.exerciseID.musclearray)= element.exerciseID.name ol diff --git a/views/workouts/workout.jade b/views/workouts/workout.jade index 456c016..f21e2c8 100644 --- a/views/workouts/workout.jade +++ b/views/workouts/workout.jade @@ -1,9 +1,19 @@ h1= workout.title - ul - li Time: #{workouttime} - each element in workout.elements - li= element.exerciseID.name - ul - each split in element.splits - li Reps: #{split.reps} Weight: #{split.weight} + li.floatleft + span(class="floatleft workoutentry") + a(class="map-link", href="/workouts/" + encodeURIComponent(workout._id))= workout.PrettyDate + each element in workout.elements + p(class="workoutelement", data-musclearray=element.exerciseID.musclearray)= element.exerciseID.name + ol + each split in element.splits + li Reps: #{split.reps} Weight: #{split.weight} + span(class="floatleft SVGBODY") + //include ../../public/images/BlankBody.svg + span(class="clearright") + + + +form(action="/workouts/" + encodeURIComponent(workout._id), method="POST") + input(name="_method", type="hidden", value="DELETE") + input(type="submit", value="Delete") \ No newline at end of file