Blame view

web/view/home.html.jinja2 19 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
    <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') }}"
60b73eb1   Goutte   Change temperatur...
19
20
           title="No data at specified interval for {{ target.title }}."
           alt="NO DATA"
80352490   Goutte   Multi model suppo...
21
           class="decorator empty">
60b73eb1   Goutte   Change temperatur...
22
23
24
25
26
      <img width="64px" height="64px"
           src="{{ static('img/target/error_128.png') }}"
           title="There was an error with {{ target.title }}."
           alt="ERROR"
           class="decorator error">
80352490   Goutte   Multi model suppo...
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
      <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">
bde97e4d   Goutte   Add more changes ...
102
103
104
      {% for p in parameters %}
      <a class="mdl-navigation__link parameter{{ ' active' if p.active }}" data-ts-slug="{{ p.slug }}" href="#">{{ p.name }}</a>
      {% endfor %}
b550c2b0   Goutte   Rework the home s...
105
106
    </nav>

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

c42fea3a   Goutte   Rework the CSS wi...
109
  </div>
80352490   Goutte   Multi model suppo...
110
111


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

b550c2b0   Goutte   Rework the home s...
114
    <div class="mdl-grid">
80352490   Goutte   Multi model suppo...
115
      <div class="mdl-cell mdl-cell--4-col mdl-cell--8-col-tablet mdl-cell--4-col-phone">
b550c2b0   Goutte   Rework the home s...
116
        <section id="orbits"></section>
cad44b6d   Goutte   Finish adding the...
117
118
        <div class="plots-actions plots-buttons">
          <button id="download" class="mdl-button mdl-button--raised mdl-button--primary"
dc0be992   Goutte   Support having no...
119
                  title="Download the raw data for each selected target and parameters.">
cad44b6d   Goutte   Finish adding the...
120
121
122
123
124
125
126
            Download
          </button>
          <button id="samp" class="samp mdl-button mdl-button--raised mdl-button--primary mdl-button--disabled"
                  title="Send the data to a connected SAMP hub.">
            SAMP
          </button>
        </div>
b550c2b0   Goutte   Rework the home s...
127
      </div>
80352490   Goutte   Multi model suppo...
128
      <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...
129
130
131
        <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...
132
133
134
      </div>
    </div>

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


