From 840f684dee2e4982ce4f4fb4126f6048ba855b28 Mon Sep 17 00:00:00 2001 From: Valerio Riva Date: Mon, 6 Apr 2020 09:47:43 +0200 Subject: [PATCH] added week min and week max columns, sorted table by week max price added css --- css/styles.css | 21 +++++++++++++++++++++ index.html | 14 ++++++-------- js/scripts.js | 25 +++++++++++++++++++------ 3 files changed, 46 insertions(+), 14 deletions(-) diff --git a/css/styles.css b/css/styles.css index e69de29..f32c3f1 100644 --- a/css/styles.css +++ b/css/styles.css @@ -0,0 +1,21 @@ +#turnipTable { + border: 1px solid #000000; + border-spacing: 0; + border-collapse: collapse; +} + +#turnipTable th, #turnipTable td { + padding: 5px; + border: 1px solid #000000; + margin: 0; + min-width: 50px; +} + +#turnipTable th { + text-align: center; + vertical-align: top; +} + +#turnipTable td { + text-align: right; +} \ No newline at end of file diff --git a/index.html b/index.html index e9112ff..e61b054 100644 --- a/index.html +++ b/index.html @@ -111,22 +111,22 @@

- +
- - + + + + - - @@ -141,9 +141,7 @@ - - - +
Your turnip prices will be one of the following patterns. Each cell contains the minimum..maximum price for that half-day. If you don't have a pattern, something's gone wrong, sorry :(. Check back next week!
PatternSundayPatternSunday Monday Tuesday Wednesday Thursday Friday SaturdayWeek MinWeek Max
AM PM AMPM

diff --git a/js/scripts.js b/js/scripts.js index bf32f09..a5ec560 100644 --- a/js/scripts.js +++ b/js/scripts.js @@ -563,6 +563,19 @@ function analyze_possibilities(sell_prices) { prices: global_min_max, }); + for (let poss of generated_possibilities) { + var weekMins = []; + var weekMaxes = []; + for (let day of poss.prices.slice(1)) { + weekMins.push(day.min); + weekMaxes.push(day.max); + } + poss.weekMin = Math.min(...weekMins); + poss.weekMax = Math.max(...weekMaxes); + } + + generated_possibilities.sort((a, b) => a.weekMax < b.weekMax); + return generated_possibilities; } @@ -620,19 +633,19 @@ $(document).on("input", function() { return; } - var output_possibilities = ""; + let output_possibilities = ""; for (let poss of analyze_possibilities(sell_prices)) { var out_line = "" + poss.pattern_description + "" for (let day of poss.prices.slice(1)) { - if (day.min != day.max) { - out_line += "" + day.min + ".." + day.max + "" + if (day.min !== day.max) { + out_line += `${day.min}..${day.max}`; } else { - out_line += "" + day.min + "" + out_line += `${day.min}`; } } - out_line += "" + out_line += `${poss.weekMin}${poss.weekMax}`; output_possibilities += out_line } $("#output").html(output_possibilities) -}) +});