1(function (drupalSettings, Drupal, once) { 2 // Taken from: https://stackoverflow.com/a/47932848 3 function camelToDash(str){ 4 return str.replace(/([A-Z])/g, function($1){return "-"+$1.toLowerCase();}); 5 } 6 7 let hcaptchaReady = false; 8 window.drupalHcaptchaOnload = function() { 9 hcaptchaReady = true; 10 Drupal.behaviors.hcaptcha.attach(); 11 }; 12 13 if (!document.getElementById('hcaptcha-src') && drupalSettings.hcaptcha) { 14 var el = document.createElement('script'); 15 el.type = 'text/javascript'; 16 el.src = drupalSettings.hcaptcha.src; 17 el.id = 'hcaptcha-src'; 18 el.async = true; 19 el.defer = true; 20 document.getElementsByTagName('head')[0].appendChild(el); 21 } 22 23 const renderWidget = function (element) { 24 const config = Object.fromEntries( 25 Object.entries(element.dataset) 26 .map(function (key_val) { return [camelToDash(key_val[0]), key_val[1]]; }) 27 ); 28 hcaptcha.render(element, config); 29 } 30 31 Drupal.behaviors.hcaptcha = { 32 attach: function () { 33 if (!hcaptchaReady) return; 34 once('hcaptcha-rendered', '.h-captcha') 35 .forEach(renderWidget); // Just use renderWidget as callback. 36 } 37 } 38})(drupalSettings, 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.