From 9e73c22c013b431c289ed812a97d1dce6ed3fbc5 Mon Sep 17 00:00:00 2001 From: Evan Raskob <erask002@gold.ac.uk> Date: Wed, 16 Dec 2020 18:40:56 +0000 Subject: [PATCH] simplifed a bit --- pixel_calculator/pixel_calculator.html | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pixel_calculator/pixel_calculator.html b/pixel_calculator/pixel_calculator.html index 9cb4ea8..b70a6d5 100644 --- a/pixel_calculator/pixel_calculator.html +++ b/pixel_calculator/pixel_calculator.html @@ -95,10 +95,6 @@ let result = document.getElementById("result"); let calcButton = document.getElementById("calculate"); - const getChannels = () => parseInt(channels.selectedOptions[0].value); - - const getChannel = () => parseInt(channel.selectedOptions[0].value); - channels.addEventListener('change', function () { // let maxOffset = getChannels()-1; doCalc(); @@ -119,7 +115,10 @@ let x = parseInt(document.getElementById("x").value); let y = parseInt(document.getElementById("y").value); - let calculation = (y * w + x) * getChannels() + getChannel(); + // calculate index in pixels array: + let calculation = (y * w + x) * + parseInt(channels.selectedOptions[0].value) + + parseInt(channel.selectedOptions[0].value); result.innerHTML = calculation; } </script> -- GitLab