<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
  <meta name="keywords" content="HAPI Heliophysics Data UI">
  <meta name="description"
    content="HAPI Server UI; https://github.com/hapi-server/server-ui">
  <meta name="keywords"
    content="AMDA, CDAWeb, Cluster Active Archive, INTERMAGNET, LISIRD, SSCWeb, SWARM, Space Weather, ViRES">

  <title>HAPI Server Browser</title>

  <link rel="apple-touch-icon" sizes="180x180"
        href="//hapi-server.org/apple-touch-icon.png">
  <link rel="icon" type="image/png" sizes="32x32"
        href="//hapi-server.org/favicon-32x32.png">
  <link rel="icon" type="image/png" sizes="16x16"
        href="//hapi-server.org/favicon-16x16.png">
  <link rel="manifest"
        href="//hapi-server.org/site.webmanifest">

  <link rel="stylesheet"
        type="text/css" href="css/jquery-ui-1.9.2.custom.css"/>
  <link rel="stylesheet"
        type="text/css" href="css/highlight-10.0.0-github.css"/>

  <link rel="stylesheet" href="css/index.css">

  <script type="text/javascript" 
          src="js/deps/jquery-1.8.3.min.js"></script>
  <script type="text/javascript"
          src="js/deps/jquery-ui-1.9.2.custom.js"></script>
  <script type="text/javascript"
          src="js/deps/jquery.ba-hashchange-1.3.js"></script>

  <script type="text/javascript"
          src="js/deps/highlight-10.0.0.min.js"></script>
  <script type="text/javascript" charset="UTF-8" 
          src="js/deps/highlight-10.0.0-python.min.js"></script>
  <script type="text/javascript" charset="UTF-8" 
          src="js/deps/highlight-10.0.0-matlab.min.js"></script>

  <script>
      hljs.initHighlightingOnLoad();
      hljs.getLanguage('python').keywords += 
            ' hapiplot hapiclient hapi server dataset parameters start stop';
      hljs.getLanguage('matlab').keywords += 
            ' hapiplot hapiclient hapi server dataset parameters start stop';
      hljs.getLanguage('javascript').keywords += 
            ' hapi server dataset parameters start stop';
  </script>

  <script src="js/deps/dayjs-1.8.29/dayjs.min.js"></script>
  <script src="js/deps/dayjs-1.8.29/duration.js"></script>
  <script>
      dayjs.extend(window.dayjs_plugin_duration);
      dayjs().format();
  </script>

  <script type="text/javascript" src="js/deps/clipboard.min.js"></script>

  <script type="text/javascript" src="js/shared/parseAllTxt.js"></script>
  <script type="text/javascript" src="js/shared/createScript.js"></script>
  <script type="text/javascript" src="js/shared/defaultDate.js"></script>

  <script type="text/javascript" src="js/ui/checkboxes.js"></script>
  <script type="text/javascript" src="js/ui/dropdowns.js"></script>
  <script type="text/javascript" src="js/ui/examples.js"></script>
  <script type="text/javascript" src="js/ui/html.js"></script>
  <script type="text/javascript" src="js/ui/tests.js"></script>

  <script type="text/javascript" src="js/output/script.js"></script>
  <script type="text/javascript" src="js/output/plot.js"></script>
  <script type="text/javascript" src="js/output/data.js"></script>

  <script type="text/javascript" src="scripts/_scriptList.js"></script>

  <script type="text/javascript" src="js/util.js"></script>
  <script type="text/javascript" src="js/hash.js"></script>
  <script type="text/javascript" src="js/query.js"></script>
  <script type="text/javascript" src="js/timer.js"></script>
  <script type="text/javascript" src="js/get.js"></script>
  <script type="text/javascript" src="js/index.js"></script>

  <script>
    let SERVER_LIST = '__SERVER_LIST__';
    let VERIFIER    = '__VERIFIER__';
    let PLOTSERVER  = '__PLOTSERVER__';
    let PROXYSERVER = '__PROXYSERVER__';

    function serverList(url) {
      return url.startsWith('__') ? "all.txt" : url;
    }

    function proxyServerURL(url) {
      if (url.startsWith('__')) {
        return "https://hapi-server.org/servers/proxy?url=";
      }
      return url;
    }

    function verifierURL(url) {
      if (url.startsWith('__')) {
        url = "https://hapi-server.org/verify";
        if (location.href.match("//localhost")) {
          url = "http://localhost:9999";
        }
      }
      return url;
    }

    function plotServerURL(url) {
      if (url.startsWith('__')) {
        url = "https://hapi-server.org/plot";
        if (location.href.match("//localhost")) {
          url = "http://localhost:5000";
        }
      }
    }

    window["HAPIUI"] = 
      {
        "options": {
          "serverList": serverList(SERVER_LIST),
          "serverListFallback": "https://hapi-server.org/all_.txt",

          "plotserver": plotServerURL(PLOTSERVER),
          "verifier": verifierURL(VERIFIER),
          "proxy": proxyServerURL(PROXYSERVER), // false => no proxy

          "metadataTimeout": 10000,
          "allTimeout": 5000,

          "dataTimeout": 20000,
          "timingUpdateInterval": 500,

          "devNote": location.href.match("hapi-server.org/servers-dev") ? "Development server.<br>." : "",

          "hapiplot": "https://hapi-server.org/plot/",
          "autoplot": "https://jfaden.net/AutoplotServlet/SimpleServlet",
          "cdawebplot": "https://cdaweb.gsfc.nasa.gov/WS/cdasr/1/dataviews/sp_phys/datasets",

          "urlwatcher": "https://hapi-server.org/urlwatcher/",
          "allowAllParameters": true
        }
      }

    $(function() {
      main(); // DOM is loaded. Call main() in js/index.js.
    })
  </script>
