1/** 2 * SailPlay Async Loader 3 * Loads bonus points data asynchronously to prevent page loading delays 4 */ 5 6jQuery(document).ready(function($) { 7 $('.bonus-toggle').on('click', function (e) { 8 $('.bonus-toggle.open').add(e.target).toggleClass('open'); 9 }); 10 // Check if we're on a page with SailPlay container 11 var $sailplayContainer = $('.sailplay-tokens-container'); 12 if ($sailplayContainer.length === 0) { 13 return; 14 } 15 16 // Show loading state 17 // $sailplayContainer.html('<div class="sailplay-loading"><img src="/images/ajax-load.gif" alt="Loading..." /> ÐагÑÑзка бонÑÑнÑÑ Ð±Ð°Ð»Ð»Ð¾Ð²...</div>'); 18 19 // Load bonus points asynchronously 20 $.ajax({ 21 url: '/index.php?option=com_mindboxapi&task=getPoints', 22 type: 'GET', 23 dataType: 'json', 24 timeout: 10000, // 10 second timeout 25 success: function(response) { 26 if (response.success && response.data) { 27 var tokens = response.data; 28 var html = '<div class="user-bonus-points">' + 29 // '<h3>ÐаÑи бонÑÑнÑе баллÑ</h3>' + 30 '<div class="bonus-points-wrapper">' + 31 '<div class="bonus-points-item">' + 32 '<span class="bonus-points-label">ÐÑего баллов</span>' + 33 '<span class="bonus-points-value">' + tokens.total + '</span>' + 34 '</div>' + 35 '<div class="bonus-points-item">' + 36 '<span class="bonus-points-label">ÐодÑвеÑжденнÑе баллÑ</span>' + 37 '<span class="bonus-points-value">' + tokens.available + '</span>' + 38 '</div>' + 39 '<div class="bonus-points-item">' + 40 '<span class="bonus-points-label">Рожидании</span>' + 41 '<span class="bonus-points-value">' + tokens.blocked + '</span>' + 42 '</div>' + 43 '</div>' + 44 '</div>'; 45 $sailplayContainer.html(html); 46 } else { 47 showError(response.message || 'ÐÑибка загÑÑзки даннÑÑ '); 48 } 49 }, 50 error: function(xhr, status, error) { 51 if (status === 'timeout') { 52 showError('ÐÑевÑÑено вÑÐµÐ¼Ñ Ð¾Ð¶Ð¸Ð´Ð°Ð½Ð¸Ñ Ð¾ÑвеÑа ÑеÑвеÑа'); 53 } else { 54 showError('ÐÑибка ÑÐ¾ÐµÐ´Ð¸Ð½ÐµÐ½Ð¸Ñ Ñ ÑеÑвеÑом'); 55 } 56 } 57 }); 58 59 // Also load history if we're on full history page 60 var $historyContainer = $('.sailplay-history-container'); 61 if ($historyContainer.length > 0) { 62 loadHistory($historyContainer); 63 } 64 65 function showError(message) { 66 $sailplayContainer.html('<div class="sailplay-error">' + message + '</div>'); 67 } 68 69 function loadHistory($container) { 70 $.ajax({
71 url: '/index.php?option=com_mindboxapi&task=getHistory', 72 type: 'GET', 73 dataType: 'json', 74 timeout: 10000, 75 success: function(response) { 76 if (response.success && response.data !== undefined && response.data.history !== undefined) { 77 var html = '' + 78 '<table><thead><th>ÐаÑа</th><th>ÐпиÑание</th><th>ÐоллиÑеÑÑво бонÑÑов</th><th>ÐаÑа подÑвеÑждениÑ</th><th>Ðней до ÑгоÑаниÑ</th></thead><tbody>'; 79 80 response.data.history.forEach(function(item) { 81 const date = new Date(item.date); 82 const date_from = new Date(item.date_from); 83 const date_untill = new Date(item.date_untill); 84 85 const curr = new Date(); 86 const utc1 = Date.UTC(curr.getFullYear(), curr.getMonth(), curr.getDate()); 87 const utc2 = Date.UTC(date_untill.getFullYear(), date_untill.getMonth(), date_untill.getDate()); 88 89 const days_until = item.date_untill !== null ? Math.max(Math.floor((utc2 - utc1) / (1000 * 60 * 60 * 24)), 0) : '—'; 90 91 let row_class; 92 let points = item.points_delta; 93 if (item.points_delta >= 0) { 94 row_class = 'points-row-pos'; 95 points = '+' + item.points_delta 96 } else { 97 row_class = 'points-row-neg'; 98 } 99 100 html += '<tr class="' + row_class + '">' + 101 '<td>' + date.toLocaleString('ru-RU') + '</td>' + 102 '<td>' + item.description + '</td>' + 103 '<td>' + points + '</td>' + 104 '<td>' + date_from.toLocaleString('ru-RU') + '</td>' + 105 '<td>' + days_until + '</td>' + 106 '</tr>'; 107 }); 108 109 html += '</tbody></table>'; 110 $container.html(html); 111 } else { 112 $container.html('<div class="sailplay-error">Ðе ÑдалоÑÑ Ð·Ð°Ð³ÑÑзиÑÑ Ð¸ÑÑоÑиÑ</div>'); 113 } 114 }, 115 error: function() { 116 $container.html('<div class="sailplay-error">ÐÑибка загÑÑзки иÑÑоÑии</div>'); 117 } 118 }); 119 } 120});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.