mirror of
https://github.com/grocy/grocy.git
synced 2025-08-18 19:37:12 +00:00
Fixed JS errors on the login page
This commit is contained in:
@@ -12,6 +12,11 @@ function RefreshHeaderClock()
|
|||||||
Grocy.HeaderClockInterval = null;
|
Grocy.HeaderClockInterval = null;
|
||||||
function CheckHeaderClockEnabled()
|
function CheckHeaderClockEnabled()
|
||||||
{
|
{
|
||||||
|
if (Grocy.UserId === -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Refresh the clock in the header every second when enabled
|
// Refresh the clock in the header every second when enabled
|
||||||
if (BoolVal(Grocy.UserSettings.show_clock_in_header))
|
if (BoolVal(Grocy.UserSettings.show_clock_in_header))
|
||||||
{
|
{
|
||||||
@@ -36,7 +41,7 @@ function CheckHeaderClockEnabled()
|
|||||||
}
|
}
|
||||||
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);
|
$("#show-clock-in-header").prop("checked", true);
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,6 @@
|
|||||||
Grocy.Api.Get('system/db-changed-time',
|
if (Grocy.UserId !== -1)
|
||||||
|
{
|
||||||
|
Grocy.Api.Get('system/db-changed-time',
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
Grocy.DatabaseChangedTime = moment(result.changed_time);
|
Grocy.DatabaseChangedTime = moment(result.changed_time);
|
||||||
@@ -7,7 +9,8 @@
|
|||||||
{
|
{
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the database has changed once a minute
|
// 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,
|
// 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;
|
Grocy.IdleTime += 1;
|
||||||
}, 1000);
|
}, 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);
|
$("#auto-reload-enabled").prop("checked", true);
|
||||||
}
|
}
|
||||||
|
@@ -56,18 +56,21 @@ $("#auto-night-mode-time-range-goes-over-midgnight").on("change", function()
|
|||||||
CheckNightMode();
|
CheckNightMode();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#night-mode-enabled").prop("checked", BoolVal(Grocy.UserSettings.night_mode_enabled));
|
if (Grocy.UserId !== -1)
|
||||||
$("#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));
|
$("#night-mode-enabled").prop("checked", BoolVal(Grocy.UserSettings.night_mode_enabled));
|
||||||
$("#auto-night-mode-enabled").trigger("change");
|
$("#auto-night-mode-enabled").prop("checked", BoolVal(Grocy.UserSettings.auto_night_mode_enabled));
|
||||||
$("#auto-night-mode-time-range-from").val(Grocy.UserSettings.auto_night_mode_time_range_from);
|
$("#auto-night-mode-time-range-goes-over-midgnight").prop("checked", BoolVal(Grocy.UserSettings.auto_night_mode_time_range_goes_over_midnight));
|
||||||
$("#auto-night-mode-time-range-from").trigger("keyup");
|
$("#auto-night-mode-enabled").trigger("change");
|
||||||
$("#auto-night-mode-time-range-to").val(Grocy.UserSettings.auto_night_mode_time_range_to);
|
$("#auto-night-mode-time-range-from").val(Grocy.UserSettings.auto_night_mode_time_range_from);
|
||||||
$("#auto-night-mode-time-range-to").trigger("keyup");
|
$("#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()
|
function CheckNightMode()
|
||||||
{
|
{
|
||||||
if (!BoolVal(Grocy.UserSettings.auto_night_mode_enabled))
|
if (Grocy.UserId === -1 || !BoolVal(Grocy.UserSettings.auto_night_mode_enabled))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -105,7 +108,10 @@ function CheckNightMode()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CheckNightMode();
|
if (Grocy.UserId !== -1)
|
||||||
|
{
|
||||||
|
CheckNightMode();
|
||||||
|
}
|
||||||
|
|
||||||
if (Grocy.Mode === "production")
|
if (Grocy.Mode === "production")
|
||||||
{
|
{
|
||||||
|
@@ -57,9 +57,15 @@
|
|||||||
Grocy.CalendarFirstDayOfWeek = '{{ GROCY_CALENDAR_FIRST_DAY_OF_WEEK }}';
|
Grocy.CalendarFirstDayOfWeek = '{{ GROCY_CALENDAR_FIRST_DAY_OF_WEEK }}';
|
||||||
Grocy.CalendarShowWeekNumbers = {{ BoolToString(GROCY_CALENDAR_SHOW_WEEK_OF_YEAR) }};
|
Grocy.CalendarShowWeekNumbers = {{ BoolToString(GROCY_CALENDAR_SHOW_WEEK_OF_YEAR) }};
|
||||||
Grocy.GettextPo = {!! $GettextPo !!};
|
Grocy.GettextPo = {!! $GettextPo !!};
|
||||||
Grocy.UserSettings = {!! json_encode($userSettings) !!};
|
|
||||||
Grocy.FeatureFlags = {!! json_encode($featureFlags) !!};
|
Grocy.FeatureFlags = {!! json_encode($featureFlags) !!};
|
||||||
|
|
||||||
|
@if (GROCY_AUTHENTICATED)
|
||||||
|
Grocy.UserSettings = {!! json_encode($userSettings) !!};
|
||||||
Grocy.UserId = {{ GROCY_USER_ID }};
|
Grocy.UserId = {{ GROCY_USER_ID }};
|
||||||
|
@else
|
||||||
|
Grocy.UserSettings = { };
|
||||||
|
Grocy.UserId = -1;
|
||||||
|
@endif
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user