1function k2block(blockClassName, callbackFunction) { 2 let identifier = blockClassName; 3 let blocks = null; 4 5 if (identifier.includes("/")) { 6 blocks = document.querySelectorAll(`[data-k2="${blockClassName}"]`); 7 } else { 8 /* old and deprecated way, but needed for backwards compatibility */ 9 blocks = document.querySelectorAll(`.${blockClassName}`); 10 11 if (blockClassName.startsWith("k2-")) { 12 identifier = "k2/" + blockClassName.substring(3); 13 } 14 } 15 16 const hasJQuery = window.k2_frontend_blocks?.[identifier]?.libraries?.includes("jquery"); 17 18 blocks.forEach((blockElement) => { 19 const props = { 20 className: blockClassName, 21 block: blockElement, 22 $: (..._) => console.error("k2block: jquery is not enabled for", blockClassName, "block"), 23 }; 24 25 if (hasJQuery) { 26 jQuery(document).ready(function ($) { 27 props.$ = $; 28 callbackFunction(props); 29 }); 30 } else { 31 callbackFunction(props); 32 } 33 34 }); 35}
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.