Blame view

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

4900d232   Goutte   Add the time inte...
5
6
7
{# This is the main template file, along with the layout. #}
{# The engine is Jinja2, close to Twig (yet not as good) #}

9390ec89   Goutte   Initial experimen...
8
9
{% block content %}

4cf497e0   Goutte   Make the targets ...
10
{% macro target_button(target) -%}
80352490   Goutte   Multi model suppo...
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
    <div class="target {{ target.slug }} {{ 'locked' if target.locked else 'active' }}"
         data-target-slug="{{ target.slug }}">
      <img width="64px" height="64px"
           src="{{ static('img/target/'~target.slug~'_128.png') }}"
           title="{{ target.title }}"
           alt="{{ target.name }}">
      <img width="64px" height="64px"
           src="{{ static('img/target/empty_128.png') }}"
           title="No data at specified interval for {{ target.title }}"
           alt="No data for {{ target.name }}"
           class="decorator empty">
{#      <img width="32px" height="32px"#}
{#           src="{{ static('img/target/loading_32.gif') }}"#}
{#           title="Loading data for {{ target.title }}…"#}
{#           alt="Loader for {{ target.name }}"#}
{#           class="decorator loading">#}
      <div class="decorator loading" title="Loading data for {{ target.title }}…">
        <div class="small-loader-container">
          <div class="small-loader-circle-1">
            <div class="small-loader-circle-2">
              <div class="small-loader-circle-3">
                <div class="small-loader-circle-4">
                  <div class="small-loader-circle-5">
                    <div class="small-loader-circle-6">
                      <div class="small-loader-circle-7">
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
4cf497e0   Goutte   Make the targets ...
46
47
{%- endmacro %}

23110c4a   Goutte   Add icons to the ...
48
{% macro icon(name) %}<i class="fa fa-{{ name }}" aria-hidden="true"></i>{% endmacro %}
9c0c4509   Goutte   Add a loader to t...
49
50
51
52
53
54
55
56
57
58

<div id="plots_loader">
  <p class="loader-text">Loading Heliopropa&hellip;<br>This might take a while.</p>
  <div id="plots_loader_img1" class="img"></div>
  <div id="plots_loader_img2" class="img"></div>
  <div id="plots_loader_img3" class="img"></div>
  <div id="plots_loader_img4" class="img"></div>
  <div id="plots_loader_img5" class="img"></div>
</div>

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

f6ed8d85   Goutte   Rework layout as ...
61
  <div class="mdl-layout__drawer">
23110c4a   Goutte   Add icons to the ...
62
    <span class="mdl-layout-title" title="Two years maximum.">{{ icon('calendar') }} Time Interval</span>
1754789b   Goutte   Decorate and clea...
63
64
65
66
67
    <form id="form_time_interval" action="#">
      <div class="mdl-textfield mdl-js-textfield">
      <input type="date" id="started_at" name="started_at" title="The date of the beginning of the interval to observe." class="mdl-textfield__input">
      <input type="date" id="stopped_at" name="stopped_at" title="The date of the end of the interval to observe. (exclusive)" class="mdl-textfield__input">
      </div>
23110c4a   Goutte   Add icons to the ...
68
      <input type="submit" id="apply_new_interval" value="Load new interval" title="Two years maximum. This may take a while." class="mdl-button mdl-js-button mdl-js-ripple-effect">
1754789b   Goutte   Decorate and clea...
69
70
71
72
    </form>

    <br>
    <hr class="clear">
4900d232   Goutte   Add the time inte...
73

23110c4a   Goutte   Add icons to the ...
74
    <span class="mdl-layout-title">{{ icon('eercast') }} Planets</span>
f6ed8d85   Goutte   Rework layout as ...
75

4900d232   Goutte   Add the time inte...
76
    <section class="targets-filters">
4cf497e0   Goutte   Make the targets ...
77
78
{% for target in planets %}
      {{ target_button(target) }}
a79c5268   Goutte   Add probes and co...
79
{% endfor %}
c42fea3a   Goutte   Rework the CSS wi...
80
    </section>
a79c5268   Goutte   Add probes and co...
81
82
83
84

    <br>
    <hr class="clear">

23110c4a   Goutte   Add icons to the ...
85
    <span class="mdl-layout-title">{{ icon('rocket') }} Probes &amp; Comets</span>
a79c5268   Goutte   Add probes and co...
86

4900d232   Goutte   Add the time inte...
87
    <section class="targets-filters">
4cf497e0   Goutte   Make the targets ...
88
89
{% for target in probes %}
      {{ target_button(target) }}
a79c5268   Goutte   Add probes and co...
90
{% endfor %}
4cf497e0   Goutte   Make the targets ...
91
92
{% for target in comets %}
      {{ target_button(target) }}
a79c5268   Goutte   Add probes and co...
93
94
95
{% endfor %}
    </section>

b550c2b0   Goutte   Rework the home s...
96
    <br>
c42fea3a   Goutte   Rework the CSS wi...
97
    <hr class="clear">
b550c2b0   Goutte   Rework the home s...
98

23110c4a   Goutte   Add icons to the ...
99
    <span class="mdl-layout-title">{{ icon('flask') }} Parameters</span>
b550c2b0   Goutte   Rework the home s...
100
101

    <nav id="parameters" class="mdl-navigation">
8cb213b9   Goutte   Clean up, and pre...
102
      {# todo: generate this from config #}
b7fe650c   Goutte   Misc bundle of ol...
103
104
105
106
107
      <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>
08569a6b   Goutte   Add a zooming bru...
108
      <a class="mdl-navigation__link parameter" data-ts-slug="angl" href="#">Angle Target-Sun-Earth</a>
b550c2b0   Goutte   Rework the home s...
109
110
    </nav>

a4a9ef03   Goutte   Cache generated C...
111
112
    <div class="mdl-layout-spacer"></div>

c42fea3a   Goutte   Rework the CSS wi...
113
  </div>
80352490   Goutte   Multi model suppo...
114
115


b7fe650c   Goutte   Misc bundle of ol...
116
  <main id="plots_wrapper" class="mdl-layout__content">
9390ec89   Goutte   Initial experimen...
117

b550c2b0   Goutte   Rework the home s...
118
    <div class="mdl-grid">
80352490   Goutte   Multi model suppo...
119
      <div class="mdl-cell mdl-cell--4-col mdl-cell--8-col-tablet mdl-cell--4-col-phone">
b550c2b0   Goutte   Rework the home s...
120
        <section id="orbits"></section>
6b149919   Goutte   Add a Download bu...
121
122
123
124
        <button id="download" class="mdl-button mdl-button--raised mdl-button--primary"
                title="Download the CSV raw data for each target in a tarball.">
          Download
        </button>
b550c2b0   Goutte   Rework the home s...
125
      </div>
80352490   Goutte   Multi model suppo...
126
      <div class="mdl-cell mdl-cell--8-col mdl-cell--8-col-tablet mdl-cell--4-col-phone">
9c0c4509   Goutte   Add a loader to t...
127
128
129
        <section id="time_series">
          <p id="zoom_controls_help" class="help mdl-cell--8-col">Drag to zoom in, double click to zoom out.</p>
        </section>
b550c2b0   Goutte   Rework the home s...
130
131
132
      </div>
    </div>

f6ed8d85   Goutte   Rework layout as ...
133
134
  </main>
</div>
9390ec89   Goutte   Initial experimen...
135
136
137
{% endblock %}


80352490   Goutte   Multi model suppo...
138
{#### CSS ####################################################################}
7d6dee0f   Goutte   Continue refacto ...
139

9390ec89   Goutte   Initial experimen...
140
141
{% block styles %}
  <style>
c42fea3a   Goutte   Rework the CSS wi...
142
    html, body {
f6ed8d85   Goutte   Rework layout as ...
143
144
{#      background-color: #322e3f;#}
{#      color: #e3e3e3;#}
c42fea3a   Goutte   Rework the CSS wi...
145
    }
23110c4a   Goutte   Add icons to the ...
146
147
148
149
    .mdl-layout__drawer > .mdl-layout-title {
      padding-left: 30px;
    }

9c0c4509   Goutte   Add a loader to t...
150
151
152
    #plots_wrapper {
{#      position: relative;#}
    }
80352490   Goutte   Multi model suppo...
153

9c0c4509   Goutte   Add a loader to t...
154
    #plots_loader {
6b149919   Goutte   Add a Download bu...
155
      position: fixed;
9c0c4509   Goutte   Add a loader to t...
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
      top: 0; left: 0; bottom: 0; right: 0;
      height: 100%;
      width: 100%;
      background-color: #fff;
      z-index: 1000;
    }

    #plots_loader .loader-text {
      width: 200px;
      height: 30px;
      position: absolute;
      top: -240px; left: -32px; bottom: 0; right: 0;
      margin: auto;
      text-align: center;
      font-size: 1.0em;
      font-style: italic;
      color: darkgrey;
    }

    #plots_loader .img {
      width: 100px;
      height: 100px;
      border-radius: 100%;
      position: absolute;
      border: 1px solid #6978ff;
80352490   Goutte   Multi model suppo...
181
      animation: keyframes_rotate 1s;
9c0c4509   Goutte   Add a loader to t...
182
183
184
185
186
187
188
189
190
191
192
      animation-iteration-count: infinite;
      transition: 2s;
      border-bottom: none;
      border-right: none;
      animation-timing-function: linear;
      margin-left: -70px;
      margin-top: -70px;
      left: 50%;
      top: 50%;
    }

80352490   Goutte   Multi model suppo...
193
    @keyframes keyframes_rotate {
9c0c4509   Goutte   Add a loader to t...
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
      from {
        transform: rotate(0deg);
      }
      50% {
        transform: rotate(180deg);
      }
      100% {
        transform: rotate(360deg);
      }
    }

    #plots_loader #plots_loader_img2 {
      width: 90px;
      height: 90px;
      left: 50.35%;
      top: 50.7%;
      animation-delay: .2s;
    }

    #plots_loader #plots_loader_img3 {
      width: 80px;
      height: 80px;
      left: 50.70%;
      top: 51.4%;
      animation-delay: .4s;
    }

    #plots_loader #plots_loader_img4 {
      width: 70px;
      height: 70px;
      left: 51.05%;
      top: 52.1%;
      animation-delay: .6s;
    }

    #plots_loader #plots_loader_img5 {
      width: 60px;
      height: 60px;
      left: 51.40%;
      top: 52.8%;
      animation-delay: .8s;
    }

6b149919   Goutte   Add a Download bu...
237
238
239
240
241
    #download {
      display: block;
      margin: 3em auto;
    }

80352490   Goutte   Multi model suppo...
242
243
244
    #time_series svg {
      cursor: crosshair;
    }
9c0c4509   Goutte   Add a loader to t...
245
246
247
248
249
250
251
252
253
254
255
    #time_series .help {
      position: absolute;
      text-align: center;
      font-size: 0.9em;
      font-style: italic;
      color: darkgrey;
      display: none;
    }
    #time_series:hover .help {
      display: block;
    }
