2 /*global ExercisePlanner:false, tizen:false, Audio:false*/
4 * These method are using when alarm is call.
8 ExercisePlanner.prototype.findCurrentAlarm = function () {
9 var currentTimeInMinutes = parseInt(this.applicationStartTime.getTime() / 1000, 10),
10 listOfAlarms = tizen.alarm.getAll();
12 return listOfAlarms.filter(function (item) {
13 // alarm relative has not date property;
18 // +40/-10 seconds tolerance;
19 if (parseInt(item.date.getTime() / 1000, 10) < (currentTimeInMinutes + 40)
20 && parseInt(item.date.getTime() / 1000, 10) > (currentTimeInMinutes - 10)) {
26 ExercisePlanner.prototype.wait = function () {
27 // lastAlert -> change +1min
28 var snozeTime = 1, currentAlarm = this.currentAlarm, newDate = new Date(), alarm;
31 newDate.setMinutes(newDate.getMinutes() + snozeTime);
32 // period value must be set so application started by alert will know current alert;
33 alarm = new tizen.AlarmAbsolute(newDate, tizen.alarm.PERIOD_WEEK * 10);
34 tizen.alarm.add(alarm, this.selfId);
35 // -- remove old snooze alarm
36 if (currentAlarm.period === tizen.alarm.PERIOD_WEEK * 10) {
37 tizen.alarm.remove(currentAlarm.id);
43 // or tizen.application.hide();
46 ExercisePlanner.prototype.ok = function () {
50 ExercisePlanner.prototype.startMusic = function () {
52 if (!this.audioOfAlert) {
53 this.audioOfAlert = new Audio();
55 this.audioOfAlert.src = 'WebContent/Runner.mp3';
56 this.audioOfAlert.load();
57 this.audioOfAlert.play();
60 ExercisePlanner.prototype.stopMusic = function () {
61 if (this.audioOfAlert) {
62 this.audioOfAlert.pause();