2018-09-29 15:39:16 +02:00
|
|
|
|
$("#night-mode-enabled").on("change", function()
|
|
|
|
|
{
|
|
|
|
|
var value = $(this).is(":checked");
|
2018-09-30 11:25:07 +02:00
|
|
|
|
|
|
|
|
|
jsonData = { };
|
|
|
|
|
jsonData.value = value;
|
|
|
|
|
console.log(jsonData);
|
|
|
|
|
Grocy.Api.Post('user/settings/night_mode_enabled', jsonData,
|
|
|
|
|
function(result)
|
|
|
|
|
{
|
|
|
|
|
// Nothing to do...
|
|
|
|
|
},
|
|
|
|
|
function(xhr)
|
|
|
|
|
{
|
|
|
|
|
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
|
|
|
|
}
|
|
|
|
|
);
|
2018-09-29 15:39:16 +02:00
|
|
|
|
|
|
|
|
|
if (value)
|
|
|
|
|
{
|
|
|
|
|
$("body").addClass("night-mode");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$("body").removeClass("night-mode");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2018-09-30 11:25:07 +02:00
|
|
|
|
if (Grocy.NightModeEnabled)
|
2018-09-29 15:39:16 +02:00
|
|
|
|
{
|
|
|
|
|
$("#night-mode-enabled").prop("checked", true);
|
|
|
|
|
}
|