80352490   Goutte   Multi model suppo...
140
{#### CSS ####################################################################}
7d6dee0f   Goutte   Continue refacto ...
141

9390ec89   Goutte   Initial experimen...
142
143
{% block styles %}
  <style>
c42fea3a   Goutte   Rework the CSS wi...
144
    html, body {
f6ed8d85   Goutte   Rework layout as ...
145
146
{#      background-color: #322e3f;#}
{#      color: #e3e3e3;#}
c42fea3a   Goutte   Rework the CSS wi...
147
    }
23110c4a   Goutte   Add icons to the ...
148
149
    .mdl-layout__drawer > .mdl-layout-title {
      padding-left: 30px;
b500e561   Goutte   Invert the orbits...
150
151
152
153
      line-height: 42px;
    }
    .mdl-layout__drawer > .mdl-layout-title:first-of-type {
      line-height: 60px;
23110c4a   Goutte   Add icons to the ...
154
155
    }

9c0c4509   Goutte   Add a loader to t...
156
157
158
    #plots_wrapper {
{#      position: relative;#}
    }
80352490   Goutte   Multi model suppo...
159

9c0c4509   Goutte   Add a loader to t...
160
    #plots_loader {
6b149919   Goutte   Add a Download bu...
161
      position: fixed;
9c0c4509   Goutte   Add a loader to t...
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
      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...
187
      animation: keyframes_rotate 1s;
9c0c4509   Goutte   Add a loader to t...
188
189
190
191
192
193
194
195
196
197
198
      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...
199
    @keyframes keyframes_rotate {
9c0c4509   Goutte   Add a loader to t...
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
237
238
239
240
241
242
      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;
    }

cad44b6d   Goutte   Finish adding the...
243
244
    .plots-buttons {
      text-align: center;
6b149919   Goutte   Add a Download bu...
245
246
      margin: 3em auto;
    }
cad44b6d   Goutte   Finish adding the...
247
248
249
    .plots-buttons button {
      margin: auto 1em;
    }
6b149919   Goutte   Add a Download bu...
250

80352490   Goutte   Multi model suppo...
251
252
253
    #time_series svg {
      cursor: crosshair;
    }
9c0c4509   Goutte   Add a loader to t...
254
255
256
257
258
259
260
261
262
263
264
    #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...
265
266
    .axis path, .axis line {
      fill: none;
f6ed8d85   Goutte   Rework layout as ...
267
{#      stroke: #f4f4f4;#}
18f38374   Goutte   Crisp edges for a...
268
269
270
      shape-rendering: crispEdges;
      stroke-width: 1px;
    }
c42fea3a   Goutte   Rework the CSS wi...
271
    svg text {
f6ed8d85   Goutte   Rework layout as ...
272
{#      fill: #f4f4f4;#}
c42fea3a   Goutte   Rework the CSS wi...
273
    }
08569a6b   Goutte   Add a zooming bru...
274
275
276
    #time_series svg .brush .selection {
      fill: #efa02c;
      fill-opacity: 0.382;
908b4423   Goutte   Bump to a newer j...
277
    }
9390ec89   Goutte   Initial experimen...
278
279
280
281
282
    path.line {
      fill: none;
      stroke: steelblue;
      stroke-width: 1px;
    }
81c9b2e8   Goutte   Add the values to...
283
    circle.cursor-circle {
b550c2b0   Goutte   Rework the home s...
284
285
286
287
288
289
290
291
      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...
292
293
294
    }
    text.cursor-text-shadow {
      stroke: white;
b550c2b0   Goutte   Rework the home s...
295
296
      stroke-width: 5px;
      opacity: 0.777
81c9b2e8   Goutte   Add the values to...
297
    }
c42fea3a   Goutte   Rework the CSS wi...
298
    path.orbit.orbit_section {
2d2af24b   Goutte   Add a basic orbit...
299
300
      fill: none;
      stroke: steelblue;
1324cc91   Goutte   Make the footer i...
301
      stroke-width: 1.5px;
c42fea3a   Goutte   Rework the CSS wi...
302
303
304
305
306
307
308
    }
    ellipse.orbit.orbit_ellipse {
      fill: none;
      stroke: #a3a3a3;
      stroke-width: 1px;
      stroke-dasharray: 5px;
    }
1754789b   Goutte   Decorate and clea...
309
310
311
312
313
314
315
316
317
    #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...
318
    .targets-filters {
a79c5268   Goutte   Add probes and co...
319
320
      padding-left: 17px;
    }
4900d232   Goutte   Add the time inte...
321
    .targets-filters .target {
c42fea3a   Goutte   Rework the CSS wi...
322
      float: left;
4cf497e0   Goutte   Make the targets ...
323
      cursor: pointer;
80352490   Goutte   Multi model suppo...
324
      position: relative;
c42fea3a   Goutte   Rework the CSS wi...
325
    }
4900d232   Goutte   Add the time inte...
326
    .targets-filters .target:not(.active) {
c42fea3a   Goutte   Rework the CSS wi...
327
328
329
330
331
332
      -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...
333
    .targets-filters .target.locked {
4cf497e0   Goutte   Make the targets ...
334
335
      cursor: not-allowed;
    }
4900d232   Goutte   Add the time inte...
336
    .targets-filters .target.loading {
6491a1f1   Goutte   Fix up the bugs l...
337
        -webkit-animation-name: keyframes_rotate;
93ee5563   Goutte   Add a loading ani...
338
339
340
        -webkit-animation-duration: 4000ms;
        -webkit-animation-iteration-count: infinite;
        -webkit-animation-timing-function: linear;
6491a1f1   Goutte   Fix up the bugs l...
341
        -moz-animation-name: keyframes_rotate;
93ee5563   Goutte   Add a loading ani...
342
343
344
        -moz-animation-duration: 4000ms;
        -moz-animation-iteration-count: infinite;
        -moz-animation-timing-function: linear;
6491a1f1   Goutte   Fix up the bugs l...
345
        -ms-animation-name: keyframes_rotate;
93ee5563   Goutte   Add a loading ani...
346
347
348
        -ms-animation-duration: 4000ms;
        -ms-animation-iteration-count: infinite;
        -ms-animation-timing-function: linear;
6491a1f1   Goutte   Fix up the bugs l...
349
        animation-name: keyframes_rotate;
93ee5563   Goutte   Add a loading ani...
350
351
352
353
        animation-duration: 4000ms;
        animation-iteration-count: infinite;
        animation-timing-function: linear;
    }
c42fea3a   Goutte   Rework the CSS wi...
354

80352490   Goutte   Multi model suppo...
355
356
357
358
359
360
361
362
363
    .targets-filters .target .decorator {
      position: absolute;
      top: 0;
      left: 0;
      display: none;
    }
    .targets-filters .target.empty .decorator.empty {
      display: block;
    }
60b73eb1   Goutte   Change temperatur...
364
365
366
    .targets-filters .target.error .decorator.error {
      display: block;
    }
80352490   Goutte   Multi model suppo...
367
368
369
370
371
372
373
    .targets-filters .target .decorator.loading {
      top:  19px;
      left: 19px;
    }
    .targets-filters .target.loading .decorator.loading {
      display: block;
    }
6f9a3852   Goutte   Hide time series ...
374
375
376
377
378
379
380

    #parameters .parameter {
      outline: 0;
    }
    #parameters .parameter.active {
      background-color: #c8d3e1;
    }
80352490   Goutte   Multi model suppo...
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
440
441
442
443
444
445
446
447
448
449
450
451

.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...
452
453
454
455
456
	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...
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
	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...
476
@keyframes small-loader-spin {
80352490   Goutte   Multi model suppo...
477
478
479
480
481
482
483
484
	from {
		transform: rotate(0deg);
	}
	to {
		transform: rotate(360deg);
	}
}

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

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

3faa136f   Goutte   Rename the CSS lo...
503
@-webkit-keyframes small-loader-spin {
80352490   Goutte   Multi model suppo...
504
505
506
507
508
509
510
511
	from {
		-webkit-transform: rotate(0deg);
	}
	to {
		-webkit-transform: rotate(360deg);
	}
}

3faa136f   Goutte   Rename the CSS lo...
512
@-moz-keyframes small-loader-spin {
80352490   Goutte   Multi model suppo...
513
514
515
516
517
518
519
520
521
	from {
		-moz-transform: rotate(0deg);
	}
	to {
		-moz-transform: rotate(360deg);
	}
}
  
  
9390ec89   Goutte   Initial experimen...
522
523
524
525
  </style>
{% endblock %}


7d6dee0f   Goutte   Continue refacto ...
526

80352490   Goutte   Multi model suppo...
527
528
{#### JAVASCRIPT #############################################################}

9390ec89   Goutte   Initial experimen...
529
{% block scripts_footer %}
f7a10f28   Goutte   Make our custom m...
530
<script type="application/javascript" src="{{ static('js/vendor/d3-custom.js') }}"></script>
a4a9ef03   Goutte   Cache generated C...
531
<script type="application/javascript" src="{{ static('js/vendor/moment.min.js') }}"></script>
80352490   Goutte   Multi model suppo...
532
<script type="application/javascript" src="{{ static('js/vendor/samp.js') }}"></script>
438929a4   Goutte   Rewrite the orbit...
533
<script type="application/javascript" src="{{ static('js/swapp.js') }}"></script>
9390ec89   Goutte   Initial experimen...
534
535
<script type="application/javascript">

ae0aa7d2   Goutte   Add an x axis lab...
536
537
538
var configuration = {
  time_series_container: '#time_series',
  orbits_container: '#orbits',
bde97e4d   Goutte   Add more changes ...
539
  api: {
6b149919   Goutte   Add a Download bu...
540
      'data_for_interval': "{{ request.url_root }}<target>_<started_at>_<stopped_at>.csv",
aa7247d6   Goutte   Generate a CDF fi...
541
542
      'download': "{{ request.url_root }}<targets>_<started_at>_<stopped_at>.cdf",
      'samp': "{{ request.url_root }}<targets>_<started_at>_<stopped_at>.cdf"
f75faf5f   Goutte   WIP
543
  },
8bd715ad   Goutte   Use a pixel art i...
544
545
546
  sun: {
    img: '{{ static('img/sun_128.png') }}'
  },
bde97e4d   Goutte   Add more changes ...
547
  targets: {
d9453685   Goutte   Clean up.
548
{% for target in targets if not target.locked %}
a21f81d9   Goutte   Enable Venus and ...
549
550
551
552
    {% if not loop.first %},{% endif %}
    '{{ target.slug }}': {
      slug: '{{ target.slug }}',
      name: '{{ target.name }}',
ae0aa7d2   Goutte   Add an x axis lab...
553
      active: true,
25071e08   Goutte   Easy fix to suppo...
554
      orbit: { a: {{ target.orbit.semimajor or 0 }}, b: {{ target.orbit.semiminor or 0 }} },
a21f81d9   Goutte   Enable Venus and ...
555
      img: '{{ static('img/target/'~target.slug~'_128.png') }}'
ae0aa7d2   Goutte   Add an x axis lab...
556
    }
a21f81d9   Goutte   Enable Venus and ...
557
{% endfor %}
aba70d3a   Goutte   Refactor time ser...
558
  },
bde97e4d   Goutte   Add more changes ...
559
560
  parameters: [
{% for p in parameters %}
aba70d3a   Goutte   Refactor time ser...
561
    {
bde97e4d   Goutte   Add more changes ...
562
563
564
565
566
567
      id: "{{ p.slug | escapejs }}",
      title: "{{ p.name | escapejs }} ({{ p.units | escapejs }})",
      active: {{ 'true' if p.active else 'false' }},
      unit: "{{ p.units | escapejs }}"
    }{{ ',' if not loop.last }}
{% endfor %}
aba70d3a   Goutte   Refactor time ser...
568
  ]
438929a4   Goutte   Rewrite the orbit...
569
};
9390ec89   Goutte   Initial experimen...
570

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

a975b380   Goutte   Clean up.
577
578
579
580
581
582
583
584
  // 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 ...
585
  };
4cf497e0   Goutte   Make the targets ...
586
587
  var isLastTargetEnabled = function(target_slug) {
    var s = 0;
4900d232   Goutte   Add the time inte...
588
    $(".targets-filters .target:not(.locked)").each(function(i,p) {
9c0c4509   Goutte   Add a loader to t...
589
      if ($(p).hasClass('active') && ! $(p).hasClass('loading')) s++;
4cf497e0   Goutte   Make the targets ...
590
591
592
    });
    return s < 2;
  };
a975b380   Goutte   Clean up.
593
  parameters.find(".parameter").click(function(e){
b7fe650c   Goutte   Misc bundle of ol...
594
595
596
597
    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.
598
599
      $(this).addClass('active');
    } else if ( ! isLastParameterEnabled(parameter_slug)) {
b7fe650c   Goutte   Misc bundle of ol...
600
      sw.disableParameter(parameter_slug);
a975b380   Goutte   Clean up.
601
      $(this).removeClass('active');
b7fe650c   Goutte   Misc bundle of ol...
602
    }
6f9a3852   Goutte   Hide time series ...
603
604
    return false;
  });
4900d232   Goutte   Add the time inte...
605
  $(".targets-filters .target:not(.locked)").on("click", function(e){
9c0c4509   Goutte   Add a loader to t...
606
    if ($(this).hasClass('loading')) return false;
4cf497e0   Goutte   Make the targets ...
607
608
609
    var switch_on = ! $(this).hasClass('active');
    var target_slug = $(this).attr('data-target-slug');
    if (switch_on) {
6bb225d6   Goutte   Link the time ser...
610
      sw.enableTarget(target_slug);
4cf497e0   Goutte   Make the targets ...
611
612
      $(this).addClass('active');
    } else if ( ! isLastTargetEnabled(target_slug)) {
6bb225d6   Goutte   Link the time ser...
613
      sw.disableTarget(target_slug);
4cf497e0   Goutte   Make the targets ...
614
615
616
617
      $(this).removeClass('active');
    }
    return false;
  });
243cd8a4   Goutte   Timestamp party c...
618
619
620
621
622
  $('#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...
623
624
625
  });
  $('#download').on("click", function(e){
    var url = sw.buildDownloadUrl();
aa7247d6   Goutte   Generate a CDF fi...
626
    console.info("Downloading " + url);
6b149919   Goutte   Add a Download bu...
627
628
629
630
    $.ajax({
      type: 'GET',
      url: url,
      processData: false,
5f63c83b   Goutte   Lint.
631
      success: function (data) { window.location = url; },
6b149919   Goutte   Add a Download bu...
632
633
634
635
636
637
638
      error: function (xhr) {
        console.error('Cannot download.', xhr);
        alert("Our apologies, there was an error while downloading.");
      }
    });
    return false;
  });
