Blame view

web/view/home.html.jinja2 7.52 KB
9390ec89   Goutte   Initial experimen...
1
2
3
4
5
6
{% extends 'layout.html.jinja2' %}
{% set menu_section = 'home' %}
{% block title %}Home{% endblock %}

{% block content %}

4cf497e0   Goutte   Make the targets ...
7
8
9
10
11
12
13
14
15
16
{% macro target_button(target) -%}
    <img width="64px" height="64px"
         src="{{ static('img/target/'~target.slug~'_128.png') }}"
         title="{{ target.title }}"
         alt="{{ target.name }}"
         class="target {{ 'locked' if target.locked else 'active' }}"
         data-target-slug="{{ target.slug }}"
    >
{%- endmacro %}

f6ed8d85   Goutte   Rework layout as ...
17
18
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-drawer">

f6ed8d85   Goutte   Rework layout as ...
19
  <div class="mdl-layout__drawer">
ae0aa7d2   Goutte   Add an x axis lab...
20
    <span class="mdl-layout-title">Planets</span>
f6ed8d85   Goutte   Rework layout as ...
21

4cf497e0   Goutte   Make the targets ...
22
23
24
    <section class="orbiters_filters">
{% for target in planets %}
      {{ target_button(target) }}
a79c5268   Goutte   Add probes and co...
25
{% endfor %}
c42fea3a   Goutte   Rework the CSS wi...
26
    </section>
a79c5268   Goutte   Add probes and co...
27
28
29
30

    <br>
    <hr class="clear">

4cf497e0   Goutte   Make the targets ...
31
    <span class="mdl-layout-title">Probes &amp; Comets</span>
a79c5268   Goutte   Add probes and co...
32

4cf497e0   Goutte   Make the targets ...
33
34
35
    <section class="orbiters_filters">
{% for target in probes %}
      {{ target_button(target) }}
a79c5268   Goutte   Add probes and co...
36
{% endfor %}
4cf497e0   Goutte   Make the targets ...
37
38
{% for target in comets %}
      {{ target_button(target) }}
a79c5268   Goutte   Add probes and co...
39
40
41
{% endfor %}
    </section>

b550c2b0   Goutte   Rework the home s...
42
    <br>
c42fea3a   Goutte   Rework the CSS wi...
43
    <hr class="clear">
b550c2b0   Goutte   Rework the home s...
44
45
46
47

    <span class="mdl-layout-title">Parameters</span>

    <nav id="parameters" class="mdl-navigation">
b7fe650c   Goutte   Misc bundle of ol...
48
49
50
51
52
53
      <a class="mdl-navigation__link parameter active" data-ts-slug="pdyn" href="#">Dynamic Pressure</a>
      <a class="mdl-navigation__link parameter" data-ts-slug="magn" href="#">B Tangential</a>
      <a class="mdl-navigation__link parameter" data-ts-slug="vlen" href="#">Velocity</a>
      <a class="mdl-navigation__link parameter" data-ts-slug="temp" href="#">Temperature</a>
      <a class="mdl-navigation__link parameter" data-ts-slug="dens" href="#">Density</a>
      <a class="mdl-navigation__link parameter" data-ts-slug="angl" href="#">Angle Source-Sun-Earth</a>
b550c2b0   Goutte   Rework the home s...
54
55
    </nav>

c42fea3a   Goutte   Rework the CSS wi...
56
  </div>
b7fe650c   Goutte   Misc bundle of ol...
57
  <main id="plots_wrapper" class="mdl-layout__content">
9390ec89   Goutte   Initial experimen...
58

b550c2b0   Goutte   Rework the home s...
59
60
61
62
63
64
65
66
67
    <div class="mdl-grid">
      <div class="mdl-cell mdl-cell--4-col">
        <section id="orbits"></section>
      </div>
      <div class="mdl-cell mdl-cell--8-col">
        <section id="time_series"></section>
      </div>
    </div>

