Skip to content

Commit

Permalink
Settings UI to switch to mmol display!
Browse files Browse the repository at this point in the history
  • Loading branch information
brianhanifin committed Jul 22, 2014
1 parent 9774ec2 commit 8cd4508
Show file tree
Hide file tree
Showing 3 changed files with 939 additions and 40 deletions.
42 changes: 2 additions & 40 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,46 +76,8 @@ <h4>Browser Preferences</h4>
<script src="/bower_components/jquery/dist/jquery.min.js"></script>
<script src="/bower_components/jQuery-Storage-API/jquery.storageapi.min.js"></script>
<script src="/js/dropdown.js"></script>
<script src="/js/client.js?a"></script>
<script src="/js/client002.js"></script>
<script src="/js/drawer.js"></script>
<script>
$(function() {
var storage = $.localStorage;
var browserSettings = {
"units": storage.get("units")
};
if (browserSettings.units == "mmol") {
$('#mmol-browser').prop('checked', true);
} else {
$('#mgdl-browser').prop('checked', true);
}

$("input#save").click(function() {
var unitsBrowser = $("input:radio[name=units-browser]:checked").val();
storeInBrowser({
"units": unitsBrowser
});

/* var formAction = $("#settings-form").attr("action");
var alertHigh = $("input#alertHigh").val();
var alertLow = $("input#alertLow").val();
storeOnServer({
"alertHigh": alertHigh,
"alertLow": alertLow
}); */

event.preventDefault();
});

function storeInBrowser(json) {
if (json.units) storage.set("units", json.units);
}

function storeOnServer(json) {
alert("TO DO: add storeOnServer() logic.\n" + json.alertHigh + "\n" + json.alertLow);
// reference: http://code.tutsplus.com/tutorials/submit-a-form-without-page-refresh-using-jquery--net-59
}
});
</script>
<script src="/js/settings.js"></script>
</body>
</html>
Loading

3 comments on commit 8cd4508

@saercnap
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the CGM setting for units just propagate everywhere?

@brianhanifin
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked if it should be a server side setting and @bewest response was:

you can't change a running server's units.
so there's no choice there

@brianhanifin
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although, in theory couldn't we use ajax to retrieve the values from the settings API just as easily as localstorage?

Please sign in to comment.