18f38374   Goutte   Crisp edges for a...
256
257
    .axis path, .axis line {
      fill: none;
f6ed8d85   Goutte   Rework layout as ...
258
{#      stroke: #f4f4f4;#}
18f38374   Goutte   Crisp edges for a...
259
260
261
      shape-rendering: crispEdges;
      stroke-width: 1px;
    }
c42fea3a   Goutte   Rework the CSS wi...
262
    svg text {
f6ed8d85   Goutte   Rework layout as ...
263
{#      fill: #f4f4f4;#}
c42fea3a   Goutte   Rework the CSS wi...
264
    }
08569a6b   Goutte   Add a zooming bru...
265
266
267
    #time_series svg .brush .selection {
      fill: #efa02c;
      fill-opacity: 0.382;
908b4423   Goutte   Bump to a newer j...
268
    }
9390ec89   Goutte   Initial experimen...
269
270
271
272
273
    path.line {
      fill: none;
      stroke: steelblue;
      stroke-width: 1px;
    }
81c9b2e8   Goutte   Add the values to...
274
    circle.cursor-circle {
b550c2b0   Goutte   Rework the home s...
275
276
277
278
279
280
281
282
      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...
283
284
285
    }
    text.cursor-text-shadow {
      stroke: white;
b550c2b0   Goutte   Rework the home s...
286
287
      stroke-width: 5px;
      opacity: 0.777
81c9b2e8   Goutte   Add the values to...
288
    }
c42fea3a   Goutte   Rework the CSS wi...
289
    path.orbit.orbit_section {
2d2af24b   Goutte   Add a basic orbit...
290
291
      fill: none;
      stroke: steelblue;
c42fea3a   Goutte   Rework the CSS wi...
292
293
294
295
296
297
298
299
      stroke-width: 3px;
    }
    ellipse.orbit.orbit_ellipse {
      fill: none;
      stroke: #a3a3a3;
      stroke-width: 1px;
      stroke-dasharray: 5px;
    }
1754789b   Goutte   Decorate and clea...
300
301
302
303
304
305
306
307
308
    #form_time_interval {
      padding-left: 30px;
    }
    #form_time_interval .mdl-textfield {
      padding-top: 0;
    }
    #started_at, #stopped_at {
      width: 85%;
    }
