/** * Admin JavaScript for the QDR Temporary Shared Storage plugin */ (function($) { 'use strict'; // Initialize datepickers on dynamically created elements function initDatepickers() { $('.qdr-tss-datepicker').datepicker({ dateFormat: 'yy-mm-dd', changeMonth: true, changeYear: true }); } // Format file size to human readable format function formatFileSize(bytes) { if (bytes === 0) return '0 Bytes'; const k = 1024; const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; const i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]; } // Format date to local format function formatDate(dateString) { if (!dateString || dateString === '0000-00-00 00:00:00') { return '-'; } var date = new Date(dateString); // Check if date is valid if (isNaN(date.getTime())) { return dateString; } return date.toLocaleString(); } // Set active sort indicators function updateSortIndicators(orderBy, order) { // Remove all indicators $('.qdr-tss-table th').removeClass('sorted asc desc'); // Add indicator to current sort column var $th = $('.qdr-tss-table th[data-sort="' + orderBy + '"]'); $th.addClass('sorted ' + order.toLowerCase()); } // Initialize tooltips function initTooltips() { $('.qdr-tss-tooltip').tooltip({ position: { my: 'center bottom-20', at: 'center top', using: function(position, feedback) { $(this).css(position); $('