Сохранение состояние скролла

This commit is contained in:
zakhy 2025-02-20 08:42:46 +07:00
parent e97eb5de44
commit 804b26b97a

View File

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>{% settings_value 'SITE_TITLE_S' %} : {{ user}}</title>
<link type="image/x-icon" href="{% static '/img/logo.png' %}?ver={% settings_value 'APP_VER' %}" rel="shortcut icon">
<link type="Image/x-icon" href="{% static 'img/logo.png' %}?ver={% settings_value 'APP_VER' %}" rel="icon">
<link type="Image/x-icon" href="{% static 'img/logo.png' %}?ver={% settings_value 'APP_VER' %}" rel="icon">
<!-- Google Font: Source Sans Pro -->
<link
rel="stylesheet"
@ -191,7 +191,7 @@
<div class="info">
<a href="/" class="d-block">{{organization}}</a>
</div>
</div>
</div>
<!-- Sidebar Menu -->
<nav class="mt-2">
<ul
@ -238,26 +238,26 @@
</li>
<li class="nav-header"></li>
<li class="nav-item">
{% if wlocationsystem == "Radiusip" %}
{% if wlocationsystem == "Radiusip" %}
<a href="/wklocation/" class="nav-link"
><i class="nav-icon fas fa-map-marked"></i>
<p>Местоположение персонала</p></a
>
{% elif wlocationsystem == "RTLS" %}
>
{% elif wlocationsystem == "RTLS" %}
<a href="{{wadress}}" class="nav-link" target="_blank" >
<i class="nav-icon fas fa-map-marked"></i>
<p>Местоположение персонала</p></a
>
{% elif wlocationsystem == "Внешняя ссылка" %}
>
{% elif wlocationsystem == "Внешняя ссылка" %}
<a href="{{wadress}}" class="nav-link" target="_blank" >
<i class="nav-icon fas fa-map-marked"></i>
<p>Местоположение персонала</p></a
>
>
{% else %}
<a href="#" class="nav-link nav-item adisabled" >
<i class="nav-icon fas fa-map-marked"></i>
<p><del>Местоположение персонала</del></p></a
>
>
{% endif %}
</li>
{% if user.profile.role == 1 %}
@ -362,6 +362,24 @@
localStorage.setItem('updateTimedelta', updateTimedelta)
})
</script>
<script>
window.addEventListener('beforeunload', () => {
// Сохраняем текущую позицию скролла
localStorage.setItem(`${window.location.href}_scrollPosition`, window.scrollY);
});
window.addEventListener('load', () => {
// Получаем сохраненную позицию скролла
const scrollPosition = localStorage.getItem(`${window.location.href}_scrollPosition`);
if (scrollPosition) {
// Прокручиваем страницу до сохраненной позиции
window.scrollTo(0, parseInt(scrollPosition));
}
// Очищаем сохраненное значение (опционально)
localStorage.removeItem(`${window.location.href}_scrollPosition`);
});
</script>
{% block script_footer %} {% endblock script_footer %}
</body>
</html>