</head>

<body>

  <div id="selections">

    <!-- Left column -->
    <div id="dropdowns">
    </div>
    <button id="clear" class="simple" type="button" title="Clear all selections">
      Clear
    </button>

    <br>
    <br>

    <details id="options-details">
      <summary>
        <span>Options</span>
      </summary>
      <div id="optionscheckboxes">
        <div title="When requesting data, show data in browser instead of only providing a download link.">
          <div style="margin-top: 0.5em; font-weight: bold;">Show</div>
          <label>
            <input id="showdata" type="checkbox" value="">
              &nbsp;data
          </label>
        </div>

        <div title="Generate and show example queries">
          <label>
            <input id="showexamplequeries" type="checkbox" value="">
            &nbsp;example queries
          </label>
        </div>

        <div title="Keep requested URLs in view after request has succeeded.">
          <label>
            <input id="showrequests" type="checkbox" value="">
            &nbsp;requested URLs
          </label>
        </div>

        <div title="Show link to server status monitoring results (for debugging server responses)">
            <label>
                <input id="showstatuslink" type="checkbox" value="">
                &nbsp;server status link
            </label>
        </div>

        <div title="Show verifier links (for debugging server responses)">
            <label>
                <input id="showverifierlink" type="checkbox" value="">
                &nbsp;verifier links
            </label>
        </div>

        <div title="Show TestData servers (for testing clients)">
            <label>
                <input id="showtestdatalink" type="checkbox" value="">
                &nbsp;test servers
            </label>
        </div>

        <div title="Show debug statements in console.">
          <label>
            <input id="showconsolemessages" type="checkbox" value="">
            &nbsp;logging in console
          </label>
        </div>

        <div title="Show UI test links.">
          <label>
            <input id="showuitests" type="checkbox" value="">
            &nbsp;UI test links
          </label>
        </div>

        <br>

        <div title="Use cached images from plot server if available.">
          <label>
            <input id="useimagecache" type="checkbox" value="">
              &nbsp;Use cached images
          </label>
        </div>

        <div title="Use cached data from plot server if available.">
          <label>
            <input id="usedatacache" type="checkbox" value="">
            &nbsp;Use cached data for images
          </label>
        </div>
      </div>
      <button id="reset-options" class="simple" type="button" title="Select defaults">
        Reset options
      </button>
    </details>

    <div id="logo">
      <a href="https://hapi-server.org">
        <img src="https://hapi-server.github.io/logos/HAPI-bw.svg" alt="HAPI Logo"/></a>
    </div>

    <div id="footer">
      <a href="https://github.com/hapi-server/server-ui" style="text-decoration:none">
        <img src="css/images/github-mark.svg" alt="GitHub logo" height="24px"/>
      </a>
      <details id="developer-details" closed>
        <summary>API</summary>
        <p>
          The <code>parameters</code> argument may be omitted in the hash fragment
          (<a href="#server=TestData2.0&dataset=dataset1&parameters=&start=1970-01-01Z&stop=1970-01-01T00:00:11Z&return=data&format=csv&style=noheader">example</a>).
        </p>
        <p>
          A server URL may be used instead of a server id
          (<a href="#server=https://hapi-server.org/servers/TestData3.1/hapi">example</a>)
          provided the server supports
          <a href="https://github.com/hapi-server/data-specification/blob/master/hapi-dev/HAPI-data-access-spec-dev.md#5-cross-origin-resource-sharing">
            CORS.
          </a>
        </p>
        <p>
          Auto-generated scripts are available from an <a href="/api">API</a>.
        </p>
        <br>
      </details>
    </div>


  </div>

  <!-- Main column -->
  <div id="infodiv">

    <div id="appError">
    </div>

    <div id="appWarning">
    </div>

    <div id="getStatus">
      <div id="allRequestError" class="requestError"></div>
      <div id="allRequestWarning" class="requestWarning"></div>
      <div id="datasetsRequestError" class="requestError"></div>
      <div id="dataRequestError" class="requestError"></div>
    </div>

    <div id="uitests">
      <details id="uitests-details" open>
        <summary>
          <b>UI Test Queries</b>
        </summary>
        <div id="uitests-details-body"></div>
        <!--button id="tests-run" class="simple" type="button" title="run tests">
          Execute all tests
        </button-->
      </details>
      <pre id="uitests-output"></pre>
    </div>

    <div id="overviewinfo">
      <b>Overview</b>
      <p>
        The Heliophysics Data Application Programmer's Interface 
        (<a href="https://hapi-server.org/">HAPI</a>) 
        specification is a time series download and streaming format specification.
      </p>
      <p>
        When data are available from a HAPI server, there is no need to download data files and write custom file reader programs. Using a HAPI client library, data can be loaded into an array using a single command in IDL, Javascript, MATLAB, and Python.
      </p>
      <p>
        Space Weather-related data are available through this interface and HAPI software from
        <a  href="http://amda.irap.omp.eu/"
            title="CDPP's Automated Multi-Dataset Analysis">
          AMDA
        </a>,
        <a  href="https://sci.esa.int/web/cluster/"
            title="ESA's Cluster Active Archive">
          CAA
        </a>, 
        <a  href="https://ccmc.gsfc.nasa.gov/"
            title="NASA's Community Coordinated Modeling Center">
          CCMC
        </a>, 
        <a  href="https://cdaweb.gsfc.nasa.gov/"
            title="NASA's Coordinated Data Analysis Web Services">
          CDAWeb</a>, 
        <a  href="https://das2.org/"
            title="University of Iowa's Data Access System, v2">
          DAS2</a>, 
        <a  href="https://intermagnet.org/"
            title="International Real-time Magnetic Observatory Network">
          INTERMAGNET</a>,
	KNMI,
        <a  href="https://intermagnet.org/"
            title="UC Boulder's LASP Interactive Solar Irradiance Data Center">
          LISIRD</a>, 
        <a  href="https://sscweb.gsfc.nasa.gov/"
            title="NASA's Satellite Situation Center Web Services">
          SSCWeb</a>, and 
        <a  href="https://vires.services/"
            title="Virtual Research Service for ESA's Swarm mission">
          ViRES</a>.
      </p>

      <p>
        <span>
          <span id="nServers"></span>
          <span id="nServersText">HAPI servers are available from this interface.</span>
        </span>
        <span id="allRequestInfo" class="requestInfo">
          <span id="allRequestURL" class="requestURL"></span>
          <span id="allRequestTiming" class="requestTime"></span>
        </span>
      </p>

      <ul id="overviewul">
        <li>
          Use this interface to 
          <ul>
            <li>
              generate a 
              <a title="Heliphysics Data Application Interface: https://hapi-server.org/"
                 href="https://hapi-server.org/">HAPI
              </a>
              URL to download data,
            </li>
            <li>
              plot data from a HAPI server, and
            </li>
            <li>generate scripts (with install instructions) that read and plot the selected parameter using HAPI clients for

              <code>cURL</code> / 

              <a title="https://github.com/hapi-server/client-idl"
                 href="https://github.com/hapi-server/client-idl">IDL</a> / 

              <a title="https://github.com/hapi-server/client-idl"
                 href="https://github.com/hapi-server/client-idl">IDL SPEDAS</a> / 

              <a title="https://github.com/hapi-server/client-javascript"
                 href="https://github.com/hapi-server/client-javascript">Javascript</a> /

              <a title="https://github.com/hapi-server/client-matlab"
                 href="https://github.com/hapi-server/client-matlab">MATLAB</a> /

              <a title="https://github.com/hapi-server/client-python"
                 href="https://github.com/hapi-server/client-python">Python</a> / 

              <a title="https://github.com/spedas/pyspedas"
                 href="https://github.com/spedas/pyspedas">Python SPEDAS</a> / 

              <a title="https://nasa.github.io/Kamodo"
                 href="https://nasa.github.io/Kamodo/">Python Kamodo</a> / 

              <code>Wget</code>.

              Example scripts can be created using links in "Example Queries".
            </li>
          </ul>
        </li>
        <li>
          Begin by selecting a HAPI-enabled data server on the left or selecting an example query below.
        </li>
      </ul>
    </div>

    <details id="all-example-details">
      <summary>
        <b><span id="selected-server"></span>Example Queries</b>
      </summary>
      <br>
      <div id="all-example-details-body"></div>
    </details>

    <div id="output">

      <details id="plot-details" open>
        <summary>
          <span id="plot-summary">Plot</span>
          &nbsp;|&nbsp;
          <span id="imageRequestTiming" class="requestTime"></span>
        </summary>
        <div>
          <span id="plot-downloadlink" style="display:none;"></span>
        </div>
        <div id="plotRequestWarning" class="requestWarning"></div>
        <div id="plotRequestError" class="requestError"></div>
        <div id="image">
        </div>
      </details>

      <details id="data-details" open>
        <summary>
          Data&nbsp;
          <span class="requestInfo">
            <span id="dataRequestURL" class="requestURL"></span>
            <span id="dataRequestTiming" class="requestTime"></span>
          </span>
        </summary>
        <div>
          <span id="data-downloadlink" style="display:none;"></span>
          <code id="data-records-and-size">&nbsp;</code>
        </div>
        <textarea id="data" class="data" readonly></textarea>
      </details>

      <details id="json-details" open>
        <summary>
          JSON
        </summary>
        <div>
          <span id="json-downloadlink" style="display:none;"></span>
        </div>
        <div id="jsontext" class="json" readonly>
          <code id="json"></code>
        </div>
      </details>

      <details id="script-details" open>
        <summary>Script</summary>
        <div>
          <span id="script-downloadlink" style="display:none;"></span>
        </div>
        <div id="scriptcopy" title="Copy to clipboard">
          <button type="button" class="btn" style="padding:0px;" data-clipboard-text="">
            <img class="clippy" width="20" src="css/clippy.png" alt="Copy to clipboard">
          </button>
          <span id="copied" title="Copied!"></span>
        </div>
        <div id="scripttext" class="data" readonly>
          <code id="script"></code>
        </div>
      </details>

    </div>

    <div id="serverinfo">
      <b>Server information</b>
      <p>
        <span>
          <span id="nDatasets"></span>
        </span>
        <div class="requestInfo">
          <div>
            <span id="catalogRequestURL" class="requestURL"></span>
            <span id="catalogRequestTiming" class="requestTime"></span>
          </div>
          <div>
            <div id="aboutRequestWarning" class="requestWarning"></div>
            <span id="aboutRequestURL" class="requestURL"></span>
            <span id="aboutRequestTiming" class="requestTime"></span>
          </div>
        </div>
      </p>
      <ul></ul>
    </div>

    <div id="datasetinfo">
      <b>Dataset information</b>
      <p>
        <span id="nParameters"></span>
        <div class="requestInfo">
          <span id="parametersRequestURL" class="requestURL"></span>
          <span id="parametersRequestTiming" class="requestTime"></span>
          <div id="parametersRequestError" class="requestError"></div>
        </div>
        <div class="requestInfo">
          <span id="urlwatcherRequestURL" class="requestURL"></span>
          <span id="urlwatcherRequestTiming" class="requestTime"></span>
          <span id="urlwatcherRequestError" class="requestTime"></span>
        </div>
      </p>
      <ul></ul>
    </div>

    <div id="parameterinfo">
      <b>Parameter information</b>
      <ul></ul>
    </div>

  </div>

</body>

</html>