From 60522cb2fc664277b5b3403bf26697d163bd4029 Mon Sep 17 00:00:00 2001 From: Goutte Date: Wed, 17 Oct 2018 19:03:52 +0200 Subject: [PATCH] Clean up a litle. --- web/static/js/main.js | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/web/static/js/main.js b/web/static/js/main.js index 7ec6146..cf75418 100644 --- a/web/static/js/main.js +++ b/web/static/js/main.js @@ -23,14 +23,11 @@ * ------------------------ * * Lots of machine-generated micro-optimizations. Most are unconsequential. - * The complex exporting pattern is ~ technical debt. Simplify it if you can. */ (function () { - // let TimeSeries; - // let Orbits; const global = typeof exports !== 'undefined' && exports || this; - const GOLDEN_RATIO = 2 / (1 + Math.sqrt(5)); + const GOLDEN_RATIO = 2 / (1 + Math.sqrt(5)); // 0.618… class Target { constructor(slug, name, config) { @@ -51,12 +48,30 @@ const INPUT_TIME_FORMAT = "YYYY-MM-DD"; class SpaceWeather { + /** + * The main app, instantiated from an inline script. + * It defaults to an interval starting two months ago, + * and ending in a month. (both at midnight) + * @param configuration + */ constructor(configuration) { const that = this; this.configuration = configuration; this.parameters = {}; this.targets = {}; - 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"); + console.info("©2017\n" + + " _ _ _ _ ____\n" + + " | | | | ___| (_) ___ | _ \\ _ __ ___ _ __ __ _\n" + + " | |_| |/ _ \\ | |/ _ \\| |_) | '__/ _ \\| '_ \\ / _` |\n" + + " | _ | __/ | | (_) | __/| | | (_) | |_) | (_| |\n" + + " |_| |_|\\___|_|_|\\___/|_|_ |_|_ \\___/| .__/ \\__,_|\n" + + " | |__ _ _ / ___| _ \\| _ \\| _ \\_|\n" + + " | '_ \\| | | | | | | | | | |_) | |_) |\n" + + " | |_) | |_| | | |___| |_| | __/| __/\n" + + " |_.__/ \\__, | \\____|____/|_| |_|\n" + + " |___/\n\n" + + "The full source of this website is available at :\n" + + "https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE"); let targets_configs = []; for (let k in this.configuration.targets) { @@ -78,7 +93,6 @@ * @param stopped_at string */ init(started_at, stopped_at) { - // "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)"; const app = this; started_at = moment(started_at).utc().hours(0).minutes(0).seconds(0); @@ -1180,15 +1194,14 @@ this.svg.select('.x.axis').attr('transform', `translate(0,${height})`); if (animate) { t = this.svg.transition().duration(750); - // t1 = this.svg.transition().duration(4750); this.svg.select('.x.axis').transition(t).call(this.xAxis); this.svg.select('.y.axis').transition(t).call(this.yAxis); } else { this.svg.select('.x.axis').call(this.xAxis); this.svg.select('.y.axis').call(this.yAxis); } - this.xAxisTitle.attr("x", width / 2).attr("y", 37); - this.yAxisTitle.attr("x", -1 * height / 2).attr("y", -30); + this.xAxisTitle.attr("x", width / 2.0).attr("y", 37); + this.yAxisTitle.attr("x", -1 * height / 2.0).attr("y", -30); return this; } @@ -1221,8 +1234,8 @@ a = config['orbit']['a']; b = config['orbit']['b']; c = Math.sqrt(a * a - b * b); - cx = width / 2 - c; - cy = height / 2; + cx = width / 2.0 - c; + cy = height / 2.0; orbit_ellipse = el['orbit_ellipse']; if (animate) { t = this.svg.transition().duration(750); @@ -1334,6 +1347,8 @@ Orbits.prototype.bisectDate = d3.bisector(d => d.t).left; + /////////////////////////////////////////////////////////////////////////// + global.SpaceWeather = SpaceWeather; global.TimeSeries = TimeSeries; global.Orbits = Orbits; -- libgit2 0.21.2