/* =========================================== */
/* CUSTOM PLACEHOLDER SYSTEM FÜR IHRE KATEGORIEN */
/* =========================================== */
(function() {
'use strict';
// Sačekaj da se stranica učita
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initCustomPlaceholder);
} else {
initCustomPlaceholder();
}
function initCustomPlaceholder() {
// Provjeri prave recenzije
if (hasRealReviews()) {
removePlaceholder();
return;
}
// Detektiraj kategoriju
const category = detectYourCategory();
console.log('Erkannte Kategorie:', category);
// Dohvati recenzije za kategoriju
const reviews = getCategoryReviews(category);
// Prikazi recenzije
displayCategoryReviews(reviews, category);
// Postavi event listenere
setupCustomEvents();
// Pokreni monitoring
startCustomMonitoring();
}
// Detekcija VAŠIH kategorija
function detectYourCategory() {
const bodyText = document.body.textContent.toLowerCase();
const title = document.querySelector('h1')?.textContent.toLowerCase() || '';
const fullText = bodyText + ' ' + title;
// Kommode
if (fullText.includes('kommode') || fullText.includes('chest') ||
fullText.includes('kommoden') || fullText.includes('nachttisch')) {
return 'kommode';
}
// Schlafsofa
if (fullText.includes('schlafsofa') || fullText.includes('schlafcouch') ||
fullText.includes('ausziehcouch') || fullText.includes('sofabett')) {
return 'schlafsofa';
}
// Sofa
if (fullText.includes('sofa') && !fullText.includes('schlafsofa') ||
fullText.includes('couch') && !fullText.includes('schlafcouch')) {
return 'sofa';
}
// Ecksofa
if (fullText.includes('ecksofa') || fullText.includes('eckcouch') ||
fullText.includes('sofaecks') || fullText.includes('sofa-ecke')) {
return 'ecksofa';
}
// Tische
if (fullText.includes('tisch') || fullText.includes('table') ||
fullText.includes('esstisch') || fullText.includes('couchtisch')) {
return 'tische';
}
// Lampen
if (fullText.includes('lampe') || fullText.includes('leuchte') ||
fullText.includes('licht') || fullText.includes('pendelleuchte')) {
return 'lampen';
}
// Sessel
if (fullText.includes('sessel') && !fullText.includes('ecksessel') ||
fullText.includes('fauteuil') || fullText.includes('lesesessel')) {
return 'sessel';
}
// Stühl
if (fullText.includes('stuhl') || fullText.includes('stühle') ||
fullText.includes('chair') || fullText.includes('dining chair')) {
return 'stuehl';
}
// Default - premium generic
return 'premium';
}
// Baza podataka za VAŠE kategorije
function getCategoryReviews(category) {
const reviewDatabase = {
'kommode': [
{
stars: 5,
text: "Diese Kommode vereint Stauraum mit Design. Jede Schublade gleitet sanft, die Oberfläche ist wunderbar verarbeitet.",
author: "Markus S.",
initials: "",
tag: "Organisationsexperte",
date: "Vor 2 Wochen"
},
{
stars: 5,
text: "Massives Holz, zeitloses Design. Passt perfekt in unser Schlafzimmer und bietet überraschend viel Stauraum.",
author: "Anna M.",
initials: "AM",
tag: "Raumgestalter",
date: "Vor 3 Wochen"
}
],
'schlafsofa': [
{
stars: 5,
text: "Perfekte Kombination aus Komfort und Funktion. Als Sofa bequem, als Bett erholsam. Ein echtes Multitalent!",
author: "Thomas W.",
initials: "TW",
tag: "Hospitality-Experte",
date: "Vor 1 Woche"
},
{
stars: 4,
text: "Platzsparend und komfortabel. Der Ausziehmechanismus funktioniert reibungslos, die Matratze ist überraschend gut.",
author: "Stadtwohnungs-Bewohner",
initials: "SB",
tag: "Platzoptimierer",
date: "Vor 5 Tagen"
}
],
'sofa': [
{
stars: 5,
text: "Dieses Sofa definiert Wohnkomfort neu. Das Polster passt sich perfekt an, die Verarbeitung ist makellos.",
author: "Wohnkomfort-Experte",
initials: "WE",
tag: "Komfort-Spezialist",
date: "Vor 3 Wochen"
},
{
stars: 5,
text: "Ein Statement-Piece das jeden Raum aufwertet. Das Design ist ikonisch, die Qualität überzeugt auf ganzer Linie.",
author: "Julia H.",
initials: "JH",
tag: "Design-Expertin",
date: "Vor 1 Monat"
}
],
'ecksofa': [
{
stars: 5,
text: "Perfekte Raumausnutzung durch dieses Ecksofa. Bietet Platz für die ganze Familie ohne sperrig zu wirken.",
author: "Sarah B.",
initials: "SB",
tag: "Family-Living",
date: "Vor 2 Wochen"
},
{
stars: 5,
text: "Die Ecke optimal genutzt! Bequemer als jedes herkömmliche Sofa, dank der durchdachten Polsterung.",
author: "Peter K.",
initials: "PB",
tag: "Raumoptimierer",
date: "Vor 10 Tagen"
}
],
'tische': [
{
stars: 5,
text: "Massivholztisch von außergewöhnlicher Qualität. Die Oberfläche ist unempfindlich und einfach zu pflegen.",
author: "Michael F.",
initials: "MF",
tag: "Materialexperte",
date: "Vor 3 Wochen"
},
{
stars: 4,
text: "Funktionalität trifft auf skandinavisches Design. Perfekt für Homeoffice und gemütliche Abendessen.",
author: "Lisa R.",
initials: "LR",
tag: "Multifunktional",
date: "Vor 1 Woche"
}
],
'lampen': [
{
stars: 5,
text: "Diese Lampe kreiert eine einzigartige Atmosphäre. Das Licht ist warm und einladend, das Design ein Kunstwerk.",
author: "David L.",
initials: "DL",
tag: "Ambiente-Spezialist",
date: "Vor 2 Wochen"
},
{
stars: 5,
text: "Kunstvolles Design das zum Mittelpunkt des Raumes wird. Die Verarbeitung ist außergewöhnlich detailliert.",
author: "Claudia V.",
initials: "CV",
tag: "Kunstliebhaber",
date: "Vor 3 Tagen"
}
],
'sessel': [
{
stars: 5,
text: "Mein persönlicher Ruhepol. Dieser Sessel bietet perfekte Unterstützung und lädt zum Entspannen ein.",
author: "Stefan G.",
initials: "SG",
tag: "Wellness-Enthusiast",
date: "Vor 1 Woche"
},
{
stars: 5,
text: "Ergonomie und Ästhetik in Perfektion. Selbst nach Stunden noch bequem - ein echtes Sitzmöbel für Kenner.",
author: "Büro-Architekt",
initials: "BA",
tag: "Ergonomie-Experte",
date: "Vor 2 Wochen"
}
],
'stuehl': [
{
stars: 5,
text: "Stühle die Komfort und Stil vereinen. Perfekt für lange Dinnerpartys - keine unangenehmen Sitzpositionen.",
author: "Nina P.",
initials: "NP",
tag: "Gastgeber-Profi",
date: "Vor 3 Wochen"
},
{
stars: 4,
text: "Robuste Konstruktion, elegantes Design. Diese Stühle halten auch intensivem Gebrauch stand.",
author: "Julia H.",
initials: "JH",
tag: "Professioneller Nutzer",
date: "Vor 5 Tagen"
}
],
'premium': [
{
stars: 5,
text: "Design das Maßstäbe setzt. Jedes Detail spricht von handwerklicher Perfektion und durchdachtem Konzept.",
author: "Anna B.",
initials: "AB",
tag: "Qualitätsbewusst",
date: "Vor 2 Wochen"
},
{
stars: 5,
text: "Vom ersten Kontakt bis zur Aufstellung - ein durchgängig hochwertiges Einkaufserlebnis.",
author: "Anny K.",
initials: "AK",
tag: "Service-Enthusiast",
date: "Vor 1 Woche"
}
]
};
return reviewDatabase[category] || reviewDatabase['premium'];
}
// Prikaz recenzija sa kategorijom-specifičnim detaljima
function displayCategoryReviews(reviews, category) {
const grid = document.getElementById('designReviewGrid');
if (!grid) return;
// Nasumično odaberi recenzije
const reviewCount = Math.min(reviews.length, Math.floor(Math.random() * 2) + 1);
const shuffled = [...reviews].sort(() => Math.random() - 0.5);
const selected = shuffled.slice(0, reviewCount);
// Dodaj kategoriju u header
updateCategoryHeader(category);
// Generiraj HTML
grid.innerHTML = selected.map(review => {
const stars = generateColoredStars(review.stars);
const badge = `${review.stars}.0/5.0`;
return `
${badge}
${stars}
"${review.text}"
${review.initials}
${review.author}
${review.tag}
${review.date}
`;
}).join('');
}
// Ažuriraj header sa kategorijom
function updateCategoryHeader(category) {
const header = document.querySelector('.design-reviews-header h3');
if (!header) return;
const categoryNames = {
'kommode': 'Kommode & Aufbewahrung',
'schlafsofa': 'Schlafsofa & Multifunktion',
'sofa': 'Sofa & Wohnkomfort',
'ecksofa': 'Ecksofa & Raumnutzung',
'tische': 'Tische & Arbeitsplätze',
'lampen': 'Lampen & Beleuchtung',
'sessel': 'Sessel & Entspannung',
'stuehl': 'Stühle & Sitzmöbel',
'premium': 'Designmöbel'
};
const categoryName = categoryNames[category] || 'Designmöbel';
header.innerHTML = `⭐ ${categoryName} - Kundenstimmen`;
}
// Generiraj zvjezdice
function generateColoredStars(count) {
let stars = '';
for (let i = 0; i < 5; i++) {
if (i < count) {
stars += '
★';
} else {
stars += '
★';
}
}
return stars;
}
// Postavi event listenere
function setupCustomEvents() {
const cta = document.getElementById('designCTA');
if (cta) {
cta.addEventListener('click', function() {
const reviewSection = document.querySelector('.uncode-single-product-reviews') ||
document.querySelector('#reviews');
if (reviewSection) {
reviewSection.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
// Animacija
reviewSection.style.transition = 'all 0.5s ease';
reviewSection.style.boxShadow = '0 0 0 3px rgba(0,0,0,0.1)';
setTimeout(() => {
reviewSection.style.boxShadow = 'none';
}, 2000);
}
});
}
}
// Monitoring
function startCustomMonitoring() {
let checks = 0;
const maxChecks = 180; // 30 minuta
const interval = setInterval(() => {
checks++;
if (hasRealReviews()) {
console.log('Echte Bewertungen gefunden, entferne Placeholder');
removePlaceholder();
clearInterval(interval);
return;
}
// Admin hint
if (document.body.classList.contains('admin-bar')) {
const pending = document.querySelectorAll('.comment-awaiting-moderation').length;
if (pending > 0) {
const hint = document.getElementById('adminHint');
const countSpan = document.getElementById('pendingCount');
if (hint && countSpan) {
countSpan.textContent = pending;
hint.style.display = 'block';
}
}
}
if (checks >= maxChecks) {
clearInterval(interval);
}
}, 10000);
}
// Helper funkcije
function hasRealReviews() {
return document.querySelector('.commentlist li, .woocommerce-Reviews .comment') !== null;
}
function removePlaceholder() {
const placeholder = document.getElementById('designReviewsPlaceholder');
if (placeholder) {
placeholder.classList.add('fade-out');
setTimeout(() => placeholder.remove(), 500);
}
}
// Ponovna inicijalizacija ako je potrebno
setTimeout(() => {
if (!document.querySelector('#designReviewGrid').innerHTML.trim()) {
initCustomPlaceholder();
}
}, 3000);
})();