fix navigation elements

This commit is contained in:
Primakov Alexandr Alexandrovich 2025-03-12 09:12:09 +03:00
parent b5301f948a
commit f91f821f86
6 changed files with 119 additions and 8 deletions

View File

@ -50,10 +50,10 @@
<!-- Навигационная шапка -->
<header class="nav-header">
<div class="nav-container">
<a href="/questioneer" class="nav-logo">Анонимные опросы</a>
<a href="javascript:;" id="nav-home-link" class="nav-logo">Анонимные опросы</a>
<nav class="nav-menu">
<a href="/questioneer" class="nav-link">Главная</a>
<a href="/questioneer/create" class="nav-link">Создать опрос</a>
<a href="javascript:;" id="nav-main-link" class="nav-link">Главная</a>
<a href="javascript:;" id="nav-create-link" class="nav-link">Создать опрос</a>
</nav>
</div>
</header>
@ -99,5 +99,19 @@
</div>
</div>
</div>
<script>
// Добавляем корректные пути к ссылкам после загрузки страницы
document.addEventListener('DOMContentLoaded', function() {
// Определяем базовый путь с учетом /ms в продакшен-версии
const isMsPath = window.location.pathname.includes('/ms/questioneer');
const basePath = isMsPath ? '/ms/questioneer' : '/questioneer';
// Устанавливаем правильные ссылки
document.getElementById('nav-home-link').href = basePath;
document.getElementById('nav-main-link').href = basePath;
document.getElementById('nav-create-link').href = basePath + '/create';
});
</script>
</body>
</html>

View File

@ -46,6 +46,17 @@
</script>
</head>
<body>
<!-- Навигационная шапка -->
<header class="nav-header">
<div class="nav-container">
<a href="javascript:;" id="nav-home-link" class="nav-logo">Анонимные опросы</a>
<nav class="nav-menu">
<a href="javascript:;" id="nav-main-link" class="nav-link">Главная</a>
<a href="javascript:;" id="nav-create-link" class="nav-link active">Создать опрос</a>
</nav>
</div>
</header>
<div class="container">
<h1>Создание нового опроса</h1>
@ -158,5 +169,19 @@
</button>
</div>
</template>
<script>
// Добавляем корректные пути к ссылкам после загрузки страницы
document.addEventListener('DOMContentLoaded', function() {
// Определяем базовый путь с учетом /ms в продакшен-версии
const isMsPath = window.location.pathname.includes('/ms/questioneer');
const basePath = isMsPath ? '/ms/questioneer' : '/questioneer';
// Устанавливаем правильные ссылки
document.getElementById('nav-home-link').href = basePath;
document.getElementById('nav-main-link').href = basePath;
document.getElementById('nav-create-link').href = basePath + '/create';
});
</script>
</body>
</html>

View File

@ -47,6 +47,17 @@
</script>
</head>
<body>
<!-- Навигационная шапка -->
<header class="nav-header">
<div class="nav-container">
<a href="javascript:;" id="nav-home-link" class="nav-logo">Анонимные опросы</a>
<nav class="nav-menu">
<a href="javascript:;" id="nav-main-link" class="nav-link">Главная</a>
<a href="javascript:;" id="nav-create-link" class="nav-link">Создать опрос</a>
</nav>
</div>
</header>
<div class="container">
<h1>Редактирование опроса</h1>
@ -175,5 +186,19 @@
</button>
</div>
</template>
<script>
// Добавляем корректные пути к ссылкам после загрузки страницы
document.addEventListener('DOMContentLoaded', function() {
// Определяем базовый путь с учетом /ms в продакшен-версии
const isMsPath = window.location.pathname.includes('/ms/questioneer');
const basePath = isMsPath ? '/ms/questioneer' : '/questioneer';
// Устанавливаем правильные ссылки
document.getElementById('nav-home-link').href = basePath;
document.getElementById('nav-main-link').href = basePath;
document.getElementById('nav-create-link').href = basePath + '/create';
});
</script>
</body>
</html>

View File

@ -53,10 +53,10 @@
<!-- Навигационная шапка -->
<header class="nav-header">
<div class="nav-container">
<a href="/questioneer" class="nav-logo">Анонимные опросы</a>
<a href="javascript:;" id="nav-home-link" class="nav-logo">Анонимные опросы</a>
<nav class="nav-menu">
<a href="/questioneer" class="nav-link active">Главная</a>
<a href="/questioneer/create" class="nav-link">Создать опрос</a>
<a href="javascript:;" id="nav-main-link" class="nav-link active">Главная</a>
<a href="javascript:;" id="nav-create-link" class="nav-link">Создать опрос</a>
</nav>
</div>
</header>
@ -65,7 +65,7 @@
<h1>Сервис анонимных опросов</h1>
<div class="main-buttons">
<a href="/questioneer/create" class="btn">Создать новый опрос</a>
<a href="javascript:;" id="create-button" class="btn">Создать новый опрос</a>
</div>
<div class="questionnaires-list">
@ -75,5 +75,20 @@
</div>
</div>
</div>
<script>
// Добавляем корректные пути к ссылкам после загрузки страницы
document.addEventListener('DOMContentLoaded', function() {
// Определяем базовый путь с учетом /ms в продакшен-версии
const isMsPath = window.location.pathname.includes('/ms/questioneer');
const basePath = isMsPath ? '/ms/questioneer' : '/questioneer';
// Устанавливаем правильные ссылки
document.getElementById('nav-home-link').href = basePath;
document.getElementById('nav-main-link').href = basePath;
document.getElementById('nav-create-link').href = basePath + '/create';
document.getElementById('create-button').href = basePath + '/create';
});
</script>
</body>
</html>

View File

@ -46,6 +46,13 @@
</script>
</head>
<body>
<!-- Навигационная шапка -->
<header class="nav-header">
<div class="nav-container">
<a href="javascript:;" id="nav-home-link" class="nav-logo">Анонимные опросы</a>
</div>
</header>
<div class="container">
<div id="loading">Загрузка опроса...</div>
@ -74,5 +81,17 @@
</div>
</div>
</div>
<script>
// Добавляем корректные пути к ссылкам после загрузки страницы
document.addEventListener('DOMContentLoaded', function() {
// Определяем базовый путь с учетом /ms в продакшен-версии
const isMsPath = window.location.pathname.includes('/ms/questioneer');
const basePath = isMsPath ? '/ms/questioneer' : '/questioneer';
// Устанавливаем правильные ссылки
document.getElementById('nav-home-link').href = basePath;
});
</script>
</body>
</html>

View File

@ -431,7 +431,20 @@ $(document).ready(function() {
success: function(result) {
if (result.success) {
showAlert('Опрос успешно удален', 'Удаление опроса', function() {
window.location.href = window.location.pathname.split('/admin')[0];
// Получаем базовый путь с учетом /ms в продакшен-версии
const isMsPath = window.location.pathname.includes('/ms/questioneer');
let basePath;
if (isMsPath) {
// Для продакшна: используем /ms/questioneer
basePath = '/ms/questioneer';
} else {
// Для локальной разработки: используем текущий путь
basePath = window.location.pathname.split('/admin')[0];
}
// Перенаправляем на главную страницу
window.location.href = basePath;
}, true);
} else {
showAlert(`Ошибка при удалении опроса: ${result.error}`, 'Ошибка');