mirror of
https://github.com/bodyrep/DemoApp.git
synced 2025-12-06 06:01:48 +00:00
started change to faster method of populating exercise list field
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
var mongoose = require('mongoose');
|
||||
var Schema = require('mongoose').Schema;
|
||||
|
||||
var UserSchema = new mongoose.Schema({
|
||||
username: {type: String, unique: true, required: true},
|
||||
@@ -6,7 +7,7 @@ var UserSchema = new mongoose.Schema({
|
||||
password: String,
|
||||
is_admin: {type: Boolean, 'default': false },
|
||||
is_imperial: {type: Boolean, 'default': false },
|
||||
favorites: [{type: [Schema.ObjectId], ref: 'Exercise'}]
|
||||
favorites: [{ type: Schema.ObjectId, ref: 'Exercises'}]
|
||||
});
|
||||
|
||||
UserSchema.methods.recentworkouts = function(callback) {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
$(document).ready(function() {
|
||||
|
||||
$.each($.getValues("/api/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('datafields', item.datafields);
|
||||
console.log("This - " + JSON.stringify($(newElem).data()));
|
||||
$(newElem).appendTo('#exerciselist');
|
||||
$("button").button();
|
||||
});
|
||||
// $.each($.getValues("/api/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('datafields', item.datafields);
|
||||
// console.log("This - " + JSON.stringify($(newElem).data()));
|
||||
// $(newElem).appendTo('#exerciselist');
|
||||
// $("button").button();
|
||||
// });
|
||||
|
||||
$("button.addthisExercise").click(function() {
|
||||
console.log("This exercise name li" + JSON.stringify($(this).closest('li').data()));
|
||||
@@ -20,6 +20,58 @@
|
||||
$('#newworkout').trigger('sortupdate');
|
||||
});
|
||||
|
||||
var exerciselistJSON = $.each($.getValues("/api/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('datafields', item.datafields);
|
||||
console.log("This - " + JSON.stringify($(newElem).data()));
|
||||
$(newElem).appendTo('#exerciselist');
|
||||
$("button").button();
|
||||
});
|
||||
|
||||
//// Notes for filter code
|
||||
|
||||
// on .filter click
|
||||
// define grepstring
|
||||
// for each .filter
|
||||
// grepstring += filter value
|
||||
// for each document in $.getValues("/api/exerciselist")
|
||||
// grep doc.keywords
|
||||
// if match
|
||||
// add to array exerciselist
|
||||
// $.each(exerciselist, funciton "updateExerciselistDIV");
|
||||
|
||||
////// Make below standalone funtion "updateExerciselistDIV"
|
||||
function PopulateExerciseList(exerciselist) {
|
||||
var newExerciselist = document.createDocumentFragment();
|
||||
$.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('datafields', item.datafields);
|
||||
console.log("This - " + JSON.stringify($(newElem).data()));
|
||||
console.log("newexlist = " + newExerciselist);
|
||||
newExerciselist.appendChild($newElem);
|
||||
console.log("newexlist = " + $newExerciselist);
|
||||
|
||||
});
|
||||
console.log("newexlist outside= " + $newExerciselist);
|
||||
$('#exerciselist').empty();
|
||||
// $(newExerciselist).appendTo('#exerciselist');
|
||||
//$('#exerciselist').append($(newExerciselist));
|
||||
$("button").button();
|
||||
}
|
||||
|
||||
var originalExerciselist = $.getValues("/api/exerciselist");
|
||||
PopulateExerciseList(originalExerciselist);
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
// function populateHandles() {
|
||||
// var options = '';
|
||||
// for (var i = 0; i < handles.length; i++) {
|
||||
// options += '<option value="' + handles[i] + '">' + handles[i] + '</option>';
|
||||
// }
|
||||
// $('#listBox').html(options);
|
||||
Reference in New Issue
Block a user