Skip to content

Commit

Permalink
Merge pull request #39 from MinoruSekine/fix/38/refine_gain_input_method
Browse files Browse the repository at this point in the history
fix: Gain input usability with replacing spin to dropdown. (#38)
  • Loading branch information
MinoruSekine authored Jul 11, 2024
2 parents a2a43ce + 8fd7580 commit 19464c4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ clean-out: clean-site
clean-site:
rm -rf $(SITE_OUT_DIR)

site: $(SITE_OUT_HTML) $(SITE_OUT_JS) $(SITE_OUT_CSS) site-jsdoc
site: site-calculator site-jsdoc

site-calculator: $(SITE_OUT_HTML) $(SITE_OUT_JS) $(SITE_OUT_CSS)

$(SITE_OUT_DIR):
mkdir -p $@
Expand Down
26 changes: 16 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,22 @@ <h2>ターゲット</h2>
<input type="number" name="to-level" id="to-level-input" value="1" step="1" min="1" max="31">
</li>
<li>
<label for="tsukumo-gain-input"><span class="target">倍率</span></label>
<input type="number" name="tsukumo-gain" id="tsukumo-gain-input" value="1.0" step="0.1" min="1.0" max="2.0">
<details>
<summary>倍率目安</summary>
<ul>
<li>x1.0: 通常時</li>
<li>x1.5: 九十九キャンペーン中</li>
<li>x2.0: もののふの日ボーナス最大</li>
</ul>
</details>
<label for="tsukumo-gain-dropdown"><span class="target">倍率</span></label>
<select name="tsukumo-gain" id="tsukumo-gain-dropdown">
<optgroup label="通常時">
<option value="1.0">x1.0</option>
</optgroup>
<optgroup label="九十九キャンペーン中">
<option value="1.5">x1.5</option>
</optgroup>
<optgroup label="もののふの日ボーナス">
<option value="1.2">x1.2</option>
<option value="1.4">x1.4</option>
<option value="1.6">x1.6</option>
<option value="1.8">x1.8</option>
<option value="2.0">x2.0</option>
</optgroup>
</select>
</li>
</ul>

Expand Down
10 changes: 4 additions & 6 deletions nol_tsukumo.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ class NolTsukumoController extends NolTsukumoModelObserverInterface {
#currentLevelInput = null;
#currentExpInput = null;
#currentNumOfActivatedTsukumo = null;
#gainInput = null;
#gainDropdown = null;
#memoButton = null;
#memoClearButton = null;
#memoUndoButton = null;
Expand All @@ -515,7 +515,7 @@ class NolTsukumoController extends NolTsukumoModelObserverInterface {
this.#currentExpInput = document.getElementById('exp-input');
this.#currentNumOfActivatedTsukumo =
document.getElementById('active-tsukumo-num-input');
this.#gainInput = document.getElementById('tsukumo-gain-input');
this.#gainDropdown = document.getElementById('tsukumo-gain-dropdown');
this.#memoButton = document.getElementById('memo-button');
this.#memoClearButton = document.getElementById('memo-clear-button');
this.#memoUndoButton = document.getElementById('memo-undo-button');
Expand All @@ -541,11 +541,9 @@ class NolTsukumoController extends NolTsukumoModelObserverInterface {
this.#model.setToLevel(parseInt(this.#toLevelInput.value, 10));
});

this.#gainInput.addEventListener('input', () => {
const gain = parseFloat(this.#gainInput.value);
this.#gainDropdown.addEventListener('change', () => {
const gain = parseFloat(this.#gainDropdown.value);
this.#model.setGain(gain);
// Do not omit ".0" even if just integer value.
this.#gainInput.value = gain.toFixed(1);
});

this.#memoButton.addEventListener('click', () => {
Expand Down

0 comments on commit 19464c4

Please sign in to comment.