From: jvoisin Date: Mon, 28 Aug 2023 21:02:15 +0000 (+0200) Subject: Correction du filtrage de relays incorrects X-Git-Url: https://nos-oignons.net/gitweb/website.git/commitdiff_plain/f58962ab032acf13685b66923148beb408f6117c?hp=82524cf320aa0fc971555b834d816f9fb246e90f Correction du filtrage de relays incorrects Voir https://stackoverflow.com/questions/21811630/splicing-a-javascript-array-from-within-the-callback-passed-to-foreach --- diff --git a/assets/bw_graphs.js b/assets/bw_graphs.js index 3efacbb..dbeb1cf 100644 --- a/assets/bw_graphs.js +++ b/assets/bw_graphs.js @@ -62,12 +62,11 @@ BwDrawer.color.range(nos_oignons_relays.map(function(r) {return r.color})); BwDrawer.draw_bandwidth_graph = function(raw_data, selector, period) { // Purge non running relays - raw_data.relays.forEach(function(r, i) { - if (typeof r.read_history === 'undefined' || typeof r.write_history === 'undefined') { - raw_data.relays.splice(i, 1); - } + raw_data.relays = raw_data.relays.filter(function(relay) { + return typeof r.read_history === 'undefined' || typeof r.write_history === 'undefined'; }); + var update_period; var svg = d3.select(selector).append("svg")