4900d232   Goutte   Add the time inte...
309
    .targets-filters {
a79c5268   Goutte   Add probes and co...
310
311
      padding-left: 17px;
    }
4900d232   Goutte   Add the time inte...
312
    .targets-filters .target {
c42fea3a   Goutte   Rework the CSS wi...
313
      float: left;
4cf497e0   Goutte   Make the targets ...
314
      cursor: pointer;
80352490   Goutte   Multi model suppo...
315
      position: relative;
c42fea3a   Goutte   Rework the CSS wi...
316
    }
4900d232   Goutte   Add the time inte...
317
    .targets-filters .target:not(.active) {
c42fea3a   Goutte   Rework the CSS wi...
318
319
320
321
322
323
      -webkit-filter: grayscale(100%);
         -moz-filter: grayscale(100%);
           -o-filter: grayscale(100%);
          -ms-filter: grayscale(100%);
              filter: grayscale(100%);
    }
4900d232   Goutte   Add the time inte...
324
    .targets-filters .target.locked {
4cf497e0   Goutte   Make the targets ...
325
326
      cursor: not-allowed;
    }
4900d232   Goutte   Add the time inte...
327
    .targets-filters .target.loading {
93ee5563   Goutte   Add a loading ani...
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
        -webkit-animation-name: spin;
        -webkit-animation-duration: 4000ms;
        -webkit-animation-iteration-count: infinite;
        -webkit-animation-timing-function: linear;
        -moz-animation-name: spin;
        -moz-animation-duration: 4000ms;
        -moz-animation-iteration-count: infinite;
        -moz-animation-timing-function: linear;
        -ms-animation-name: spin;
        -ms-animation-duration: 4000ms;
        -ms-animation-iteration-count: infinite;
        -ms-animation-timing-function: linear;
        animation-name: spin;
        animation-duration: 4000ms;
        animation-iteration-count: infinite;
        animation-timing-function: linear;
    }