ae0aa7d2   Goutte   Add an x axis lab...
68
{#    <div class="loader"><div class="hole"></div></div>#}
f6ed8d85   Goutte   Rework layout as ...
69
70
  </main>
</div>
9390ec89   Goutte   Initial experimen...
71
72
73
{% endblock %}


7d6dee0f   Goutte   Continue refacto ...
74

9390ec89   Goutte   Initial experimen...
75
76
{% block styles %}
  <style>
c42fea3a   Goutte   Rework the CSS wi...
77
    html, body {
f6ed8d85   Goutte   Rework layout as ...
78
79
{#      background-color: #322e3f;#}
{#      color: #e3e3e3;#}
c42fea3a   Goutte   Rework the CSS wi...
80
    }
18f38374   Goutte   Crisp edges for a...
81
82
    .axis path, .axis line {
      fill: none;
f6ed8d85   Goutte   Rework layout as ...
83
{#      stroke: #f4f4f4;#}
18f38374   Goutte   Crisp edges for a...
84
85
86
      shape-rendering: crispEdges;
      stroke-width: 1px;
    }
c42fea3a   Goutte   Rework the CSS wi...
87
    svg text {
f6ed8d85   Goutte   Rework layout as ...
88
{#      fill: #f4f4f4;#}
c42fea3a   Goutte   Rework the CSS wi...
89
    }
9390ec89   Goutte   Initial experimen...
90
91
92
93
94
    path.line {
      fill: none;
      stroke: steelblue;
      stroke-width: 1px;
    }
81c9b2e8   Goutte   Add the values to...
95
    circle.cursor-circle {
b550c2b0   Goutte   Rework the home s...
96
97
98
99
100
101
102
103
      fill: black;
      stroke: rgba(20, 20, 20, 0.48);
    }
    text.cursor-text {
{#      font-family: 'Ubuntu', 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva', 'Verdana', sans-serif;#}
{#      font-family: 'Consolas', 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace;#}
      font-family: "Ubuntu Mono", 'Consolas', 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
      text-align: right;
81c9b2e8   Goutte   Add the values to...
104
105
106
    }
    text.cursor-text-shadow {
      stroke: white;
b550c2b0   Goutte   Rework the home s...
107
108
      stroke-width: 5px;
      opacity: 0.777
81c9b2e8   Goutte   Add the values to...
109
    }
c42fea3a   Goutte   Rework the CSS wi...
110
    path.orbit.orbit_section {
2d2af24b   Goutte   Add a basic orbit...
111
112
      fill: none;
      stroke: steelblue;
c42fea3a   Goutte   Rework the CSS wi...
113
114
115
116
117
118
119
120
      stroke-width: 3px;
    }
    ellipse.orbit.orbit_ellipse {
      fill: none;
      stroke: #a3a3a3;
      stroke-width: 1px;
      stroke-dasharray: 5px;
    }
4cf497e0   Goutte   Make the targets ...
121
    .orbiters_filters {
a79c5268   Goutte   Add probes and co...
122
123
      padding-left: 17px;
    }
4cf497e0   Goutte   Make the targets ...
124
    .orbiters_filters .target {
c42fea3a   Goutte   Rework the CSS wi...
125
      float: left;
4cf497e0   Goutte   Make the targets ...
126
      cursor: pointer;
c42fea3a   Goutte   Rework the CSS wi...
127
    }
4cf497e0   Goutte   Make the targets ...
128
    .orbiters_filters .target:not(.active) {
c42fea3a   Goutte   Rework the CSS wi...
129
130
131
132
133
134
      -webkit-filter: grayscale(100%);
         -moz-filter: grayscale(100%);
           -o-filter: grayscale(100%);
          -ms-filter: grayscale(100%);
              filter: grayscale(100%);
    }
4cf497e0   Goutte   Make the targets ...
135
136
137
    .orbiters_filters .target.locked {
      cursor: not-allowed;
    }
c42fea3a   Goutte   Rework the CSS wi...
138
139

    #orbits {
f6ed8d85   Goutte   Rework layout as ...
140
141
142
{#      background-image: url('{{ static('img/orbitals_background.png') }}');#}
{#      background-repeat: repeat;#}
{#      background-size: 42%;#}
2d2af24b   Goutte   Add a basic orbit...
143
    }
6f9a3852   Goutte   Hide time series ...
144
145
146
147
148
149
150

    #parameters .parameter {
      outline: 0;
    }
    #parameters .parameter.active {
      background-color: #c8d3e1;
    }
4cf497e0   Goutte   Make the targets ...
151
152
153
  #time_series svg {
    cursor: crosshair;
  }
9390ec89   Goutte   Initial experimen...
154
155
156
157
  </style>
{% endblock %}


7d6dee0f   Goutte   Continue refacto ...
158

9390ec89   Goutte   Initial experimen...
159
{% block scripts_footer %}
84cb553d   Goutte   Move to material ...
160
<script type="application/javascript" src="{{ static('js/vendor/d3.min.js') }}"></script>
438929a4   Goutte   Rewrite the orbit...
161
<script type="application/javascript" src="{{ static('js/swapp.js') }}"></script>
9390ec89   Goutte   Initial experimen...
162
163
<script type="application/javascript">

ae0aa7d2   Goutte   Add an x axis lab...
164
165
166
var configuration = {
  time_series_container: '#time_series',
  orbits_container: '#orbits',
f75faf5f   Goutte   WIP
167
168
169
170
  api : {
      'data_for_interval': "{{ request.url_root }}<source>/data.csv"
                           // ?started_at=<started_at>&stopped_at=<stopped_at>
  },
8bd715ad   Goutte   Use a pixel art i...
171
172
173
  sun: {
    img: '{{ static('img/sun_128.png') }}'
  },
ae0aa7d2   Goutte   Add an x axis lab...
174
  sources : {
a21f81d9   Goutte   Enable Venus and ...
175
176
177
178
179
{% for target in targets if not target.locked%}
    {% if not loop.first %},{% endif %}
    '{{ target.slug }}': {
      slug: '{{ target.slug }}',
      name: '{{ target.name }}',
ae0aa7d2   Goutte   Add an x axis lab...
180
      active: true,
a21f81d9   Goutte   Enable Venus and ...
181
182
      orbit: { a: {{ target.orbit.semimajor }}, b: {{ target.orbit.semiminor }} },
      img: '{{ static('img/target/'~target.slug~'_128.png') }}'
ae0aa7d2   Goutte   Add an x axis lab...
183
    }
a21f81d9   Goutte   Enable Venus and ...
184
185
186
187
188
189
190
191
192
193
{% endfor %}
{#    jupiter: {#}
{#      slug: 'jupiter',#}
{#      name: 'Jupiter',#}
{#      active: true,#}
{#      minDate: '1990-01-01T01:30:00',#}
{#      maxDate: '2017-02-19T00:00:00',#}
{#      orbit: { a: 5.45516759, b: 4.95155843 },#}
{#      img: '{{ static('img/target/jupiter_128.png') }}'#}
{#    },#}
aba70d3a   Goutte   Refactor time ser...
194
  },
f75faf5f   Goutte   WIP
195
{# todo @Nicolas Define -somehow- error margins of each parameter #}
aba70d3a   Goutte   Refactor time ser...
196
197
198
  parameters : [
    {
      id: 'pdyn',
4cf497e0   Goutte   Make the targets ...
199
      title: "Dyn. Pressure (nPa)",
b7fe650c   Goutte   Misc bundle of ol...
200
      active: true,
f75faf5f   Goutte   WIP
201
      unit: "nPa"
aba70d3a   Goutte   Refactor time ser...
202
203
204
    },
    {
      id: 'magn',
f75faf5f   Goutte   WIP
205
      title: "Magnetism (nT)",
b7fe650c   Goutte   Misc bundle of ol...
206
      active: false,
f75faf5f   Goutte   WIP
207
      unit: "nT"
aba70d3a   Goutte   Refactor time ser...
208
209
210
    },
    {
      id: 'vlen',
f75faf5f   Goutte   WIP
211
      title: "Velocity (km/s)",
b7fe650c   Goutte   Misc bundle of ol...
212
      active: false,
f75faf5f   Goutte   WIP
213
      unit: "km/s"
aba70d3a   Goutte   Refactor time ser...
214
215
216
    },
    {
      id: 'temp',
f75faf5f   Goutte   WIP
217
      title: "Temperature (K)",
b7fe650c   Goutte   Misc bundle of ol...
218
      active: false,
f75faf5f   Goutte   WIP
219
      unit: "K"
aba70d3a   Goutte   Refactor time ser...
220
221
222
    },
    {
      id: 'dens',
f75faf5f   Goutte   WIP
223
      title: "Density N (cm⁻³)",
b7fe650c   Goutte   Misc bundle of ol...
224
      active: false,
f75faf5f   Goutte   WIP
225
      unit: "cm⁻³"
aba70d3a   Goutte   Refactor time ser...
226
227
228
    },
    {
      id: 'angl',
f75faf5f   Goutte   WIP
229
      title: "Angle S-S-E (deg)",
b7fe650c   Goutte   Misc bundle of ol...
230
      active: false,
f75faf5f   Goutte   WIP
231
      unit: "deg"
aba70d3a   Goutte   Refactor time ser...
232
233
    }
  ]
438929a4   Goutte   Rewrite the orbit...
234
};
9390ec89   Goutte   Initial experimen...
235
236

jQuery().ready(function($){
a975b380   Goutte   Clean up.
237
  // Space Weather app itself, handling data downloads and plot draws.
ae0aa7d2   Goutte   Add an x axis lab...
238
  var sw = new SpaceWeather(configuration);
fe3132dd   Goutte   Refactor even more.
239
  sw.init();
ae0aa7d2   Goutte   Add an x axis lab...
240

a975b380   Goutte   Clean up.
241
242
243
244
245
246
247
248
  // User Interface (except plots' interactivity, such as mouse hovers)
  var parameters = $('#parameters');
  var isLastParameterEnabled = function(parameter_id) {
    var s = 0;
    parameters.find('.parameter[data-ts-slug]').each(function(i,p) {
      if ($(p).hasClass('active')) s++;
    });
    return s < 2;
6f9a3852   Goutte   Hide time series ...
249
  };
4cf497e0   Goutte   Make the targets ...
250
251
252
253
254
255
256
  var isLastTargetEnabled = function(target_slug) {
    var s = 0;
    $(".orbiters_filters .target:not(.locked)").each(function(i,p) {
      if ($(p).hasClass('active')) s++;
    });
    return s < 2;
  };
a975b380   Goutte   Clean up.
257
  parameters.find(".parameter").click(function(e){
b7fe650c   Goutte   Misc bundle of ol...
258
259
260
261
    var switch_on = ! $(this).hasClass('active');
    var parameter_slug = $(this).attr('data-ts-slug');
    if (switch_on) {
      sw.enableParameter(parameter_slug);
a975b380   Goutte   Clean up.
262
263
      $(this).addClass('active');
    } else if ( ! isLastParameterEnabled(parameter_slug)) {
b7fe650c   Goutte   Misc bundle of ol...
264
      sw.disableParameter(parameter_slug);
a975b380   Goutte   Clean up.
265
      $(this).removeClass('active');
b7fe650c   Goutte   Misc bundle of ol...
266
    }
6f9a3852   Goutte   Hide time series ...
267
268
    return false;
  });
4cf497e0   Goutte   Make the targets ...
269
270
271
272
273
274
275
276
277
278
279
280
281
  $(".orbiters_filters .target:not(.locked)").click(function(e){
    var switch_on = ! $(this).hasClass('active');
    var target_slug = $(this).attr('data-target-slug');
    if (switch_on) {
      sw.showSource(target_slug);
      $(this).addClass('active');
    } else if ( ! isLastTargetEnabled(target_slug)) {
      sw.hideSource(target_slug);
      $(this).removeClass('active');
    }
    return false;
  });

6f9a3852   Goutte   Hide time series ...
282

9390ec89   Goutte   Initial experimen...
283
284
});
</script>
9390ec89   Goutte   Initial experimen...
285
{% endblock %}