refactor(Settings): Moved active intents settings into seperate settings page

Signed-off-by: Stuart McCulloch Anderson's avatarStuart McCulloch Anderson <stuart@nxfifteen.me.uk>
parent 70c69222
......@@ -2358,14 +2358,10 @@ class ApiBabel
$plusTargetSteps = -1;
if ($string == "steps") {
$userPushLength = $this->getAppClass()->getUserSetting($this->getActiveUser(), "push_length",
'50');
$userPushStartString = $this->getAppClass()->getUserSetting($this->getActiveUser(), "push",
'12-01 last sunday'); // Default to last Sunday in March
$userPushStartDate = date("Y-m-d",
strtotime(date("Y") . '-' . $userPushStartString)); // Default to last Sunday in March
$userPushEndDate = date("Y-m-d",
strtotime($userPushStartDate . ' +' . $userPushLength . ' day')); // Default to last Sunday in March
$userPushLength = $this->getAppClass()->getUserSetting($this->getActiveUser(), "push_length", '50');
$userPushStartString = $this->getAppClass()->getUserSetting($this->getActiveUser(), "push", '12-01 last sunday'); // Default to last Sunday in March
$userPushStartDate = date("Y-m-d", strtotime(date("Y") . '-' . $userPushStartString)); // Default to last Sunday in March
$userPushEndDate = date("Y-m-d", strtotime($userPushStartDate . ' +' . $userPushLength . ' day')); // Default to last Sunday in March
$today = strtotime(date("Y-m-d"));
if ($today >= strtotime($userPushStartDate) && $today <= strtotime($userPushEndDate)) {
......
......@@ -121,6 +121,11 @@ if ($_COOKIE['_nx_fb_usr'] == $App->getNxFit()->getSetting('ownerFuid', null, fa
<a class="nav-link" href="settings/privacy.html"><i class="fa fa-tasks"></i> Privacy</a>
</li>
</ul>
<ul class="nav-dropdown-items">
<li class="nav-item">
<a class="nav-link" href="settings/settings.html"><i class="fa fa-tasks"></i> Settings</a>
</li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="settings/devices.html"><i class="fa fa-chain"></i> Devices</a>
......
......@@ -10,28 +10,7 @@
$(function () {
'use strict';
$.getJSON("../json.php?user=" + fitbitUserId + "&data=Account", function (data) {
var switches = '<div class="row">';
$.each(data.results.babel, function (babelKey, babelValues) {
switches += '<div class="col-9 col-md-2">';
switches += '<span class="form-control-label" style="padding-right: 10px">'+babelValues.name+'</span>';
switches += '</div>';
switches += '<div class="col-3 col-md-1">';
switches += '<label class="switch switch-text switch-pill switch-success" style="margin-right: 10px">';
switches += ' <input type="checkbox" class="switch-input" name="'+babelValues.name+'" id="'+babelKey+'" onchange="submitSwitch(this)"';
if (babelValues.status) {
switches += ' checked';
}
switches += ' >';
switches += ' <span class="switch-label" data-on="On" data-off="Off"></span>';
switches += ' <span class="switch-handle"></span>';
switches += '</label>';
switches += '</div>';
});
switches += '</div>';
$('#ActiveIntents').html(switches);
$('#fullName').html(data.results.name);
$('#fuid').html(data.results.fuid);
$('#email').val(data.results.eml);
......@@ -118,23 +97,3 @@ $("#apiKeyRefresh").submit(function (e) {
e.preventDefault(); // avoid to execute the actual submit of the form.
});
function submitSwitch(e) {
var url = "../ajax.php"; // the script where you handle the form input.
var data = "formId=intentSwitch&switch=" + e.id + "&value=" + e.checked;
$.ajax({
type: "POST",
url: url,
data: data
}).done(function (response) {
if (e.checked) {
$('#ActiveIntentsReport').html("Enabled " + e.name);
} else {
$('#ActiveIntentsReport').html("Disabled " + e.name);
}
}).fail(function (response) {
$('#ActiveIntentsReport').html(response.responseText);
});
}
/*******************************************************************************
* This file is part of NxFIFTEEN Fitness Core.
*
* Copyright (c) 2017. Stuart McCulloch Anderson
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
******************************************************************************/
$(function () {
'use strict';
$.getJSON("../json.php?user=" + fitbitUserId + "&data=Account", function (data) {
var switches = '<div class="row">';
$.each(data.results.babel, function (babelKey, babelValues) {
switches += '<div class="col-9 col-md-2">';
switches += '<span class="form-control-label" style="padding-right: 10px">'+babelValues.name+'</span>';
switches += '</div>';
switches += '<div class="col-3 col-md-1">';
switches += '<label class="switch switch-text switch-pill switch-success" style="margin-right: 10px">';
switches += ' <input type="checkbox" class="switch-input" name="'+babelValues.name+'" id="'+babelKey+'" onchange="submitSwitch(this)"';
if (babelValues.status) {
switches += ' checked';
}
switches += ' >';
switches += ' <span class="switch-label" data-on="On" data-off="Off"></span>';
switches += ' <span class="switch-handle"></span>';
switches += '</label>';
switches += '</div>';
});
switches += '</div>';
$('#ActiveIntents').html(switches);
});
});
function submitSwitch(e) {
var url = "../ajax.php"; // the script where you handle the form input.
var data = "formId=intentSwitch&switch=" + e.id + "&value=" + e.checked;
$.ajax({
type: "POST",
url: url,
data: data
}).done(function (response) {
if (e.checked) {
$('#ActiveIntentsReport').html("Enabled " + e.name);
} else {
$('#ActiveIntentsReport').html("Disabled " + e.name);
}
}).fail(function (response) {
$('#ActiveIntentsReport').html(response.responseText);
});
}
......@@ -99,24 +99,6 @@
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
Active Intents
</div>
<div class="card-block">
<form class="form-signin" id="ActiveIntents">
<div class="form-group row"></div>
</form>
</div>
<div class="card-footer">
<div id="ActiveIntentsReport">&nbsp;</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-12 col-md-2">
......
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ This file is part of NxFIFTEEN Fitness Core.
~
~ Copyright (c) 2017. Stuart McCulloch Anderson
~
~ For the full copyright and license information, please view the LICENSE
~ file that was distributed with this source code.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<script>
var requireJS = [];
loadJS(requireJS, "js/views/settings.js");
// loadCSS("");
setUpBreadcrumb(['Settings'], 'Settings');
</script>
<div class="animated fadeIn">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
Active Intents
</div>
<div class="card-block">
<form class="form-signin" id="ActiveIntents">
<div class="form-group row"></div>
</form>
</div>
<div class="card-footer">
<div id="ActiveIntentsReport">&nbsp;</div>
</div>
</div>
</div>
</div>
</div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment