home.html.jinja2 3.52 KB
{% extends 'layout.html.jinja2' %}
{% set menu_section = 'home' %}
{% block title %}Home{% endblock %}

{% block content %}

<div class="mdl-grid">
  <div class="mdl-cell mdl-cell--4-col">
    <section id="orbits"></section>
    <section id="orbiters_filters">
      <img src="{{ static('img/planet/jupiter_128.png') }}" width="64px" height="64px" alt="Jupiter">
      <img src="{{ static('img/planet/earth_128.png') }}" width="64px" height="64px" alt="Earth (locked)" class="locked">
      <img src="{{ static('img/planet/mars_128.png') }}" width="64px" height="64px" alt="Mars (locked)" class="locked">
    </section>
    <hr class="clear">
    <p>Measures</p>
    <p>Options</p>
  </div>
  <div class="mdl-cell mdl-cell--8-col">
    <section id="time_series"></section>
  </div>
</div>

{% endblock %}


{% block styles %}
  <style>
    html, body {
      background-color: #322e3f;
      color: #e3e3e3;
    }
    .axis path, .axis line {
      fill: none;
      stroke: #f4f4f4;
      shape-rendering: crispEdges;
      stroke-width: 1px;
    }
    svg text {
      fill: #f4f4f4;
    }
    path.line {
      fill: none;
      stroke: steelblue;
      stroke-width: 1px;
    }
    path.orbit.orbit_section {
      fill: none;
      stroke: steelblue;
      stroke-width: 3px;
    }
    ellipse.orbit.orbit_ellipse {
      fill: none;
      stroke: #a3a3a3;
      stroke-width: 1px;
      stroke-dasharray: 5px;
    }
    #orbiters_filters img {
      float: left;
    }
    #orbiters_filters img.locked {
      -webkit-filter: grayscale(100%);
         -moz-filter: grayscale(100%);
           -o-filter: grayscale(100%);
          -ms-filter: grayscale(100%);
              filter: grayscale(100%);
    }

    #orbits {
      background-image: url('{{ static('img/orbitals_background.png') }}');
      background-repeat: repeat;
      background-size: 42%;
    }
  </style>
{% endblock %}


{% block scripts_footer %}
<script type="application/javascript" src="{{ static('js/vendor/d3.min.js') }}"></script>
<script type="application/javascript" src="{{ static('js/swapp.js') }}"></script>
<script type="application/javascript">

// Sorry, no ES6. Feel free to refactor.

var orbiters = {
  jupiter: {
    name: "Jupiter",
    orbit: { a: 5.45516759, b: 4.95155843 },
    img: "{{ static('img/planet/jupiter_128.png') }}"
  }
};

jQuery().ready(function($){
  var timeSeries = [];
  var orbits;

  d3.csv("{{ url_for('get_csv') }}", function(csv){
    var timeFormat = d3.timeParse('%Y-%m-%dT%H:%M:%S%Z');
    var data = {'pdyn': [], 'magn': [], 'vlen': []};
    csv.forEach(function (d) {
      data['pdyn'].push({x: timeFormat(d['time']), y: parseFloat(d['pdyn'])});
      data['magn'].push({x: timeFormat(d['time']), y: parseFloat(d['magn'])});
      data['vlen'].push({x: timeFormat(d['time']), y: parseFloat(d['vlen'])});
    });

    var container = "#time_series";
    timeSeries.push(new TimeSeries(
        'Dynamic Pressure (nPa)', data['pdyn'], container
    ));
    timeSeries.push(new TimeSeries(
        'Magnetism (nT)', data['magn'], container
    ));
    timeSeries.push(new TimeSeries(
        'Velocity (km/s)', data['vlen'], container
    ));

  });

  d3.csv("{{ url_for('get_astral_coordinates_csv') }}", function(csv){
    var data = [];
    csv.forEach(function (d) {
      data.push({x: parseFloat(d['x_hci']), y: parseFloat(d['y_hci'])});
    });

    orbits = new Orbits(orbiters, data, '#orbits');
  });

  window.addEventListener('resize', function() {
    timeSeries.forEach(function(ts){ ts.resize(); });
    orbits.resize();
  });

});
</script>

{% endblock %}