mirror of
https://github.com/bodyrep/DemoApp.git
synced 2026-01-25 06:32:11 +00:00
started moving content to corretn divs
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
$(document).ready(function() {
|
||||
//makes buttons buttons
|
||||
$("button").button();
|
||||
|
||||
console.log('document ready');
|
||||
//makes datepickers
|
||||
$( ".datepicker" ).datepicker();
|
||||
//$('#newworkout').find('input.datepicker').datepicker();
|
||||
@@ -25,6 +25,8 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
originalExerciselist = $.getValues("/api/exerciselist");
|
||||
|
||||
|
||||
$("button#addExercise").click(function() {
|
||||
console.log("click!");
|
||||
@@ -128,6 +130,124 @@ $(document).ready(function() {
|
||||
|
||||
//$('#newworkout').trigger('sortupdate');
|
||||
|
||||
$("button.map-link").click(function () {
|
||||
console.log('mapclick');
|
||||
var id = $(this).attr('value');
|
||||
console.log(id);
|
||||
$('div#Rightpane').empty().load(id, function(){
|
||||
PopulateExerciseList(originalExerciselist);
|
||||
});
|
||||
});
|
||||
|
||||
$(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">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" );
|
||||
$('#newworkout').trigger('sortupdate');
|
||||
})
|
||||
);
|
||||
|
||||
//filteredExerciseArray = filterarray(originalExerciselist);
|
||||
//PopulateExerciseList(arr);
|
||||
|
||||
$(document).on('click', '.filter',(function (){
|
||||
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)';
|
||||
}
|
||||
|
||||
console.log("Regex= " + keyREGEX);
|
||||
filteredExerciseArray = filterarray(originalExerciselist, keyREGEX);
|
||||
PopulateExerciseList(filteredExerciseArray);
|
||||
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
|
||||
|
||||
// for each exercise in workout
|
||||
// get H1RM for exercise
|
||||
// C1RMsum = 0
|
||||
// for each set in exercise
|
||||
// calculate C1RM and store in array
|
||||
// find highest C1RM in array
|
||||
// if C1RM > H1RM then
|
||||
// H1RM = C1RM
|
||||
// set comment to "yay"
|
||||
// for each value in array
|
||||
// set[index] = value/H1RM
|
||||
// C1RMsum += value/H1RM
|
||||
// Done
|
||||
|
||||
|
||||
// assume sum sumarray * each in musclearray
|
||||
|
||||
|
||||
|
||||
////// Make below standalone funtion "updateExerciselistDIV"
|
||||
function PopulateExerciseList(exerciselist) {
|
||||
console.time('PopulateExList');
|
||||
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>');
|
||||
$(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);
|
||||
});
|
||||
console.log("newexlist outside= " + newExerciselist);
|
||||
$('#exerciselist').empty();
|
||||
$(newExerciselist).appendTo('#exerciselist');
|
||||
$("button").button();
|
||||
console.timeEnd('PopulateExList');
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -59,6 +59,26 @@
|
||||
return arr;
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
// Pseudocode for 1RM calcs
|
||||
|
||||
// for each exercise in workout
|
||||
// get H1RM for exercise
|
||||
// C1RMsum = 0
|
||||
// for each set in exercise
|
||||
// calculate C1RM and store in array
|
||||
// find highest C1RM in array
|
||||
// if C1RM > H1RM then
|
||||
// H1RM = C1RM
|
||||
// set comment to "yay"
|
||||
// for each value in array
|
||||
// set[index] = value/H1RM
|
||||
// C1RMsum += value/H1RM
|
||||
// Done
|
||||
|
||||
|
||||
// assume sum sumarray * each in musclearray
|
||||
|
||||
|
||||
|
||||
////// Make below standalone funtion "updateExerciselistDIV"
|
||||
@@ -85,5 +105,3 @@ function PopulateExerciseList(exerciselist) {
|
||||
var originalExerciselist = $.getValues("/api/exerciselist");
|
||||
PopulateExerciseList(originalExerciselist);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -15,6 +15,14 @@ list-style-type: none;
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
#Leftpane {
|
||||
float: left;
|
||||
}
|
||||
|
||||
|
||||
#Rightpane {
|
||||
float: left;
|
||||
}
|
||||
|
||||
#exerciselist {
|
||||
width : 500px;
|
||||
|
||||
Reference in New Issue
Block a user