Skip to content

Commit

Permalink
B3046
Browse files Browse the repository at this point in the history
Weather Diary tweaks
  • Loading branch information
mcrossley committed Jan 2, 2019
1 parent e0fa999 commit 989c960
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 37 deletions.
4 changes: 2 additions & 2 deletions interface/diaryeditor.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ <h1>Diary editor</h1>
<div class="form-group">
<label for="inputComment" class="control-label col-xs-2">Comments</label>
<div class="col-xs-10">
<input type="text" class="form-control" id="inputComment">
<input type="text" class="form-control" id="inputComment" style="height: 70px">
</div>
</div>
<div class="form-group">
Expand All @@ -123,7 +123,7 @@ <h1>Diary editor</h1>
<label for="inputSnowDepth" class="control-label col-xs-2">Snow Depth (cm)</label>
<div class="col-xs-10">
</div>
<input type="number" class="form-control" id="inputSnowDepth" step="0.01" style="width: 83%">
<input type="number" class="form-control" id="inputSnowDepth" step="0.01" style="width: 120px">
</div>
</div>
<div class="form-group">
Expand Down
76 changes: 41 additions & 35 deletions interface/js/diaryeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ $(document).ready(function () {
var currYear = date.getFullYear();
var currMonth = date.getMonth() + 1;


$.ajax({
url : 'api/settings/version.json',
dataType: 'json',
Expand Down Expand Up @@ -37,6 +36,7 @@ $(document).ready(function () {
}
});

$("#datepicker").datepicker('setDate', '0');
getSummaryData(currYear, currMonth);

$('#datepicker').on('changeDate', function () {
Expand Down Expand Up @@ -80,26 +80,29 @@ function deleteEntry() {
'"snowFalling":"' + ($('#inputSnowFalling').prop('checked') ? 1 : 0) + '",' +
'"snowLying":"' + ($('#inputSnowLying').prop('checked') ? 1 : 0) + '",' +
'"snowDepth":"' + ($('#inputSnowDepth').val() ? $('#inputSnowDepth').val() : 0) + '"}';
$.ajax({
url : 'api/edit/diarydelete',
type : 'POST',
data : body,
dataType: 'json',
success : function (result) {
console.log(result.result);
// notify user
if (result.result === 'Success') {
$('#inputComment').val(null);
$('#inputSnowFalling').prop('checked', false);
$('#inputSnowLying').prop('checked', false);
$('#inputSnowDepth').val(null);
$('#status').text('Entry deleted.');
if ('' == date) {
$('#status').text('Error: You must select a date first.');
} else {
$.ajax({
url : 'api/edit/diarydelete',
type : 'POST',
data : body,
dataType: 'json',
success : function (result) {
console.log(result.result);
// notify user
if (result.result === 'Success') {
$('#inputComment').val(null);
$('#inputSnowFalling').prop('checked', false);
$('#inputSnowLying').prop('checked', false);
$('#inputSnowDepth').val(null);
$('#status').text('Entry deleted.');
}
// update datepicker
getSummaryData();
}
// update datepicker
getSummaryData();
}

});
});
}
}

function applyEntry() {
Expand All @@ -109,20 +112,23 @@ function applyEntry() {
'"snowFalling":"' + ($('#inputSnowFalling').prop('checked') ? 1 : 0) + '",' +
'"snowLying":"' + ($('#inputSnowLying').prop('checked') ? 1 : 0) + '",' +
'"snowDepth":"' + ($('#inputSnowDepth').val() ? $('#inputSnowDepth').val() : 0) + '"}';
$.ajax({
url : 'api/edit/diarydata',
type : 'POST',
data : body,
dataType: 'json',
success : function (result) {
console.log(result.result);
// notify user
if (result.result === 'Success') {
$('#status').text('Entry added/updated OK.');
if ('' == date) {
$('#status').text('Error: You must select a date first.');
} else {
$.ajax({
url : 'api/edit/diarydata',
type : 'POST',
data : body,
dataType: 'json',
success : function (result) {
console.log(result.result);
// notify user
if (result.result === 'Success') {
$('#status').text('Entry added/updated OK.');
}
// update datepicker
getSummaryData();
}
// update datepicker
getSummaryData();
}
});

});
}
}

0 comments on commit 989c960

Please sign in to comment.