mirror of
https://github.com/sstent/alex_app1.git
synced 2025-12-06 08:02:03 +00:00
basics working
This commit is contained in:
97
admin.html
Normal file
97
admin.html
Normal file
@@ -0,0 +1,97 @@
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>BodyREP Demo ADMIN</title>
|
||||
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
|
||||
<script type="text/javascript" src="http://code.jquery.com/ui/1.8.18/jquery-ui.min.js"></script>
|
||||
<script type='text/javascript' src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js"></script>
|
||||
<script src="/static/javascripts/jsrender.js"></script>
|
||||
<script src="/socket.io/socket.io.js"></script>
|
||||
<script src="/static/form2js/form2js.js"></script>
|
||||
<script src="/static/form2js/jquery.toObject.js"></script>
|
||||
<script src="/static/form2js/json2.js"></script>
|
||||
<script src="/static/javascripts/script_admin.js"></script>
|
||||
<link rel="stylesheet" href="/static/stylesheets/smoothness/jquery-ui-1.8.20.custom.css"/>
|
||||
<link rel="stylesheet" href="/static/stylesheets/jui_style.css"/>
|
||||
<link rel="stylesheet" href="/static/stylesheets/style.css"/>
|
||||
<script id="movieTemplate1" type="text/x-jsrender">
|
||||
<h3>{{:Activities.Activity.date}}</h3>
|
||||
<div class="workoutdata">
|
||||
<a href=# class="activitydelete" title="{{:_id}}" >Delete</a>
|
||||
<a href=# class="activityedit" title="{{:_id}}" >Edit</a>
|
||||
{{if Activities.Activity.Lap}}
|
||||
{{for Activities.Activity.Lap}}
|
||||
<p>Workout step {{:#index+1}} -
|
||||
{{if cardio}} Cardio - {{:cardio.name}} - {{:cardio.distance}} x {{:cardio.time}} -- {{:cardio.muscledata}} {{/if}}
|
||||
{{if exercise}} Exercise - {{:exercise.name}} - {{:exercise.sets}} x {{:exercise.reps}} with {{:exercise.weight}} Kg -- {{:exercise.muscledata}}{{/if}}
|
||||
{{if rest}} Recovery Step {{/if}}
|
||||
</p>
|
||||
|
||||
{{/for}}
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
</script>
|
||||
<script id="DataTemplate1" type="text/x-jsrender">
|
||||
<h3>{{:Activities.Activity.date}}</h3>
|
||||
<div class="workoutdata">
|
||||
// <h4>{{:Activities.Activity.date}} - {{:Activities.Activity.name}}</h4>
|
||||
<a href=# class="activitydelete" title="{{:_id}}" >Delete</a>
|
||||
<a href=# class="activityedit" title="{{:_id}}" >Edit</a>
|
||||
</div>
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="logo"><H1>BodyREP Demo ADMIN</h1></div>
|
||||
<div id="display">
|
||||
|
||||
<ul>
|
||||
<li style="display: none" class="new-lap ui-state-default removable">
|
||||
<label class="uiindex"></label>
|
||||
<select class="laptype" >
|
||||
<option value="">Select...</option>
|
||||
<option value="Cardio">Cardio</option>
|
||||
<option value="Exercise">Weights</option>
|
||||
</select>
|
||||
<span><a href=# class=delete>delete</a></span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<button type="button" id="addexerciseformopen" value="AddExercise"/>Add New Exercise</button>
|
||||
|
||||
<div id="ExerciseEditor" >
|
||||
<span class="EditExerciseID">
|
||||
<ul id="exercises">
|
||||
</ul>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="ExerciseEditorForm" >
|
||||
<span class="EditExerciseID">
|
||||
<form id="EditExerciseForm">
|
||||
<ul id="editexercise">
|
||||
</ul>
|
||||
<button type="submit" id="saveexercises" value="Save">Save</button>
|
||||
<button type="button" id="cancelexerciseform" value="Cancel"/>Cancel</button>
|
||||
</form>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div></body>
|
||||
</html>
|
||||
9
node_modules/async/.gitmodules
generated
vendored
Normal file
9
node_modules/async/.gitmodules
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
[submodule "deps/nodeunit"]
|
||||
path = deps/nodeunit
|
||||
url = git://github.com/caolan/nodeunit.git
|
||||
[submodule "deps/UglifyJS"]
|
||||
path = deps/UglifyJS
|
||||
url = https://github.com/mishoo/UglifyJS.git
|
||||
[submodule "deps/nodelint"]
|
||||
path = deps/nodelint
|
||||
url = https://github.com/tav/nodelint.git
|
||||
4
node_modules/async/.npmignore
generated
vendored
Normal file
4
node_modules/async/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
deps
|
||||
dist
|
||||
test
|
||||
nodelint.cfg
|
||||
19
node_modules/async/LICENSE
generated
vendored
Normal file
19
node_modules/async/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2010 Caolan McMahon
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
25
node_modules/async/Makefile
generated
vendored
Normal file
25
node_modules/async/Makefile
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
PACKAGE = asyncjs
|
||||
NODEJS = $(if $(shell test -f /usr/bin/nodejs && echo "true"),nodejs,node)
|
||||
CWD := $(shell pwd)
|
||||
NODEUNIT = $(CWD)/node_modules/nodeunit/bin/nodeunit
|
||||
UGLIFY = $(CWD)/node_modules/uglify-js/bin/uglifyjs
|
||||
NODELINT = $(CWD)/node_modules/nodelint/nodelint
|
||||
|
||||
BUILDDIR = dist
|
||||
|
||||
all: clean test build
|
||||
|
||||
build: $(wildcard lib/*.js)
|
||||
mkdir -p $(BUILDDIR)
|
||||
$(UGLIFY) lib/async.js > $(BUILDDIR)/async.min.js
|
||||
|
||||
test:
|
||||
$(NODEUNIT) test
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILDDIR)
|
||||
|
||||
lint:
|
||||
$(NODELINT) --config nodelint.cfg lib/async.js
|
||||
|
||||
.PHONY: test build all
|
||||
1021
node_modules/async/README.md
generated
vendored
Normal file
1021
node_modules/async/README.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3
node_modules/async/index.js
generated
vendored
Normal file
3
node_modules/async/index.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
// This file is just added for convenience so this repository can be
|
||||
// directly checked out into a project's deps folder
|
||||
module.exports = require('./lib/async');
|
||||
692
node_modules/async/lib/async.js
generated
vendored
Normal file
692
node_modules/async/lib/async.js
generated
vendored
Normal file
@@ -0,0 +1,692 @@
|
||||
/*global setTimeout: false, console: false */
|
||||
(function () {
|
||||
|
||||
var async = {};
|
||||
|
||||
// global on the server, window in the browser
|
||||
var root = this,
|
||||
previous_async = root.async;
|
||||
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = async;
|
||||
}
|
||||
else {
|
||||
root.async = async;
|
||||
}
|
||||
|
||||
async.noConflict = function () {
|
||||
root.async = previous_async;
|
||||
return async;
|
||||
};
|
||||
|
||||
//// cross-browser compatiblity functions ////
|
||||
|
||||
var _forEach = function (arr, iterator) {
|
||||
if (arr.forEach) {
|
||||
return arr.forEach(iterator);
|
||||
}
|
||||
for (var i = 0; i < arr.length; i += 1) {
|
||||
iterator(arr[i], i, arr);
|
||||
}
|
||||
};
|
||||
|
||||
var _map = function (arr, iterator) {
|
||||
if (arr.map) {
|
||||
return arr.map(iterator);
|
||||
}
|
||||
var results = [];
|
||||
_forEach(arr, function (x, i, a) {
|
||||
results.push(iterator(x, i, a));
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
var _reduce = function (arr, iterator, memo) {
|
||||
if (arr.reduce) {
|
||||
return arr.reduce(iterator, memo);
|
||||
}
|
||||
_forEach(arr, function (x, i, a) {
|
||||
memo = iterator(memo, x, i, a);
|
||||
});
|
||||
return memo;
|
||||
};
|
||||
|
||||
var _keys = function (obj) {
|
||||
if (Object.keys) {
|
||||
return Object.keys(obj);
|
||||
}
|
||||
var keys = [];
|
||||
for (var k in obj) {
|
||||
if (obj.hasOwnProperty(k)) {
|
||||
keys.push(k);
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
};
|
||||
|
||||
//// exported async module functions ////
|
||||
|
||||
//// nextTick implementation with browser-compatible fallback ////
|
||||
if (typeof process === 'undefined' || !(process.nextTick)) {
|
||||
async.nextTick = function (fn) {
|
||||
setTimeout(fn, 0);
|
||||
};
|
||||
}
|
||||
else {
|
||||
async.nextTick = process.nextTick;
|
||||
}
|
||||
|
||||
async.forEach = function (arr, iterator, callback) {
|
||||
callback = callback || function () {};
|
||||
if (!arr.length) {
|
||||
return callback();
|
||||
}
|
||||
var completed = 0;
|
||||
_forEach(arr, function (x) {
|
||||
iterator(x, function (err) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
callback = function () {};
|
||||
}
|
||||
else {
|
||||
completed += 1;
|
||||
if (completed === arr.length) {
|
||||
callback(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
async.forEachSeries = function (arr, iterator, callback) {
|
||||
callback = callback || function () {};
|
||||
if (!arr.length) {
|
||||
return callback();
|
||||
}
|
||||
var completed = 0;
|
||||
var iterate = function () {
|
||||
iterator(arr[completed], function (err) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
callback = function () {};
|
||||
}
|
||||
else {
|
||||
completed += 1;
|
||||
if (completed === arr.length) {
|
||||
callback(null);
|
||||
}
|
||||
else {
|
||||
iterate();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
iterate();
|
||||
};
|
||||
|
||||
async.forEachLimit = function (arr, limit, iterator, callback) {
|
||||
callback = callback || function () {};
|
||||
if (!arr.length || limit <= 0) {
|
||||
return callback();
|
||||
}
|
||||
var completed = 0;
|
||||
var started = 0;
|
||||
var running = 0;
|
||||
|
||||
(function replenish () {
|
||||
if (completed === arr.length) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
while (running < limit && started < arr.length) {
|
||||
started += 1;
|
||||
running += 1;
|
||||
iterator(arr[started - 1], function (err) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
callback = function () {};
|
||||
}
|
||||
else {
|
||||
completed += 1;
|
||||
running -= 1;
|
||||
if (completed === arr.length) {
|
||||
callback();
|
||||
}
|
||||
else {
|
||||
replenish();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})();
|
||||
};
|
||||
|
||||
|
||||
var doParallel = function (fn) {
|
||||
return function () {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
return fn.apply(null, [async.forEach].concat(args));
|
||||
};
|
||||
};
|
||||
var doSeries = function (fn) {
|
||||
return function () {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
return fn.apply(null, [async.forEachSeries].concat(args));
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
var _asyncMap = function (eachfn, arr, iterator, callback) {
|
||||
var results = [];
|
||||
arr = _map(arr, function (x, i) {
|
||||
return {index: i, value: x};
|
||||
});
|
||||
eachfn(arr, function (x, callback) {
|
||||
iterator(x.value, function (err, v) {
|
||||
results[x.index] = v;
|
||||
callback(err);
|
||||
});
|
||||
}, function (err) {
|
||||
callback(err, results);
|
||||
});
|
||||
};
|
||||
async.map = doParallel(_asyncMap);
|
||||
async.mapSeries = doSeries(_asyncMap);
|
||||
|
||||
|
||||
// reduce only has a series version, as doing reduce in parallel won't
|
||||
// work in many situations.
|
||||
async.reduce = function (arr, memo, iterator, callback) {
|
||||
async.forEachSeries(arr, function (x, callback) {
|
||||
iterator(memo, x, function (err, v) {
|
||||
memo = v;
|
||||
callback(err);
|
||||
});
|
||||
}, function (err) {
|
||||
callback(err, memo);
|
||||
});
|
||||
};
|
||||
// inject alias
|
||||
async.inject = async.reduce;
|
||||
// foldl alias
|
||||
async.foldl = async.reduce;
|
||||
|
||||
async.reduceRight = function (arr, memo, iterator, callback) {
|
||||
var reversed = _map(arr, function (x) {
|
||||
return x;
|
||||
}).reverse();
|
||||
async.reduce(reversed, memo, iterator, callback);
|
||||
};
|
||||
// foldr alias
|
||||
async.foldr = async.reduceRight;
|
||||
|
||||
var _filter = function (eachfn, arr, iterator, callback) {
|
||||
var results = [];
|
||||
arr = _map(arr, function (x, i) {
|
||||
return {index: i, value: x};
|
||||
});
|
||||
eachfn(arr, function (x, callback) {
|
||||
iterator(x.value, function (v) {
|
||||
if (v) {
|
||||
results.push(x);
|
||||
}
|
||||
callback();
|
||||
});
|
||||
}, function (err) {
|
||||
callback(_map(results.sort(function (a, b) {
|
||||
return a.index - b.index;
|
||||
}), function (x) {
|
||||
return x.value;
|
||||
}));
|
||||
});
|
||||
};
|
||||
async.filter = doParallel(_filter);
|
||||
async.filterSeries = doSeries(_filter);
|
||||
// select alias
|
||||
async.select = async.filter;
|
||||
async.selectSeries = async.filterSeries;
|
||||
|
||||
var _reject = function (eachfn, arr, iterator, callback) {
|
||||
var results = [];
|
||||
arr = _map(arr, function (x, i) {
|
||||
return {index: i, value: x};
|
||||
});
|
||||
eachfn(arr, function (x, callback) {
|
||||
iterator(x.value, function (v) {
|
||||
if (!v) {
|
||||
results.push(x);
|
||||
}
|
||||
callback();
|
||||
});
|
||||
}, function (err) {
|
||||
callback(_map(results.sort(function (a, b) {
|
||||
return a.index - b.index;
|
||||
}), function (x) {
|
||||
return x.value;
|
||||
}));
|
||||
});
|
||||
};
|
||||
async.reject = doParallel(_reject);
|
||||
async.rejectSeries = doSeries(_reject);
|
||||
|
||||
var _detect = function (eachfn, arr, iterator, main_callback) {
|
||||
eachfn(arr, function (x, callback) {
|
||||
iterator(x, function (result) {
|
||||
if (result) {
|
||||
main_callback(x);
|
||||
main_callback = function () {};
|
||||
}
|
||||
else {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}, function (err) {
|
||||
main_callback();
|
||||
});
|
||||
};
|
||||
async.detect = doParallel(_detect);
|
||||
async.detectSeries = doSeries(_detect);
|
||||
|
||||
async.some = function (arr, iterator, main_callback) {
|
||||
async.forEach(arr, function (x, callback) {
|
||||
iterator(x, function (v) {
|
||||
if (v) {
|
||||
main_callback(true);
|
||||
main_callback = function () {};
|
||||
}
|
||||
callback();
|
||||
});
|
||||
}, function (err) {
|
||||
main_callback(false);
|
||||
});
|
||||
};
|
||||
// any alias
|
||||
async.any = async.some;
|
||||
|
||||
async.every = function (arr, iterator, main_callback) {
|
||||
async.forEach(arr, function (x, callback) {
|
||||
iterator(x, function (v) {
|
||||
if (!v) {
|
||||
main_callback(false);
|
||||
main_callback = function () {};
|
||||
}
|
||||
callback();
|
||||
});
|
||||
}, function (err) {
|
||||
main_callback(true);
|
||||
});
|
||||
};
|
||||
// all alias
|
||||
async.all = async.every;
|
||||
|
||||
async.sortBy = function (arr, iterator, callback) {
|
||||
async.map(arr, function (x, callback) {
|
||||
iterator(x, function (err, criteria) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
}
|
||||
else {
|
||||
callback(null, {value: x, criteria: criteria});
|
||||
}
|
||||
});
|
||||
}, function (err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
else {
|
||||
var fn = function (left, right) {
|
||||
var a = left.criteria, b = right.criteria;
|
||||
return a < b ? -1 : a > b ? 1 : 0;
|
||||
};
|
||||
callback(null, _map(results.sort(fn), function (x) {
|
||||
return x.value;
|
||||
}));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
async.auto = function (tasks, callback) {
|
||||
callback = callback || function () {};
|
||||
var keys = _keys(tasks);
|
||||
if (!keys.length) {
|
||||
return callback(null);
|
||||
}
|
||||
|
||||
var results = {};
|
||||
|
||||
var listeners = [];
|
||||
var addListener = function (fn) {
|
||||
listeners.unshift(fn);
|
||||
};
|
||||
var removeListener = function (fn) {
|
||||
for (var i = 0; i < listeners.length; i += 1) {
|
||||
if (listeners[i] === fn) {
|
||||
listeners.splice(i, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
var taskComplete = function () {
|
||||
_forEach(listeners.slice(0), function (fn) {
|
||||
fn();
|
||||
});
|
||||
};
|
||||
|
||||
addListener(function () {
|
||||
if (_keys(results).length === keys.length) {
|
||||
callback(null, results);
|
||||
callback = function () {};
|
||||
}
|
||||
});
|
||||
|
||||
_forEach(keys, function (k) {
|
||||
var task = (tasks[k] instanceof Function) ? [tasks[k]]: tasks[k];
|
||||
var taskCallback = function (err) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
// stop subsequent errors hitting callback multiple times
|
||||
callback = function () {};
|
||||
}
|
||||
else {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
if (args.length <= 1) {
|
||||
args = args[0];
|
||||
}
|
||||
results[k] = args;
|
||||
taskComplete();
|
||||
}
|
||||
};
|
||||
var requires = task.slice(0, Math.abs(task.length - 1)) || [];
|
||||
var ready = function () {
|
||||
return _reduce(requires, function (a, x) {
|
||||
return (a && results.hasOwnProperty(x));
|
||||
}, true) && !results.hasOwnProperty(k);
|
||||
};
|
||||
if (ready()) {
|
||||
task[task.length - 1](taskCallback, results);
|
||||
}
|
||||
else {
|
||||
var listener = function () {
|
||||
if (ready()) {
|
||||
removeListener(listener);
|
||||
task[task.length - 1](taskCallback, results);
|
||||
}
|
||||
};
|
||||
addListener(listener);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
async.waterfall = function (tasks, callback) {
|
||||
callback = callback || function () {};
|
||||
if (!tasks.length) {
|
||||
return callback();
|
||||
}
|
||||
var wrapIterator = function (iterator) {
|
||||
return function (err) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
callback = function () {};
|
||||
}
|
||||
else {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
var next = iterator.next();
|
||||
if (next) {
|
||||
args.push(wrapIterator(next));
|
||||
}
|
||||
else {
|
||||
args.push(callback);
|
||||
}
|
||||
async.nextTick(function () {
|
||||
iterator.apply(null, args);
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
wrapIterator(async.iterator(tasks))();
|
||||
};
|
||||
|
||||
async.parallel = function (tasks, callback) {
|
||||
callback = callback || function () {};
|
||||
if (tasks.constructor === Array) {
|
||||
async.map(tasks, function (fn, callback) {
|
||||
if (fn) {
|
||||
fn(function (err) {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
if (args.length <= 1) {
|
||||
args = args[0];
|
||||
}
|
||||
callback.call(null, err, args);
|
||||
});
|
||||
}
|
||||
}, callback);
|
||||
}
|
||||
else {
|
||||
var results = {};
|
||||
async.forEach(_keys(tasks), function (k, callback) {
|
||||
tasks[k](function (err) {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
if (args.length <= 1) {
|
||||
args = args[0];
|
||||
}
|
||||
results[k] = args;
|
||||
callback(err);
|
||||
});
|
||||
}, function (err) {
|
||||
callback(err, results);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
async.series = function (tasks, callback) {
|
||||
callback = callback || function () {};
|
||||
if (tasks.constructor === Array) {
|
||||
async.mapSeries(tasks, function (fn, callback) {
|
||||
if (fn) {
|
||||
fn(function (err) {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
if (args.length <= 1) {
|
||||
args = args[0];
|
||||
}
|
||||
callback.call(null, err, args);
|
||||
});
|
||||
}
|
||||
}, callback);
|
||||
}
|
||||
else {
|
||||
var results = {};
|
||||
async.forEachSeries(_keys(tasks), function (k, callback) {
|
||||
tasks[k](function (err) {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
if (args.length <= 1) {
|
||||
args = args[0];
|
||||
}
|
||||
results[k] = args;
|
||||
callback(err);
|
||||
});
|
||||
}, function (err) {
|
||||
callback(err, results);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
async.iterator = function (tasks) {
|
||||
var makeCallback = function (index) {
|
||||
var fn = function () {
|
||||
if (tasks.length) {
|
||||
tasks[index].apply(null, arguments);
|
||||
}
|
||||
return fn.next();
|
||||
};
|
||||
fn.next = function () {
|
||||
return (index < tasks.length - 1) ? makeCallback(index + 1): null;
|
||||
};
|
||||
return fn;
|
||||
};
|
||||
return makeCallback(0);
|
||||
};
|
||||
|
||||
async.apply = function (fn) {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
return function () {
|
||||
return fn.apply(
|
||||
null, args.concat(Array.prototype.slice.call(arguments))
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
var _concat = function (eachfn, arr, fn, callback) {
|
||||
var r = [];
|
||||
eachfn(arr, function (x, cb) {
|
||||
fn(x, function (err, y) {
|
||||
r = r.concat(y || []);
|
||||
cb(err);
|
||||
});
|
||||
}, function (err) {
|
||||
callback(err, r);
|
||||
});
|
||||
};
|
||||
async.concat = doParallel(_concat);
|
||||
async.concatSeries = doSeries(_concat);
|
||||
|
||||
async.whilst = function (test, iterator, callback) {
|
||||
if (test()) {
|
||||
iterator(function (err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
async.whilst(test, iterator, callback);
|
||||
});
|
||||
}
|
||||
else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
async.until = function (test, iterator, callback) {
|
||||
if (!test()) {
|
||||
iterator(function (err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
async.until(test, iterator, callback);
|
||||
});
|
||||
}
|
||||
else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
async.queue = function (worker, concurrency) {
|
||||
var workers = 0;
|
||||
var q = {
|
||||
tasks: [],
|
||||
concurrency: concurrency,
|
||||
saturated: null,
|
||||
empty: null,
|
||||
drain: null,
|
||||
push: function (data, callback) {
|
||||
if(data.constructor !== Array) {
|
||||
data = [data];
|
||||
}
|
||||
_forEach(data, function(task) {
|
||||
q.tasks.push({
|
||||
data: task,
|
||||
callback: typeof callback === 'function' ? callback : null
|
||||
});
|
||||
if (q.saturated && q.tasks.length == concurrency) {
|
||||
q.saturated();
|
||||
}
|
||||
async.nextTick(q.process);
|
||||
});
|
||||
},
|
||||
process: function () {
|
||||
if (workers < q.concurrency && q.tasks.length) {
|
||||
var task = q.tasks.shift();
|
||||
if(q.empty && q.tasks.length == 0) q.empty();
|
||||
workers += 1;
|
||||
worker(task.data, function () {
|
||||
workers -= 1;
|
||||
if (task.callback) {
|
||||
task.callback.apply(task, arguments);
|
||||
}
|
||||
if(q.drain && q.tasks.length + workers == 0) q.drain();
|
||||
q.process();
|
||||
});
|
||||
}
|
||||
},
|
||||
length: function () {
|
||||
return q.tasks.length;
|
||||
},
|
||||
running: function () {
|
||||
return workers;
|
||||
}
|
||||
};
|
||||
return q;
|
||||
};
|
||||
|
||||
var _console_fn = function (name) {
|
||||
return function (fn) {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
fn.apply(null, args.concat([function (err) {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
if (typeof console !== 'undefined') {
|
||||
if (err) {
|
||||
if (console.error) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
else if (console[name]) {
|
||||
_forEach(args, function (x) {
|
||||
console[name](x);
|
||||
});
|
||||
}
|
||||
}
|
||||
}]));
|
||||
};
|
||||
};
|
||||
async.log = _console_fn('log');
|
||||
async.dir = _console_fn('dir');
|
||||
/*async.info = _console_fn('info');
|
||||
async.warn = _console_fn('warn');
|
||||
async.error = _console_fn('error');*/
|
||||
|
||||
async.memoize = function (fn, hasher) {
|
||||
var memo = {};
|
||||
var queues = {};
|
||||
hasher = hasher || function (x) {
|
||||
return x;
|
||||
};
|
||||
var memoized = function () {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
var callback = args.pop();
|
||||
var key = hasher.apply(null, args);
|
||||
if (key in memo) {
|
||||
callback.apply(null, memo[key]);
|
||||
}
|
||||
else if (key in queues) {
|
||||
queues[key].push(callback);
|
||||
}
|
||||
else {
|
||||
queues[key] = [callback];
|
||||
fn.apply(null, args.concat([function () {
|
||||
memo[key] = arguments;
|
||||
var q = queues[key];
|
||||
delete queues[key];
|
||||
for (var i = 0, l = q.length; i < l; i++) {
|
||||
q[i].apply(null, arguments);
|
||||
}
|
||||
}]));
|
||||
}
|
||||
};
|
||||
memoized.unmemoized = fn;
|
||||
return memoized;
|
||||
};
|
||||
|
||||
async.unmemoize = function (fn) {
|
||||
return function () {
|
||||
return (fn.unmemoized || fn).apply(null, arguments);
|
||||
};
|
||||
};
|
||||
|
||||
}());
|
||||
31
node_modules/async/package.json
generated
vendored
Normal file
31
node_modules/async/package.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
337
static/javascripts/script_admin.js
Normal file
337
static/javascripts/script_admin.js
Normal file
@@ -0,0 +1,337 @@
|
||||
$(document).ready(function() {
|
||||
//makes buttons buttons
|
||||
$("button").button();
|
||||
|
||||
|
||||
$("#ExerciseEditorForm").dialog({ autoOpen: false });
|
||||
$( "#ExerciseEditorForm" ).dialog( "option", "minHeight", 330 );
|
||||
$( "#ExerciseEditorForm" ).dialog( "option", "minWidth", 630 );
|
||||
$( "#ExerciseEditorForm" ).dialog({ buttons: [
|
||||
{
|
||||
text: "Close/Cancel",
|
||||
click: function() { $(this).dialog("close"); }
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
$("button#addexerciseformopen").click(function() {
|
||||
// socket.emit('getexercises', 'please');
|
||||
$('ul#editexercise li').remove();
|
||||
$('span.EditExerciseID').removeAttr('docid');
|
||||
var newElem = $('<li><label>Name</label><input type="text" name="exercise.name" value=""></li>');
|
||||
newElem.append('<li><label>Exercise Class</label><input type="text" name="exercise.class" value=""></li>');
|
||||
newElem.append('<li><label>Muscle Data Array</label><input type="text" name="exercise.muscledata" value=""></li>');
|
||||
$(newElem).appendTo('#editexercise');
|
||||
$("#ExerciseEditorForm").dialog("open");
|
||||
});
|
||||
|
||||
// $("#Activity").dialog({ autoOpen: false });
|
||||
// $( "#Activity" ).dialog( "option", "minHeight", 330 );
|
||||
// $( "#Activity" ).dialog( "option", "minWidth", 730 );
|
||||
// $( "#Activity" ).dialog({ buttons: [
|
||||
// {
|
||||
// text: "Close/Cancel",
|
||||
// click: function() { $(this).dialog("close"); }
|
||||
// }
|
||||
// ]
|
||||
// });
|
||||
|
||||
// $("button#openactivities").click(function() {
|
||||
// //
|
||||
// $("#Activity").dialog("open");
|
||||
// });
|
||||
|
||||
|
||||
|
||||
//makes datepickers
|
||||
$( "#datepicker" ).datepicker();
|
||||
$('#Activity').find('input.datepicker').datepicker();
|
||||
$('#Activity').find('input.datepicker').datepicker('setDate', new Date());
|
||||
|
||||
var socket = io.connect();
|
||||
exercise_autocompletedata = "unset";
|
||||
bike_autocompletedata = "unset";
|
||||
|
||||
socket.emit('getactivites', 'please');
|
||||
socket.emit('getexercises', 'please');
|
||||
socket.emit('getexerciselist', 'cardio');
|
||||
socket.emit('getexerciselist', 'weights');
|
||||
|
||||
socket.on('populateactivities', function(json) {
|
||||
console.log('#poulate recieved');
|
||||
var content = "";
|
||||
$(".workoutdata").hide();
|
||||
$('#ActivityList').empty();
|
||||
$( "#ActivityList" ).html(
|
||||
$( "#movieTemplate1" ).render( json )
|
||||
);
|
||||
$(".ui-accordion-content").css("display", "block");
|
||||
// $("#ActivityList").accordion('destroy').accordion({
|
||||
// header: 'h3',
|
||||
// active: false,
|
||||
// collapsible: true
|
||||
// });
|
||||
});
|
||||
//poulate activity by id
|
||||
socket.on('populateactivitybyid', function(json) {
|
||||
// clear it first
|
||||
$('ul#sortable li').remove('.removable');
|
||||
$('span.ActivityID').removeAttr('docid');
|
||||
$('#Activity').find('input').attr('value','');
|
||||
$('#Activity').find('input.datepicker').datepicker();
|
||||
$('#Activity').find('input.datepicker').datepicker('setDate', new Date());
|
||||
|
||||
//set document id
|
||||
$('span.ActivityID').attr('docid',json._id);
|
||||
//poulate name
|
||||
// $('input[name="Activities.Activity.name"]').attr('value', json.Activities.Activity.name)
|
||||
//poulate date
|
||||
$('input[name="Activities.Activity.date"]').attr('value', json.Activities.Activity.date)
|
||||
// Activities.Activity.date
|
||||
// for each lap
|
||||
if ("Lap" in json.Activities.Activity) {
|
||||
var array = json.Activities.Activity.Lap;
|
||||
$.each(array, function(index, value) {
|
||||
////if cardio
|
||||
if ("cardio" in value) {
|
||||
//get exercise muscledata
|
||||
var lapmuscledata = exercise_autocompletedata[value.cardio.selection].muscledata;
|
||||
AddPopulatedLap("Cardio", value.cardio.name, value.cardio.time, value.cardio.distance, "", "" , "", exercise_autocompletedata[value.cardio.selection].muscledata)
|
||||
};
|
||||
////if exercise
|
||||
if ("exercise" in value) {
|
||||
//get exercise muscledata
|
||||
console.log("selction = " + value.exercise.selection);
|
||||
var lapmuscledata = exercise_autocompletedata[value.exercise.selection].muscledata;
|
||||
AddPopulatedLap("Exercise", value.exercise.name, "", "", value.exercise.sets, value.exercise.reps , value.exercise.weight , lapmuscledata)
|
||||
};
|
||||
});
|
||||
};
|
||||
///refresh table
|
||||
$('#sortable').trigger('sortupdate');
|
||||
|
||||
});
|
||||
|
||||
|
||||
socket.on('populateexercisebyid', function(array) {
|
||||
// clear it first
|
||||
$('ul#editexercise li').remove();
|
||||
$('span.EditExerciseID').removeAttr('docid');
|
||||
//set document id
|
||||
$('span.EditExerciseID').attr('docid',array._id);
|
||||
console.log('name= ' + array.exercise.name);
|
||||
console.log('class= ' + array.exercise.class);
|
||||
console.log('muscledata= ' + array.exercise.muscledata);
|
||||
var newElem = $('<li><input type="text" name="exercise.name" value="'+ array.exercise.name + '"><input type="text" name="exercise.class" value="'+ array.exercise.class + '"><input type="text" name="exercise.muscledata" value="'+ array.exercise.muscledata + '"></li>');
|
||||
$(newElem).appendTo('#editexercise');
|
||||
});
|
||||
|
||||
|
||||
|
||||
function AddPopulatedLap(type, name, time, distance, sets, reps, weight, muscledata) {
|
||||
console.log('type= ' + type);
|
||||
console.log('muscledata= ' + muscledata);
|
||||
var newElem = $('.new-lap').clone(true).attr('style', 'display: block');
|
||||
$(newElem).removeClass('new-lap');
|
||||
$(newElem).appendTo('#sortable');
|
||||
$(newElem).children('.laptype').val(type).trigger('change');
|
||||
$(newElem).children('input').attr('disabled',false);
|
||||
$(newElem).find('.lapname').attr('value', name);
|
||||
$(newElem).find('.lapdistance').attr('value', distance);
|
||||
$(newElem).find('.laptime').attr('value', time);
|
||||
$(newElem).find('.sets').attr('value', sets);
|
||||
$(newElem).find('.reps').attr('value', reps);
|
||||
$(newElem).find('.weight').attr('value', weight);
|
||||
$(newElem).find('.muscledata').attr('value', muscledata);
|
||||
$(newElem).sortable( "refresh" );
|
||||
};
|
||||
|
||||
function AddPopulatedExercise(name, exclass, muscledata) {
|
||||
//$(newElem).sortable( "refresh" );
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
////populate exercise tables
|
||||
socket.on('populateexercises', function(json) {
|
||||
var content = "";
|
||||
$('ul#exercises li').remove();
|
||||
///// for loop
|
||||
var array = json;
|
||||
exercise_autocompletedata = array;
|
||||
$.each(json, function(index, array) {
|
||||
$( "ul#exercises" ).append('<li><input type="text" name="exercise.name" value="'+ array.exercise.name + '"><input type="text" name="exercise.class" value="'+ array.exercise.class + '"><input type="text" name="exercise.muscledata" value="'+ array.exercise.muscledata + '"><a href=# class="exercisedelete" title="' + array._id +'" >Delete</a><a href=# class="exerciseedit" title="' + array._id +'" >Edit</a></li>');
|
||||
})
|
||||
;
|
||||
});
|
||||
|
||||
//THe Sortable Stuff
|
||||
$("#sortable").sortable({
|
||||
placeholder: "ui-state-highlight",
|
||||
revert: true,
|
||||
stop: function(event, ui) {
|
||||
$('#sortable').trigger('sortupdate')
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
$("#sortable").bind('sortupdate', function(event, ui) {
|
||||
$('#sortable li').each(function(){
|
||||
var itemindex= $(this).index()
|
||||
$(this).children('label.uiindex').html('Exercise '+ itemindex );
|
||||
$(this).find('input, select').not('.laptype').each(function(){
|
||||
var newname = $(this).attr('name').replace(/\[[0-9]*\]/,'[' + itemindex + ']');
|
||||
$(this).attr("name",newname);
|
||||
});
|
||||
$(this).find('input.exertags').autocomplete({source: exercise_autocompletedata});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$("#sortableexercises").bind('sortupdate', function(event, ui) {
|
||||
$('#sortableexercises li').each(function(){
|
||||
var itemindex= $(this).index()
|
||||
$(this).find('input, select').each(function(){
|
||||
var newname = $(this).attr('name').replace(/\[[0-9]*\]/,'[' + itemindex + ']');
|
||||
$(this).attr("name",newname);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$('#ActivityList').delegate('a.activitydelete', 'click', function() {
|
||||
socket.emit('delactivity', $(this).attr('title'));
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#ActivityList').delegate('a.activityedit', 'click', function() {
|
||||
socket.emit('getactivitybyid', $(this).attr('title'));
|
||||
$("#Activity").dialog("open");
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#exercises').delegate('a.exercisedelete', 'click', function() {
|
||||
console.log("exercisedelete_click");
|
||||
socket.emit('delexercise', $(this).attr('title'));
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#exercises').delegate('a.exerciseedit', 'click', function() {
|
||||
console.log("exerciseedit_click");
|
||||
socket.emit('getexercisebyid', $(this).attr('title'));
|
||||
$("#ExerciseEditorForm").dialog("open");
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
$('ul').on('click', '.delete',function() {
|
||||
$(this).closest('li').remove();
|
||||
$('#sortable').trigger('sortupdate')
|
||||
});
|
||||
|
||||
//adds selectable element
|
||||
$("button").click(function() {
|
||||
var addtype = $(this).attr('value');
|
||||
var newElem = $('.new-' + addtype).clone(true).attr('style', 'display: block');
|
||||
$(newElem).removeClass("new-" + addtype);
|
||||
$(newElem).children('input').attr('disabled',false);
|
||||
$(newElem).appendTo('#sortable');
|
||||
$(newElem).sortable( "refresh" );
|
||||
|
||||
|
||||
$('#sortable').trigger('sortupdate');
|
||||
//$('#sortableexercises').trigger('sortupdate');
|
||||
});
|
||||
|
||||
// $("button.AddExercise").click(function() {
|
||||
// $( "ul#sortableexercises" ).append('<li class=ui-state-default><input type="text" name="exercise[].name" hint="Name" placeholder="Exercise Name"><input type="text" name="exercise[].class" placeholder="cardio or weights"><input class="addexercisemusclearray" type="text" name="exercise[].muscledata" hint="Muscle Array" placeholder="Muscle Array"><a href=# class=delete>delete</a></li>')
|
||||
// $('#sortableexercises').trigger('sortupdate');
|
||||
// });
|
||||
|
||||
|
||||
// $('#save').click(function() {
|
||||
// var docid =$(this).closest('span').attr('docid');
|
||||
// var selector= "#myForm"
|
||||
// var formDataAll = $(selector).toObject({mode: 'all'});
|
||||
// socket.emit('addactivity', formDataAll[0], docid);
|
||||
// $('ul#sortable li').remove('.removable');
|
||||
// $('#Activity').find('input').attr('value','');
|
||||
// $('span.ActivityID').removeAttr('docid');
|
||||
// $('#Activity').find('input.datepicker').datepicker();
|
||||
// $('#Activity').find('input.datepicker').datepicker('setDate', new Date());
|
||||
// socket.emit('getactivites', 'please');
|
||||
// socket.emit('getexercises', 'please');
|
||||
// return false;
|
||||
|
||||
// });
|
||||
|
||||
$('#saveexercises').click(function() {
|
||||
console.log("saving exercise");
|
||||
var docid =$(this).closest('span').attr('docid');
|
||||
var selector= "#EditExerciseForm"
|
||||
var formDataAll = $(selector).toObject({mode: 'all'});
|
||||
socket.emit('updateexercises', formDataAll[0], docid);
|
||||
//cleanup[]
|
||||
$('ul#newexercises').find('input').attr('value','');
|
||||
$('ul#newexercises').find('select').attr('selected','');
|
||||
//socket.emit('getactivites', 'please');
|
||||
socket.emit('getexercises', 'please');
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
$('#cancelform').click(function() {
|
||||
$('ul#sortable li').remove('.removable');
|
||||
$('span.ActivityID').removeAttr('docid');
|
||||
$('#Activity').find('input').attr('value','');
|
||||
$('#Activity').find('input.datepicker').datepicker();
|
||||
$('#Activity').find('input.datepicker').datepicker('setDate', new Date());
|
||||
return false;
|
||||
socket.emit('getactivites', 'please');
|
||||
socket.emit('getexercises', 'please');
|
||||
});
|
||||
|
||||
$('#cancelexerciseform').click(function(){
|
||||
//$('ul#editexercise li').remove();
|
||||
$('#editexercise li').children('input').attr('value','');
|
||||
$('span.EditExerciseID').removeAttr('docid');
|
||||
socket.emit('getexercises', 'please');
|
||||
//return false;
|
||||
});
|
||||
|
||||
$('ul').on('change', '.laptype',function() {
|
||||
console.log ('value= ' + $(this).val() );
|
||||
var currentselect;
|
||||
switch($(this).val()) {
|
||||
case "Cardio":
|
||||
$(this).siblings('span').html('<select class="ExerciseDropDownCardio" name="Activities.Activity.Lap[0].cardio.selection"></select><input type="text" class="lapdistance" name="Activities.Activity.Lap[0].cardio.distance" placeholder="Distance"><input type="text" class="laptime" name="Activities.Activity.Lap[0].cardio.time" placeholder="hh:mm:ss"><input style="display: none" type=text class="muscledata" name="Activities.Activity.Lap[0].cardio.muscledata"><a href=# class=delete>delete</a>');
|
||||
$(exercise_autocompletedata).each(function(index)
|
||||
{
|
||||
var option = $('<option />');
|
||||
if (this.class == 'cardio') {
|
||||
option.attr('value', index).text(this.name);
|
||||
$('.ExerciseDropDownCardio').append(option);
|
||||
};
|
||||
});
|
||||
|
||||
break;
|
||||
case "Exercise":
|
||||
$(this).siblings('span').html('<select class="ExerciseDropDown" name="Activities.Activity.Lap[0].exercise.selection"></select> <input type="text" class="sets" name="Activities.Activity.Lap[0].exercise.sets" placeholder="Sets"><input type="text" class="reps" name="Activities.Activity.Lap[0].exercise.reps" placeholder="Reps"><input type="text" name="Activities.Activity.Lap[0].exercise.weight" class="weight" placeholder="Weight in KG"><input style="display: none" type=text class="muscledata" name="Activities.Activity.Lap[0].exercise.muscledata"><a href=# class=delete>delete</a>');
|
||||
$(exercise_autocompletedata).each(function(index)
|
||||
{
|
||||
console.log("resetingdropdown")
|
||||
var option = $('<option />');
|
||||
if (this.class == 'weights') {
|
||||
option.attr('value', index).text(this.name);
|
||||
$('.ExerciseDropDown').append(option);
|
||||
};
|
||||
});
|
||||
break;
|
||||
};
|
||||
$('#sortable').trigger('sortupdate')
|
||||
});
|
||||
|
||||
//document closing
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user