117 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			117 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <!DOCTYPE html>
 | ||
| <html lang="ru">
 | ||
| <head>
 | ||
|   <meta charset="UTF-8">
 | ||
|   <meta name="viewport" content="width=device-width, initial-scale=1.0">
 | ||
|   <title>Управление опросом</title>
 | ||
|   <!-- Добавляем проверку на различные пути -->
 | ||
|   <script>
 | ||
|     // Определяем путь к статическим файлам с учетом prod и dev окружений
 | ||
|     function getStaticPath() {
 | ||
|       if (window.location.pathname.includes('/ms/questioneer')) {
 | ||
|         // Для продакшна
 | ||
|         return '/ms/questioneer/static';
 | ||
|       } else {
 | ||
|         // Для локальной разработки
 | ||
|         const basePath = window.location.pathname.split('/admin')[0];
 | ||
|         // Проверяем, заканчивается ли путь на слеш
 | ||
|         return basePath + (basePath.endsWith('/') ? 'static' : '/static');
 | ||
|       }
 | ||
|     }
 | ||
|     
 | ||
|     // Динамически добавляем CSS
 | ||
|     const cssLink = document.createElement('link');
 | ||
|     cssLink.rel = 'stylesheet';
 | ||
|     cssLink.href = getStaticPath() + '/css/style.css';
 | ||
|     document.head.appendChild(cssLink);
 | ||
|   </script>
 | ||
|   
 | ||
|   <!-- Добавляем jQuery -->
 | ||
|   <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
 | ||
|   <script src="https://cdnjs.cloudflare.com/ajax/libs/qrcode-generator/1.4.4/qrcode.min.js"></script>
 | ||
|   <script>
 | ||
|     document.addEventListener('DOMContentLoaded', function() {
 | ||
|       // Динамически добавляем скрипты
 | ||
|       const scriptPaths = [
 | ||
|         '/js/common.js',
 | ||
|         '/js/admin.js'
 | ||
|       ];
 | ||
|       
 | ||
|       const staticPath = getStaticPath();
 | ||
|       scriptPaths.forEach(path => {
 | ||
|         const script = document.createElement('script');
 | ||
|         script.src = staticPath + path;
 | ||
|         document.body.appendChild(script);
 | ||
|       });
 | ||
|     });
 | ||
|   </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>
 | ||
|     
 | ||
|     <div id="loading">Загрузка опроса...</div>
 | ||
|     
 | ||
|     <div id="questionnaire-container" style="display: none;">
 | ||
|       <div class="questionnaire-header">
 | ||
|         <h2 id="questionnaire-title"></h2>
 | ||
|         <p id="questionnaire-description"></p>
 | ||
|       </div>
 | ||
|       
 | ||
|       <div class="questionnaire-links">
 | ||
|         <div class="link-group">
 | ||
|           <h3>Ссылка для голосования:</h3>
 | ||
|           <div class="link-input-group">
 | ||
|             <input type="text" id="public-link" readonly>
 | ||
|             <button class="btn btn-small" id="copy-public-link">Копировать</button>
 | ||
|             <button class="btn btn-small" id="show-qr-code">QR-код</button>
 | ||
|           </div>
 | ||
|         </div>
 | ||
|         
 | ||
|         <div class="link-group">
 | ||
|           <h3>Административная ссылка:</h3>
 | ||
|           <div class="link-input-group">
 | ||
|             <input type="text" id="admin-link" readonly>
 | ||
|             <button class="btn btn-small" id="copy-admin-link">Копировать</button>
 | ||
|           </div>
 | ||
|         </div>
 | ||
|       </div>
 | ||
|       
 | ||
|       <div class="questionnaire-stats">
 | ||
|         <h3>Статистика ответов</h3>
 | ||
|         <div id="stats-container"></div>
 | ||
|       </div>
 | ||
|       
 | ||
|       <div class="questionnaire-actions">
 | ||
|         <button id="edit-questionnaire" class="btn">Редактировать опрос</button>
 | ||
|         <button id="delete-questionnaire" class="btn btn-danger">Удалить опрос</button>
 | ||
|       </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>  |