Commit 60522cb2fc664277b5b3403bf26697d163bd4029
1 parent
64a671cd
Exists in
master
and in
2 other branches
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 | 23 | * ------------------------ |
24 | 24 | * |
25 | 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 | 28 | (function () { |
30 | - // let TimeSeries; | |
31 | - // let Orbits; | |
32 | 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 | 32 | class Target { |
36 | 33 | constructor(slug, name, config) { |
... | ... | @@ -51,12 +48,30 @@ |
51 | 48 | const INPUT_TIME_FORMAT = "YYYY-MM-DD"; |
52 | 49 | |
53 | 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 | 57 | constructor(configuration) { |
55 | 58 | const that = this; |
56 | 59 | this.configuration = configuration; |
57 | 60 | this.parameters = {}; |
58 | 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 | 76 | let targets_configs = []; |
62 | 77 | for (let k in this.configuration.targets) { |
... | ... | @@ -78,7 +93,6 @@ |
78 | 93 | * @param stopped_at string |
79 | 94 | */ |
80 | 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 | 96 | const app = this; |
83 | 97 | |
84 | 98 | started_at = moment(started_at).utc().hours(0).minutes(0).seconds(0); |
... | ... | @@ -1180,15 +1194,14 @@ |
1180 | 1194 | this.svg.select('.x.axis').attr('transform', `translate(0,${height})`); |
1181 | 1195 | if (animate) { |
1182 | 1196 | t = this.svg.transition().duration(750); |
1183 | - // t1 = this.svg.transition().duration(4750); | |
1184 | 1197 | this.svg.select('.x.axis').transition(t).call(this.xAxis); |
1185 | 1198 | this.svg.select('.y.axis').transition(t).call(this.yAxis); |
1186 | 1199 | } else { |
1187 | 1200 | this.svg.select('.x.axis').call(this.xAxis); |
1188 | 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 | 1205 | return this; |
1193 | 1206 | } |
1194 | 1207 | |
... | ... | @@ -1221,8 +1234,8 @@ |
1221 | 1234 | a = config['orbit']['a']; |
1222 | 1235 | b = config['orbit']['b']; |
1223 | 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 | 1239 | orbit_ellipse = el['orbit_ellipse']; |
1227 | 1240 | if (animate) { |
1228 | 1241 | t = this.svg.transition().duration(750); |
... | ... | @@ -1334,6 +1347,8 @@ |
1334 | 1347 | |
1335 | 1348 | Orbits.prototype.bisectDate = d3.bisector(d => d.t).left; |
1336 | 1349 | |
1350 | + /////////////////////////////////////////////////////////////////////////// | |
1351 | + | |
1337 | 1352 | global.SpaceWeather = SpaceWeather; |
1338 | 1353 | global.TimeSeries = TimeSeries; |
1339 | 1354 | global.Orbits = Orbits; | ... | ... |