mirror of
https://github.com/bodyrep/DemoApp.git
synced 2025-12-06 06:01:48 +00:00
fixing a few bits
This commit is contained in:
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 128 KiB After Width: | Height: | Size: 128 KiB |
@@ -1,14 +1,11 @@
|
||||
$(document).ready(function() {
|
||||
//makes buttons buttons
|
||||
$("button").button();
|
||||
console.log('document ready');
|
||||
//makes datepickers
|
||||
$( ".datepicker" ).datepicker();
|
||||
//$('#newworkout').find('input.datepicker').datepicker();
|
||||
$('.datepicker').datepicker('setDate', new Date());
|
||||
//$('.datepicker').datepicker("hide");
|
||||
|
||||
//jsut everything work better
|
||||
//just everything works better when synchro
|
||||
$.ajax({async:false});
|
||||
|
||||
jQuery.extend({
|
||||
@@ -28,33 +25,53 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
originalExerciselist = $.getValues("/api/exerciselist");
|
||||
//*[@id="F_x5F_Pectorals"]
|
||||
var musclesearcharray = [];
|
||||
var muscleSVGmap = ['Triceps','Forearms','Biceps','Deltoids','Back','Lats','Glutes','Hamstrings','Calves','Traps','Abs','Quads','Shins','Pectorals'];
|
||||
|
||||
// $('div#SVG1').empty().load("/images/BlankBody.svg", function(){
|
||||
// console.log('svg loaded');
|
||||
// });
|
||||
function LoadBodyHistory() {
|
||||
$('span.SVGBODY').empty().load("/images/BlankBody.svg", function(){
|
||||
workoutmusclesum = [0,0,0,0,0,0,0,0,0,0,0,0,0,0];
|
||||
var currentsvg = $(this).first('svg#Layer_1');
|
||||
$(this).siblings('.workoutentry').each(function(){
|
||||
$(this).children('p.workoutelement').each(function(){
|
||||
exercisemusculearray = $(this).data("musclearray");
|
||||
|
||||
// $('div#SVG1').svg({
|
||||
// loadURL: '/images/BlankBody.svg', // External document to load
|
||||
// onLoad: null, // Callback once loaded
|
||||
// settings: {width: '10cm', height: '5cm'}, // Additional settings for SVG element
|
||||
// initPath: ''});
|
||||
jQuery.each(exercisemusculearray, function(index, element) {
|
||||
//console.log('marray'+index +'=' + element);
|
||||
workoutmusclesum[index] = workoutmusclesum[index] + element; });
|
||||
});
|
||||
//console.log('Tarray= '+workoutmusclesum);
|
||||
|
||||
$('span.SVGBODY').empty().load("/images/BlankBody.svg", function(){
|
||||
//$("button").button();
|
||||
});
|
||||
jQuery.each(workoutmusclesum, function(index, element) {
|
||||
console.log('color='+ muscleSVGmap[index] +'=' + (element/5));
|
||||
$(currentsvg).find('g#' + muscleSVGmap[index]).children().css("opacity",(element/5));
|
||||
$(currentsvg).find('g#' + muscleSVGmap[index]).children().css("fill",'#0AADE3');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
LoadBodyHistory();
|
||||
var colors = "0f0 0ff f60 f0f 00f f00".split(' '), i=0;
|
||||
|
||||
$(document).on('click', '.SVGBODYFilter g',(function() {
|
||||
console.log('click ' + this.id);
|
||||
$(this).children('path').css("fill",'#'+colors[i++%colors.length] +'');
|
||||
})
|
||||
if ($(this).data('Clicked') === 'True') {
|
||||
$(this).data('Clicked', 'False');
|
||||
$(this).children('path').css("fill",'#0AADE3');
|
||||
musclesearcharray.splice(musclesearcharray.indexOf(this.id),1);
|
||||
filterarray();
|
||||
} else {
|
||||
$(this).data('Clicked', 'True');
|
||||
$(this).children('path').css("fill",'#00ff00');
|
||||
musclesearcharray.push(this.id);
|
||||
filterarray();
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
$("button#addExercise").click(function() {
|
||||
console.log("click!");
|
||||
var newElem = $('<li class=ui-state-default ><label for="element">elements[0][exerciseID]<br /></label><input name="elements[][exerciseID]" class="element"><button type="button" class="addSet">Add Set</button><button type="button" class="delete">Delete Exercise</button><ul class="sets"></ul></li>');
|
||||
$(newElem).appendTo('ul#exercises');
|
||||
$("button").button();
|
||||
@@ -93,20 +110,10 @@ $(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 + ']');
|
||||
$(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 + ']'));
|
||||
|
||||
// //var newname = $(this).html.replace(/elements\[[0-9]*\]/,'elements[' + itemindex + ']');
|
||||
// //$(this).html(newname);
|
||||
// });
|
||||
|
||||
$(this).find('ul li').each(function(){
|
||||
var itemindex2= $(this).index();
|
||||
|
||||
@@ -117,8 +124,6 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
$(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);
|
||||
});
|
||||
@@ -135,19 +140,18 @@ $(document).ready(function() {
|
||||
|
||||
|
||||
});
|
||||
//return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$("#Leftpane").delegate("button.recent-link", "click",function () {
|
||||
var id = $(this).attr('value');
|
||||
$('div#Rightpane').empty().load("/workouts/"+ id + "/recent/", function(){
|
||||
$("button").button();
|
||||
$('span.SVGBODY').empty().load("/images/BlankBody.svg", function(){
|
||||
//$('span.SVGBODY').empty().load("/images/BlankBody.svg", function(){
|
||||
//$("button").button();
|
||||
});
|
||||
//});
|
||||
LoadBodyHistory();
|
||||
});
|
||||
$('div#Leftpane').empty().load("/users/"+ id + "/sidebar", function(){
|
||||
$("button").button();
|
||||
@@ -182,30 +186,24 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
$("#top").delegate("button.home-link", "click",function() {
|
||||
//$("#top").delegate("button.home-link", "click",function () {
|
||||
// window.location = this.id;
|
||||
|
||||
var id = $(this).attr('value');
|
||||
$('div#Rightpane').empty().load("/workouts/"+ id + "/recent/", function(){
|
||||
$("button").button();
|
||||
console.log('here');
|
||||
$('span.SVGBODY').empty().load("/images/BlankBody.svg", function(){
|
||||
//$("button").button();
|
||||
var id = $(this).attr('value');
|
||||
$('div#Rightpane').empty().load("/workouts/"+ id + "/recent/", function(){
|
||||
$("button").button();
|
||||
$('span.SVGBODY').empty().load("/images/BlankBody.svg", function(){
|
||||
});
|
||||
});
|
||||
$('div#Leftpane').empty().load("/users/"+ id + "/sidebar", 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;
|
||||
var id = $(this).attr('href');
|
||||
$('div#Rightpane').empty().load(id , function(){
|
||||
$("button").button();
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#Leftpane").delegate("button.map-link", "click",function () {
|
||||
@@ -215,8 +213,6 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
$(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'));
|
||||
@@ -229,12 +225,10 @@ $(document).ready(function() {
|
||||
})
|
||||
);
|
||||
|
||||
//filteredExerciseArray = filterarray(originalExerciselist);
|
||||
//PopulateExerciseList(arr);
|
||||
|
||||
$(document).on('click', '.filter', function(){
|
||||
filterarray();
|
||||
});
|
||||
$(document).on('click', '.filter', function(){
|
||||
filterarray();
|
||||
});
|
||||
|
||||
$(document).on('keyup', '#searchbox', function(){
|
||||
filterarray();
|
||||
@@ -255,44 +249,36 @@ $(document).ready(function() {
|
||||
|
||||
if ($(".filter:checked").length > 0)
|
||||
{
|
||||
// any one is checked
|
||||
var len = $('.filter').length;
|
||||
$(".filter").each(function(index, element) {
|
||||
|
||||
if ($(this).is (':checked'))
|
||||
{
|
||||
// Do stuff
|
||||
if ($(this).is (':checked')){
|
||||
keyREGEX += '('+ $(this).val() +')';
|
||||
}
|
||||
});
|
||||
//keyREGEX += "'";
|
||||
keyREGEX = keyREGEX.replace(/\)\(/g, ")|(");
|
||||
}
|
||||
|
||||
if (musclesearcharray.length > 0 ){
|
||||
jQuery.each(musclesearcharray, function(index, element) {
|
||||
keyREGEX += '('+ this +')';
|
||||
});
|
||||
}
|
||||
keyREGEX = keyREGEX.replace(/\)\(/g, ")|(");
|
||||
console.log("Regex= " + keyREGEX);
|
||||
//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();
|
||||
}
|
||||
});
|
||||
@@ -301,6 +287,38 @@ $(document).ready(function() {
|
||||
}
|
||||
|
||||
|
||||
// function filterarrayMuscles(){
|
||||
// console.time('FilterMuscles');
|
||||
// var keyREGEX= "";
|
||||
// if (musclesearcharray.length > 0 ){
|
||||
// jQuery.each(musclesearcharray, function(index, element) {
|
||||
// keyREGEX += '('+ this +')';
|
||||
// });
|
||||
// }
|
||||
// keyREGEX = keyREGEX.replace(/\)\(/g, ")|(");
|
||||
// console.log("Regex= " + keyREGEX);
|
||||
|
||||
// $("#exerciselist li").each(function(){
|
||||
// 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) ) {
|
||||
// $(this).show();
|
||||
// } else {
|
||||
// $(this).hide();
|
||||
// }
|
||||
// }
|
||||
// else if (keyworddata.search(new RegExp(keyREGEX,'ig')) > -1)
|
||||
// {
|
||||
// $(this).show();
|
||||
// }
|
||||
// else {
|
||||
// $(this).hide();
|
||||
// }
|
||||
// });
|
||||
|
||||
// console.timeEnd('Filter');
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -331,7 +349,6 @@ 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 + '<button type="button" class="addthisExercise">+</li>');
|
||||
$(newElem).data('name', item.name);
|
||||
$(newElem).data('exid', item._id);
|
||||
@@ -341,7 +358,6 @@ function PopulateExerciseList(exerciselist) {
|
||||
$(newElem).data('datafields', item.datafields);
|
||||
newExerciselist.append(newElem);
|
||||
});
|
||||
console.log("newexlist outside= " + newExerciselist);
|
||||
$('#exerciselist').empty();
|
||||
$(newExerciselist).appendTo('#exerciselist');
|
||||
$("button").button();
|
||||
@@ -351,10 +367,3 @@ function PopulateExerciseList(exerciselist) {
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -35,10 +35,11 @@ form(id="newexercise", method="POST", action="/admin/exercises/" + encodeURIComp
|
||||
label(for="type") Exercise Difficulty<br />
|
||||
input#difficulty(name="difficulty", value= exercise.difficulty)
|
||||
i = 0
|
||||
- for (i ; i < 10; ++i) {
|
||||
marraymap = ['Triceps','Forearms','Biceps','Deltoids','Back','Lats','Glutes','Hamstrings','Calves','Traps','Abs','Quads','Shins','Pectorals']
|
||||
- for (i ; i < 14; ++i) {
|
||||
marray = "musclearray[" + i + "]"
|
||||
li
|
||||
label(for="type") Muscle data #{i}
|
||||
label(for="type") Muscle data #{marraymap[i]}
|
||||
input(name= marray, class="musclearray", id= marray, value= exercise.musclearray[i])
|
||||
- }
|
||||
li
|
||||
|
||||
@@ -24,5 +24,5 @@ ul
|
||||
- }
|
||||
|
||||
- if (! lastPage) {
|
||||
a(href="?page=" + (page + 1)) Next
|
||||
a(href="/admin/exercises?page=" + (page + 1)) Next
|
||||
- }
|
||||
@@ -15,10 +15,11 @@ form(id="newexercise", method="POST", action="/admin/exercises/new")
|
||||
label(for="type") Exercise Difficulty<br />
|
||||
input#difficulty(name="difficulty")
|
||||
i = 0
|
||||
- for (i ; i < 10; ++i) {
|
||||
marraymap = ['Triceps','Forearms','Biceps','Deltoids','Back','Lats','Glutes','Hamstrings','Calves','Traps','Abs','Quads','Shins','Pectorals']
|
||||
- for (i ; i < 14; ++i) {
|
||||
marray = "musclearray[" + i + "]"
|
||||
li
|
||||
label(for="type") Muscle data #{i}
|
||||
label(for="type") Muscle data #{marraymap[i]}
|
||||
input(name= marray, class="musclearray", id= marray)
|
||||
- }
|
||||
li
|
||||
|
||||
@@ -2,10 +2,10 @@ h3 Recent workouts:
|
||||
ul
|
||||
- recentworkouts.forEach(function(workout) {
|
||||
li.floatleft
|
||||
span(class="floatleft")
|
||||
span(class="floatleft workoutentry")
|
||||
a(class="map-link", href="/workouts/" + encodeURIComponent(workout._id))= workout._id
|
||||
each element in workout.elements
|
||||
p= element.exerciseID.name
|
||||
p(class="workoutelement", data-musclearray=element.exerciseID.musclearray)= element.exerciseID.name
|
||||
ol
|
||||
each split in element.splits
|
||||
li Reps: #{split.reps} Weight: #{split.weight}
|
||||
|
||||
Reference in New Issue
Block a user