{% if is_eol %}
{# Creates a banner at the top of the page for EOL versions. #}
<div id='banner' class='Admonition caution'>
  <p>You are reading an unmaintained version of the Ansible community documentation. Unmaintained Ansible versions can contain security vulnerabilities (CVEs). Please upgrade to a maintained version. See <a href="/ansible/latest/">the latest Ansible documentation</a>. Note that this statement does not apply to Red Hat Ansible Automation Platform subscriptions. See the <a href="https://access.redhat.com/support/policy/updates/ansible-automation-platform">Ansible Automation Platform Life Cycle</a>.</p>
</div>
{% else %}
  <script>
    function startsWith(str, needle) {
      return str.slice(0, needle.length) == needle
    }
    function startsWithOneOf(str, needles) {
      return needles.some(function (needle) {
        return startsWith(str, needle);
      });
    }
    var banner = '';
      /*use extra_banner for when we want something extra, like a survey or Community Day notice */
      var extra_banner = '';
    
      var extra_banner =
      '<div id="latest_extra_banner_id" class="admonition important">' +
        '<p style="padding-bottom: 1.2rem;text-align: center;">' +
        'Slides for those who attended AnsibleFest at <a href="https://www.redhat.com/en/summit?sc_cid=RHCTG1250000442936">Red Hat Summit</a> will be available soon.' +
        '</p>' +
      '</div>';
    
    // Create a banner if we're not on the official docs site
    if (location.host == "docs.testing.ansible.com") {
      document.write('<div id="testing_banner_id" class="admonition important">' +
                     '<p>This is the testing site for Ansible Documentation. Unless you are reviewing pre-production changes, please visit the <a href="https://docs.ansible.com/ansible/latest/">official documentation website</a>.</p> <p></p>' +
                     '</div>');
    }
    {% if available_versions is defined %}
      // Create a banner
      current_url_path = window.location.pathname;

      var important = false;
      var msg = '<p>';
      if (startsWith(current_url_path, "/ansible-core/")) {
        msg += 'You are reading documentation for Ansible Core, which contains no plugins except for those in ansible.builtin. For documentation of the Ansible package, go to <a href="/ansible/latest">the latest documentation</a>.';
        /* temp - add extra warning about core-2.19. This should move to latest at release time */
        msg += '<br><p><strong>Important:</strong> The ansible-core 2.19 release has made <b>significant templating changes that might require you to update playbooks and roles</b>. The templating changes enable reporting of numerous problematic behaviors that went undetected in previous releases, with wide-ranging positive effects on security, performance, and user experience. You should validate your content to ensure compatibility with these templating changes before upgrading to ansible-core 2.19. See the <a href="https://docs.ansible.com/ansible/devel/porting_guides/porting_guide_12.html">porting guide</a> to understand where you may need to update your playbooks and roles.';
      } else if (startsWithOneOf(current_url_path, ["/ansible/latest/", "/ansible/{{ latest_version }}/"])) {
        /* temp extra banner to advertise something */
        banner += extra_banner;

        msg += 'This is the <b>latest</b> (stable) Ansible community documentation. For Red Hat Ansible Automation Platform subscriptions, see <a href="https://access.redhat.com/support/policy/updates/ansible-automation-platform">Life Cycle</a> for version details.';
      } else if (startsWith(current_url_path, "/ansible/2.9/")) {
        msg += 'You are reading the latest Red Hat released version of the Ansible documentation. Community users can use this version, or select <b>latest</b> from the version selector to the left for the most recent community version.';
      } else if (startsWith(current_url_path, "/ansible/devel/")) {
        /* temp extra banner to advertise something */
        banner += extra_banner;

        msg += 'You are reading the <b>devel</b> version of the Ansible documentation - this version is not guaranteed stable. Use the version selection to the left if you want the <b>latest</b> (stable) released version.';
      } else {
        msg += 'You are reading an older version of the Ansible documentation. Use the version selection to the left if you want the <b>latest</b> (stable) released version.';
        /* temp extra banner to advertise something - this is for testing*/
        banner += extra_banner;

      }
      msg += '</p>';

      banner += '<div id="banner_id" class="admonition ';
      banner += important ? 'important' : 'caution';
      banner += '">';
      banner += important ? '<br>' : '';
      banner += msg;
      banner += important ? '<br>' : '';
      banner += '</div>';
      document.write(banner);
    {% endif %}
  </script>
{% endif %}
