Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First Pass at a 'Start New Week' feature #323

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

--button-text-color: var(--nook-phone-text-color);
--button-reset-text-color: #E45B5B;
--button-newweek-text-color: #49b87f;

--table-range0: hsl(140, 80%, 85%);
--table-range1: hsl(90, 80%, 85%);
Expand Down Expand Up @@ -108,6 +109,7 @@

--button-text-color: var(--nook-phone-text-color);
--button-reset-text-color: #E45B5B;
--button-newweek-text-color: #49b87f;

--table-range0: hsl(140, 80%, 27%);
--table-range1: hsl(90, 80%, 20%);
Expand Down Expand Up @@ -433,8 +435,20 @@ input[type=number] {
box-shadow: 0 1px 6px var(--shadow-5), 0 3px 6px var(--shadow-9);
}

#reset-btns {
display: flex;
padding: 10px;
}

.button.button--reset {
color: var(--button-reset-text-color);
margin: 10px;
}

.button.button--newweek {
color: var(--button-newweek-text-color);
display: none;
margin: 10px;
}

.table-wrapper {
Expand Down
5 changes: 4 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ <h6 data-i18n="weekdays.saturday"></h6>
<path fill="currentColor" d="M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z"></path>
</svg>
</div>
<button type="button" id="reset" class="button button--reset" name="action" data-i18n="prices.reset"></button>
<div id="reset-btns">
<button type="button" id="reset" class="button button--reset" name="action" data-i18n="prices.reset"></button>
<button type="button" id="new-week" class="button button--newweek" name="action" data-i18n="prices.new-week"></button>
</div>
</form>


Expand Down
17 changes: 17 additions & 0 deletions js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ const initialize = function () {
update();
}
});

$("#new-week").on("click", function() {
if (window.confirm(i18next.t("prices.week-warning"))) {
var prev = $("#new-week").attr("nextPattern")
sell_inputs.forEach(input => input.value = '')
fillFields([], false, prev)
$("#new-week").hide();
update()
}
});

console.log('finished initializing');
state.initialized = true;
Expand Down Expand Up @@ -301,6 +311,13 @@ const calculateOutput = function (data, first_buy, previous_pattern) {
.filter(val => val.pattern_number == poss.pattern_number)
.length;
out_line += `<td rowspan=${pattern_count}>${displayPercentage(poss.category_total_probability)}</td>`;
if(poss.category_total_probability >= .9995) {
$("#new-week").show();
$("#new-week").attr("nextPattern", poss.pattern_number);
} else {
$("#new-week").hide();
$("#new-week").attr("nextPattern", -1);
}
}
out_line += `<td>${displayPercentage(poss.probability)}</td>`;
for (let day of poss.prices.slice(2)) {
Expand Down
4 changes: 3 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
"copy-permalink": "Copy permalink",
"permalink-copied": "Permalink copied!",
"reset": "Reset Turnip Prophet",
"reset-warning": "Are you sure you want to reset all fields?\n\nThis cannot be undone!"
"reset-warning": "Are you sure you want to reset all fields?\n\nThis cannot be undone!",
Bpendragon marked this conversation as resolved.
Show resolved Hide resolved
"new-week": "Start New Week",
Bpendragon marked this conversation as resolved.
Show resolved Hide resolved
"week-warning": "Are you sure you want to reset prices?\nThis will also automatically set the input for the Previous Pattern\nThis cannot be undone!"
},
"weekdays": {
"monday": "Monday",
Expand Down