6f9a3852   Goutte   Hide time series ...
639

9390ec89   Goutte   Initial experimen...
640
641
});
</script>
cad44b6d   Goutte   Finish adding the...
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680

{#### SAMP ###################################################################}
<script type="text/javascript">
  jQuery().ready(function ($) {
    // Flag to know when a hub is connected or not
    var isConnected = false;

    // Show SAMP button(s) depending on whether the hub is available or not.
    var onHubAvailability = function (isHubRunning) {
      $(".samp").each(function (index, element) {
        if (isHubRunning) {
          isConnected = true;
          $(element).removeClass('disabled mdl-button--disabled');
        } else {
          isConnected = false;
          $(element).addClass('disabled mdl-button--disabled');
        }
      });
    };

    // Update the document about the presence of any SAMP hub every 10 sec.
    var connector = new samp.Connector("Sender");
    connector.onHubAvailability(onHubAvailability, 10000);
    window.onunload = function () {
      connector.unregister();
    };

    // Clicking on a SAMP button sends the CDF file to the connected hub.
    $("#samp").click(function (event) {
      event.stopPropagation();
      if ($(this).hasClass('disabled')) { return; }
      // pitfall : connector.connection is ALWAYS undefined here
      if ( ! isConnected) {  // so we use a bool flag instead
        alert("We do not detect any connected SAMP hub.\n" +
            "Wait some more, or try refreshing this page?");
        return;
      }
      var name = sw.buildSampName();
      var url = sw.buildSampUrl();
aa7247d6   Goutte   Generate a CDF fi...
681
      console.info("Trying to activate SAMP…", name, url);
cad44b6d   Goutte   Finish adding the...
682
683
684
685
686
687
688
689
690
691
692
693
694
695
      connector.runWithConnection(function (connection) {
        var msg = new samp.Message("table.load.cdf", {
          "name": name,
          "url": url // absolute URL required
        });
        connection.notifyAll([msg]);
      }, function (error) {
        var msg = 'Error: ' + error;
        console.error(msg);
        alert(msg);  // let's yell at the user as well
      });
    });
  });
</script>
9390ec89   Goutte   Initial experimen...
696
{% endblock %}