added methods and routes for getting an exercises history, and the sum of a workouts musclearrays -- incl a modifier

This commit is contained in:
2013-01-25 00:20:32 -05:00
parent 1e3238dcc7
commit 5584faedef
10 changed files with 105 additions and 35 deletions

View File

@@ -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);
}
});