Add counter, fix null addition to ignored list

master
kiichan 2 years ago
parent
commit
3532836a4d
  1. 12
      picker.html

12
picker.html

@ -56,7 +56,7 @@ @@ -56,7 +56,7 @@
<td><button onClick="pickem('5')">Pick a Poke</button></td><td id="5"></td><td><button onClick="ignorem('5')">Mark used</button></td>
</tr>
<tr>
<td></td><td><button onClick="reset()">Clear current team</button></td><td><button onClick="ignore_team()">Mark team used</button></td><td></td>
<td id="count"></td><td><button onClick="reset()">Clear current team</button></td><td><button onClick="ignore_team()">Mark team used</button></td><td></td>
</tr>
</table>
</div>
@ -74,6 +74,11 @@ @@ -74,6 +74,11 @@
function get_ignores () {
var ignores = document.getElementById("ignored_pkmn").value;
ignored_pkmn = ignores.split("\n").filter(line => line !== "").sort();
set_count();
}
function set_count() {
document.getElementById("count").innerHTML = (pkmn.length-ignored_pkmn.length-picked.filter(t => t).length).toString()+" Pokes left";
}
function pickem (id) {
@ -84,6 +89,7 @@ @@ -84,6 +89,7 @@
elem.innerHTML = available[ix];
picked[Number(id)] = available[ix]
elem.style.color = "white";
set_count();
}
function ignorem (id) {
@ -102,7 +108,7 @@ @@ -102,7 +108,7 @@
var elem = document.getElementById(i.toString());
var to_ignore = elem.innerHTML;
document.getElementById(i.toString()).innerHTML = "";
if (!ignored_pkmn.includes(to_ignore)) {
if (!ignored_pkmn.includes(to_ignore) & to_ignore !== "") {
ignored_pkmn[ignored_pkmn.length] = to_ignore;
}
elem.style.color = "white";
@ -110,6 +116,7 @@ @@ -110,6 +116,7 @@
}
ignored_pkmn.sort();
document.getElementById("ignored_pkmn").value = ignored_pkmn.join("\n");
set_count();
}
function reset () {
@ -119,6 +126,7 @@ @@ -119,6 +126,7 @@
elem.style.color = "white";
picked[i] = null;
}
set_count();
}
function copy_used() {