--- /dev/null
+Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Flora License, Version 1.
+Please, see the LICENSE.Flora file for Flora License terms and conditions.
+
<?xml version="1.0" encoding="UTF-8"?>
-<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://sample-web-application.tizen.org/ExercisePlanner" version="2.0.0" viewmodes="maximized">
- <tizen:application id="3YbLJNtYMR" required_version="1.0"/>
- <content src="index.html"/>
- <tizen:privilege name="http://tizen.org/privilege/alarm"/>
- <tizen:privilege name="http://tizen.org/privilege/application.launch"/>
- <tizen:privilege name="http://tizen.org/privilege/application.read"/>
- <tizen:privilege name="http://tizen.org/privilege/time"/>
- <tizen:privilege name="http://tizen.org/privilege/tizen"/>
- <icon src="icon.png"/>
- <name>ExercisePlanner</name>
- <tizen:setting screen-orientation="portrait" context-menu="enable"/>
+<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://sample-web-application.tizen.org/ExercisePlanner" version="2.1.0" viewmodes="maximized">
+ <tizen:application id="zED1oRD3Hv.ExercisePlanner" package="zED1oRD3Hv" required_version="2.1"/>
+ <content src="index.html"/>
+ <icon src="icon.png"/>
+ <name>ExercisePlanner</name>
+ <tizen:privilege name="http://tizen.org/privilege/alarm"/>
+ <tizen:privilege name="http://tizen.org/privilege/application.launch"/>
+ <tizen:privilege name="http://tizen.org/privilege/application.read"/>
+ <tizen:privilege name="http://tizen.org/privilege/time"/>
+ <tizen:setting screen-orientation="portrait" context-menu="disable" background-support="enable" encryption="disable" install-location="auto"/>
</widget>
-
#communicate {
font-size: 17pt;
text-align: center;
- min-height: 70px;
+ min-height: 50px;
}
#communicate.onAlert {
font-size: 60px;
}
+h2.ui-title {
+ width:99%;
+ text-overflow: ellipsis;
+}
+/**
+ * Removing disturbing paddings from wide button
+ **/
+#addTimeRange .ui-btn-inner.ui-btn-hastxt,
+#selectExercises .ui-btn-inner.ui-btn-hastxt {
+ padding-left:0;
+ padding-right:0;
+}
+#addTimeRange .ui-btn-text.ui-btn-text-padding-left,
+#selectExercises .ui-btn-text.ui-btn-text-padding-left {
+ padding:0;
+}
+
/**
old styles;
padding: 4px;
margin-right: 12px;
}
-
.ui-li-text-sub-right {
font-size: 18px;
margin-right: 17px;
div.period {
padding-left: 10px;
}
+
+.ui-header .ui-title,
+.ui-footer .ui-btn-text {
+ text-transform: uppercase;
+}
<title>ExercisePlanner</title>
-<script src="/usr/share/tizen-web-ui-fw/latest/js/jquery.js"></script>
-<script src="/usr/share/tizen-web-ui-fw/latest/js/tizen-web-ui-fw-libs.js"></script>
-<script src="/usr/share/tizen-web-ui-fw/latest/js/tizen-web-ui-fw.js"
+<script src="/usr/share/tizen-web-ui-fw/latest/js/jquery.min.js"></script>
+<script src="/usr/share/tizen-web-ui-fw/latest/js/tizen-web-ui-fw-libs.min.js"></script>
+<script src="/usr/share/tizen-web-ui-fw/latest/js/tizen-web-ui-fw.min.js"
data-framework-theme="tizen-white"></script>
-<script src="./js/UI.js"></script>
-<script src="./js/UI.simpleTemplate.js"></script>
-<script src="./js/ext.jqMobile.js"></script>
-<script src="./js/GraphSchedule.js"></script>
+<script defer="defer" src="./js/UI.js"></script>
+<script defer="defer" src="./js/UI.simpleTemplate.js"></script>
+<script defer="defer" src="./js/ext.jqMobile.js"></script>
+<script defer="defer" src="./js/GraphSchedule.js"></script>
-<script src="./js/app.js"></script>
-<script src="./js/app.alarms.js"></script>
-<script src="./js/app.timeRange.js"></script>
-<script src="./js/app.alarmsGenerating.js"></script>
-<script src="./js/app.onAlarm.js"></script>
-<script type="text/javascript" src="./js/main.js"></script>
+<script defer="defer" src="./js/app.js"></script>
+<script defer="defer" src="./js/app.alarms.js"></script>
+<script defer="defer" src="./js/app.timeRange.js"></script>
+<script defer="defer" src="./js/app.alarmsGenerating.js"></script>
+<script defer="defer" src="./js/app.onAlarm.js"></script>
+<script defer="defer" src="./js/main.js"></script>
<link rel="stylesheet" type="text/css" href="./css/style.css" />
<link rel="stylesheet" type="text/css" href="./css/GraphSchedule.css" />
<body>
<div data-role="page" id="one" data-add-back-btn="footer" data-footer-exist="true">
- <div data-role="content">
+ <div data-role="content" data-scroll="none">
<div class="screen">
- <div id="logo">Exercise Planner</div>
+ <div id="logo">EXCERSISE PLANNER</div>
<div id="status"></div>
<div class="schedule"></div>
<div id="communicate"></div>
<div data-role="footer" data-position="fixed">
<div data-role="tabbar" id="mainControl" data-style="tabbar">
<ul>
- <li><a href="#" id="startStop">stop training</a></li>
- <li><a href="#two" id="options">options</a></li>
+ <li><a href="#" id="startStop">Stop Training</a></li>
+ <li><a href="#two" id="options">Options</a></li>
</ul>
</div>
<ul>
<li><a href="#" id="ok">OK</a></li>
<li><a href="#" id="wait">Wait</a></li>
- <li><a href="#" id="todayOffAll">Today off all</a></li>
+ <li><a href="#" id="todayOffAll">Today Off All</a></li>
</ul>
</div>
</div>
</div>
- <div data-role="page" id="two" data-add-back-btn="footer" data-footer-exist="true">
+ <div data-role="page" id="two" data-add-back-btn="footer">
<div data-role="header" data-position="fixed">
- <h1>ExercisePlanner > options</h1>
+ <h1>Exercise Planner > Options</h1>
</div>
<div data-role="content">
<div data-role="tabbar" data-style="tabbar" class="typeOfPeriods">
<ul>
- <li id="workdaysType"><a>workday</a></li>
- <li id="weekendType"><a>weekend</a></li>
+ <li id="workdaysType"><a>Workday</a></li>
+ <li id="weekendType"><a>Weekend</a></li>
</ul>
</div>
<div class="increasingStrength">
<input type="checkbox" name="tizen-check1-1"
id="increasingStrength" />
- <label for="increasingStrength">progressive effort</label>
+ <label for="increasingStrength">Progressive Effort</label>
</div>
- <a data-role="button" data-icon="plus" id="addTimeRange" data-inline="false">add time</a>
+ <a data-role="button" data-icon="plus" id="addTimeRange" data-inline="false">Add Time</a>
<ul data-role="swipelist" id="availableTime"></ul>
</div>
<div data-role="footer" data-position="fixed">
<div data-role="tabbar" data-style="toolbar">
<ul>
- <li><a href="#selectExercises">select workouts</a></li>
+ <li><a href="#selectExercises">Select Workouts</a></li>
</ul>
</div>
</div>
</div>
- <div data-role="page" id="selectExercises" data-add-back-btn="footer" data-footer-exist="true">
+ <div data-role="page" id="selectExercises" data-add-back-btn="footer">
<div data-role="header" data-position="fixed">
- <h2>ExercisePlanner > select workouts</h2>
+ <h2>ExercisePlanner > Select Workouts</h2>
</div>
<div data-role="content">
<div class="optionsExercises">
- <div>Select workouts</div>
- <ul data-role="listview" id="exercises">
- <li class="ui-li-1line-toggle"><span class="ui-li-text-main">bends</span>
- <div data-role="toggleswitch"></div></li>
-
- <li class="ui-li-1line-btn2"><span class="ui-li-text-main">custom</span>
- <div data-role="button" data-inline="true" data-icon="plus"
- data-style="circle"></div></li>
- </ul>
- <a data-role="button" data-icon="plus" href="#customExercises">add
- custom workout</a>
+ <div>Select Workouts</div>
+ <ul data-role="listview" id="exercises"></ul>
+ <a data-role="button" data-icon="plus" href="#customExercises" id="add_custom_workout_btn">Add Custom Workout</a>
</div>
</div>
<div data-role="footer" data-position="fixed"></div>
</div>
- <div data-role="page" id="customExercises" data-add-back-btn="footer" data-footer-exist="true">
+ <div data-role="page" id="customExercises" data-add-back-btn="footer">
<div data-role="header" data-position="fixed">
- <h1>ExercisePlanner > add custom workout</h1>
+ <h1>ExercisePlanner > Add Custom Workout</h1>
</div>
<div data-role="content">
<div class="newExerciseName">
<div>Enter workout name:</div>
<input data-role="input" type="text" name="newExercise"
- id="newExerciseName" />
+ id="newExerciseName" maxlength="20"/>
<input data-role="button" id="btnNewExercise" data-inline="true" type="button"
value="add"/>
</div>
<div data-role="footer" data-position="fixed"></div>
</div>
- <div data-role="page" id="rangesOfTimes" data-add-back-btn="footer" data-footer-exist="true">
+ <div data-role="page" id="rangesOfTimes" data-add-back-btn="footer">
<div data-role="header">
- <h1>add time</h1>
+ <h1>Add Time</h1>
</div>
<div data-role="content">
<legend>Choose a type of period:</legend>
<input type="radio" name="periodType" id="periodType1"
value="everyday" checked="checked" />
- <label for="periodType1">everyday</label>
+ <label for="periodType1">Everyday</label>
<input type="radio" name="periodType" id="periodType2"
value="weekend" />
- <label for="periodType2">weekend</label>
+ <label for="periodType2">Weekend</label>
<input type="radio" name="periodType" id="periodType3"
value="workday" />
- <label for="periodType3">workday</label>
+ <label for="periodType3">Workday</label>
</fieldset>
<div class="enableOption">
<span>Enabled</span>
};
GraphSchedule.prototype.createUI = function createUI() {
- console.log('GraphSchedule..createUI');
var $tmp = $('<div></div>');
$tmp.html(this.template);
};
GraphSchedule.prototype.onTemplateLoad = function onTemplateLoad() {
- console.log('GraphSchedule..onTemplateLoad');
};
GraphSchedule.prototype.init = function init(params) {
this.flags = [];
$loader.load('templates/GraphSchedule.tmpl', null, function (data) {
- console.log('$loader.onLoad');
this.template = data;
this.createUI();
this.onTemplateLoad();
};
GraphSchedule.prototype.addCurrentTimeBar = function addCurrentTimeBar() {
- console.log('addCurrentTimeBar()');
// remove old time bar;
var $currentTimeBar = this.$graph.find('.currentTimeBar'),
currentTime = new Date(),
};
GraphSchedule.prototype.addFlag = function addFlag(newFlag) {
- console.log('addFlag()');
var $flagClone, hours = newFlag.time.getHours();
if (hours < 10) {
hours = '0' + hours;
-/*jslint devel: true, nomen: true*/
-/*global $, GraphSchedule, confirm, range, history */
+/*jslint nomen: true*/
+/*global $, GraphSchedule, confirm, range, history, setTimeout */
function UI() {
"use strict";
}
};
UI.prototype.fillExercises = function (exercisesData) {
- console.log('UI_fillExercises', exercisesData);
var i, len, self = this;
$('#exercises').replaceWith(
- $('<div id="exercises"></div>')
+ $('<ul data-role="listview" id="exercises"></ul>')
);
for (i = 0, len = exercisesData.length; i < len; i += 1) {
$('#exercises').append(
$(this.getExercisesTemplate(exercisesData[i], i))
);
}
+ $('#exercises').listview();
$('#exercises :jqmData(role="slider")').slider();
-
+ $('#exercises li').on('tap', function () {
+ var $toggle = $(this).find(':jqmData(role="slider")');
+ $toggle.val(($toggle.val() === 'off') ? 'on' : 'off');
+ $toggle.slider('refresh');
+ self.app.saveExercises(self.getExercisesList());
+ });
$('#exercises :jqmData(role="slider")').on('change', function (e) {
- console.log('slider:change');
+ e.preventDefault();
+ e.stopPropagation();
self.app.saveExercises(self.getExercisesList());
});
};
UI.prototype.fillTimesRanges = function (timesData) {
- console.log('UI_fillTimesRanges', timesData);
var self = this, len, i;
$('#availableTime').replaceWith(
.append($(this.getAvailableTimeTemplate(timesData[i])));
}
$('#availableTime').trigger('create');
- $('#availableTime').listview();
+ $('#availableTime').listview().listview('refresh');
$('#availableTime :jqmData(name=edit)').on('tap', function (e) {
e.preventDefault();
e.stopPropagation();
};
UI.prototype.fillTimeRangeForm = function fillTimeRangeForm(timeRange) {
- console.log('UI.fillTimeRangeForm', timeRange);
var tmpData = new Date();
// Filling form;
$('#startTime').attr('data-val',
.call(this, field, pat);
result.values = range(1, 20);
result.data = range(1, 20);
+ result.current -= 1;
return result;
};
}
-
+ $.each($("input[name='periodType']"), function () {
+ $(this).attr('checked', $(this).val() === timeRange.style)
+ .checkboxradio('refresh');
+ });
$('#formEnablePeriod')[0].value = timeRange.enabled ? 'on' : 'off';
$('#formEnablePeriod').slider('refresh');
};
UI.prototype.editTimeRange = function (nr, event) {
- console.log('UI_editTimerange', nr, this);
if (event && typeof event.stopPropagation === 'function') {
event.preventDefault();
event.stopPropagation();
if (this.app.editTimeRange(nr) >= 0) {
$('#updateTime').val('modify');
+ $('#rangesOfTimes h1').text('Edit Time')
} else {
$('#updateTime').val('add');
+ $('#rangesOfTimes h1').text('Add Time')
}
// change page to form;
};
UI.prototype.getExercisesList = function () {
- console.log('UI_getExercisesList');
return $('#exercises :jqmData(role=slider)').map(function (o, v) {
return ({
index : $(v).attr('data-index'),
};
UI.prototype.addExercise = function () {
- console.log('UI_addExercise');
- if ($("#newExerciseName").val()) {
- if (this.app.addExercise($("#newExerciseName").val())) {
- history.back();
+ var trimmedName = $("#newExerciseName").val().trim();
+ if (trimmedName !== '') {
+ if (this.app.addExercise(trimmedName)) {
+ $("#newExerciseName").trigger('blur');
+ setTimeout(history.back.bind(history), 50);
}
} else {
this.showErrors([ {
};
UI.prototype.configToUI = function () {
- console.log('UI_configToUI');
};
UI.prototype.updateMainUI = function () {
- console.log('updateMainUI');
this.setStatusRun(this.app.config.trainingEnabled);
- console.log('updateMainUI: graphSchedule: ', this.graphSchedule);
this.graphSchedule.setTimeRanges(this.app.periodsWeekToBoolArray());
};
};
UI.prototype.editTimeRangeAction = function (nr) {
- console.log('UI_editTimeRangeAction', nr);
if (this.app.saveTimeRange(nr, this.getTimeRangeFromForm())) {
history.back();
} else {
};
UI.prototype.showNoticeInMonitor = function (notice, alarm) {
- console.log('UI_showNoticeInMonitor', notice, alarm);
$('#communicate').html(notice);
$('#communicate').toggleClass('onAlert', alarm);
};
UI.prototype.changeButtonAddTime = function (text) {
- console.log('UI_changeButtonAddTime', text);
$('#addTime').html(text);
};
UI.prototype.showErrors = function (errors) {
- console.log('UI_showErrors', errors);
var i; // count;
for (i = 0; i < errors.length; i += 1) {
alert(errors[i].name);
};
UI.prototype.showAlarmInMonitor = function (data) {
- console.log('UI_showAlarmInMonitor', data);
var notice = '';
function formatNN(val) {
return (val < 10) ? ('0' + val) : val;
this.showNoticeInMonitor(notice, false);
};
- UI.prototype.getSentence = function (type) {
- console.log('UIgetSentence', type);
+ UI.prototype.getSentence = function UI_getSentence(type) {
return (this.sentence[type] || {
text : 'No sentence',
signature : 'anonymous'
};
UI.prototype.setSentence = function (type) {
- console.log('UI_setSentence');
var sentence = this.getSentence(type);
$('#sentence').html('"' + sentence.text + '"');
$('#signature').html('- ' + sentence.signature);
};
UI.prototype.showWaitOk = function () {
- console.log('UI_showWaitOk');
$('#mainControl').hide();
$('#one .ui-btn-back').hide();
};
UI.prototype.setStatusRun = function (bool) {
- console.log('UI_setStatusRun', bool);
if (bool) {
// icon;
$('#status').removeClass('lazy').addClass('run');
// sentence;
this.setSentence('run');
// button in control bar;
- $('#startStop .ui-btn-text').html('stop training');
+ $('#startStop .ui-btn-text').html('Stop Training');
} else {
$('#status').removeClass('run').addClass('lazy');
this.setSentence('lazy');
$('#communicate').html('');
- $('#startStop .ui-btn-text').html('start training');
+ $('#startStop .ui-btn-text').html('Start Training');
}
};
$('#one').on(
'pageshow',
function (page, options) {
- console.log('#one pageshow');
if (self.graphSchedule.ui) {
$('#one .schedule').append(self.graphSchedule.ui);
self.app.updateGraph();
$('#one .schedule').on('touchstart', function (ev) {
ev.stopPropagation();
});
+
+ // workaround for scroll lock;
+ $.mobile.activePage.css('position', 'fixed');
}
);
$('#two').on('pageshow', function (page, options) {
- console.log('#two pageshow');
+
+ //FIXME (two scrollbar workaround)
+ setTimeout(
+ function () {
+ var newHeight = $('#two').find('[data-role="content"]').prop('style').height;
+ $('#two').css({'min-height': newHeight, 'height': newHeight});
+ },
+ 0
+ );
+
if (self.graphSchedule.ui) {
$('#two .scheduleOptions').append(self.graphSchedule.ui);
self.graphSchedule.refresh();
});
$('#two').on('pageinit', function (page, options) {
- console.log('#two pageinit');
$('.ui-radio input', $('#frequency')).change(function (ev) {
self.app.setFrequency(this.value);
self.updateMainUI();
$('#selectExercises').on('pageinit', function (page, options) {
self.app.updateExercises();
self.configToUI();
+ });
- $('#btnNewExercise').on('tap', self.addExercise.bind(self));
+ $('#customExercises').on('pageinit', function (page, options) {
+ $('#btnNewExercise').on('click', self.addExercise.bind(self));
});
$('#customExercises').on('pageshow', function (page, options) {
});
$('#rangesOfTimes').on('pageinit', function (page, options) {
- console.log('#rangesOfTimes init');
- $("#updateTime").on("tap", function (e) {
+ $("#updateTime").on("click", function (e) {
e.preventDefault();
e.stopPropagation();
self.editTimeRangeAction(self.app.currentEditingTimePeriodId);
});
$('#rangesOfTimes').on('pageshow', function (page, options) {
- console.log('#rangesOfTimes pageshow');
$('#updateTime').data('button').refresh();
self.fillTimeRangeForm(self.app.currentEditingTimePeriod);
});
};
UI.prototype.onGraphSchedule = function onGraphSchedule(onInitEnd) {
- console.log('(UI..initialize).onGraphSchedule');
this.updateMainUI();
$('#one .schedule').append(this.graphSchedule.ui);
};
UI.prototype.initialize = function (onInitEnd) {
- console.log('UI..initialize');
+ $.mobile.tizen.disableSelection(document);
this.bindEvents();
- $('html').css('font-size', '');
- $('body').css('font-size', '');
+ $('html, body').css('font-size', '');
+ $('[data-role=footer]').height('');
this.graphSchedule = new GraphSchedule({
onSuccess : this.onGraphSchedule.bind(this, onInitEnd)
(function () {
"use strict";
UI.prototype.getAvailableTimeTemplate = function getAvailableTimeTemplate(obj) {
- return '<li>' + '<div class="timeRangeLabel">start: ' + obj.start
- + ' (duration: ' + obj.duration + 'h) ' + obj.style + '</div>'
+ return '<li>' + '<div class="timeRangeLabel">Start: ' + obj.start
+ + ' (Duration: ' + obj.duration + 'h) ' + obj.style + '</div>'
+ '<div class="timeRangeButtons">'
+ '<div data-role="button" data-inline="true" data-name="edit" data-val="' + obj.nr + '">Edit</div>'
+ '<div data-role="button" data-inline="true" data-name="disable" data-val="' + obj.nr + '">'
+ ((obj.enabled) ? 'Dis' : 'En') + 'able</div>'
+ '<div data-role="button" data-inline="true" data-name="delete" data-val="' + obj.nr + '">Delete</div>'
- + '<div class="activeStatus' + ((obj.enabled) ? '' : ' activeStatusDisable') + '" data-inline="true">' + ((obj.enabled) ? 'En' : 'Dis') + 'able</div>'
+ + '<div class="activeStatus' + ((obj.enabled) ? '' : ' activeStatusDisable') + '" data-inline="true">' + ((obj.enabled) ? 'En' : 'Dis') + 'abled</div>'
+ '</div>' + '</li>';
};
UI.prototype.getExercisesTemplate = function (obj, i) {
- return '<div>'
+ return '<li>'
+ '<span>' + obj.name + '</span>'
+ '<select data-role="slider" data-index="' + i + '">'
+ '<option value="off" ' + (obj.enabled ? '' : 'selected="selected"') + '></option>'
+ '<option value="on" ' + (obj.enabled ? 'selected="selected"' : '') + '></option>'
- + '</select>' + '</div>';
+ + '</select>' + '</li>';
};
}());
-/*jslint devel: true*/
+/*jslint devel:true*/
/*global ExercisePlanner:false, tizen:false*/
/**
* Methods for add / remove alarms by API;
* Wrapper on remove all alarms joined with app
*/
ExercisePlanner.prototype.removeAllAlarms = function () {
- console.log('ExercisePlanner_removeAllAlarms');
tizen.alarm.removeAll();
};
ExercisePlanner.prototype.addAlarmFromArray = function addAlarmFromArray(tabOfAlarm, defOfPeriod) {
var i, len = tabOfAlarm.length, alarm;
- console.log('tabOfAlarm:', tabOfAlarm);
- console.log('definition of period:', defOfPeriod);
for (i = 0; i < len; i += 1) {
alarm = new tizen.AlarmAbsolute(tabOfAlarm[i], defOfPeriod);
try {
* @returns {Array}
*/
ExercisePlanner.prototype.generateAlarmsByFactor = function (factor, tmpPeriods) {
- console.log('ExercisePlanner_generateAlarmsByFactor', factor, tmpPeriods);
var i, numberOfPeriods = tmpPeriods.length,
period,
begin,
}
dayTime.setSeconds(0);
- console.log('generateAlarmsByFactor: end | begin ', end, begin);
if (factor.count === 1) {
// One alarm per day, default placed in middle of available time;
optimalTime = this.findNearestTimeRange((end + begin) / 2, tmpPeriods);
- console.log('optimale Hour', optimalTime);
dayTime.setHours(parseInt(optimalTime.optimalHour, 10));
dayTime.setMinutes(60 * (optimalTime.optimalHour - parseInt(optimalTime.optimalHour, 10)));
deltaTime += period.duration;
// if available period is too small, then accumulate time
// and continue to next period;
- console.log('delta & factor: ', deltaTime, factor.period);
while (deltaTime >= factor.period * 0.999) {
deltaTime -= factor.period;
}
}
}
-
return tableOfAlarms;
};
* @param {Date} customDate;
*/
ExercisePlanner.prototype.generateAlarms = function () {
- console.log('ExercisePlanner_generateAlarms');
var factors,
alarms = this.alarms,
periodsWeek = {
factors = this.calculateFactors(this.getSummaryAvailableTime());
// Set new alarms;
- if (periodsWeek.everyday.length > 0) {
- alarms.everyday = this.generateAlarmsByFactor(factors.everyday, periodsWeek.everyday);
- } else {
- alarms.workday = this.generateAlarmsByFactor(factors.workday, periodsWeek.workday);
- alarms.weekend = this.generateAlarmsByFactor(factors.weekend, periodsWeek.weekend);
- }
+ alarms.everyday = this.generateAlarmsByFactor(factors.everyday, periodsWeek.everyday);
+ alarms.workday = this.generateAlarmsByFactor(factors.workday, periodsWeek.workday);
+ alarms.weekend = this.generateAlarmsByFactor(factors.weekend, periodsWeek.weekend);
// if trainig is in run then resinstall alarm imediately
if (this.config.trainingEnabled) {
-/*jslint browser: true, devel: true */
+/*jslint devel:true*/
/*global tizen, $, app, localStorage, Audio, document, unlockScreen, UI */
var ExercisePlanner = function () {
"use strict";
* (use localStorage)
*/
ExercisePlanner.prototype.loadConfig = function () {
- console.log('ExercisePlanner_loadConfig');
var configStr = localStorage.getItem('config');
if (configStr) {
this.config = JSON.parse(configStr);
* (use localStorage)
*/
ExercisePlanner.prototype.saveConfig = function () {
- console.log('ExercisePlanner_saveConfig');
localStorage.setItem('config', JSON.stringify(this.config));
};
ExercisePlanner.prototype.stopTraining = function () {
- console.log('ExercisePlanner_stopTraining');
this.removeAllAlarms();
this.ui.setStatusRun(this.config.trainingEnabled);
};
ExercisePlanner.prototype.startTraining = function () {
- console.log('ExercisePlanner_startTraining');
this.ui.setStatusRun(this.config.trainingEnabled);
this.startAlarms();
};
* Toggle start/stop alarms for workouts
*/
ExercisePlanner.prototype.appStartStop = function () {
- console.log('ExercisePlanner_appStartStop');
this.config.trainingEnabled = !this.config.trainingEnabled;
if (this.config.trainingEnabled) {
this.startTraining();
* Closing application with the configuration data saving
*/
ExercisePlanner.prototype.exit = function () {
- console.log('ExercisePlanner_exit');
this.saveConfig();
this.stopMusic();
tizen.application.getCurrentApplication().exit();
* @param value
*/
ExercisePlanner.prototype.setFrequency = function (value) {
- console.log('ExercisePlanner_setFrequency', value);
this.config.frequency[this.config.currentTypeOfPeriods] = parseInt(value, 10);
this.saveConfig();
* @param value
*/
ExercisePlanner.prototype.setStrength = function (value) {
- console.log('ExercisePlanner_setStrength', value);
this.config.strength[this.config.currentTypeOfPeriods] = parseInt(value, 10);
this.saveConfig();
};
* Sending array of exercises to UI for update
*/
ExercisePlanner.prototype.updateExercises = function () {
- console.log('ExercisePlanner_updateExercises');
this.ui.fillExercises(this.config.exercises);
};
* & update graph schedule
*/
ExercisePlanner.prototype.updateTimesRanges = function () {
- console.log('ExercisePlanner_updateTimesRanges');
this.ui.fillTimesRanges(this.config.timesRanges);
this.ui.graphSchedule.updateTimeRanges();
* @param newData
*/
ExercisePlanner.prototype.saveExercises = function (newData) {
- console.log('ExercisePlanner_saveExercises', newData);
var i, l;
if (newData) {
* and show in UI
*/
ExercisePlanner.prototype.showNextAlarm = function showNextAlarm() {
- console.log('ExercisePlanner_showNextAlarm');
var alarms,
currentDate = new Date();
}).sort(function (a, b) {
return a.date - b.date;
});
- console.log(alarms);
if (this.config.nearestExercise > -1) {
this.ui.showAlarmInMonitor({
* @returns
*/
ExercisePlanner.prototype.checkExerciseName = function (name) {
- console.log('ExercisePlanner_checkExerciseName', name);
var i, l;
+ name = $.trim(name);
- if (name) {
- for (i = 0, l = this.config.exercises.length; i < l; i += 1) {
- if (this.config.exercises[i].name === name) {
- return i;
- }
+ for (i = 0, l = this.config.exercises.length; i < l; i += 1) {
+ if (this.config.exercises[i].name === name) {
+ return false;
}
- return -1;
}
+
+ return true;
};
/**
* @returns {Boolean}
*/
ExercisePlanner.prototype.addExercise = function (name) {
- console.log('ExercisePlanner_addExercise', name);
- if (this.checkExerciseName(name) < 0) {
+ if (this.checkExerciseName(name) === true) {
this.config.exercises.push({
name: name,
enabled: false
this.ui.fillExercises(this.config.exercises);
return true;
}
- this.ui.showErrors({name: 'Element exists!'});
+
+ this.ui.showErrors([{name: 'Given exercise already exists!'}]);
return false;
};
* @returns {number}
*/
ExercisePlanner.prototype.getNumberOfWorkoutsByFrequency = function getNumberOfWorkoutsByFrequency(value) {
- console.log('ExercisePlanner_frequencyMap', value);
var iMap = [1, 2, 4, 8, 16, 24, 150],
// -- times per 24h; proportion to set periods of available time;
numberOfWorkouts = iMap[value];
* @returns {number}
*/
ExercisePlanner.prototype.getStrength = function strengthMap(value, count) {
- console.log('ExercisePlanner_strengthMap', value, count);
var sMap = [1, 1, 2, 4, 10, 20],
base = sMap[value] || 2;
* Generate name of exercise for nearest workout
*/
ExercisePlanner.prototype.generateNearestExercise = function () {
- console.log('ExercisePlanner_generateNearestExercise');
var tmp = this.config.exercises.filter(function (item) {
return item.enabled;
});
* @param {String} typeOfPeriods ['workday'|'weekend']
*/
ExercisePlanner.prototype.updateGraph = function updateGraph(typeOfPeriods) {
- console.log('updateGraph');
var alarms;
if (!this.ui.graphSchedule) {
throw {
}
typeOfPeriods = typeOfPeriods || ((this.todayIsWorkday()) ? 'workday' : 'weekend');
- console.log('typeOfPeriods: ', typeOfPeriods);
if (typeOfPeriods === 'workday') {
alarms = this.alarms.workday;
// Initialize function
ExercisePlanner.prototype.init = function init() {
var onUiInitialize = function onUiInitialize() {
- console.log('onUiInitialize');
// register watcher on visibility change;
document.addEventListener('webkitvisibilitychange', this.onVisibilityChange.bind(this));
this.showNextAlarm();
this.onVisibilityChange();
}.bind(this);
- console.log('ExercisePlanner..init');
this.selfId = tizen.application.getAppContext().appId;
this.ui = new UI();
this.ui.app = this;
+/*jslint devel:true*/
/*global ExercisePlanner:false, tizen:false, Audio:false*/
/**
* These method are using when alarm is call.
(function () {
"use strict";
ExercisePlanner.prototype.findCurrentAlarm = function () {
- console.log('ExercisePlanner_findCurrentAlarm');
var currentTimeInMinutes = parseInt(this.applicationStartTime.getTime() / 1000, 10),
listOfAlarms = tizen.alarm.getAll();
}
// +40/-10 seconds tolerance;
- console.log(item.date);
if (parseInt(item.date.getTime() / 1000, 10) < (currentTimeInMinutes + 40)
&& parseInt(item.date.getTime() / 1000, 10) > (currentTimeInMinutes - 10)) {
return true;
};
ExercisePlanner.prototype.wait = function () {
- console.log('ExercisePlanner_wait');
// lastAlert -> change +1min
var snozeTime = 1, currentAlarm = this.currentAlarm, newDate = new Date(), alarm;
};
ExercisePlanner.prototype.startMusic = function () {
- console.log('ExercisePlanner_startMusic');
if (!this.audioOfAlert) {
this.audioOfAlert = new Audio();
};
ExercisePlanner.prototype.stopMusic = function () {
- console.log('ExercisePlanner_stopMusic');
if (this.audioOfAlert) {
this.audioOfAlert.pause();
}
(function () {
"use strict";
ExercisePlanner.prototype.checkNewTimeRange = function (start, duration, style) {
- console.log('ExercisePlanner_checkNewTimeRange', start, duration, style);
var result = [];
- // check start / stop
- /*
- * deprecated if (start >= stop) { result.push({ name: 'Start time is greater or equal than
- * stop time.', code: 1 }); }
- */
-
- if (!start) {
- result.push({
- name: 'Start time is not set.',
- code: 2
- });
- }
-
if (duration < 1 || duration > 24) {
result.push({
name: 'Duration is not set properly.',
code: 2
});
}
-
- /*
- * deprecated if (!stop) { result.push({ name: 'Stop time is not set.', code: 3 }); }
- */
return result;
};
* Sort method for time ranges;
*/
ExercisePlanner.prototype.sortTimeRanges = function () {
- console.log('ExercisePlanner_sortTimeRanges');
this.config.timesRanges.sort(function (a, b) {
return a.start - b.start;
});
* Save time range
*
* @param nr
- * @param start
- * @param duration
- * @param style
- * @param enabled
+ * @param timeRange
* @returns {Boolean}
*/
ExercisePlanner.prototype.saveTimeRange = function (nr, timeRange) {
- console.log('ExercisePlanner_saveTimeRange', nr, timeRange);
var index = -1,
errors = this.checkNewTimeRange(timeRange.start, timeRange.duration, timeRange.style);
- console.log(errors);
// new timeRanges has nr === -1; this mean we must get max number from config
if (nr === -1) {
* @returns {Boolean}
*/
ExercisePlanner.prototype.deleteTimeRange = function (nr) {
- console.log('ExercisePlanner_deleteTimeRange', nr);
var index,
timeRange = this.getTimeRangeByNr(nr);
* @returns {Boolean}
*/
ExercisePlanner.prototype.disableTimeRange = function (nr) {
- console.log('ExercisePlanner_disableTimeRange', nr);
var timeRange = this.getTimeRangeByNr(nr);
if (timeRange === undefined) {
};
ExercisePlanner.prototype.mergePeriods = function mergePeriods() {
- console.log('ExercisePlanner_mergePeriods');
var i, len, onlyEveryDay = true,
ranges = this.config.timesRanges,
result = {
};
ExercisePlanner.prototype.getSummaryAvailableTime = function getSummaryAvailableTime() {
- console.log('ExercisePlanner_getSummaryAvailableTime');
var i, len,
periods = this.cache.periodsWeek,
sum = {
};
ExercisePlanner.prototype.findNearestTimeRange = function (hour, ranges) {
- console.log('ExercisePlanner_findNearestTimeRange', hour, ranges);
var nearResult,
result = {
requestedHour: hour,
</Reference>
<Reference URI="js/app.alarms.js">
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
-<DigestValue>7t0Zyyn9Cu0/HXEXaxEinFCFYpmDDgP7vdyN5UVWkQk=</DigestValue>
+<DigestValue>HDdDyO50lysh2ImUEF4O+gENJ0kqYe/jG+//wKCUjkU=</DigestValue>
</Reference>
<Reference URI="js/app.js">
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
-<DigestValue>MtoxmfFtOOUWSBu/kfMTnCeClw9RLIjMS77IWrMG7wg=</DigestValue>
+<DigestValue>u7zFScgBYrNWfqbfF6xh8PSKtoVOHjAr5nzQN8E/DjI=</DigestValue>
</Reference>
<Reference URI="js/ext.jqMobile.js">
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
</Reference>
<Reference URI="js/app.onAlarm.js">
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
-<DigestValue>A52TbnmMcr8G0QDY86BmznRMEAVLMrBShC2E51RITb4=</DigestValue>
+<DigestValue>gdy4iv5tDE/HgIt8uUhIh4Ep1qDnJc0xSaboi6aqkoA=</DigestValue>
</Reference>
<Reference URI="js/app.timeRange.js">
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
-<DigestValue>4cLd4pP/oi83KOcF8LVUJB6gxUWBsE8ZiDBCoJzjE/o=</DigestValue>
+<DigestValue>ncgE4da2cxhO5CoPxZ3LupzDf07rAUs+pj9m3p4CICM=</DigestValue>
</Reference>
<Reference URI="js/UI.simpleTemplate.js">
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
-<DigestValue>xcxpAXCb5SX9K2yPYnYXSg/lFPbD5exPgfKQcvSSqr4=</DigestValue>
+<DigestValue>MWgj37kIVCFxWxjNTDUKHVACshY3Jo8+0S70rbOPER0=</DigestValue>
</Reference>
<Reference URI="js/UI.js">
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
-<DigestValue>o9r/AN5tPtlHjYYiVoB5AfJgQsH+Aj2cUZYdzSUgyr8=</DigestValue>
+<DigestValue>Z7EAQPjD1cdBo62ZKtQIyn1kBffgTfzMj68PRkOB55s=</DigestValue>
</Reference>
<Reference URI="js/GraphSchedule.js">
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
-<DigestValue>ZpmuwAVONsdanK1S4KQPaHj1EYC8Ezs1QDZQbaFWm4M=</DigestValue>
+<DigestValue>H9a1T3N+7RfPsLghpkoqoZvimeVptZA9UNl+dPFQ2cg=</DigestValue>
</Reference>
<Reference URI="js/app.alarmsGenerating.js">
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
-<DigestValue>1i4kpyIdtiDzToEKnuhiGitX2hVtPRVto9KixvY1B+s=</DigestValue>
+<DigestValue>aHXi3ninQ45QvscpkxSKOR3FNlF3dKusGlnJc0l/wvE=</DigestValue>
</Reference>
<Reference URI="config.xml">
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
-<DigestValue>XTYWoMBP0dm54DvvQmpdv0uG7UuU8wt06y9PfLGVI8E=</DigestValue>
+<DigestValue>ca7mpH3CCpE5/XQ/fPo+8yAZKWrkOhc8e4zAj9Ei1AY=</DigestValue>
</Reference>
<Reference URI="icon.png">
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
</Reference>
<Reference URI="index.html">
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
-<DigestValue>PrB+bVW3O2ESYgM0lAXMNEnGAXpB8AtcD2xvSegCIvU=</DigestValue>
+<DigestValue>xFBASVTxrmM97Kiwv85+646AJu23m4FJl7/NG9JPtFI=</DigestValue>
</Reference>
<Reference URI="css/jquery.ui.layout.css">
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
</Reference>
<Reference URI="css/style.css">
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
-<DigestValue>WvY/5k6O0wSwUO7d7S4qaedAyzxw4zdmPOOv6ZuFz+c=</DigestValue>
+<DigestValue>miNScnFdCe9HXHU/gs87RJdJDHJahAKjhCNH6w6MhFE=</DigestValue>
</Reference>
<Reference URI="css/GraphSchedule.css">
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
<DigestValue>FMRxMozySMCFzVvfumNqZOHA+/qDtj84zddroztYWME=</DigestValue>
</Reference>
-<Reference URI="NOTICE.Flora">
+<Reference URI="NOTICE">
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod>
-<DigestValue>M7oEsiEdLNeaSAYdtR7uR5WGeAELG/V70u7Huzl42Xs=</DigestValue>
+<DigestValue>L7tfBCBf+4lj0QNjO1kNBMsq5EZfBkHrO/JGAbrFtQs=</DigestValue>
</Reference>
<Reference URI="#prop">
<Transforms>
</Reference>
</SignedInfo>
<SignatureValue>
-q9jMxR0PK+VpYO8PfFvcJyjnNizJ3NNjovCkzI27U9+Z9hEPCLtLfOOuPEhYfJyjQJiU0h1L+3O0
-iidyZpM3PrTfyPQHuuUQ/6VlBazd/dvd/aHEZDe7+B7sr4lLfXVlOriiwPtlR7YA7YQxYJwAgGq1
-etkYVBAMO9+wW45rrAs=
+fnvaRZX3LOmKTYmCqiGF/h25V7KdirSw4iNsVeeQwlvAgte8HgWtnxZL1+mNmBR0j8ZxrzXH7i7Z
+1oJZPDFmDdSb7IiDrXcXcmpVBBkRZoSERmalFTEcvDun/P0+xeoQU/l2MofA5FuQEqJ7dn3Jrmg5
+VagMmsLjFx0MvLG5NgE=
</SignatureValue>
<KeyInfo>
<X509Data>