Chris@0: /** Chris@0: * @file Chris@0: * Parse inline JSON and initialize the drupalSettings global object. Chris@0: */ Chris@0: Chris@17: (function() { Chris@0: // Use direct child elements to harden against XSS exploits when CSP is on. Chris@17: const settingsElement = document.querySelector( Chris@17: 'head > script[type="application/json"][data-drupal-selector="drupal-settings-json"], body > script[type="application/json"][data-drupal-selector="drupal-settings-json"]', Chris@17: ); Chris@0: Chris@0: /** Chris@0: * Variable generated by Drupal with all the configuration created from PHP. Chris@0: * Chris@0: * @global Chris@0: * Chris@0: * @type {object} Chris@0: */ Chris@0: window.drupalSettings = {}; Chris@0: Chris@0: if (settingsElement !== null) { Chris@0: window.drupalSettings = JSON.parse(settingsElement.textContent); Chris@0: } Chris@17: })();