mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 17:45:39 +00:00
Fixed JS errors on the login page
This commit is contained in:
parent
78b658e86e
commit
d580990b25
@ -12,6 +12,11 @@ function RefreshHeaderClock()
|
||||
Grocy.HeaderClockInterval = null;
|
||||
function CheckHeaderClockEnabled()
|
||||
{
|
||||
if (Grocy.UserId === -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Refresh the clock in the header every second when enabled
|
||||
if (BoolVal(Grocy.UserSettings.show_clock_in_header))
|
||||
{
|
||||
@ -36,7 +41,7 @@ function CheckHeaderClockEnabled()
|
||||
}
|
||||
CheckHeaderClockEnabled();
|
||||
|
||||
if (BoolVal(Grocy.UserSettings.show_clock_in_header))
|
||||
if (Grocy.UserId !== -1 && BoolVal(Grocy.UserSettings.show_clock_in_header))
|
||||
{
|
||||
$("#show-clock-in-header").prop("checked", true);
|
||||
}
|
||||
|
@ -1,13 +1,16 @@
|
||||
Grocy.Api.Get('system/db-changed-time',
|
||||
function(result)
|
||||
{
|
||||
Grocy.DatabaseChangedTime = moment(result.changed_time);
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
if (Grocy.UserId !== -1)
|
||||
{
|
||||
Grocy.Api.Get('system/db-changed-time',
|
||||
function(result)
|
||||
{
|
||||
Grocy.DatabaseChangedTime = moment(result.changed_time);
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Check if the database has changed once a minute
|
||||
// If a change is detected, reload the current page, but only if already idling for at least 50 seconds,
|
||||
@ -56,7 +59,7 @@ setInterval(function()
|
||||
Grocy.IdleTime += 1;
|
||||
}, 1000);
|
||||
|
||||
if (BoolVal(Grocy.UserSettings.auto_reload_on_db_change))
|
||||
if (Grocy.UserId !== -1 && BoolVal(Grocy.UserSettings.auto_reload_on_db_change))
|
||||
{
|
||||
$("#auto-reload-enabled").prop("checked", true);
|
||||
}
|
||||
|
@ -56,18 +56,21 @@ $("#auto-night-mode-time-range-goes-over-midgnight").on("change", function()
|
||||
CheckNightMode();
|
||||
});
|
||||
|
||||
$("#night-mode-enabled").prop("checked", BoolVal(Grocy.UserSettings.night_mode_enabled));
|
||||
$("#auto-night-mode-enabled").prop("checked", BoolVal(Grocy.UserSettings.auto_night_mode_enabled));
|
||||
$("#auto-night-mode-time-range-goes-over-midgnight").prop("checked", BoolVal(Grocy.UserSettings.auto_night_mode_time_range_goes_over_midnight));
|
||||
$("#auto-night-mode-enabled").trigger("change");
|
||||
$("#auto-night-mode-time-range-from").val(Grocy.UserSettings.auto_night_mode_time_range_from);
|
||||
$("#auto-night-mode-time-range-from").trigger("keyup");
|
||||
$("#auto-night-mode-time-range-to").val(Grocy.UserSettings.auto_night_mode_time_range_to);
|
||||
$("#auto-night-mode-time-range-to").trigger("keyup");
|
||||
if (Grocy.UserId !== -1)
|
||||
{
|
||||
$("#night-mode-enabled").prop("checked", BoolVal(Grocy.UserSettings.night_mode_enabled));
|
||||
$("#auto-night-mode-enabled").prop("checked", BoolVal(Grocy.UserSettings.auto_night_mode_enabled));
|
||||
$("#auto-night-mode-time-range-goes-over-midgnight").prop("checked", BoolVal(Grocy.UserSettings.auto_night_mode_time_range_goes_over_midnight));
|
||||
$("#auto-night-mode-enabled").trigger("change");
|
||||
$("#auto-night-mode-time-range-from").val(Grocy.UserSettings.auto_night_mode_time_range_from);
|
||||
$("#auto-night-mode-time-range-from").trigger("keyup");
|
||||
$("#auto-night-mode-time-range-to").val(Grocy.UserSettings.auto_night_mode_time_range_to);
|
||||
$("#auto-night-mode-time-range-to").trigger("keyup");
|
||||
}
|
||||
|
||||
function CheckNightMode()
|
||||
{
|
||||
if (!BoolVal(Grocy.UserSettings.auto_night_mode_enabled))
|
||||
if (Grocy.UserId === -1 || !BoolVal(Grocy.UserSettings.auto_night_mode_enabled))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -105,7 +108,10 @@ function CheckNightMode()
|
||||
}
|
||||
}
|
||||
}
|
||||
CheckNightMode();
|
||||
if (Grocy.UserId !== -1)
|
||||
{
|
||||
CheckNightMode();
|
||||
}
|
||||
|
||||
if (Grocy.Mode === "production")
|
||||
{
|
||||
|
@ -57,9 +57,15 @@
|
||||
Grocy.CalendarFirstDayOfWeek = '{{ GROCY_CALENDAR_FIRST_DAY_OF_WEEK }}';
|
||||
Grocy.CalendarShowWeekNumbers = {{ BoolToString(GROCY_CALENDAR_SHOW_WEEK_OF_YEAR) }};
|
||||
Grocy.GettextPo = {!! $GettextPo !!};
|
||||
Grocy.UserSettings = {!! json_encode($userSettings) !!};
|
||||
Grocy.FeatureFlags = {!! json_encode($featureFlags) !!};
|
||||
|
||||
@if (GROCY_AUTHENTICATED)
|
||||
Grocy.UserSettings = {!! json_encode($userSettings) !!};
|
||||
Grocy.UserId = {{ GROCY_USER_ID }};
|
||||
@else
|
||||
Grocy.UserSettings = { };
|
||||
Grocy.UserId = -1;
|
||||
@endif
|
||||
</script>
|
||||
</head>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user