c42fea3a   Goutte   Rework the CSS wi...
345

80352490   Goutte   Multi model suppo...
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
    .targets-filters .target .decorator {
      position: absolute;
      top: 0;
      left: 0;
      display: none;
    }
    .targets-filters .target.empty .decorator.empty {
      display: block;
    }
    .targets-filters .target .decorator.loading {
      top:  19px;
      left: 19px;
    }
    .targets-filters .target.loading .decorator.loading {
      display: block;
    }
6f9a3852   Goutte   Hide time series ...
362
363
364
365
366
367
368

    #parameters .parameter {
      outline: 0;
    }
    #parameters .parameter.active {
      background-color: #c8d3e1;
    }
80352490   Goutte   Multi model suppo...
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439

.small-loader-container {
	width: 27px;
	margin: 0 auto;
  background: none;
  pointer-events: none;
}

.small-loader-circle-1 {
	height: 27px;
	width: 27px;
	background: rgba(255, 238, 195, 0.72);
}

.small-loader-circle-2 {
	height: 22px;
	width: 22px;
  background: none;
{#	background: rgba(56, 53, 194, 0.5);#}
}

.small-loader-circle-3 {
	height: 18px;
	width: 18px;
	background: rgba(29, 65, 255, 0.9);
}

.small-loader-circle-4 {
	height: 13px;
	width: 13px;
	background: none;
{#	background: rgba(98, 109, 237, 0.5);#}
}

.small-loader-circle-5 {
	height: 9px;
	width: 9px;
	background: rgba(238, 238, 238, 0.8);
}

.small-loader-circle-6 {
	height: 4px;
	width: 4px;
	background: none;
{#	background: rgba(0, 0, 0, 0);#}
}

.small-loader-circle-7 {
	height: 2px;
	width: 2px;
	background: rgb(110, 102, 255);
}

.small-loader-circle-1,
.small-loader-circle-2,
.small-loader-circle-3,
.small-loader-circle-4,
.small-loader-circle-5,
.small-loader-circle-6,
.small-loader-circle-7 {
	border-bottom: none;
	border-radius: 50%;
		-o-border-radius: 50%;
		-ms-border-radius: 50%;
		-webkit-border-radius: 50%;
		-moz-border-radius: 50%;
	box-shadow: 0px 0px 0px rgba(0,0,0,0.1);
		-o-box-shadow: 0px 0px 0px rgba(0,0,0,0.1);
		-ms-box-shadow: 0px 0px 0px rgba(0,0,0,0.1);
		-webkit-box-shadow: 0px 0px 0px rgba(0,0,0,0.1);
		-moz-box-shadow: 0px 0px 0px rgba(0,0,0,0.1);
3faa136f   Goutte   Rename the CSS lo...
440
441
442
443
444
	animation-name: small-loader-spin;
		-o-animation-name: small-loader-spin;
		-ms-animation-name: small-loader-spin;
		-webkit-animation-name: small-loader-spin;
		-moz-animation-name: small-loader-spin;
80352490   Goutte   Multi model suppo...
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
	animation-duration: 4600ms;
		-o-animation-duration: 4600ms;
		-ms-animation-duration: 4600ms;
		-webkit-animation-duration: 4600ms;
		-moz-animation-duration: 4600ms;
	animation-iteration-count: infinite;
		-o-animation-iteration-count: infinite;
		-ms-animation-iteration-count: infinite;
		-webkit-animation-iteration-count: infinite;
		-moz-animation-iteration-count: infinite;
	animation-timing-function: linear;
		-o-animation-timing-function: linear;
		-ms-animation-timing-function: linear;
		-webkit-animation-timing-function: linear;
		-moz-animation-timing-function: linear;
}



3faa136f   Goutte   Rename the CSS lo...
464
@keyframes small-loader-spin {
80352490   Goutte   Multi model suppo...
465
466
467
468
469
470
471
472
	from {
		transform: rotate(0deg);
	}
	to {
		transform: rotate(360deg);
	}
}

3faa136f   Goutte   Rename the CSS lo...
473
@-o-keyframes small-loader-spin {
80352490   Goutte   Multi model suppo...
474
475
476
477
478
479
480
481
	from {
		-o-transform: rotate(0deg);
	}
	to {
		-o-transform: rotate(360deg);
	}
}

3faa136f   Goutte   Rename the CSS lo...
482
@-ms-keyframes small-loader-spin {
80352490   Goutte   Multi model suppo...
483
484
485
486
487
488
489
490
	from {
		-ms-transform: rotate(0deg);
	}
	to {
		-ms-transform: rotate(360deg);
	}
}

3faa136f   Goutte   Rename the CSS lo...
491
@-webkit-keyframes small-loader-spin {
80352490   Goutte   Multi model suppo...
492
493
494
495
496
497
498
499
	from {
		-webkit-transform: rotate(0deg);
	}
	to {
		-webkit-transform: rotate(360deg);
	}
}

3faa136f   Goutte   Rename the CSS lo...
500
@-moz-keyframes small-loader-spin {
80352490   Goutte   Multi model suppo...
501
502
503
504
505
506
507
508
509
	from {
		-moz-transform: rotate(0deg);
	}
	to {
		-moz-transform: rotate(360deg);
	}
}
  
  
9390ec89   Goutte   Initial experimen...
510
511
512
513
  </style>
{% endblock %}


7d6dee0f   Goutte   Continue refacto ...
514

80352490   Goutte   Multi model suppo...
515
516
{#### JAVASCRIPT #############################################################}

9390ec89   Goutte   Initial experimen...
517
{% block scripts_footer %}
f7a10f28   Goutte   Make our custom m...
518
<script type="application/javascript" src="{{ static('js/vendor/d3-custom.js') }}"></script>
a4a9ef03   Goutte   Cache generated C...
519
<script type="application/javascript" src="{{ static('js/vendor/moment.min.js') }}"></script>
80352490   Goutte   Multi model suppo...
520
<script type="application/javascript" src="{{ static('js/vendor/samp.js') }}"></script>
438929a4   Goutte   Rewrite the orbit...
521
<script type="application/javascript" src="{{ static('js/swapp.js') }}"></script>
9390ec89   Goutte   Initial experimen...
522
523
<script type="application/javascript">

ae0aa7d2   Goutte   Add an x axis lab...
524
525
526
var configuration = {
  time_series_container: '#time_series',
  orbits_container: '#orbits',
f75faf5f   Goutte   WIP
527
  api : {
6b149919   Goutte   Add a Download bu...
528
529
      'data_for_interval': "{{ request.url_root }}<target>_<started_at>_<stopped_at>.csv",
      'download': "{{ request.url_root }}<targets>_<started_at>_<stopped_at>.tar.gz"
f75faf5f   Goutte   WIP
530
  },
8bd715ad   Goutte   Use a pixel art i...
531
532
533
  sun: {
    img: '{{ static('img/sun_128.png') }}'
  },
b60e7acd   Goutte   Rename "source" i...
534
  targets : {
d9453685   Goutte   Clean up.
535
{% for target in targets if not target.locked %}
a21f81d9   Goutte   Enable Venus and ...
536
537
538
539
    {% if not loop.first %},{% endif %}
    '{{ target.slug }}': {
      slug: '{{ target.slug }}',
      name: '{{ target.name }}',
ae0aa7d2   Goutte   Add an x axis lab...
540
      active: true,
a21f81d9   Goutte   Enable Venus and ...
541
542
      orbit: { a: {{ target.orbit.semimajor }}, b: {{ target.orbit.semiminor }} },
      img: '{{ static('img/target/'~target.slug~'_128.png') }}'
ae0aa7d2   Goutte   Add an x axis lab...
543
    }
a21f81d9   Goutte   Enable Venus and ...
544
{% endfor %}
aba70d3a   Goutte   Refactor time ser...
545
  },
8cb213b9   Goutte   Clean up, and pre...
546
{# todo @Nicolas Define -somehow- error margins of each parameter ? #}
80352490   Goutte   Multi model suppo...
547
{# todo: generate this from config PARAMETERS #}
aba70d3a   Goutte   Refactor time ser...
548
549
550
  parameters : [
    {
      id: 'pdyn',
4cf497e0   Goutte   Make the targets ...
551
      title: "Dyn. Pressure (nPa)",
b7fe650c   Goutte   Misc bundle of ol...
552
      active: true,
f75faf5f   Goutte   WIP
553
      unit: "nPa"
aba70d3a   Goutte   Refactor time ser...
554
555
556
    },
    {
      id: 'magn',
80352490   Goutte   Multi model suppo...
557
      title: "B Tangential (nT)",
b7fe650c   Goutte   Misc bundle of ol...
558
      active: false,
f75faf5f   Goutte   WIP
559
      unit: "nT"
aba70d3a   Goutte   Refactor time ser...
560
561
562
    },
    {
      id: 'vlen',
f75faf5f   Goutte   WIP
563
      title: "Velocity (km/s)",
b7fe650c   Goutte   Misc bundle of ol...
564
      active: false,
f75faf5f   Goutte   WIP
565
      unit: "km/s"
aba70d3a   Goutte   Refactor time ser...
566
567
568
    },
    {
      id: 'temp',
f75faf5f   Goutte   WIP
569
      title: "Temperature (K)",
b7fe650c   Goutte   Misc bundle of ol...
570
      active: false,
f75faf5f   Goutte   WIP
571
      unit: "K"
aba70d3a   Goutte   Refactor time ser...
572
573
574
    },
    {
      id: 'dens',
f75faf5f   Goutte   WIP
575
      title: "Density N (cm⁻³)",
b7fe650c   Goutte   Misc bundle of ol...
576
      active: false,
f75faf5f   Goutte   WIP
577
      unit: "cm⁻³"
aba70d3a   Goutte   Refactor time ser...
578
579
580
    },
    {
      id: 'angl',
08569a6b   Goutte   Add a zooming bru...
581
      title: "Angle T-S-E (deg)",
b7fe650c   Goutte   Misc bundle of ol...
582
      active: false,
f75faf5f   Goutte   WIP
583
      unit: "deg"
aba70d3a   Goutte   Refactor time ser...
584
585
    }
  ]
438929a4   Goutte   Rewrite the orbit...
586
};
9390ec89   Goutte   Initial experimen...
587

06a3a1f1   Goutte   Continue bug hunt...
588
var sw;
9390ec89   Goutte   Initial experimen...
589
jQuery().ready(function($){
a975b380   Goutte   Clean up.
590
  // Space Weather app itself, handling data downloads and plot draws.
06a3a1f1   Goutte   Continue bug hunt...
591
  sw = new SpaceWeather(configuration);
fe3132dd   Goutte   Refactor even more.
592
  sw.init();
ae0aa7d2   Goutte   Add an x axis lab...
593

a975b380   Goutte   Clean up.
594
595
596
597
598
599
600
601
  // 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 ...
602
  };
4cf497e0   Goutte   Make the targets ...
603
604
  var isLastTargetEnabled = function(target_slug) {
    var s = 0;
4900d232   Goutte   Add the time inte...
605
    $(".targets-filters .target:not(.locked)").each(function(i,p) {
9c0c4509   Goutte   Add a loader to t...
606
      if ($(p).hasClass('active') && ! $(p).hasClass('loading')) s++;
4cf497e0   Goutte   Make the targets ...
607
608
609
    });
    return s < 2;
  };
a975b380   Goutte   Clean up.
610
  parameters.find(".parameter").click(function(e){
b7fe650c   Goutte   Misc bundle of ol...
611
612
613
614
    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.
615
616
      $(this).addClass('active');
    } else if ( ! isLastParameterEnabled(parameter_slug)) {
b7fe650c   Goutte   Misc bundle of ol...
617
      sw.disableParameter(parameter_slug);
a975b380   Goutte   Clean up.
618
      $(this).removeClass('active');
b7fe650c   Goutte   Misc bundle of ol...
619
    }
6f9a3852   Goutte   Hide time series ...
620
621
    return false;
  });
4900d232   Goutte   Add the time inte...
622
  $(".targets-filters .target:not(.locked)").on("click", function(e){
9c0c4509   Goutte   Add a loader to t...
623
    if ($(this).hasClass('loading')) return false;
4cf497e0   Goutte   Make the targets ...
624
625
626
    var switch_on = ! $(this).hasClass('active');
    var target_slug = $(this).attr('data-target-slug');
    if (switch_on) {
6bb225d6   Goutte   Link the time ser...
627
      sw.enableTarget(target_slug);
4cf497e0   Goutte   Make the targets ...
628
629
      $(this).addClass('active');
    } else if ( ! isLastTargetEnabled(target_slug)) {
6bb225d6   Goutte   Link the time ser...
630
      sw.disableTarget(target_slug);
4cf497e0   Goutte   Make the targets ...
631
632
633
634
      $(this).removeClass('active');
    }
    return false;
  });
243cd8a4   Goutte   Timestamp party c...
635
636
637
638
639
  $('#apply_new_interval').on("click", function(e){
    var started_at = moment($("#started_at").val());
    var stopped_at = moment($("#stopped_at").val());
    sw.resizeDomain(started_at, stopped_at);
    return false;
6b149919   Goutte   Add a Download bu...
640
641
642
643
644
645
646
  });
  $('#download').on("click", function(e){
    var url = sw.buildDownloadUrl();
    $.ajax({
      type: 'GET',
      url: url,
      processData: false,
5f63c83b   Goutte   Lint.
647
      success: function (data) { window.location = url; },
6b149919   Goutte   Add a Download bu...
648
649
650
651
652
653
654
      error: function (xhr) {
        console.error('Cannot download.', xhr);
        alert("Our apologies, there was an error while downloading.");
      }
    });
    return false;
  });
6f9a3852   Goutte   Hide time series ...
655

9390ec89   Goutte   Initial experimen...
656
657
});
</script>
9390ec89   Goutte   Initial experimen...
658
{% endblock %}