1// Function for sending data 2function sendDataAccessibleWP() { 3 // Creating an object to send 4 const eventData = { 5 events: [ { 6 "event": "Accessibility-Toolbar-click", 7 "content": "user click Accessibility Toolbar button", 8 "siteUrl": AccessibleWPData.siteUrl, 9 } ] 10 11 }; 12 13 // Converting Data to JSON String 14 const jsonData = JSON.stringify(eventData); 15 16 // Sending a request using the Fetch API 17 fetch('https://api.userway.org/api/abn/events', { 18 method: 'POST', 19 headers: { 20 'Content-Type': 'application/json', 21 }, 22 body: jsonData, 23 }) 24 .then(response => { 25 if (!response.ok) { 26 throw new Error('An error occurred while executing the request: ${response.statusText}'); 27 } 28 return response.json(); 29 }) 30 .then(data => { 31 // Handling a successful response from the server 32 console.log('Response from the server:', data); 33 }) 34 .catch(error => { 35 // Error processing 36 console.error('An error has occurred:', error.message); 37 }); 38} 39 40// Attach the function to the button's click event 41document.addEventListener('DOMContentLoaded', (event) => { 42 const wpButton = document.getElementById('acwp-toolbar-btn'); 43 if (wpButton) { 44 wpButton.addEventListener('click', sendDataAccessibleWP); 45 } else { 46 console.error('Button with ID "plugin-button-notice" not found.'); 47 } 48}); 49 50 51 52 53 54 55 56 57 58 59 // Function for sending data page first time load 60function sendDataPageLoad() { 61 // Creating an object to send 62 const eventData = { 63 events: [{ 64 "event": "Accessibility-Page-load", 65 "content": "Page load with AccessibleWP widget", 66 "siteUrl": AccessibleWPData.siteUrl, 67 }] 68 }; 69 70 // Converting Data to JSON String 71 const jsonData = JSON.stringify(eventData); 72 73 // Sending a request using the Fetch API 74 fetch('https://api.userway.org/api/abn/events', { 75 method: 'POST', 76 headers: { 77 'Content-Type': 'application/json', 78 }, 79 body: jsonData, 80 }) 81 .then(response => { 82 if (!response.ok) { 83 throw new Error(`An error occurred while executing the request: ${response.statusText}`); 84 } 85 return response.json(); 86 }) 87 .then(data => { 88 // Handling a successful response from the server 89 console.log('Response from the server:', data); 90 }) 91 .catch(error => { 92 // Error processing 93 console.error('An error has occurred:', error.message); 94 }); 95} 96 97// Function to check if it's the first page load in the session 98function checkFirstLoadAndSendData() { 99 // Check if the data has already been sent in this session 100 if (!sessionStorage.getItem('dataSent')) { 101 // If not, send the data and set the flag 102 sendDataPageLoad(); 103 sessionStorage.setItem('dataSent', 'true'); 104 } 105} 106 107// Attach the function to the document's load event 108document.addEventListener('DOMContentLoaded', (event) => { 109 // Send data on first page load in the session 110 checkFirstLoadAndSendData(); 111}); 112
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.