Skip to content

Commit

Permalink
Merge pull request #26 from nightscout/feature/settings-ui
Browse files Browse the repository at this point in the history
Settings UI to switch to mmol display!
  • Loading branch information
brianhanifin committed Jul 22, 2014
2 parents a1599ab + 8cd4508 commit 581b3c7
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

0 comments on commit 581b3c7

Please sign in to comment.