HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //var/www/test.kaunokolegija.lt/kk_wp_content/plugins/events/assets/admin-script.js
// Kauno Events Admin JavaScript

jQuery(document).ready(function($) {
    
    // Form validation
    $('.event-form').on('submit', function(e) {
        var title = $('#title').val().trim();
        var eventDate = $('#event_date').val();
        var language = $('#language').val();
        
        if (!title) {
            alert('Please enter an event title');
            e.preventDefault();
            return false;
        }
        
        if (!eventDate) {
            alert('Please select an event date and time');
            e.preventDefault();
            return false;
        }
        
        if (!language) {
            alert('Please select a language');
            e.preventDefault();
            return false;
        }
        
        // Check if date is in the future
        var selectedDate = new Date(eventDate);
        var now = new Date();
        
        if (selectedDate <= now) {
            if (!confirm('The selected date is in the past. Are you sure you want to continue?')) {
                e.preventDefault();
                return false;
            }
        }
    });
    
    // Auto-save draft functionality (optional)
    var autoSaveTimer;
    $('.event-form input, .event-form textarea, .event-form select').on('input change', function() {
        clearTimeout(autoSaveTimer);
        autoSaveTimer = setTimeout(function() {
            // Auto-save logic can be implemented here
            console.log('Auto-saving...');
        }, 2000);
    });
    
    // Confirmation dialogs for delete actions
    $('.button-link-delete').on('click', function(e) {
        if (!confirm('Are you sure you want to delete this item? This action cannot be undone.')) {
            e.preventDefault();
            return false;
        }
    });
    
    // Enhanced table interactions
    $('.wp-list-table tbody tr').hover(
        function() {
            $(this).addClass('hover-highlight');
        },
        function() {
            $(this).removeClass('hover-highlight');
        }
    );
    
    // Status badge interactions
    $('.status-badge').on('click', function() {
        var $badge = $(this);
        var currentStatus = $badge.text().toLowerCase();
        
        // This could be expanded to allow inline status changes
        console.log('Status clicked:', currentStatus);
    });
    
    // Search/filter functionality (can be expanded)
    if ($('#events-search').length) {
        $('#events-search').on('input', function() {
            var searchTerm = $(this).val().toLowerCase();
            $('.wp-list-table tbody tr').each(function() {
                var rowText = $(this).text().toLowerCase();
                if (rowText.indexOf(searchTerm) === -1) {
                    $(this).hide();
                } else {
                    $(this).show();
                }
            });
        });
    }
    
    // Bulk actions (can be implemented)
    $('#bulk-action-selector-top').on('change', function() {
        var action = $(this).val();
        if (action) {
            console.log('Bulk action selected:', action);
        }
    });
    
    // Real-time character count for description
    $('#description').on('input', function() {
        var length = $(this).val().length;
        var maxLength = 1000; // Set your desired max length
        
        if (!$('.char-count').length) {
            $(this).after('<div class="char-count"></div>');
        }
        
        $('.char-count').text(length + ' characters');
        
        if (length > maxLength) {
            $('.char-count').css('color', '#dc2626');
        } else {
            $('.char-count').css('color', '#6b7280');
        }
    });
    
    // Language-specific form adjustments
    $('#language').on('change', function() {
        var language = $(this).val();
        
        // You can adjust form labels/placeholders based on selected language
        if (language === 'en') {
            $('label[for="title"]').text('Event Title *');
            $('label[for="description"]').text('Description');
            $('label[for="location"]').text('Location');
        } else {
            $('label[for="title"]').text('Įvykio pavadinimas *');
            $('label[for="description"]').text('Aprašymas');
            $('label[for="location"]').text('Vieta');
        }
    });
});