1/** 2 * @file 3 * Loads the correct Sched.com embed.js for a schedule page. 4 * 5 * Sched's embed.js always targets the same fixed element id (#sched-embed) and 6 * injects its own instance's schedule into it. Loading several instances' 7 * embed.js globally makes them race for that single element, so the wrong 8 * schedule can win. Instead, read the intended instance from the #sched-embed 9 * anchor's href (e.g. //inc522025.sched.com/) and inject only that one script. 10 */ 11(function (Drupal, once) { 12 'use strict'; 13 14 Drupal.behaviors.schedEmbed = { 15 attach: function (context) { 16 once('sched-embed', '#sched-embed', context).forEach(function (el) { 17 if (!el.href) { 18 return; 19 } 20 21 var host = new URL(el.href, window.location.href).hostname; 22 23 // Only ever load scripts from Sched. 24 if (!/\.sched\.com$/.test(host)) { 25 return; 26 } 27 28 var src = '//' + host + '/js/embed.js'; 29 30 // Guard against loading the same instance twice. 31 if (document.querySelector('script[src="' + src + '"]')) { 32 return; 33 } 34 35 var script = document.createElement('script'); 36 script.src = src; 37 script.async = true; 38 document.body.appendChild(script); 39 }); 40 } 41 }; 42})(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.