diff --git a/css/styles.css b/css/styles.css index f8120ec..70b0a23 100644 --- a/css/styles.css +++ b/css/styles.css @@ -208,7 +208,8 @@ h2 { outline: none; } -.dialog-box p { +.dialog-box p, +.dialog-box label { font-family: 'Raleway', sans-serif; font-weight: 800; font-size: 1rem; diff --git a/index.html b/index.html index 2305aad..b27f394 100644 --- a/index.html +++ b/index.html @@ -121,7 +121,7 @@
- +
@@ -308,10 +308,10 @@

:

-

:

+

:

-

:

+

:

diff --git a/js/predictions.js b/js/predictions.js index e5627da..eb680b4 100644 --- a/js/predictions.js +++ b/js/predictions.js @@ -657,7 +657,6 @@ class Predictor { } yield { - pattern_description: i18next.t("patterns.fluctuating"), pattern_number: 0, prices: predicted_prices, probability, @@ -725,8 +724,8 @@ class Predictor { } // Now each day is independent of next - let min_randoms = [0.9, 1.4, 2.0, 1.4, 0.9, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4] - let max_randoms = [1.4, 2.0, 6.0, 2.0, 1.4, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9] + let min_randoms = [0.9, 1.4, 2.0, 1.4, 0.9, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4]; + let max_randoms = [1.4, 2.0, 6.0, 2.0, 1.4, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9]; for (let i = peak_start; i < 14; i++) { probability *= this.generate_individual_random_price( given_prices, predicted_prices, i, 1, min_randoms[i - peak_start], @@ -736,7 +735,6 @@ class Predictor { } } yield { - pattern_description: i18next.t("patterns.large-spike"), pattern_number: 1, prices: predicted_prices, probability, @@ -783,7 +781,6 @@ class Predictor { } yield { - pattern_description: i18next.t("patterns.decreasing"), pattern_number: 2, prices: predicted_prices, probability, @@ -864,7 +861,6 @@ class Predictor { } yield { - pattern_description: i18next.t("patterns.small-spike"), pattern_number: 3, prices: predicted_prices, probability, @@ -909,11 +905,11 @@ class Predictor { } else { // All buy prices are equal probability and we're at the outmost layer, // so don't need to multiply_generator_probability here. - yield* this.generate_all_patterns(temp_sell_prices, previous_pattern) + yield* this.generate_all_patterns(temp_sell_prices, previous_pattern); } } } else { - yield* this.generate_all_patterns(sell_prices, previous_pattern) + yield* this.generate_all_patterns(sell_prices, previous_pattern); } } @@ -921,7 +917,7 @@ class Predictor { const sell_prices = this.prices; const first_buy = this.first_buy; const previous_pattern = this.previous_pattern; - let generated_possibilities = [] + let generated_possibilities = []; for (let i = 0; i < 6; i++) { this.fudge_factor = i; generated_possibilities = Array.from(this.generate_possibilities(sell_prices, first_buy, previous_pattern)); @@ -958,7 +954,7 @@ class Predictor { poss.weekMax = Math.max(...weekMaxes); } - let category_totals = {} + let category_totals = {}; for (let i of [0, 1, 2, 3]) { category_totals[i] = generated_possibilities .filter(value => value.pattern_number == i) @@ -979,7 +975,7 @@ class Predictor { const prices = { min: 999, max: 0, - } + }; for (let poss of generated_possibilities) { if (poss.prices[day].min < prices.min) { prices.min = poss.prices[day].min; @@ -992,7 +988,6 @@ class Predictor { } generated_possibilities.unshift({ - pattern_description: i18next.t("patterns.all"), pattern_number: 4, prices: global_min_max, weekGuaranteedMinimum: Math.min(...generated_possibilities.map(poss => poss.weekGuaranteedMinimum)), diff --git a/js/scripts.js b/js/scripts.js index 5339a4c..51fd89b 100644 --- a/js/scripts.js +++ b/js/scripts.js @@ -1,18 +1,18 @@ //Reusable Fields const getSellFields = function () { - let fields = [] + let fields = []; for (var i = 2; i < 14; i++) { - fields.push($("#sell_" + i)[0]) + fields.push($("#sell_" + i)[0]); } - return fields -} + return fields; +}; const getFirstBuyRadios = function () { return [ $("#first-time-radio-no")[0], $("#first-time-radio-yes")[0] ]; -} +}; const getPreviousPatternRadios = function () { return [ @@ -22,11 +22,11 @@ const getPreviousPatternRadios = function () { $("#pattern-radio-large-spike")[0], $("#pattern-radio-decreasing")[0] ]; -} +}; const getCheckedRadio = function (radio_array) { return radio_array.find(radio => radio.checked === true).value; -} +}; const checkRadioByValue = function (radio_array, value) { if (value === null) { @@ -34,15 +34,15 @@ const checkRadioByValue = function (radio_array, value) { } value = value.toString(); radio_array.find(radio => radio.value == value).checked = true; -} +}; -const sell_inputs = getSellFields() -const buy_input = $("#buy") -const first_buy_radios = getFirstBuyRadios() -const previous_pattern_radios = getPreviousPatternRadios() -const permalink_input = $('#permalink-input') -const permalink_button = $('#permalink-btn') -const snackbar = $('#snackbar') +const sell_inputs = getSellFields(); +const buy_input = $("#buy"); +const first_buy_radios = getFirstBuyRadios(); +const previous_pattern_radios = getPreviousPatternRadios(); +const permalink_input = $('#permalink-input'); +const permalink_button = $('#permalink-btn'); +const snackbar = $('#snackbar'); //Functions const fillFields = function (prices, first_buy, previous_pattern) { @@ -50,21 +50,21 @@ const fillFields = function (prices, first_buy, previous_pattern) { checkRadioByValue(previous_pattern_radios, previous_pattern); buy_input.focus(); - buy_input.val(prices[0] || '') + buy_input.val(prices[0] || ''); buy_input.blur(); - const sell_prices = prices.slice(2) + const sell_prices = prices.slice(2); sell_prices.forEach((price, index) => { if (!price) { - return + return; } else { const element = $("#sell_" + (index + 2)); element.focus(); element.val(price); element.blur(); } - }) -} + }); +}; const initialize = function () { try { @@ -73,9 +73,9 @@ const initialize = function () { const previous_pattern = previous[1]; const prices = previous[2]; if (prices === null) { - fillFields([], first_buy, previous_pattern) + fillFields([], first_buy, previous_pattern); } else { - fillFields(prices, first_buy, previous_pattern) + fillFields(prices, first_buy, previous_pattern); } } catch (e) { console.error(e); @@ -83,32 +83,32 @@ const initialize = function () { $(document).trigger("input"); - $("#permalink-btn").on("click", copyPermalink) + $("#permalink-btn").on("click", copyPermalink); $("#reset").on("click", function () { if (window.confirm(i18next.t("prices.reset-warning"))) { - sell_inputs.forEach(input => input.value = '') - fillFields([], false, -1) - update() + sell_inputs.forEach(input => input.value = ''); + fillFields([], false, -1); + update(); } - }) -} + }); +}; const updateLocalStorage = function (prices, first_buy, previous_pattern) { try { - if (prices.length !== 14) throw "The data array needs exactly 14 elements to be valid" - localStorage.setItem("sell_prices", JSON.stringify(prices)) + if (prices.length !== 14) throw "The data array needs exactly 14 elements to be valid"; + localStorage.setItem("sell_prices", JSON.stringify(prices)); localStorage.setItem("first_buy", JSON.stringify(first_buy)); localStorage.setItem("previous_pattern", JSON.stringify(previous_pattern)); } catch (e) { - console.error(e) + console.error(e); } -} +}; const isEmpty = function (arr) { - const filtered = arr.filter(value => value !== null && value !== '' && !isNaN(value)) - return filtered.length == 0 -} + const filtered = arr.filter(value => value !== null && value !== '' && !isNaN(value)); + return filtered.length == 0; +}; const getFirstBuyStateFromQuery = function (param) { try { @@ -131,15 +131,15 @@ const getFirstBuyStateFromQuery = function (param) { } catch (e) { return null; } -} +}; const getFirstBuyStateFromLocalstorage = function () { - return JSON.parse(localStorage.getItem('first_buy')) -} + return JSON.parse(localStorage.getItem('first_buy')); +}; const getPreviousPatternStateFromLocalstorage = function () { - return JSON.parse(localStorage.getItem('previous_pattern')) -} + return JSON.parse(localStorage.getItem('previous_pattern')); +}; const getPreviousPatternStateFromQuery = function (param) { try { @@ -167,7 +167,7 @@ const getPreviousPatternStateFromQuery = function (param) { } catch (e) { return null; } -} +}; const getPricesFromLocalstorage = function () { try { @@ -245,8 +245,8 @@ const getSellPrices = function () { //Checks all sell inputs and returns an array with their values return res = sell_inputs.map(function (input) { return parseInt(input.value || ''); - }) -} + }); +}; const getPriceClass = function(buy_price, max) { const priceBrackets = [200, 30, 0, -30, -99]; @@ -257,7 +257,7 @@ const getPriceClass = function(buy_price, max) { } } return ""; -} +}; const displayPercentage = function(fraction) { if (Number.isFinite(fraction)) { @@ -270,28 +270,29 @@ const displayPercentage = function(fraction) { return '<0.01%'; } } else { - return '—' + return '—'; } -} +}; const calculateOutput = function (data, first_buy, previous_pattern) { if (isEmpty(data)) { $("#output").html(""); return; } + let pat_desc = {0:"fluctuating", 1:"large-spike", 2:"decreasing", 3:"small-spike", 4:"all"}; let output_possibilities = ""; let predictor = new Predictor(data, first_buy, previous_pattern); let analyzed_possibilities = predictor.analyze_possibilities(); let buy_price = parseInt(buy_input.val()); - previous_pattern_number = "" + previous_pattern_number = ""; for (let poss of analyzed_possibilities) { - var out_line = "" + poss.pattern_description + ""; + var out_line = "" + i18next.t("patterns." + pat_desc[poss.pattern_number]) + ""; const style_price = buy_price || poss.prices[0].min; if (previous_pattern_number != poss.pattern_number) { - previous_pattern_number = poss.pattern_number + previous_pattern_number = poss.pattern_number; pattern_count = analyzed_possibilities .filter(val => val.pattern_number == poss.pattern_number) - .length + .length; out_line += `${displayPercentage(poss.category_total_probability)}`; } out_line += `${displayPercentage(poss.probability)}`; @@ -307,13 +308,13 @@ const calculateOutput = function (data, first_buy, previous_pattern) { var min_class = getPriceClass(style_price, poss.weekGuaranteedMinimum); var max_class = getPriceClass(style_price, poss.weekMax); out_line += `${poss.weekGuaranteedMinimum}${poss.weekMax}`; - output_possibilities += out_line + output_possibilities += out_line; } - $("#output").html(output_possibilities) + $("#output").html(output_possibilities); update_chart(data, analyzed_possibilities); -} +}; const generatePermalink = function (buy_price, sell_prices, first_buy, previous_pattern) { let searchParams = new URLSearchParams(); @@ -337,7 +338,7 @@ const generatePermalink = function (buy_price, sell_prices, first_buy, previous_ } return searchParams.toString() && window.location.origin.concat('?', searchParams.toString()); -} +}; const copyPermalink = function () { let text = permalink_input[0]; @@ -350,17 +351,17 @@ const copyPermalink = function () { permalink_input.hide(); flashMessage(i18next.t("prices.permalink-copied")); -} +}; const flashMessage = function(message) { snackbar.text(message); snackbar.addClass('show'); setTimeout(function () { - snackbar.removeClass('show') + snackbar.removeClass('show'); snackbar.text(''); }, 3000); -} +}; const update = function () { const sell_prices = getSellPrices(); @@ -383,4 +384,4 @@ const update = function () { } calculateOutput(prices, first_buy, previous_pattern); -} +}; diff --git a/locales/pl.json b/locales/pl.json index 7efb24b..14df76c 100644 --- a/locales/pl.json +++ b/locales/pl.json @@ -3,7 +3,7 @@ "daisy-mae": "Daisy Mae" }, "welcome": { - "salutation": "Cześć, witam w aplikacji Turnip Prophet na Twoim Nook Phone.", + "salutation": "Cześć, witaj w aplikacji Turnip Prophet na Twoim Nook Phone.", "description": "Ta aplikacja pozwoli Ci codziennie śledzić ceny rzep na twojej wyspie, jednak będziesz musiał uzupełniać je samodzielnie.", "conclusion": "Następnie aplikacja Turnip Prophet w magiczny sposób przewidzi jakie ceny rzep będziesz mieć przez resztę tygodnia" }, @@ -54,7 +54,7 @@ }, "times": { "morning": "Rano", - "afternoon": "Południe" + "afternoon": "Popołudnie" }, "output": { "title": "Wyniki", @@ -73,9 +73,9 @@ "development": "Ta aplikacja wciąż jest w produkcji, lecz z czasem zostanie poprawiona!", "thanks": "Nie udałoby nam się to bez pracy Ninji, który dowiedział się jak Timmy and Tommy wyceniają rzepy.", "support": "Wsparcie, komentarze i wpłaty są możliwe pod adresem Github", - "sponsor": "Chcesz, wesprzeć twórców tego projektu? Wejdź na stronę GitHub i wciśnij '❤ Sponsor'", - "contributors-text": "Oh! I nie zapominajmy o tych, którzy dotychczas nas wspierali!", - "contributors": "Fundatorzy", + "sponsor": "Chcesz wesprzeć twórców tego projektu? Wejdź na stronę GitHub i wciśnij '❤ Sponsor'", + "contributors-text": "Aha! I nie zapominajmy o tych, którzy dotychczas nas wspierali!", + "contributors": "Współautorzy", "language": "Język" } } diff --git a/locales/zh-TW.json b/locales/zh-TW.json index ec87fc3..06540f6 100644 --- a/locales/zh-TW.json +++ b/locales/zh-TW.json @@ -69,7 +69,7 @@ } }, "textbox": { - "description": "在你紀錄了一些大頭菜價格後,Turnip Prophet 會預測,並顯示自己島上可能出現的不同模型。", + "description": "在你記錄了一些大頭菜價格後,Turnip Prophet 會預測,並顯示自己島上可能出現的不同模型。", "development": "此工具仍在開發中,但會隨著時間的推移而改善!", "thanks": "要不是 Ninji 協助釐清豆狸和粒狸的大頭菜估價方式,這一切都不可能實現。", "support": "可於 GitHub 取得支援、討論及貢獻。",