<!--
  ============LICENSE_START==========================================
  ONAP Portal
  ===================================================================
  Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
  ===================================================================
 
  Unless otherwise specified, all software contained herein is licensed
  under the Apache License, Version 2.0 (the "License");
  you may not use this software except in compliance with the License.
  You may obtain a copy of the License at
 
              http://www.apache.org/licenses/LICENSE-2.0
 
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
 
  Unless otherwise specified, all documentation contained herein is licensed
  under the Creative Commons License, Attribution 4.0 Intl. (the "License");
  you may not use this documentation except in compliance with the License.
  You may obtain a copy of the License at
 
              https://creativecommons.org/licenses/by/4.0/
 
  Unless required by applicable law or agreed to in writing, documentation
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
 
  ============LICENSE_END============================================
 
  
  -->
<!doctype html>
<html lang="en">
<head>
<script>
        __Zone_enable_cross_context_check = true;
        function nthIndex(str, pat, n) {
          var L = str.length, i = -1;
          while (n-- && i++ < L) {
            i = str.indexOf(pat, i);
            if (i < 0) break;
          }
          return i;
        }
        function addBaseHref(base) {
          //document.write("<base href='" + base + "' />");
          baseNode=document.createElement('base');
          baseNode.href=base;

          //document.getElementsByTagName('head')[0].appendChild(baseNode);
          var head = document.getElementsByTagName('head')[0];
          head.insertBefore(baseNode,head.childNodes[0] || null);
          window.base = base;
        }
        if (window.location.href.includes('webtest.csp.att.com') || window.location.href.includes('www.e-access.att.com') || window.location.href.includes('ecomp.e-access.att.com')) {
          //change to webjuction context
          var base = window.location.pathname.substring(0, nthIndex(window.location.pathname, "/", 3) + 1);
          //document.write("<base href='/ecompportal/ecompportal/' />");
          addBaseHref(base);

        } else {
          //not webjunction
          var base = window.location.pathname.substring(0, nthIndex(window.location.pathname,"/", 1) + 1);
          //document.write("<base href='/ecompportal/' />");
          addBaseHref(base);

        }
      </script>
  <meta charset="utf-8">
  <title>ONAP Portal</title>
  <base href="/">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <link rel="stylesheet" href="styles.19ce2a92d11ceb6c5db4.css">
</head>
<body>
  <app-root>Loading...</app-root>
  <script>
      __Zone_enable_cross_context_check = true;
      </script>
</body>
</html>
