From b909a301888be3cd5a9ed8177653cb3c99a50c2d Mon Sep 17 00:00:00 2001 From: Marcos Vinicius Date: Tue, 31 Jan 2023 23:08:19 -0300 Subject: [PATCH] updated --- application/views/receita.php | 54 ++++----- application/views/receitas.php | 4 +- assets/images/message.txt | 215 --------------------------------- 3 files changed, 25 insertions(+), 248 deletions(-) delete mode 100644 assets/images/message.txt diff --git a/application/views/receita.php b/application/views/receita.php index aeef405..0f1b6d1 100644 --- a/application/views/receita.php +++ b/application/views/receita.php @@ -119,8 +119,8 @@ '.ucfirst($ingrediente->name).' - % - g + % + g '; @@ -138,7 +138,7 @@ @@ -159,37 +159,29 @@ gramas = document.querySelectorAll('.gramas'); - for(let x of gramas){ - + for(let i = 0; i < percents.length; i++){ + percents[i].addEventListener('change', () => { base = 0; - x.addEventListener('change', () => { - - j = 0; - - for(let i of percents){ - console.log(gramas[0].value); - if(i.value == 100){ - base = gramas[j].value/100; - break; - } - - j++; - + for(let j = 0; j < percents.length; j++){ + if(percents[j].value == 100){ + base = gramas[j].value/100; + break; } - - - j = 0; - - for(let i of gramas){ - - i.value = percents[j].value*base; - j++; - } - - }); - - } + for(let j = 0; j < gramas.length; j++){ + gramas[j].value = (percents[j].value * base).toFixed(2); + } + }); +} + +for(let i = 0; i < gramas.length; i++){ + gramas[i].addEventListener('change', () => { + base = gramas[i].value/percents[i].value; + for(let j = 0; j < gramas.length; j++){ + gramas[j].value = (percents[j].value * base).toFixed(2); + } + }); +} z = 0; for(let i of names){ diff --git a/application/views/receitas.php b/application/views/receitas.php index 9a55270..1bd4465 100644 --- a/application/views/receitas.php +++ b/application/views/receitas.php @@ -36,8 +36,8 @@
Ops...

Parece que você ainda não adicionou receitas a essa categoria!

-
diff --git a/assets/images/message.txt b/assets/images/message.txt deleted file mode 100644 index 5e2534c..0000000 --- a/assets/images/message.txt +++ /dev/null @@ -1,215 +0,0 @@ - - - - - - - - - - - -