
    


// Note: This is just the initiator file. It loads certain files for certain domains. It should not be edited. 
// If the A11y fixes are causing interference on any Disney instances, 
// please only edit Accessibility Patch - CSS or Accessibility Patch - JavaScript 

(function() {

  // Get hostname so that we can select between QA and Production scripts.

  var hostName = location.hostname;

  // Need to apply hostName to localHost var so that we can load our script(s) locally.

  var localHost = hostName;

  hostName = hostName.substring(hostName.indexOf(".") + 1);

  var localPaths = localHost === "localhost";
  var testPaths = hostName === "runmytests.com" || hostName === "talentbrew.com" || hostName === "radancy.dev" || hostName === "tmpqa.com";
  
  // Add A11y CSS

  var disneyA11yCSS = document.createElement("link");
  disneyA11yCSS.setAttribute("id", "disney-a11y-css");
  disneyA11yCSS.setAttribute("rel", "stylesheet");

  // Create and add GDPR script

  var disneyA11yJS = document.createElement("script");
  disneyA11yJS.setAttribute("id", "disney-a11y-js");
  
  // Run QA version

  if(testPaths) {

    disneyA11yCSS.setAttribute("href", "https://tbcdn.talentbrew.com/company/391/v3_0/css/a11y-patch.css");
    disneyA11yJS.setAttribute("src", "https://newdisney.runmytests.com/a11y-patch-js/"); 
    
    // For Spell's Testing (uncomment below and comment out above when testing)
    
    // disneyA11yCSS.setAttribute("href", "https://radancy.dev/playground/client/disney/init.css");
    // disneyA11yJS.setAttribute("src", "https://radancy.dev/playground/client/disney/init.js");

  } else {

    // ... else, run the production version
    
    disneyA11yCSS.setAttribute("href", "https://tbcdn.talentbrew.com/company/391/v3_0/css/a11y-patch.css");
    disneyA11yJS.setAttribute("src", "https://jobs.disneycareers.com/a11y-patch-js/");

  }
  
  // Append CSS and Script to DOM.
  
  var a11yPatchCSS = document.getElementById("a11y-patch-css");
  var a11yPatchJS = document.getElementById("a11y-patch-js");
  
  if(!a11yPatchCSS) {

    document.head.appendChild(disneyA11yCSS);
  
  }
  
  if(!a11yPatchJS) {
  
  
    document.body.appendChild(disneyA11yJS);
  
  }

 })();