added week min and week max columns, sorted table by week max price

added css
master
Valerio Riva 4 years ago committed by Mike Bryant
parent 348fdaf1ab
commit 840f684dee

@ -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;
}

@ -111,22 +111,22 @@
</p>
<p>
<table>
<table id="turnipTable">
<caption>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!</caption>
<thead>
<tr>
<th>Pattern</th>
<th>Sunday</th>
<th rowspan="2">Pattern</th>
<th rowspan="2">Sunday</th>
<th colspan="2">Monday</th>
<th colspan="2">Tuesday</th>
<th colspan="2">Wednesday</th>
<th colspan="2">Thursday</th>
<th colspan="2">Friday</th>
<th colspan="2">Saturday</th>
<th rowspan="2">Week Min</th>
<th rowspan="2">Week Max</th>
</tr>
<tr>
<th></th>
<th></th>
<th>AM</th>
<th>PM</th>
<th>AM</th>
@ -141,9 +141,7 @@
<th>PM</th>
</tr>
</thead>
<tbody id="output">
</tbody>
<tbody id="output"></tbody>
</table>
</p>

@ -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 = "<tr><td>" + poss.pattern_description + "</td>"
for (let day of poss.prices.slice(1)) {
if (day.min != day.max) {
out_line += "<td>" + day.min + ".." + day.max + "</td>"
if (day.min !== day.max) {
out_line += `<td>${day.min}..${day.max}</td>`;
} else {
out_line += "<td>" + day.min + "</td>"
out_line += `<td class="one">${day.min}</td>`;
}
}
out_line += "</tr>"
out_line += `<td class="one">${poss.weekMin}</td><td class="one">${poss.weekMax}</td></tr>`;
output_possibilities += out_line
}
$("#output").html(output_possibilities)
})
});

Loading…
Cancel
Save