MediaWiki:Common.js: відмінності між версіями
Перейти до навігації
Перейти до пошуку
Немає опису редагування |
Немає опису редагування |
||
| Рядок 251: | Рядок 251: | ||
grid.appendChild(card); | grid.appendChild(card); | ||
}); | }); | ||
}); | |||
}); | |||
/* ══════════════════════════════════════════════ | |||
Vue-додаток для сторінки "Викладачі" | |||
Підключає Vue 3 через CDN і монтує на #vue-teachers | |||
══════════════════════════════════════════════ */ | |||
mw.hook('wikipage.content').add(function() { | |||
var mountEl = document.getElementById('vue-teachers'); | |||
if (!mountEl) return; | |||
// Завантажуємо Vue 3 з CDN | |||
mw.loader.getScript('https://unpkg.com/vue@3/dist/vue.global.prod.js').then(function() { | |||
var apiBase = mw.config.get('wgScriptPath') + '/api.php'; | |||
/* ── Парсер інфобоксу ── */ | |||
function parseInfobox(wikitext) { | |||
var result = { title: '', occupation: '', faculty: '', image: '' }; | |||
if (!wikitext) return result; | |||
var titleMatch = wikitext.match(/\|\s*title\s*=\s*([^\|\n\}]+)/i); | |||
if (titleMatch) result.title = titleMatch[1].trim(); | |||
var occMatch = wikitext.match(/\|\s*occupation\s*=\s*([^\|\n\}]+)/i); | |||
if (occMatch) result.occupation = occMatch[1].trim(); | |||
var imgMatch = wikitext.match(/\|\s*image\s*=\s*([^\|\n\}]+)/i); | |||
if (imgMatch) result.image = imgMatch[1].trim(); | |||
// Факультет з поля title | |||
if (result.title.toLowerCase().includes('схід') || result.title.toLowerCase().includes('слов')) { | |||
result.faculty = 'Факультет східної і слов\'янської філології'; | |||
} else if (result.title.toLowerCase().includes('філолог')) { | |||
result.faculty = 'Філологічний факультет'; | |||
} else if (result.title.toLowerCase().includes('географ') || result.title.toLowerCase().includes('туризм')) { | |||
result.faculty = 'Інший факультет'; | |||
} else { | |||
result.faculty = 'Інший факультет'; | |||
} | |||
return result; | |||
} | |||
/* ── Отримати посаду коротко ── */ | |||
function getPosition(title) { | |||
if (!title) return 'Викладач'; | |||
var t = title.toLowerCase(); | |||
if (t.includes('професор')) return 'Професор'; | |||
if (t.includes('доцент')) return 'Доцент'; | |||
if (t.includes('викладач')) return 'Викладач'; | |||
return 'Інше'; | |||
} | |||
var app = Vue.createApp({ | |||
data() { | |||
return { | |||
teachers: [], | |||
loading: true, | |||
searchQuery: '', | |||
activeFilter: 'Всі', | |||
activeSort: 'alpha', | |||
filters: ['Всі', 'Професор', 'Доцент', 'Викладач'], | |||
}; | |||
}, | |||
computed: { | |||
filteredTeachers() { | |||
var vm = this; | |||
var result = this.teachers.filter(function(t) { | |||
var matchSearch = t.fullName.toLowerCase().includes(vm.searchQuery.toLowerCase()) || | |||
t.occupation.toLowerCase().includes(vm.searchQuery.toLowerCase()); | |||
var matchFilter = vm.activeFilter === 'Всі' || t.position === vm.activeFilter; | |||
return matchSearch && matchFilter; | |||
}); | |||
if (this.activeSort === 'alpha') { | |||
result = result.slice().sort(function(a, b) { | |||
return a.fullName.localeCompare(b.fullName, 'uk'); | |||
}); | |||
} else if (this.activeSort === 'position') { | |||
var order = { 'Професор': 0, 'Доцент': 1, 'Викладач': 2, 'Інше': 3 }; | |||
result = result.slice().sort(function(a, b) { | |||
return (order[a.position] || 3) - (order[b.position] || 3); | |||
}); | |||
} | |||
return result; | |||
} | |||
}, | |||
mounted() { | |||
this.loadTeachers(); | |||
}, | |||
methods: { | |||
async loadTeachers() { | |||
this.loading = true; | |||
try { | |||
// Крок 1: всі сторінки з категорії Викладачі | |||
var catResp = await fetch( | |||
apiBase + '?action=query&list=categorymembers&cmtitle=Категорія:Викладачі' + | |||
'&cmlimit=50&cmnamespace=0&format=json' | |||
); | |||
var catData = await catResp.json(); | |||
var members = catData.query.categorymembers; | |||
if (!members || members.length === 0) { | |||
this.loading = false; | |||
return; | |||
} | |||
var titles = members.map(function(m) { return m.title; }).join('|'); | |||
// Крок 2: вміст статей | |||
var pageResp = await fetch( | |||
apiBase + '?action=query&titles=' + encodeURIComponent(titles) + | |||
'&prop=revisions&rvprop=content&format=json' | |||
); | |||
var pageData = await pageResp.json(); | |||
var pages = Object.values(pageData.query.pages); | |||
// Крок 3: для кожної статті отримати зображення | |||
var teacherPromises = pages.map(async function(page) { | |||
var content = (page.revisions && page.revisions[0]) ? (page.revisions[0]['*'] || '') : ''; | |||
var info = parseInfobox(content); | |||
var imgSrc = null; | |||
if (info.image) { | |||
try { | |||
var imgResp = await fetch( | |||
apiBase + '?action=query&titles=File:' + encodeURIComponent(info.image) + | |||
'&prop=imageinfo&iiprop=url&iiurlwidth=200&format=json' | |||
); | |||
var imgData = await imgResp.json(); | |||
var imgPages = Object.values(imgData.query.pages); | |||
if (imgPages[0] && imgPages[0].imageinfo && imgPages[0].imageinfo[0]) { | |||
imgSrc = imgPages[0].imageinfo[0].thumburl || imgPages[0].imageinfo[0].url; | |||
} | |||
} catch(e) {} | |||
} | |||
var pageUrl = mw.config.get('wgArticlePath').replace( | |||
'$1', encodeURIComponent(page.title.replace(/ /g, '_')) | |||
); | |||
return { | |||
fullName: page.title, | |||
title: info.title, | |||
occupation: info.occupation, | |||
faculty: info.faculty, | |||
position: getPosition(info.title), | |||
imgSrc: imgSrc, | |||
pageUrl: pageUrl, | |||
}; | |||
}); | |||
this.teachers = await Promise.all(teacherPromises); | |||
} catch(e) { | |||
console.error('[Vue Teachers] error:', e); | |||
} | |||
this.loading = false; | |||
} | |||
}, | |||
template: ` | |||
<div class="vt-app"> | |||
<!-- Заголовок --> | |||
<div class="vt-header"> | |||
<h1 class="vt-title">Викладачі</h1> | |||
<p class="vt-subtitle">Науково-педагогічний склад університету</p> | |||
</div> | |||
<!-- Панель керування --> | |||
<div class="vt-controls"> | |||
<!-- Пошук --> | |||
<div class="vt-search-wrap"> | |||
<svg class="vt-search-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> | |||
<circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/> | |||
</svg> | |||
<input | |||
class="vt-search" | |||
v-model="searchQuery" | |||
placeholder="Пошук за іменем або спеціальністю..." | |||
/> | |||
<button v-if="searchQuery" class="vt-search-clear" @click="searchQuery = ''">✕</button> | |||
</div> | |||
<!-- Фільтри по посаді --> | |||
<div class="vt-filters"> | |||
<button | |||
v-for="f in filters" | |||
:key="f" | |||
class="vt-filter-btn" | |||
:class="{ active: activeFilter === f }" | |||
@click="activeFilter = f" | |||
>{{ f }}</button> | |||
</div> | |||
<!-- Сортування --> | |||
<div class="vt-sort"> | |||
<span class="vt-sort-label">Сортування:</span> | |||
<button class="vt-sort-btn" :class="{ active: activeSort === 'alpha' }" @click="activeSort = 'alpha'">А → Я</button> | |||
<button class="vt-sort-btn" :class="{ active: activeSort === 'position' }" @click="activeSort = 'position'">За посадою</button> | |||
</div> | |||
</div> | |||
<!-- Лічильник --> | |||
<div class="vt-count" v-if="!loading"> | |||
Знайдено: <strong>{{ filteredTeachers.length }}</strong> з {{ teachers.length }} | |||
</div> | |||
<!-- Завантаження --> | |||
<div class="vt-loading" v-if="loading"> | |||
<div class="vt-spinner"></div> | |||
<span>Завантаження викладачів...</span> | |||
</div> | |||
<!-- Порожній результат --> | |||
<div class="vt-empty" v-else-if="!loading && filteredTeachers.length === 0"> | |||
<div class="vt-empty-icon">🔍</div> | |||
<p>Нікого не знайдено за вашим запитом</p> | |||
<button class="vt-reset-btn" @click="searchQuery = ''; activeFilter = 'Всі'">Скинути фільтри</button> | |||
</div> | |||
<!-- Сітка карток --> | |||
<div class="vt-grid" v-else> | |||
<a | |||
v-for="t in filteredTeachers" | |||
:key="t.fullName" | |||
:href="t.pageUrl" | |||
class="vt-card" | |||
> | |||
<div class="vt-card-img-wrap"> | |||
<img v-if="t.imgSrc" :src="t.imgSrc" :alt="t.fullName" class="vt-card-img" /> | |||
<div v-else class="vt-card-img-placeholder">{{ t.fullName.charAt(0) }}</div> | |||
</div> | |||
<div class="vt-card-body"> | |||
<div class="vt-card-position" :class="'pos-' + t.position.toLowerCase()">{{ t.position }}</div> | |||
<div class="vt-card-name">{{ t.fullName }}</div> | |||
<div class="vt-card-occupation" v-if="t.occupation">{{ t.occupation }}</div> | |||
<div class="vt-card-title" v-if="t.title">{{ t.title }}</div> | |||
</div> | |||
</a> | |||
</div> | |||
</div> | |||
` | |||
}); | |||
app.mount('#vue-teachers'); | |||
}); | }); | ||
}); | }); | ||
Версія за 15:21, 16 лютого 2026
$(function() {
$('.category-card').each(function() {
var $card = $(this);
var href = $card.attr('data-href');
if (href) {
$card.css('cursor', 'pointer');
$card.on('click', function(e) {
if ($(e.target).closest('a').length === 0) {
window.location.href = href;
}
});
$card.hover(
function() { $card.addClass('card-hover'); },
function() { $card.removeClass('card-hover'); }
);
}
});
});
/* ── Випадкові статті на головній сторінці ── */
/* Витягнути назву зображення з вікі-тексту */
function extractImageName(wikitext) {
if (!wikitext) return null;
// 1. Шукаємо в Infobox: | image = Файл.jpg
var infoboxImg = wikitext.match(/\|\s*image\s*=\s*([^\|\n\}]+)/i);
if (infoboxImg) {
var name = infoboxImg[1].trim();
if (name && name.length > 0) return name;
}
// 2. Шукаємо [[Файл:Назва.jpg|...]] або [[File:...]]
var fileMatch = wikitext.match(/\[\[(?:Файл|File|Зображення|Image):([^\|\]]+)/i);
if (fileMatch) {
return fileMatch[1].trim();
}
return null;
}
/* Витягнути перший змістовний абзац */
function extractDescription(wikitext) {
if (!wikitext) return '';
// Прибрати інфобокс {{...}} (може бути багаторядковим)
var text = wikitext;
var depth = 0;
var infoboxEnd = -1;
for (var i = 0; i < text.length; i++) {
if (text[i] === '{') depth++;
else if (text[i] === '}') {
depth--;
if (depth === 0) { infoboxEnd = i + 1; break; }
}
}
if (infoboxEnd > 0) text = text.substring(infoboxEnd);
// Прибрати [[Файл:...]] блоки
text = text.replace(/\[\[(?:Файл|File|Зображення|Image):[^\]]*\]\]/gi, '');
// Прибрати wikitable {| ... |}
text = text.replace(/\{\|[\s\S]*?\|\}/g, '');
// Прибрати шаблони {{...}}
text = text.replace(/\{\{[^}]*\}\}/g, '');
// Прибрати заголовки == ... ==
text = text.replace(/={2,6}[^=\n]+=+/g, '');
// Прибрати вікі-посилання — залишити текст
text = text.replace(/\[\[(?:[^\|\]]*\|)?([^\]]+)\]\]/g, '$1');
// Прибрати зовнішні посилання [url текст]
text = text.replace(/\[[^\s\]]+\s+([^\]]+)\]/g, '$1');
text = text.replace(/\[[^\]]+\]/g, '');
// Прибрати жирний/курсив
text = text.replace(/'{2,3}/g, '');
// Прибрати HTML теги
text = text.replace(/<[^>]+>/g, '');
// Прибрати рядки що починаються з * # : ;
text = text.replace(/^[\*#:;].*/gm, '');
// Прибрати порожні рядки і зайві пробіли
var lines = text.split('\n').map(function(l) { return l.trim(); }).filter(function(l) { return l.length > 20; });
// Взяти перший змістовний рядок
if (lines.length > 0) {
var result = lines[0].substring(0, 160);
if (lines[0].length > 160) result += '…';
return result;
}
return '';
}
function loadRandomArticles() {
var list = document.getElementById('random-articles-list');
if (!list) return;
list.innerHTML = '<div class="random-articles-loading">Завантаження...</div>';
var apiBase = mw.config.get('wgScriptPath') + '/api.php';
// Сторінки які не повинні з'являтись у випадкових статтях
var excludedPages = ['Головна сторінка', 'Структурні підрозділи', 'Викладачі'];
fetch(apiBase + '?action=query&list=random&rnnamespace=0&rnlimit=10&format=json')
.then(function(r) { return r.json(); })
.then(function(data) {
var pages = data.query.random.filter(function(p) {
return excludedPages.indexOf(p.title) === -1;
}).slice(0, 3);
var titles = pages.map(function(p) { return p.title; }).join('|');
return fetch(
apiBase +
'?action=query' +
'&titles=' + encodeURIComponent(titles) +
'&prop=revisions' +
'&rvprop=content' +
'&format=json'
);
})
.then(function(r) { return r.json(); })
.then(function(data) {
var pages = Object.values(data.query.pages);
list.innerHTML = '';
var promises = pages.map(function(page) {
var title = page.title;
var pageUrl = mw.config.get('wgArticlePath').replace(
'$1', encodeURIComponent(title.replace(/ /g, '_'))
);
var content = '';
if (page.revisions && page.revisions[0]) {
content = page.revisions[0]['*'] || '';
}
var excerpt = extractDescription(content);
if (!excerpt) excerpt = 'Немає опису.';
var imgName = extractImageName(content);
if (imgName) {
var fileTitle = imgName.match(/^(Файл|File|Image|Зображення):/i)
? imgName
: 'File:' + imgName;
return fetch(
apiBase +
'?action=query' +
'&titles=' + encodeURIComponent(fileTitle) +
'&prop=imageinfo' +
'&iiprop=url' +
'&iiurlwidth=120' +
'&format=json'
)
.then(function(r) { return r.json(); })
.then(function(imgData) {
var imgPages = Object.values(imgData.query.pages);
var imgSrc = null;
if (imgPages[0] && imgPages[0].imageinfo && imgPages[0].imageinfo[0]) {
imgSrc = imgPages[0].imageinfo[0].thumburl || imgPages[0].imageinfo[0].url;
}
return { title: title, excerpt: excerpt, pageUrl: pageUrl, imgSrc: imgSrc };
})
.catch(function() {
return { title: title, excerpt: excerpt, pageUrl: pageUrl, imgSrc: null };
});
}
return Promise.resolve({ title: title, excerpt: excerpt, pageUrl: pageUrl, imgSrc: null });
});
return Promise.all(promises);
})
.then(function(results) {
var list2 = document.getElementById('random-articles-list');
if (!list2) return;
list2.innerHTML = '';
results.forEach(function(item) {
var thumbHtml = item.imgSrc
? '<img class="random-article-thumb" src="' + item.imgSrc + '" alt="">'
: '<div class="random-article-thumb-placeholder">📄</div>';
var card = document.createElement('a');
card.href = item.pageUrl;
card.className = 'random-article-card';
card.innerHTML =
thumbHtml +
'<div class="random-article-info">' +
'<div class="random-article-title">' + mw.html.escape(item.title) + '</div>' +
'<div class="random-article-excerpt">' + mw.html.escape(item.excerpt) + '</div>' +
'</div>';
list2.appendChild(card);
});
})
.catch(function(err) {
var list3 = document.getElementById('random-articles-list');
if (list3) list3.innerHTML = '<div class="random-articles-loading">Не вдалося завантажити статті.</div>';
console.error('[RA] error:', err);
});
}
/* Запуск */
mw.hook('wikipage.content').add(function() {
var panel = document.getElementById('random-articles-panel');
if (!panel) return;
loadRandomArticles();
var btn = document.getElementById('random-articles-refresh');
if (btn) {
btn.addEventListener('click', function() {
loadRandomArticles();
});
}
});
/* ── Сортування карточок за прізвищем ── */
mw.hook('wikipage.content').add(function() {
// Знаходимо всі grid-контейнери з карточками
document.querySelectorAll('div[style*="grid-template-columns"]').forEach(function(grid) {
var cards = Array.from(grid.children);
if (cards.length < 2) return;
cards.sort(function(a, b) {
// Беремо текст посилання з імʼям (перший <a> у блоці flex-grow)
var aLink = a.querySelector('div[style*="flex-grow"] a');
var bLink = b.querySelector('div[style*="flex-grow"] a');
if (!aLink || !bLink) return 0;
// Беремо прізвище — перше слово повного імені
var aSurname = aLink.textContent.trim().split(' ')[0];
var bSurname = bLink.textContent.trim().split(' ')[0];
return aSurname.localeCompare(bSurname, 'uk');
});
// Переставляємо DOM-елементи в відсортованому порядку
cards.forEach(function(card) {
grid.appendChild(card);
});
});
});
/* ══════════════════════════════════════════════
Vue-додаток для сторінки "Викладачі"
Підключає Vue 3 через CDN і монтує на #vue-teachers
══════════════════════════════════════════════ */
mw.hook('wikipage.content').add(function() {
var mountEl = document.getElementById('vue-teachers');
if (!mountEl) return;
// Завантажуємо Vue 3 з CDN
mw.loader.getScript('https://unpkg.com/vue@3/dist/vue.global.prod.js').then(function() {
var apiBase = mw.config.get('wgScriptPath') + '/api.php';
/* ── Парсер інфобоксу ── */
function parseInfobox(wikitext) {
var result = { title: '', occupation: '', faculty: '', image: '' };
if (!wikitext) return result;
var titleMatch = wikitext.match(/\|\s*title\s*=\s*([^\|\n\}]+)/i);
if (titleMatch) result.title = titleMatch[1].trim();
var occMatch = wikitext.match(/\|\s*occupation\s*=\s*([^\|\n\}]+)/i);
if (occMatch) result.occupation = occMatch[1].trim();
var imgMatch = wikitext.match(/\|\s*image\s*=\s*([^\|\n\}]+)/i);
if (imgMatch) result.image = imgMatch[1].trim();
// Факультет з поля title
if (result.title.toLowerCase().includes('схід') || result.title.toLowerCase().includes('слов')) {
result.faculty = 'Факультет східної і слов\'янської філології';
} else if (result.title.toLowerCase().includes('філолог')) {
result.faculty = 'Філологічний факультет';
} else if (result.title.toLowerCase().includes('географ') || result.title.toLowerCase().includes('туризм')) {
result.faculty = 'Інший факультет';
} else {
result.faculty = 'Інший факультет';
}
return result;
}
/* ── Отримати посаду коротко ── */
function getPosition(title) {
if (!title) return 'Викладач';
var t = title.toLowerCase();
if (t.includes('професор')) return 'Професор';
if (t.includes('доцент')) return 'Доцент';
if (t.includes('викладач')) return 'Викладач';
return 'Інше';
}
var app = Vue.createApp({
data() {
return {
teachers: [],
loading: true,
searchQuery: '',
activeFilter: 'Всі',
activeSort: 'alpha',
filters: ['Всі', 'Професор', 'Доцент', 'Викладач'],
};
},
computed: {
filteredTeachers() {
var vm = this;
var result = this.teachers.filter(function(t) {
var matchSearch = t.fullName.toLowerCase().includes(vm.searchQuery.toLowerCase()) ||
t.occupation.toLowerCase().includes(vm.searchQuery.toLowerCase());
var matchFilter = vm.activeFilter === 'Всі' || t.position === vm.activeFilter;
return matchSearch && matchFilter;
});
if (this.activeSort === 'alpha') {
result = result.slice().sort(function(a, b) {
return a.fullName.localeCompare(b.fullName, 'uk');
});
} else if (this.activeSort === 'position') {
var order = { 'Професор': 0, 'Доцент': 1, 'Викладач': 2, 'Інше': 3 };
result = result.slice().sort(function(a, b) {
return (order[a.position] || 3) - (order[b.position] || 3);
});
}
return result;
}
},
mounted() {
this.loadTeachers();
},
methods: {
async loadTeachers() {
this.loading = true;
try {
// Крок 1: всі сторінки з категорії Викладачі
var catResp = await fetch(
apiBase + '?action=query&list=categorymembers&cmtitle=Категорія:Викладачі' +
'&cmlimit=50&cmnamespace=0&format=json'
);
var catData = await catResp.json();
var members = catData.query.categorymembers;
if (!members || members.length === 0) {
this.loading = false;
return;
}
var titles = members.map(function(m) { return m.title; }).join('|');
// Крок 2: вміст статей
var pageResp = await fetch(
apiBase + '?action=query&titles=' + encodeURIComponent(titles) +
'&prop=revisions&rvprop=content&format=json'
);
var pageData = await pageResp.json();
var pages = Object.values(pageData.query.pages);
// Крок 3: для кожної статті отримати зображення
var teacherPromises = pages.map(async function(page) {
var content = (page.revisions && page.revisions[0]) ? (page.revisions[0]['*'] || '') : '';
var info = parseInfobox(content);
var imgSrc = null;
if (info.image) {
try {
var imgResp = await fetch(
apiBase + '?action=query&titles=File:' + encodeURIComponent(info.image) +
'&prop=imageinfo&iiprop=url&iiurlwidth=200&format=json'
);
var imgData = await imgResp.json();
var imgPages = Object.values(imgData.query.pages);
if (imgPages[0] && imgPages[0].imageinfo && imgPages[0].imageinfo[0]) {
imgSrc = imgPages[0].imageinfo[0].thumburl || imgPages[0].imageinfo[0].url;
}
} catch(e) {}
}
var pageUrl = mw.config.get('wgArticlePath').replace(
'$1', encodeURIComponent(page.title.replace(/ /g, '_'))
);
return {
fullName: page.title,
title: info.title,
occupation: info.occupation,
faculty: info.faculty,
position: getPosition(info.title),
imgSrc: imgSrc,
pageUrl: pageUrl,
};
});
this.teachers = await Promise.all(teacherPromises);
} catch(e) {
console.error('[Vue Teachers] error:', e);
}
this.loading = false;
}
},
template: `
<div class="vt-app">
<!-- Заголовок -->
<div class="vt-header">
<h1 class="vt-title">Викладачі</h1>
<p class="vt-subtitle">Науково-педагогічний склад університету</p>
</div>
<!-- Панель керування -->
<div class="vt-controls">
<!-- Пошук -->
<div class="vt-search-wrap">
<svg class="vt-search-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/>
</svg>
<input
class="vt-search"
v-model="searchQuery"
placeholder="Пошук за іменем або спеціальністю..."
/>
<button v-if="searchQuery" class="vt-search-clear" @click="searchQuery = ''">✕</button>
</div>
<!-- Фільтри по посаді -->
<div class="vt-filters">
<button
v-for="f in filters"
:key="f"
class="vt-filter-btn"
:class="{ active: activeFilter === f }"
@click="activeFilter = f"
>{{ f }}</button>
</div>
<!-- Сортування -->
<div class="vt-sort">
<span class="vt-sort-label">Сортування:</span>
<button class="vt-sort-btn" :class="{ active: activeSort === 'alpha' }" @click="activeSort = 'alpha'">А → Я</button>
<button class="vt-sort-btn" :class="{ active: activeSort === 'position' }" @click="activeSort = 'position'">За посадою</button>
</div>
</div>
<!-- Лічильник -->
<div class="vt-count" v-if="!loading">
Знайдено: <strong>{{ filteredTeachers.length }}</strong> з {{ teachers.length }}
</div>
<!-- Завантаження -->
<div class="vt-loading" v-if="loading">
<div class="vt-spinner"></div>
<span>Завантаження викладачів...</span>
</div>
<!-- Порожній результат -->
<div class="vt-empty" v-else-if="!loading && filteredTeachers.length === 0">
<div class="vt-empty-icon">🔍</div>
<p>Нікого не знайдено за вашим запитом</p>
<button class="vt-reset-btn" @click="searchQuery = ''; activeFilter = 'Всі'">Скинути фільтри</button>
</div>
<!-- Сітка карток -->
<div class="vt-grid" v-else>
<a
v-for="t in filteredTeachers"
:key="t.fullName"
:href="t.pageUrl"
class="vt-card"
>
<div class="vt-card-img-wrap">
<img v-if="t.imgSrc" :src="t.imgSrc" :alt="t.fullName" class="vt-card-img" />
<div v-else class="vt-card-img-placeholder">{{ t.fullName.charAt(0) }}</div>
</div>
<div class="vt-card-body">
<div class="vt-card-position" :class="'pos-' + t.position.toLowerCase()">{{ t.position }}</div>
<div class="vt-card-name">{{ t.fullName }}</div>
<div class="vt-card-occupation" v-if="t.occupation">{{ t.occupation }}</div>
<div class="vt-card-title" v-if="t.title">{{ t.title }}</div>
</div>
</a>
</div>
</div>
`
});
app.mount('#vue-teachers');
});
});