vacancy detail SEO
This commit is contained in:
@@ -4,10 +4,10 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<!-- Базовые SEO теги -->
|
||||
<!-- SEO теги будут заменены сервером -->
|
||||
<title id="pageTitle">Вакансия | Rabota.Today</title>
|
||||
<meta name="description" id="metaDescription" content="Подробная информация о вакансии на Rabota.Today. Зарплата, требования, условия работы, контакты работодателя.">
|
||||
<meta name="keywords" content="вакансия, работа, поиск работы, Rabota.Today, трудоустройство">
|
||||
<meta name="keywords" id="metaKeywords" content="вакансия, работа, поиск работы, Rabota.Today, трудоустройство">
|
||||
<meta name="author" content="Rabota.Today">
|
||||
<meta name="robots" content="index, follow">
|
||||
|
||||
@@ -33,46 +33,17 @@
|
||||
<meta name="format-detection" content="telephone=no">
|
||||
<meta name="theme-color" content="#0b1c34">
|
||||
|
||||
<!-- Структурированные данные (JSON-LD) -->
|
||||
<!-- Структурированные данные (JSON-LD) будут заменены сервером -->
|
||||
<script type="application/ld+json" id="structuredData">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "JobPosting",
|
||||
"title": "",
|
||||
"description": "",
|
||||
"datePosted": "",
|
||||
"validThrough": "",
|
||||
"employmentType": "FULL_TIME",
|
||||
"hiringOrganization": {
|
||||
"@type": "Organization",
|
||||
"name": "",
|
||||
"sameAs": "",
|
||||
"logo": "https://yarmarka.rabota.today/static/images/logo.png"
|
||||
},
|
||||
"jobLocation": {
|
||||
"@type": "Place",
|
||||
"address": {
|
||||
"@type": "PostalAddress",
|
||||
"addressLocality": "Москва",
|
||||
"addressCountry": "RU"
|
||||
}
|
||||
},
|
||||
"baseSalary": {
|
||||
"@type": "MonetaryAmount",
|
||||
"currency": "RUB",
|
||||
"value": {
|
||||
"@type": "QuantitativeValue",
|
||||
"value": 0,
|
||||
"unitText": "MONTH"
|
||||
}
|
||||
},
|
||||
"employmentType": "FULL_TIME",
|
||||
"workHours": "Полный день"
|
||||
"description": ""
|
||||
}
|
||||
</script>
|
||||
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
||||
<!-- Подключаем библиотеку для генерации QR-кодов -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/qrcode@1.5.1/build/qrcode.min.js"></script>
|
||||
|
||||
<style>
|
||||
@@ -204,7 +175,6 @@
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* Кнопка QR в шапке */
|
||||
.qr-button {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
@@ -252,7 +222,6 @@
|
||||
box-shadow: 0 2px 4px rgba(239,68,68,0.3);
|
||||
}
|
||||
|
||||
/* Кликабельная компания */
|
||||
.vacancy-company-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -345,7 +314,6 @@
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
/* Информация о компании */
|
||||
.company-info {
|
||||
background: #f9fcff;
|
||||
border-radius: 30px;
|
||||
@@ -506,15 +474,6 @@
|
||||
background: #eef4fa;
|
||||
}
|
||||
|
||||
.btn-success {
|
||||
background: #10b981;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-success:hover {
|
||||
background: #059669;
|
||||
}
|
||||
|
||||
.applied-badge {
|
||||
background: #10b981;
|
||||
color: white;
|
||||
@@ -536,7 +495,7 @@
|
||||
border-top: 1px solid #dee9f5;
|
||||
}
|
||||
|
||||
/* Модальное окно для QR */
|
||||
/* QR Modal Styles */
|
||||
.qr-modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
@@ -831,6 +790,25 @@
|
||||
color: white;
|
||||
}
|
||||
|
||||
.fallback-link {
|
||||
padding: 20px;
|
||||
background: white;
|
||||
border-radius: 15px;
|
||||
margin: 10px;
|
||||
word-break: break-all;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.fallback-link a {
|
||||
color: #3b82f6;
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.fallback-link a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
@keyframes slideIn {
|
||||
from { transform: translateX(100%); opacity: 0; }
|
||||
to { transform: translateX(0%); opacity: 1; }
|
||||
@@ -957,11 +935,9 @@
|
||||
let currentVacancy = null;
|
||||
let qrViewCount = 0;
|
||||
|
||||
// Получаем ID вакансии из URL
|
||||
const pathParts = window.location.pathname.split('/');
|
||||
const vacancyId = pathParts[pathParts.length - 1];
|
||||
|
||||
// Функция для декодирования HTML-сущностей
|
||||
function decodeHtmlEntities(text) {
|
||||
if (!text) return '';
|
||||
const textarea = document.createElement('textarea');
|
||||
@@ -969,7 +945,6 @@
|
||||
return textarea.value;
|
||||
}
|
||||
|
||||
// Функция для экранирования HTML
|
||||
function escapeHtml(unsafe) {
|
||||
if (!unsafe) return '';
|
||||
return unsafe.toString()
|
||||
@@ -980,92 +955,22 @@
|
||||
.replace(/'/g, "'");
|
||||
}
|
||||
|
||||
// Функция для обновления SEO тегов
|
||||
function updateSEOTags(vacancy) {
|
||||
const decodedTitle = decodeHtmlEntities(vacancy.title);
|
||||
const decodedCompany = decodeHtmlEntities(vacancy.company_name || 'Компания');
|
||||
const salary = vacancy.salary || 'Зарплата не указана';
|
||||
const description = vacancy.description || 'Подробная информация о вакансии';
|
||||
|
||||
// Формируем описание для SEO
|
||||
const shortDescription = description.length > 160 ? description.substring(0, 157) + '...' : description;
|
||||
const seoDescription = `${decodedTitle} в компании ${decodedCompany}. ${salary}. ${shortDescription}`;
|
||||
|
||||
// Заголовок страницы
|
||||
document.title = `${decodedTitle} в ${decodedCompany} | Rabota.Today`;
|
||||
|
||||
// Мета-теги
|
||||
document.querySelector('meta[name="description"]')?.setAttribute('content', seoDescription);
|
||||
document.querySelector('meta[name="keywords"]')?.setAttribute('content', `${decodedTitle}, работа, вакансия, ${decodedCompany}, трудоустройство, поиск работы`);
|
||||
|
||||
// Open Graph теги
|
||||
document.querySelector('meta[property="og:title"]')?.setAttribute('content', `${decodedTitle} в ${decodedCompany}`);
|
||||
document.querySelector('meta[property="og:description"]')?.setAttribute('content', seoDescription);
|
||||
document.querySelector('meta[property="og:url"]')?.setAttribute('content', window.location.href);
|
||||
|
||||
// Twitter Card
|
||||
document.querySelector('meta[name="twitter:title"]')?.setAttribute('content', `${decodedTitle} в ${decodedCompany}`);
|
||||
document.querySelector('meta[name="twitter:description"]')?.setAttribute('content', seoDescription);
|
||||
|
||||
// Canonical URL
|
||||
document.querySelector('link[rel="canonical"]')?.setAttribute('href', window.location.href);
|
||||
|
||||
// Структурированные данные (JSON-LD)
|
||||
const salaryMatch = salary.match(/(\d+)/);
|
||||
const salaryValue = salaryMatch ? parseInt(salaryMatch[0]) : 0;
|
||||
|
||||
const structuredData = {
|
||||
"@context": "https://schema.org",
|
||||
"@type": "JobPosting",
|
||||
"title": decodedTitle,
|
||||
"description": description,
|
||||
"datePosted": vacancy.created_at,
|
||||
"validThrough": new Date(new Date(vacancy.created_at).getTime() + 30 * 24 * 60 * 60 * 1000).toISOString(),
|
||||
"employmentType": "FULL_TIME",
|
||||
"hiringOrganization": {
|
||||
"@type": "Organization",
|
||||
"name": decodedCompany,
|
||||
"sameAs": vacancy.company_website || "",
|
||||
"logo": vacancy.company_logo || "https://yarmarka.rabota.today/static/images/logo.png"
|
||||
},
|
||||
"jobLocation": {
|
||||
"@type": "Place",
|
||||
"address": {
|
||||
"@type": "PostalAddress",
|
||||
"addressLocality": vacancy.company_address || "Москва",
|
||||
"addressCountry": "RU"
|
||||
}
|
||||
},
|
||||
"baseSalary": {
|
||||
"@type": "MonetaryAmount",
|
||||
"currency": "RUB",
|
||||
"value": {
|
||||
"@type": "QuantitativeValue",
|
||||
"value": salaryValue,
|
||||
"unitText": "MONTH"
|
||||
}
|
||||
},
|
||||
"workHours": "Полный день"
|
||||
};
|
||||
|
||||
const scriptElement = document.getElementById('structuredData');
|
||||
if (scriptElement) {
|
||||
scriptElement.textContent = JSON.stringify(structuredData, null, 2);
|
||||
function showNotification(message, type = 'info') {
|
||||
const notification = document.getElementById('notification');
|
||||
if (!notification) return;
|
||||
notification.className = `notification ${type}`;
|
||||
notification.innerHTML = message;
|
||||
notification.style.display = 'block';
|
||||
setTimeout(() => { notification.style.display = 'none'; }, 3000);
|
||||
}
|
||||
|
||||
console.log('✅ SEO теги обновлены');
|
||||
}
|
||||
|
||||
// Проверка авторизации
|
||||
async function checkAuth() {
|
||||
const token = localStorage.getItem('accessToken');
|
||||
|
||||
if (token) {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/user`, {
|
||||
headers: { 'Authorization': `Bearer ${token}` }
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
currentUser = await response.json();
|
||||
} else {
|
||||
@@ -1075,18 +980,14 @@
|
||||
console.error('Error checking auth:', error);
|
||||
}
|
||||
}
|
||||
|
||||
updateNavigation();
|
||||
}
|
||||
|
||||
// Обновление навигации
|
||||
function updateNavigation() {
|
||||
const nav = document.getElementById('nav');
|
||||
|
||||
if (currentUser) {
|
||||
const firstName = currentUser.full_name.split(' ')[0];
|
||||
const adminBadge = currentUser.is_admin ? '<span class="admin-badge">Admin</span>' : '';
|
||||
|
||||
nav.innerHTML = `
|
||||
<a href="/">Главная</a>
|
||||
<a href="/vacancies" class="active">Вакансии</a>
|
||||
@@ -1108,31 +1009,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Загрузка вакансии
|
||||
async function loadVacancy() {
|
||||
const token = localStorage.getItem('accessToken');
|
||||
|
||||
try {
|
||||
const headers = {};
|
||||
if (token) {
|
||||
headers['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
|
||||
const response = await fetch(`${API_BASE_URL}/vacancies/${vacancyId}`, {
|
||||
headers: headers
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Вакансия не найдена');
|
||||
}
|
||||
|
||||
const headers = token ? { 'Authorization': `Bearer ${token}` } : {};
|
||||
const response = await fetch(`${API_BASE_URL}/vacancies/${vacancyId}`, { headers });
|
||||
if (!response.ok) throw new Error('Вакансия не найдена');
|
||||
currentVacancy = await response.json();
|
||||
|
||||
// Обновляем SEO теги
|
||||
updateSEOTags(currentVacancy);
|
||||
|
||||
renderVacancy(currentVacancy);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading vacancy:', error);
|
||||
document.getElementById('vacancyDetail').innerHTML = `
|
||||
@@ -1147,18 +1031,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Отображение вакансии
|
||||
function renderVacancy(vacancy) {
|
||||
const container = document.getElementById('vacancyDetail');
|
||||
const token = localStorage.getItem('accessToken');
|
||||
|
||||
const isApplied = vacancy.has_applied;
|
||||
const canApply = token && currentUser && currentUser.role === 'employee' && !isApplied;
|
||||
|
||||
// Получаем ID компании
|
||||
const companyId = vacancy.company_id || '';
|
||||
|
||||
// Декодируем названия
|
||||
const decodedTitle = decodeHtmlEntities(vacancy.title);
|
||||
const decodedCompanyName = decodeHtmlEntities(vacancy.company_name || '');
|
||||
|
||||
@@ -1171,7 +1049,6 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Кликабельная компания -->
|
||||
${vacancy.company_name ? `
|
||||
<a href="/company/${companyId}" class="vacancy-company-link" ${!companyId ? 'onclick="event.preventDefault(); showNotification(\'Страница компании в разработке\')"' : ''}>
|
||||
<i class="fas fa-building"></i>
|
||||
@@ -1193,43 +1070,22 @@
|
||||
<h2 class="section-title">Описание вакансии</h2>
|
||||
<div class="vacancy-description">${escapeHtml(vacancy.description || 'Описание отсутствует').replace(/\n/g, '<br>')}</div>
|
||||
|
||||
<!-- Информация о компании -->
|
||||
${vacancy.company_name ? `
|
||||
<div class="company-info">
|
||||
<div class="company-info-header">
|
||||
<h3>
|
||||
<i class="fas fa-building"></i> О компании
|
||||
</h3>
|
||||
${companyId ? `
|
||||
<a href="/company/${companyId}" class="company-view-all">
|
||||
<i class="fas fa-external-link-alt"></i> Все вакансии компании
|
||||
</a>
|
||||
` : ''}
|
||||
<h3><i class="fas fa-building"></i> О компании</h3>
|
||||
${companyId ? `<a href="/company/${companyId}" class="company-view-all"><i class="fas fa-external-link-alt"></i> Все вакансии компании</a>` : ''}
|
||||
</div>
|
||||
<div class="company-info-grid">
|
||||
<div class="company-info-item">
|
||||
<i class="fas fa-building"></i>
|
||||
<div>
|
||||
<div style="font-weight: 600;">${escapeHtml(decodedCompanyName)}</div>
|
||||
${companyId ? `
|
||||
<a href="/company/${companyId}" style="font-size: 13px; color: #3b82f6;">
|
||||
перейти в профиль компании →
|
||||
</a>
|
||||
` : ''}
|
||||
${companyId ? `<a href="/company/${companyId}" style="font-size: 13px; color: #3b82f6;">перейти в профиль компании →</a>` : ''}
|
||||
</div>
|
||||
</div>
|
||||
${vacancy.company_website ? `
|
||||
<div class="company-info-item">
|
||||
<i class="fas fa-globe"></i>
|
||||
<a href="${escapeHtml(vacancy.company_website)}" target="_blank">${escapeHtml(vacancy.company_website)}</a>
|
||||
</div>
|
||||
` : ''}
|
||||
${vacancy.company_address ? `
|
||||
<div class="company-info-item">
|
||||
<i class="fas fa-map-marker-alt"></i>
|
||||
<span>${escapeHtml(vacancy.company_address)}</span>
|
||||
</div>
|
||||
` : ''}
|
||||
${vacancy.company_website ? `<div class="company-info-item"><i class="fas fa-globe"></i><a href="${escapeHtml(vacancy.company_website)}" target="_blank">${escapeHtml(vacancy.company_website)}</a></div>` : ''}
|
||||
${vacancy.company_address ? `<div class="company-info-item"><i class="fas fa-map-marker-alt"></i><span>${escapeHtml(vacancy.company_address)}</span></div>` : ''}
|
||||
</div>
|
||||
${vacancy.company_description ? `
|
||||
<div style="margin-top: 20px; color: #1f3f60; line-height: 1.6; padding: 15px; background: white; border-radius: 15px;">
|
||||
@@ -1243,50 +1099,18 @@
|
||||
|
||||
<h2 class="section-title">Контактная информация</h2>
|
||||
<div class="contact-info">
|
||||
<div class="contact-item">
|
||||
<i class="fab fa-telegram"></i>
|
||||
<span>${escapeHtml(vacancy.contact || vacancy.user_telegram || 'Контакт не указан')}</span>
|
||||
</div>
|
||||
${vacancy.company_email ? `
|
||||
<div class="contact-item">
|
||||
<i class="fas fa-envelope"></i>
|
||||
<a href="mailto:${escapeHtml(vacancy.company_email)}">${escapeHtml(vacancy.company_email)}</a>
|
||||
</div>
|
||||
` : ''}
|
||||
${vacancy.company_phone ? `
|
||||
<div class="contact-item">
|
||||
<i class="fas fa-phone"></i>
|
||||
<a href="tel:${escapeHtml(vacancy.company_phone)}">${escapeHtml(vacancy.company_phone)}</a>
|
||||
</div>
|
||||
` : ''}
|
||||
<div class="contact-item"><i class="fab fa-telegram"></i><span>${escapeHtml(vacancy.contact || vacancy.user_telegram || 'Контакт не указан')}</span></div>
|
||||
${vacancy.company_email ? `<div class="contact-item"><i class="fas fa-envelope"></i><a href="mailto:${escapeHtml(vacancy.company_email)}">${escapeHtml(vacancy.company_email)}</a></div>` : ''}
|
||||
${vacancy.company_phone ? `<div class="contact-item"><i class="fas fa-phone"></i><a href="tel:${escapeHtml(vacancy.company_phone)}">${escapeHtml(vacancy.company_phone)}</a></div>` : ''}
|
||||
</div>
|
||||
|
||||
<div class="action-buttons">
|
||||
${isApplied ? `
|
||||
<div class="applied-badge">
|
||||
<i class="fas fa-check-circle"></i> Вы уже откликнулись
|
||||
</div>
|
||||
` : canApply ? `
|
||||
<button class="btn btn-primary" onclick="applyForVacancy()">
|
||||
<i class="fas fa-paper-plane"></i> Откликнуться
|
||||
</button>
|
||||
` : token && currentUser && currentUser.role === 'employer' ? `
|
||||
<button class="btn btn-primary" disabled title="Работодатели не могут откликаться на вакансии">
|
||||
<i class="fas fa-ban"></i> Отклик недоступен
|
||||
</button>
|
||||
` : !token ? `
|
||||
<button class="btn btn-primary" onclick="redirectToLogin()">
|
||||
<i class="fas fa-sign-in-alt"></i> Войдите чтобы откликнуться
|
||||
</button>
|
||||
` : ''}
|
||||
|
||||
<button class="btn btn-outline" onclick="saveToFavorites()">
|
||||
<i class="fas fa-heart"></i> В избранное
|
||||
</button>
|
||||
|
||||
<button class="btn btn-outline" onclick="shareVacancy()">
|
||||
<i class="fas fa-share-alt"></i> Поделиться
|
||||
</button>
|
||||
${isApplied ? `<div class="applied-badge"><i class="fas fa-check-circle"></i> Вы уже откликнулись</div>` :
|
||||
canApply ? `<button class="btn btn-primary" onclick="applyForVacancy()"><i class="fas fa-paper-plane"></i> Откликнуться</button>` :
|
||||
token && currentUser && currentUser.role === 'employer' ? `<button class="btn btn-primary" disabled><i class="fas fa-ban"></i> Отклик недоступен</button>` :
|
||||
!token ? `<button class="btn btn-primary" onclick="redirectToLogin()"><i class="fas fa-sign-in-alt"></i> Войдите чтобы откликнуться</button>` : ''}
|
||||
<button class="btn btn-outline" onclick="saveToFavorites()"><i class="fas fa-heart"></i> В избранное</button>
|
||||
<button class="btn btn-outline" onclick="shareVacancy()"><i class="fas fa-share-alt"></i> Поделиться</button>
|
||||
</div>
|
||||
|
||||
<div class="stats">
|
||||
@@ -1296,27 +1120,19 @@
|
||||
`;
|
||||
}
|
||||
|
||||
// ========== ФУНКЦИИ ДЛЯ QR-КОДА ==========
|
||||
|
||||
// Открыть модальное окно с QR
|
||||
// QR Code functions
|
||||
function openQRModal() {
|
||||
if (!currentVacancy) return;
|
||||
|
||||
const decodedTitle = decodeHtmlEntities(currentVacancy.title);
|
||||
const decodedCompanyName = decodeHtmlEntities(currentVacancy.company_name || '');
|
||||
|
||||
document.getElementById('qrVacancyTitle').textContent = decodedTitle;
|
||||
|
||||
const vacancyUrl = window.location.origin + '/vacancy/' + vacancyId;
|
||||
document.getElementById('qrVacancyUrl').textContent = vacancyUrl.replace('https://', '').replace('http://', '');
|
||||
|
||||
document.getElementById('qrViewCount').textContent = ++qrViewCount;
|
||||
document.getElementById('qrViewBadge').textContent = qrViewCount;
|
||||
document.getElementById('qrSalaryInfo').textContent = currentVacancy.salary || 'з/п не указана';
|
||||
document.getElementById('qrCompanyName').textContent = decodedCompanyName || '—';
|
||||
|
||||
generateQRCodeWithLogo(vacancyUrl, currentVacancy.company_logo);
|
||||
|
||||
document.getElementById('qrModal').classList.add('active');
|
||||
}
|
||||
|
||||
@@ -1326,34 +1142,35 @@
|
||||
|
||||
function generateQRCodeWithLogo(text, logoUrl) {
|
||||
const canvas = document.getElementById('qrCanvas');
|
||||
if (!canvas) { showNotification('Ошибка: не найден элемент для QR-кода', 'error'); return; }
|
||||
if (typeof QRCode === 'undefined') {
|
||||
showNotification('Ошибка загрузки библиотеки QR-кода', 'error');
|
||||
const container = document.getElementById('qrContainer');
|
||||
if (container && !container.querySelector('.fallback-link')) {
|
||||
const fallback = document.createElement('div');
|
||||
fallback.className = 'fallback-link';
|
||||
fallback.innerHTML = `<a href="${text}" target="_blank">${text}</a>`;
|
||||
container.appendChild(fallback);
|
||||
}
|
||||
return;
|
||||
}
|
||||
const options = { width: 250, height: 250, color: { dark: '#0b1c34', light: '#ffffff' }, errorCorrectionLevel: 'H' };
|
||||
QRCode.toCanvas(canvas, text, options, function(error) {
|
||||
if (error) { showNotification('Ошибка генерации QR-кода', 'error'); }
|
||||
else {
|
||||
const logoOverlay = document.getElementById('qrLogoOverlay');
|
||||
const logoImg = document.getElementById('qrLogoImg');
|
||||
const logoIcon = document.getElementById('qrLogoIcon');
|
||||
|
||||
const options = {
|
||||
width: 250,
|
||||
height: 250,
|
||||
color: { dark: '#0b1c34', light: '#ffffff' },
|
||||
errorCorrectionLevel: 'H'
|
||||
};
|
||||
|
||||
QRCode.toCanvas(canvas, text, options, function(error) {
|
||||
if (error) {
|
||||
console.error('Error generating QR code:', error);
|
||||
showNotification('Ошибка генерации QR-кода', 'error');
|
||||
} else {
|
||||
logoOverlay.style.display = 'flex';
|
||||
|
||||
if (logoUrl) {
|
||||
if (logoOverlay) logoOverlay.style.display = 'flex';
|
||||
if (logoUrl && logoImg) {
|
||||
logoImg.src = logoUrl;
|
||||
logoImg.style.display = 'block';
|
||||
logoIcon.style.display = 'none';
|
||||
if (logoIcon) logoIcon.style.display = 'none';
|
||||
logoImg.onerror = function() {
|
||||
logoImg.style.display = 'none';
|
||||
logoIcon.style.display = 'block';
|
||||
logoIcon.className = 'fas fa-briefcase';
|
||||
if (logoImg) logoImg.style.display = 'none';
|
||||
if (logoIcon) { logoIcon.style.display = 'block'; logoIcon.className = 'fas fa-briefcase'; }
|
||||
};
|
||||
} else {
|
||||
} else if (logoIcon) {
|
||||
logoImg.style.display = 'none';
|
||||
logoIcon.style.display = 'block';
|
||||
logoIcon.className = 'fas fa-briefcase';
|
||||
@@ -1364,11 +1181,11 @@
|
||||
|
||||
function downloadQR() {
|
||||
const canvas = document.getElementById('qrCanvas');
|
||||
if (!canvas) { showNotification('QR-код не найден', 'error'); return; }
|
||||
const combinedCanvas = document.createElement('canvas');
|
||||
combinedCanvas.width = canvas.width;
|
||||
combinedCanvas.height = canvas.height;
|
||||
const ctx = combinedCanvas.getContext('2d');
|
||||
|
||||
ctx.drawImage(canvas, 0, 0);
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.beginPath();
|
||||
@@ -1379,59 +1196,40 @@
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'middle';
|
||||
ctx.fillText('', 125, 125);
|
||||
|
||||
const link = document.createElement('a');
|
||||
const decodedTitle = decodeHtmlEntities(currentVacancy.title);
|
||||
const filename = `vacancy_${decodedTitle.toLowerCase().replace(/[^a-zа-я0-9]/g, '_')}.png`;
|
||||
link.download = filename;
|
||||
link.href = combinedCanvas.toDataURL('image/png');
|
||||
link.click();
|
||||
|
||||
showNotification('QR-код скачан', 'success');
|
||||
}
|
||||
|
||||
function copyVacancyLink() {
|
||||
const url = window.location.origin + '/vacancy/' + vacancyId;
|
||||
navigator.clipboard.writeText(url).then(() => {
|
||||
showNotification('Ссылка скопирована', 'success');
|
||||
}).catch(() => {
|
||||
showNotification('Ошибка копирования', 'error');
|
||||
});
|
||||
navigator.clipboard.writeText(url).then(() => showNotification('Ссылка скопирована', 'success')).catch(() => showNotification('Ошибка копирования', 'error'));
|
||||
}
|
||||
|
||||
function shareVacancy() {
|
||||
const url = window.location.href;
|
||||
if (navigator.share) {
|
||||
navigator.share({ title: document.title, url: url }).catch(() => copyVacancyLink());
|
||||
} else {
|
||||
copyVacancyLink();
|
||||
}
|
||||
if (navigator.share) { navigator.share({ title: document.title, url: url }).catch(() => copyVacancyLink()); }
|
||||
else { copyVacancyLink(); }
|
||||
}
|
||||
|
||||
function printQR() {
|
||||
const canvas = document.getElementById('qrCanvas');
|
||||
const decodedTitle = decodeHtmlEntities(currentVacancy.title);
|
||||
const decodedCompany = decodeHtmlEntities(currentVacancy.company_name || '');
|
||||
|
||||
const printWindow = window.open('', '_blank');
|
||||
printWindow.document.write(`
|
||||
<html>
|
||||
<head><title>QR-код вакансии</title>
|
||||
<style>
|
||||
body { display: flex; justify-content: center; align-items: center; height: 100vh; flex-direction: column; font-family: Arial; margin: 0; padding: 20px; }
|
||||
h2 { color: #0b1c34; text-align: center; word-break: break-word; }
|
||||
h3 { color: #3b82f6; text-align: center; }
|
||||
img { max-width: 300px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); border-radius: 20px; }
|
||||
.url { color: #4f7092; margin-top: 20px; word-break: break-all; text-align: center; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<html><head><title>QR-код вакансии</title>
|
||||
<style>body{display:flex;justify-content:center;align-items:center;height:100vh;flex-direction:column;font-family:Arial;margin:0;padding:20px;}h2{color:#0b1c34;text-align:center;}h3{color:#3b82f6;text-align:center;}img{max-width:300px;box-shadow:0 10px 30px rgba(0,0,0,0.1);border-radius:20px;}.url{color:#4f7092;margin-top:20px;text-align:center;}</style>
|
||||
</head><body>
|
||||
<h2>${escapeHtml(decodedTitle)}</h2>
|
||||
<h3>${escapeHtml(decodedCompany)}</h3>
|
||||
<img src="${canvas.toDataURL()}" />
|
||||
<div class="url">${window.location.origin}/vacancy/${vacancyId}</div>
|
||||
</body>
|
||||
</html>
|
||||
</body></html>
|
||||
`);
|
||||
printWindow.document.close();
|
||||
printWindow.focus();
|
||||
@@ -1442,60 +1240,31 @@
|
||||
const url = window.location.origin + '/vacancy/' + vacancyId;
|
||||
const decodedTitle = decodeHtmlEntities(currentVacancy.title);
|
||||
const text = `Вакансия: ${decodedTitle} на Rabota.Today`;
|
||||
|
||||
let shareUrl = '';
|
||||
switch(platform) {
|
||||
case 'whatsapp': shareUrl = `https://wa.me/?text=${encodeURIComponent(text + ' ' + url)}`; break;
|
||||
case 'telegram': shareUrl = `https://t.me/share/url?url=${encodeURIComponent(url)}&text=${encodeURIComponent(text)}`; break;
|
||||
case 'email': shareUrl = `mailto:?subject=${encodeURIComponent('Вакансия ' + decodedTitle)}&body=${encodeURIComponent(text + '\n\n' + url)}`; break;
|
||||
}
|
||||
if (platform === 'whatsapp') shareUrl = `https://wa.me/?text=${encodeURIComponent(text + ' ' + url)}`;
|
||||
else if (platform === 'telegram') shareUrl = `https://t.me/share/url?url=${encodeURIComponent(url)}&text=${encodeURIComponent(text)}`;
|
||||
else if (platform === 'email') shareUrl = `mailto:?subject=${encodeURIComponent('Вакансия ' + decodedTitle)}&body=${encodeURIComponent(text + '\n\n' + url)}`;
|
||||
if (shareUrl) window.open(shareUrl, '_blank');
|
||||
}
|
||||
|
||||
async function applyForVacancy() {
|
||||
const token = localStorage.getItem('accessToken');
|
||||
if (!token) { redirectToLogin(); return; }
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/vacancies/${vacancyId}/apply`, {
|
||||
method: 'POST',
|
||||
headers: { 'Authorization': `Bearer ${token}` }
|
||||
});
|
||||
if (response.ok) {
|
||||
showNotification('Отклик отправлен! Работодатель свяжется с вами.', 'success');
|
||||
loadVacancy();
|
||||
} else {
|
||||
const error = await response.json();
|
||||
throw new Error(error.detail || 'Ошибка отправки');
|
||||
}
|
||||
} catch (error) {
|
||||
showNotification(error.message, 'error');
|
||||
}
|
||||
const response = await fetch(`${API_BASE_URL}/vacancies/${vacancyId}/apply`, { method: 'POST', headers: { 'Authorization': `Bearer ${token}` } });
|
||||
if (response.ok) { showNotification('Отклик отправлен! Работодатель свяжется с вами.', 'success'); loadVacancy(); }
|
||||
else { const error = await response.json(); throw new Error(error.detail || 'Ошибка отправки'); }
|
||||
} catch (error) { showNotification(error.message, 'error'); }
|
||||
}
|
||||
|
||||
function saveToFavorites() {
|
||||
const token = localStorage.getItem('accessToken');
|
||||
if (!token) {
|
||||
if (confirm('Для добавления в избранное нужно войти в систему. Перейти на страницу входа?')) {
|
||||
window.location.href = '/login';
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!token) { if (confirm('Для добавления в избранное нужно войти в систему. Перейти на страницу входа?')) { window.location.href = '/login'; } return; }
|
||||
showNotification('Вакансия добавлена в избранное', 'success');
|
||||
}
|
||||
|
||||
function redirectToLogin() {
|
||||
if (confirm('Для отклика нужно войти в систему. Перейти на страницу входа?')) {
|
||||
window.location.href = '/login';
|
||||
}
|
||||
}
|
||||
|
||||
function showNotification(message, type = 'info') {
|
||||
const notification = document.getElementById('notification');
|
||||
notification.className = `notification ${type}`;
|
||||
notification.innerHTML = message;
|
||||
notification.style.display = 'block';
|
||||
setTimeout(() => { notification.style.display = 'none'; }, 3000);
|
||||
if (confirm('Для отклика нужно войти в систему. Перейти на страницу входа?')) { window.location.href = '/login'; }
|
||||
}
|
||||
|
||||
window.onclick = function(event) {
|
||||
|
||||
Reference in New Issue
Block a user