File size: 10,994 Bytes
18a3a34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
// Global variables
let selectedService = null;
let ratings = {
    community: 0,
    customer: 0,
    value: 0,
    quality: 0,
    recommendation: 0
};
let reviews = JSON.parse(localStorage.getItem('nomarddeskReviews')) || [];

// Initialize the app
document.addEventListener('DOMContentLoaded', function() {
    initializeParticles();
    loadReviews();
    feather.replace();
});

// Create animated particles
function initializeParticles() {
    const bg = document.querySelector('.animated-bg');
    if (!bg) return;
    
    for (let i = 0; i < 3; i++) {
        const particle = document.createElement('div');
        particle.className = 'particle';
        bg.appendChild(particle);
    }
}

// Scroll to review section
function scrollToReview() {
    document.getElementById('review-section').scrollIntoView({ 
        behavior: 'smooth' 
    });
}

// Select service
function selectService(service) {
    selectedService = service;
    
    // Update UI
    document.querySelectorAll('.service-card').forEach(card => {
        card.classList.remove('selected');
        if (card.textContent.includes(service)) {
            card.classList.add('selected');
        }
    });
    
    // Show rating section with animation
    const ratingSection = document.getElementById('rating-section');
    ratingSection.classList.remove('hidden');
    ratingSection.style.animation = 'slideUp 0.5s ease-out';
    
    // Reset ratings
    Object.keys(ratings).forEach(key => {
        ratings[key] = 0;
        updateStarDisplay(key);
    });
}

// Set rating for category
function setRating(category, rating) {
    ratings[category] = rating;
    updateStarDisplay(category);
    
    // Add animation effect
    const stars = document.querySelectorAll(`[data-category="${category}"] .star`);
    stars.forEach((star, index) => {
        setTimeout(() => {
            star.style.transform = 'scale(1.2)';
            setTimeout(() => {
                star.style.transform = 'scale(1)';
            }, 100);
        }, index * 50);
    });
}

// Update star display
function updateStarDisplay(category) {
    const stars = document.querySelectorAll(`[data-category="${category}"] .star`);
    stars.forEach((star, index) => {
        if (index < ratings[category]) {
            star.classList.add('filled');
            star.classList.remove('text-gray-600');
        } else {
            star.classList.remove('filled');
            star.classList.add('text-gray-600');
        }
    });
}

// Submit review
function submitReview() {
    // Validate
    if (!selectedService) {
        showNotification('Please select a service', 'error');
        return;
    }
    
    const hasRatings = Object.values(ratings).some(r => r > 0);
    if (!hasRatings) {
        showNotification('Please provide at least one rating', 'error');
        return;
    }
    
    // Create review object
    const review = {
        id: Date.now(),
        service: selectedService,
        ratings: { ...ratings },
        feedback: document.getElementById('feedback').value,
        date: new Date().toISOString(),
        averageRating: Object.values(ratings).reduce((a, b) => a + b, 0) / Object.values(ratings).filter(r => r > 0).length
    };
    
    // Save review
    reviews.unshift(review);
    localStorage.setItem('nomarddeskReviews', JSON.stringify(reviews));
    
    // Show success modal
    showSuccessModal();
    
    // Reset form
    resetForm();
    
    // Update display
    loadReviews();
}

// Reset form
function resetForm() {
    selectedService = null;
    Object.keys(ratings).forEach(key => {
        ratings[key] = 0;
    });
    document.getElementById('feedback').value = '';
    document.querySelectorAll('.service-card').forEach(card => {
        card.classList.remove('selected');
    });
    document.getElementById('rating-section').classList.add('hidden');
}

// Show success modal
function showSuccessModal() {
    const modal = document.getElementById('success-modal');
    modal.style.display = 'flex';
    modal.classList.add('animate-fadeIn');
}

// Close modal
function closeModal() {
    const modal = document.getElementById('success-modal');
    modal.style.display = 'none';
}

// Load reviews
function loadReviews() {
    const container = document.getElementById('reviews-container');
    container.innerHTML = '';
    
    // Sample reviews if no reviews exist
    if (reviews.length === 0) {
        const sampleReviews = [
            {
                id: 1,
                service: 'Telegram Promotion',
                ratings: { community: 5, customer: 5, value: 4, quality: 5, recommendation: 5 },
                feedback: 'Excellent service! Our Telegram community grew by 10k members in just 2 weeks.',
                date: new Date(Date.now() - 86400000).toISOString(),
                averageRating: 4.8
            },
            {
                id: 2,
                service: 'Vibe Coding / App Development',
                ratings: { community: 5, customer: 5, value: 5, quality: 5, recommendation: 5 },
                feedback: 'The app they built for us exceeded all expectations. Professional team and great communication!',
                date: new Date(Date.now() - 172800000).toISOString(),
                averageRating: 5
            },
            {
                id: 3,
                service: 'Music Marketing',
                ratings: { community: 4, customer: 4, value: 4, quality: 4, recommendation: 4 },
                feedback: 'Helped promote my latest track effectively. Got great results within budget.',
                date: new Date(Date.now() - 259200000).toISOString(),
                averageRating: 4
            }
        ];
        reviews = sampleReviews;
    }
    
    // Display reviews
    reviews.slice(0, 6).forEach(review => {
        const card = createReviewCard(review);
        container.appendChild(card);
    });
}

