From 9b3d8b81e793c399e1bbb07df464c4248bd9cc07 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 26 May 2020 06:34:27 +0300 Subject: [PATCH] Replace `$.each` with native methods. Signed-off-by: XhmikosR --- scripts/pi-hole/js/index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 018c7029..f2a51c83 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -310,11 +310,12 @@ function updateQueryTypesPie() { iter = data; } - $.each(iter, function (key, value) { - v.push(value); + Object.keys(iter).forEach(function (key) { + v.push(iter[key]); c.push(colors[i++ % colors.length]); k.push(key); }); + // Build a single dataset with the data to be pushed var dd = { data: v, backgroundColor: c }; // and push it at once @@ -469,7 +470,9 @@ function updateForwardDestinationsPie() { values = []; // Collect values and colors - $.each(data.forward_destinations, function (key, value) { + Object.keys(data.forward_destinations).forEach(function (key) { + var value = data.forward_destinations[key]; + if (key.indexOf("|") !== -1) { key = key.substr(0, key.indexOf("|")); } @@ -478,7 +481,7 @@ function updateForwardDestinationsPie() { }); // Split data into individual arrays for the graphs - $.each(values, function (key, value) { + values.forEach(function (value) { k.push(value[0]); v.push(value[1]); c.push(value[2]);