1/** 2 * EchoAI Frontend Script 3 * 4 * Handles frontend interactions and includes REST API nonce for security 5 */ 6(function($) { 7 'use strict'; 8 9 // Initialize when document is ready 10 $(document).ready(function() { 11 // Store the nonce and API root for secure REST API requests 12 if (typeof echoAISettings !== 'undefined') { 13 // Setup for any AJAX requests to WordPress REST API 14 $.ajaxSetup({ 15 beforeSend: function(xhr) { 16 // Add the nonce to all REST API requests 17 xhr.setRequestHeader('X-WP-Nonce', echoAISettings.nonce); 18 } 19 }); 20 } 21 }); 22 23 /** 24 * Make a secure request to the Echo API 25 * 26 * @param {string} endpoint - The API endpoint to call 27 * @param {Object} data - The data to send 28 * @param {Function} callback - The success callback 29 */ 30 window.echoAISecureRequest = function(endpoint, data, callback) { 31 if (typeof echoAISettings === 'undefined') { 32 console.error('EchoAI settings not available'); 33 return; 34 } 35 36 $.ajax({ 37 url: echoAISettings.root + 'echoai/v1/' + endpoint, 38 method: 'POST', 39 data: data, 40 beforeSend: function(xhr) { 41 xhr.setRequestHeader('X-WP-Nonce', echoAISettings.nonce); 42 }, 43 success: callback, 44 error: function(response) { 45 console.error('EchoAI API Error:', response); 46 } 47 }); 48 }; 49 50})(jQuery);
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.