[ExercisePlanner] updated ExercisePlanner sources
authorPiotr Dabrowski <p.dabrowski2@samsung.com>
Fri, 27 Sep 2013 11:26:27 +0000 (13:26 +0200)
committerPiotr Dabrowski <p.dabrowski2@samsung.com>
Fri, 27 Sep 2013 11:26:27 +0000 (13:26 +0200)
Change-Id: I1ded66cefc43448b1aeea760d2130562f5743549

js/app.js
js/app.onAlarm.js

index d66e17f..b343319 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -54,6 +54,11 @@ var ExercisePlanner = function () {
                                enabled: false
                        }],
 
+                       /**
+                        * List of generate available exercises;
+                        */
+                       availableExercises: null,
+
                        // deprecated for this version;
                        increasingStrength: true,
 
@@ -249,14 +254,12 @@ var ExercisePlanner = function () {
                        return a.date - b.date;
                });
 
-               if (this.config.nearestExercise > -1) {
+               if (this.config.availableExercises.length > 0) {
                        this.ui.showAlarmInMonitor({
                                alarm: alarms[0],
-                               exerciseName: this.config.exercises[this.config.nearestExercise].name,
+                               exerciseName: this.config.availableExercises[this.config.nearestExercise].name,
                                numberOfTimes: this.getStrength(this.config.strength.workday, this.config.count)
                        });
-
-                       this.config.count += 1;
                }
                this.saveConfig();
        };
@@ -341,10 +344,10 @@ var ExercisePlanner = function () {
         * Generate name of exercise for nearest workout
         */
        ExercisePlanner.prototype.generateNearestExercise = function () {
-               var tmp = this.config.exercises.filter(function (item) {
+               this.config.availableExercises = this.config.exercises.filter(function (item) {
                        return item.enabled;
                });
-               this.config.nearestExercise = parseInt(Math.random() * tmp.length, 10);
+               this.config.nearestExercise = parseInt(Math.random() * this.config.availableExercises.length, 10);
        };
 
 
index 14f734d..577384a 100644 (file)
@@ -44,6 +44,7 @@
        };
 
        ExercisePlanner.prototype.ok = function () {
+               this.config.count += 1;
                this.exit();
        };