1(function (Drupal, once) { 2 Drupal.behaviors.audio_counter = { 3 attach: function (context, settings) { 4 const getCsrfToken = async () => { 5 try { 6 const response = await fetch(Drupal.url('session/token')); 7 const token = await response.text(); 8 return token; 9 } catch (error) { 10 console.log('There was an error', error); 11 } 12 } 13 14 const postAudioPlayerCounter = async (url, token, object) => { 15 try { 16 const response = await fetch(url + '/entity/audio_player_counter?_format=json', { 17 method: "POST", 18 body: JSON.stringify(object), 19 headers: { 20 "Content-Type": "application/json", 21 'X-CSRF-Token': token 22 } 23 }); 24 return response.json(); 25 } catch (error) { 26 console.log('There was an error', error); 27 } 28 } 29 30 once('counter', context.querySelector('.mejs__play > button'), context).forEach(el => { 31 el.addEventListener('click', async (e) => { 32 let audioPlayerState = e.currentTarget.title; 33 let uid = drupalSettings.audioPlayerCounterUid; 34 let content = drupalSettings.audioPlayerCounterContent; 35 let url = drupalSettings.audioPlayerCounterUrl; 36 let ip = drupalSettings.audioPlayerCounterIp; 37 let audioPlayerCounterData = { 38 uid: [{ 39 target_id: uid 40 }], 41 content: [{ 42 target_id: content 43 }], 44 type: [{ 45 value: audioPlayerState 46 }], 47 ip: [{ 48 value: ip 49 }] 50 }; 51 let token = await getCsrfToken(); 52 let data = await postAudioPlayerCounter(url, token, audioPlayerCounterData); 53 }); 54 }); 55 } 56 }; 57})(Drupal, once);
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.