enabled: false
}],
+ /**
+ * List of generate available exercises;
+ */
+ availableExercises: [],
+
// deprecated for this version;
increasingStrength: true,
* (use localStorage)
*/
ExercisePlanner.prototype.saveConfig = function () {
- localStorage.setItem('config', JSON.stringify(this.config));
+ try {
+ localStorage.setItem('config', JSON.stringify(this.config));
+ } catch (e) {
+ if (e.code === 22) //QuotaExceededError
+ this.ui.showErrors([{name: 'Not enough memory. Please remove unnecessary files'}]);
+ }
};
ExercisePlanner.prototype.stopTraining = 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();
};
* @param type
*/
ExercisePlanner.prototype.changeTypeOfPeriods = function changeTypeOfPeriods(type) {
- if (this.config.currentTypeOfPeriods !== type) {
this.config.currentTypeOfPeriods = type;
this.updateGraph(this.config.currentTypeOfPeriods);
- }
};
/**
* 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);
};
this.config.currentTypeOfPeriods = (this.todayIsWorkday()) ? 'workday' : 'weekend';
this.generateAlarms();
-
this.ui.initialize(onUiInitialize);
};
}());