Commit 60522cb2fc664277b5b3403bf26697d163bd4029

Authored by Goutte
1 parent 64a671cd

Clean up a litle.

Showing 1 changed file with 26 additions and 11 deletions   Show diff stats
web/static/js/main.js
@@ -23,14 +23,11 @@ @@ -23,14 +23,11 @@
23 * ------------------------ 23 * ------------------------
24 * 24 *
25 * Lots of machine-generated micro-optimizations. Most are unconsequential. 25 * Lots of machine-generated micro-optimizations. Most are unconsequential.
26 - * The complex exporting pattern is ~ technical debt. Simplify it if you can.  
27 */ 26 */
28 27
29 (function () { 28 (function () {
30 - // let TimeSeries;  
31 - // let Orbits;  
32 const global = typeof exports !== 'undefined' && exports || this; 29 const global = typeof exports !== 'undefined' && exports || this;
33 - const GOLDEN_RATIO = 2 / (1 + Math.sqrt(5)); 30 + const GOLDEN_RATIO = 2 / (1 + Math.sqrt(5)); // 0.618…
34 31
35 class Target { 32 class Target {
36 constructor(slug, name, config) { 33 constructor(slug, name, config) {
@@ -51,12 +48,30 @@ @@ -51,12 +48,30 @@
51 const INPUT_TIME_FORMAT = "YYYY-MM-DD"; 48 const INPUT_TIME_FORMAT = "YYYY-MM-DD";
52 49
53 class SpaceWeather { 50 class SpaceWeather {
  51 + /**
  52 + * The main app, instantiated from an inline script.
  53 + * It defaults to an interval starting two months ago,
  54 + * and ending in a month. (both at midnight)
  55 + * @param configuration
  56 + */
54 constructor(configuration) { 57 constructor(configuration) {
55 const that = this; 58 const that = this;
56 this.configuration = configuration; 59 this.configuration = configuration;
57 this.parameters = {}; 60 this.parameters = {};
58 this.targets = {}; 61 this.targets = {};
59 - console.info("©2017\n _ _ _ _ ____\n | | | | ___| (_) ___ | _ \\ _ __ ___ _ __ __ _\n | |_| |/ _ \\ | |/ _ \\| |_) | '__/ _ \\| '_ \\ / _` |\n | _ | __/ | | (_) | __/| | | (_) | |_) | (_| |\n |_| |_|\\___|_|_|\\___/|_|_ |_|_ \\___/| .__/ \\__,_|\n | |__ _ _ / ___| _ \\| _ \\| _ \\_|\n | '_ \\| | | | | | | | | | |_) | |_) |\n | |_) | |_| | | |___| |_| | __/| __/\n |_.__/ \\__, | \\____|____/|_| |_|\n |___/\n\nThe full source of this website is available at :\nhttps://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE"); 62 + console.info("©2017\n" +
  63 + " _ _ _ _ ____\n" +
  64 + " | | | | ___| (_) ___ | _ \\ _ __ ___ _ __ __ _\n" +
  65 + " | |_| |/ _ \\ | |/ _ \\| |_) | '__/ _ \\| '_ \\ / _` |\n" +
  66 + " | _ | __/ | | (_) | __/| | | (_) | |_) | (_| |\n" +
  67 + " |_| |_|\\___|_|_|\\___/|_|_ |_|_ \\___/| .__/ \\__,_|\n" +
  68 + " | |__ _ _ / ___| _ \\| _ \\| _ \\_|\n" +
  69 + " | '_ \\| | | | | | | | | | |_) | |_) |\n" +
  70 + " | |_) | |_| | | |___| |_| | __/| __/\n" +
  71 + " |_.__/ \\__, | \\____|____/|_| |_|\n" +
  72 + " |___/\n\n" +
  73 + "The full source of this website is available at :\n" +
  74 + "https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE");
60 75
61 let targets_configs = []; 76 let targets_configs = [];
62 for (let k in this.configuration.targets) { 77 for (let k in this.configuration.targets) {
@@ -78,7 +93,6 @@ @@ -78,7 +93,6 @@
78 * @param stopped_at string 93 * @param stopped_at string
79 */ 94 */
80 init(started_at, stopped_at) { 95 init(started_at, stopped_at) {
81 - // "This is called by the inline bootstrap javascript code.\nThis ain't in the constructor because it might return a Promise later on.\n(for the loader, for example)";  
82 const app = this; 96 const app = this;
83 97
84 started_at = moment(started_at).utc().hours(0).minutes(0).seconds(0); 98 started_at = moment(started_at).utc().hours(0).minutes(0).seconds(0);
@@ -1180,15 +1194,14 @@ @@ -1180,15 +1194,14 @@
1180 this.svg.select('.x.axis').attr('transform', `translate(0,${height})`); 1194 this.svg.select('.x.axis').attr('transform', `translate(0,${height})`);
1181 if (animate) { 1195 if (animate) {
1182 t = this.svg.transition().duration(750); 1196 t = this.svg.transition().duration(750);
1183 - // t1 = this.svg.transition().duration(4750);  
1184 this.svg.select('.x.axis').transition(t).call(this.xAxis); 1197 this.svg.select('.x.axis').transition(t).call(this.xAxis);
1185 this.svg.select('.y.axis').transition(t).call(this.yAxis); 1198 this.svg.select('.y.axis').transition(t).call(this.yAxis);
1186 } else { 1199 } else {
1187 this.svg.select('.x.axis').call(this.xAxis); 1200 this.svg.select('.x.axis').call(this.xAxis);
1188 this.svg.select('.y.axis').call(this.yAxis); 1201 this.svg.select('.y.axis').call(this.yAxis);
1189 } 1202 }
1190 - this.xAxisTitle.attr("x", width / 2).attr("y", 37);  
1191 - this.yAxisTitle.attr("x", -1 * height / 2).attr("y", -30); 1203 + this.xAxisTitle.attr("x", width / 2.0).attr("y", 37);
  1204 + this.yAxisTitle.attr("x", -1 * height / 2.0).attr("y", -30);
1192 return this; 1205 return this;
1193 } 1206 }
1194 1207
@@ -1221,8 +1234,8 @@ @@ -1221,8 +1234,8 @@
1221 a = config['orbit']['a']; 1234 a = config['orbit']['a'];
1222 b = config['orbit']['b']; 1235 b = config['orbit']['b'];
1223 c = Math.sqrt(a * a - b * b); 1236 c = Math.sqrt(a * a - b * b);
1224 - cx = width / 2 - c;  
1225 - cy = height / 2; 1237 + cx = width / 2.0 - c;
  1238 + cy = height / 2.0;
1226 orbit_ellipse = el['orbit_ellipse']; 1239 orbit_ellipse = el['orbit_ellipse'];
1227 if (animate) { 1240 if (animate) {
1228 t = this.svg.transition().duration(750); 1241 t = this.svg.transition().duration(750);
@@ -1334,6 +1347,8 @@ @@ -1334,6 +1347,8 @@
1334 1347
1335 Orbits.prototype.bisectDate = d3.bisector(d => d.t).left; 1348 Orbits.prototype.bisectDate = d3.bisector(d => d.t).left;
1336 1349
  1350 + ///////////////////////////////////////////////////////////////////////////
  1351 +
1337 global.SpaceWeather = SpaceWeather; 1352 global.SpaceWeather = SpaceWeather;
1338 global.TimeSeries = TimeSeries; 1353 global.TimeSeries = TimeSeries;
1339 global.Orbits = Orbits; 1354 global.Orbits = Orbits;