// Create review card
function createReviewCard(review) {
    const card = document.createElement('div');
    card.className = 'review-card';
    
    const starsHtml = '★'.repeat(Math.round(review.averageRating)) + '☆'.repeat(5 - Math.round(review.averageRating));
    
    card.innerHTML = `
        <div class="flex items-center justify-between mb-3">
            <span class="review-stars">${starsHtml}</span>
            <span class="text-sm text-gray-400">${formatDate(review.date)}</span>
        </div>
        <span class="review-service">${review.service}</span>
        ${review.feedback ? `<p class="mt-3 text-gray-300">${review.feedback}</p>` : ''}
        <div class="mt-4 grid grid-cols-5 gap-2 text-xs">
            <div class="text-center">
                <div class="text-yellow-400">★</div>
                <div class="text-gray-500">Comm</div>
                <div>${review.ratings.community || '-'}</div>
            </div>
            <div class="text-center">
                <div class="text-yellow-400">★</div>
                <div class="text-gray-500">Service</div>
                <div>${review.ratings.customer || '-'}</div>
            </div>
            <div class="text-center">
                <div class="text-yellow-400">★</div>
                <div class="text-gray-500">Value</div>
                <div>${review.ratings.value || '-'}</div>
            </div>
            <div class="text-center">
                <div class="text-yellow-400">★</div>
                <div class="text-gray-500">Quality</div>
                <div>${review.ratings.quality || '-'}</div>
            </div>
            <div class="text-center">
                <div class="text-yellow-400">★</div>
                <div class="text-gray-500">Rec</div>
                <div>${review.ratings.recommendation || '-'}</div>
            </div>
        </div>
    `;
    
    return card;
}

// Format date
function formatDate(dateString) {
    const date = new Date(dateString);
    const now = new Date();
    const diffTime = Math.abs(now - date);
    const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24));
    
    if (diffDays === 0) return 'Today';
    if (diffDays === 1) return 'Yesterday';
    if (diffDays < 7) return `${diffDays} days ago`;
    if (diffDays < 30) return `${Math.floor(diffDays / 7)} weeks ago`;
    if (diffDays < 365) return `${Math.floor(diffDays / 30)} months ago`;
    return `${Math.floor(diffDays / 365)} years ago`;
}

// Filter reviews
function filterReviews(filter) {
    const buttons = document.querySelectorAll('.filter-btn');
    buttons.forEach(btn => btn.classList.remove('active'));
    event.target.classList.add('active');
    
    let filteredReviews = [...reviews];
    
    switch(filter) {
        case 'highest':
            filteredReviews.sort((a, b) => b.averageRating - a.averageRating);
            break;
        case 'recent':
            filteredReviews.sort((a, b) => new Date(b.date) - new Date(a.date));
            break;
    }
    
    const container = document.getElementById('reviews-container');
    container.innerHTML = '';
    
    filteredReviews.slice(0, 6).forEach(review => {
        const card = createReviewCard(review);
        container.appendChild(card);
    });
}

// Show notification
function showNotification(message, type = 'info') {
    const notification = document.createElement('div');
    notification.className = `fixed top-20 right-4 px-6 py-3 rounded-lg z-50 animate-slideUp ${
        type === 'error' ? 'bg-red-500' : 'bg-green-500'
    }`;
    notification.textContent = message;
    document.body.appendChild(notification);
    
    setTimeout(() => {
        notification.remove();
    }, 3000);
}

// Add keyboard navigation
document.addEventListener('keydown', function(e) {
    if (e.key === 'Escape') {
        closeModal();
    }
});

// Add smooth scroll behavior
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
    anchor.addEventListener('click', function (e) {
        e.preventDefault();
        const target = document.querySelector(this.getAttribute('href'));
        if (target) {
            target.scrollIntoView({ behavior: 'smooth' });
        }
    });
});

// Add parallax effect to hero section
window.addEventListener('scroll', function() {
    const scrolled = window.pageYOffset;
    const parallax = document.querySelector('.animated-bg');
    if (parallax) {
        parallax.style.transform = `translateY(${scrolled * 0.5}px)`;
    }
});

// Add intersection observer for animations
const observerOptions = {
    threshold: 0.1,
    rootMargin: '0px 0px -50px 0px'
};

const observer = new IntersectionObserver((entries) => {
    entries.forEach(entry => {
        if (entry.isIntersecting) {
            entry.target.style.animation = 'slideUp 0.5s ease-out forwards';
        }
    });
}, observerOptions);

// Observe all review cards
document.addEventListener('DOMContentLoaded', function() {
    document.querySelectorAll('.review-card').forEach(card => {
        observer.observe(card);
    });
});