mirror of
https://github.com/bodyrep/DemoApp.git
synced 2026-01-25 14:43:00 +00:00
added methods and routes for getting an exercises history, and the sum of a workouts musclearrays -- incl a modifier
This commit is contained in:
@@ -66,30 +66,41 @@ $(document).ready(function() {
|
||||
$("#newworkout").bind('sortupdate', function(event, ui) {
|
||||
$('#exercises > li').each(function(){
|
||||
var itemindex= $(this).index();
|
||||
var newname = $(this).find('input, select').attr('name').replace(/elements\[[0-9]*\]/,'elements[' + itemindex + ']');
|
||||
// var newname = $(this).find('input, select').attr('name').replace(/elements\[[0-9]*\]/,'elements[' + itemindex + ']');
|
||||
$(this).find('input, select').each(function() {
|
||||
var newname = $(this).attr('name').replace(/elements\[[0-9]*\]/,'elements[' + itemindex + ']');
|
||||
$(this).attr('name', newname);
|
||||
});
|
||||
// $(this).find('label').each(function() {
|
||||
// var value = $(this).attr('href');
|
||||
// console.log ('value -' + value);
|
||||
// $(this).attr('href', value.replace(/elements\[[0-9]*\]/,'elements[' + itemindex + ']'));
|
||||
|
||||
$(this).children('label').html(newname);
|
||||
$(this).children('input').attr('name', newname);
|
||||
// //var newname = $(this).html.replace(/elements\[[0-9]*\]/,'elements[' + itemindex + ']');
|
||||
// //$(this).html(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 = $(this).attr('name').replace(/\[splits\]\[[0-9]*\]/,'[splits][' + itemindex2 + ']');
|
||||
newname2 = newname2.replace(/elements\[[0-9]*\]/,'elements[' + itemindex + ']');
|
||||
$(this).children('label').each(function(){
|
||||
//var newname2 = $(this).attr('name').replace(/\[splits\]\[[0-9]*\]/,'[splits][' + itemindex2 + ']');
|
||||
//newname2 = newname2.replace(/elements\[[0-9]*\]/,'elements[' + itemindex + ']');
|
||||
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();
|
||||
console.log(">1 " + $(this).siblings('.set').length);
|
||||
} else {
|
||||
$(this).children('.delete').hide();
|
||||
console.log("=1 " + $(this).siblings('.set').length);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -3,8 +3,11 @@
|
||||
$(document).on('click', '.addthisExercise',(function() {
|
||||
// $("button.addthisExercise").click(function() {
|
||||
console.log("This exercise name li" + JSON.stringify($(this).closest('li').data()));
|
||||
var newElem = $('<li class=ui-state-default ><label for="element">elements[0][exerciseID]<br /></label><input name="elements[][exerciseID]" class="element" value="' + $(this).closest('li').data('name') + '"><button type="button" class="addSet">Add Set</button><button type="button" class="delete">Delete Exercise</button><ul class="sets"><li class="set"><label for="element" name="elements[0][splits][0][reps]">elements[0][splits][0][reps]<br /></label><input name="elements[0][splits][0][reps]" class="element"><label for="element" name="elements[0][splits][0][weight]"><br />elements[0][splits][0][weight]<br /></label><input name="elements[0][splits][0][weight]" class="element"><button type="button" class="delete">Delete Set</button></li></ul></li>');
|
||||
var newElem = $('<li class=ui-state-default ><label for="element">Name</label><input name="exercisename" class="element" value="' + $(this).closest('li').data('name') + '"><input name="elements[][exerciseID]" class="hiddenelement" value="' + $(this).closest('li').data('exid') + '"><input name="elements[][Modifier]" class="element" value="' + $(this).closest('li').data('musclearrayMod') + '"><button type="button" class="addSet">Add Set</button><button type="button" class="delete">Delete Exercise</button><ul class="sets"><li class="set"><label for="element" name="elements[0][splits][0][reps]">elements[0][splits][0][reps]<br /></label><input name="elements[0][splits][0][reps]" class="element"><label for="element" name="elements[0][splits][0][weight]"><br />elements[0][splits][0][weight]<br /></label><input name="elements[0][splits][0][weight]" class="element"><button type="button" class="delete">Delete Set</button></li></ul></li>');
|
||||
$(newElem).data('musclearray', $(this).closest('li').data('musclearray'));
|
||||
$(newElem).data('musclearrayMod', $(this).closest('li').data('musclearrayMod'));
|
||||
$(newElem).appendTo('ul#exercises');
|
||||
$( ".hiddenelement" ).hide();
|
||||
$("button").button();
|
||||
$( "ul#exercises" ).sortable( "refresh" );
|
||||
$( "ul#sets" ).sortable( "refresh" );
|
||||
@@ -16,19 +19,26 @@
|
||||
//PopulateExerciseList(arr);
|
||||
|
||||
$(document).on('click', '.filter',(function (){
|
||||
console.time('Filter');
|
||||
var keyREGEX= "";
|
||||
var len = $('.filter').length;
|
||||
$(".filter").each(function(index, element) {
|
||||
var keyREGEX= "";
|
||||
if ($(".filter:checked").length > 0)
|
||||
{
|
||||
// any one is checked
|
||||
var len = $('.filter').length;
|
||||
$(".filter").each(function(index, element) {
|
||||
|
||||
if ($(this).is (':checked'))
|
||||
{
|
||||
// Do stuff
|
||||
keyREGEX += '('+ $(this).val() +')';
|
||||
}
|
||||
});
|
||||
//keyREGEX += "'";
|
||||
keyREGEX = keyREGEX.replace(")(", ")|(");
|
||||
} else {
|
||||
// none is checked
|
||||
keyREGEX = '(none is checked)';
|
||||
}
|
||||
|
||||
if ($(this).is (':checked'))
|
||||
{
|
||||
// Do stuff
|
||||
keyREGEX += '('+ $(this).val() +')';
|
||||
}
|
||||
});
|
||||
//keyREGEX += "'";
|
||||
keyREGEX = keyREGEX.replace(")(", ")|(");
|
||||
console.log("Regex= " + keyREGEX);
|
||||
filteredExerciseArray = filterarray(originalExerciselist, keyREGEX);
|
||||
PopulateExerciseList(filteredExerciseArray);
|
||||
@@ -59,6 +69,9 @@ function PopulateExerciseList(exerciselist) {
|
||||
//console.log("Exercisename = " + item.name);
|
||||
var newElem = $('<li>'+item.name + ' - ' + item.description + ' - ' + item.keywords +'<button type="button" class="addthisExercise">+</li>');
|
||||
$(newElem).data('name', item.name);
|
||||
$(newElem).data('exid', item._id);
|
||||
$(newElem).data('musclearray', item.musclearray);
|
||||
//$(newElem).data('musclearrayMod', item.musclearrayMod);
|
||||
$(newElem).data('datafields', item.datafields);
|
||||
newExerciselist.append(newElem);
|
||||
});
|
||||
@@ -74,9 +87,3 @@ function PopulateExerciseList(exerciselist) {
|
||||
});
|
||||
|
||||
|
||||
// function populateHandles() {
|
||||
// var options = '';
|
||||
// for (var i = 0; i < handles.length; i++) {
|
||||
// options += '<option value="' + handles[i] + '">' + handles[i] + '</option>';
|
||||
// }
|
||||
// $('#listBox').html(options);
|
||||
@@ -15,6 +15,7 @@ list-style-type: none;
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
|
||||
#exerciselist {
|
||||
width : 500px;
|
||||
height : 400px;
|
||||
|
||||
Reference in New Issue
Block a user