Skip to content

Commit

Permalink
code reformatting, added amiibo toggle, failed attempt to optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
ranidspace committed Jan 3, 2024
1 parent 4130e66 commit 8b1a0b7
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 50 deletions.
8 changes: 5 additions & 3 deletions GearCheck.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<script src="GearCheckData\gearchecker.js"></script>
</head>
<body onload=loadpage()>
<h1 class="title">Splatoon 3 Gear Completion Checker <small>V1.0.0</small></h1> <button
<h1 class="title">Splatoon 3 Gear Completion Checker <small>V1.1.0</small></h1> <button
onclick=changetheme()
type="button"
data-theme-toggle
Expand All @@ -31,8 +31,10 @@ <h1 class="title">Splatoon 3 Gear Completion Checker <small>V1.0.0</small></h1>

<p>Upload the geardata file and press submit:</p><br />

<input type="file" id="geardata" name="file" accept=".json" class="inputbutton" />
<button onclick=submit()>Submit</button>
<input type="file" id="geardata" name="file" accept=".json" class="inputbutton" /><br />
<input type="checkbox" id="amiibo">
<label for="amiibo">Exclude Missing Amiibo Gear</label><br />
<button onclick=submit()>Start</button>
<div id='output'></div>

</body>
Expand Down
99 changes: 54 additions & 45 deletions GearCheckData/gearchecker.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
var output = ""
function submit(){
//clear all data on the page
document.getElementById("output").innerHTML = "";
const noamiibo = document.getElementById("amiibo").checked;

//grab data
let gearfile = document.getElementById('geardata').files[0];
console.log(gearfile);
const gearfile = document.getElementById('geardata').files[0];
//read data
let reader = new FileReader();
const reader = new FileReader();
reader.readAsText(gearfile);

//do things with the data
reader.onload = async function() {
var result = JSON.parse(reader.result);
const result = JSON.parse(reader.result);

//prepping html stuff
div = document.createElement("h1");
Expand All @@ -25,13 +24,14 @@ function submit(){
document.getElementById("output").appendChild(div);

//run the missing gear function
await missinggear(result, 'head', "Head")
await missinggear(result, 'clothing', "Clothes")
await missinggear(result, 'shoes', "Shoes")
await missinggear(result, 'head', "Head", noamiibo)
await missinggear(result, 'clothing', "Clothes", noamiibo)
await missinggear(result, 'shoes', "Shoes", noamiibo)

//Loop through 0-5 stars and find the gear for each
for (let i = 0; i < 6; i++){
div = document.createElement("h1");
div.textContent = (`${i} Star Gear`);
div.textContent = (i+` Star Gear`);
document.getElementById("output").appendChild(div);

div = document.createElement("div");
Expand All @@ -47,14 +47,36 @@ function submit(){

}

//this function just shows the missing gear for
async function missinggear(gearlist, Gear, GearInfo) {
var path = gearlist['gear']['data'][Gear+"Gears"]['nodes'];
var jsonlist = await jfetch(`https://raw.githubusercontent.com/Leanny/splat3/main/data/mush/600/GearInfo${GearInfo}.json`);
jsonlist = jsonlist.filter(x => !(x["HowToGet"] === "Impossible" || x["__RowId"] === "Shs_SHT012" || x["__RowId"] === "Shs_SHI011"|| x["__RowId"] === "Clt_HAP001"|| x["__RowId"] === "Clt_TES030" || x["__RowId"] === "Clt_TNK003"));
var translate = await jfetch(`https://raw.githubusercontent.com/Leanny/splat3/main/data/language/USen.json`);

let difference = jsonlist.filter(entry1 => !path.some(entry2 => entry1.Id === entry2[Gear+"GearId"]));
//this function shows the missing gear for
async function missinggear(gearlist, Gear, GearInfo, noamiibo) {
const path = gearlist['gear']['data'][Gear+"Gears"]['nodes'];
const jsonlistunfiltered = await jfetch(`https://raw.githubusercontent.com/Leanny/splat3/main/data/mush/600/GearInfo${GearInfo}.json`);
const translate = await jfetch(`https://raw.githubusercontent.com/Leanny/splat3/main/data/language/USen.json`);

let jsonlist = [];
//TODO: improve performace. apparently for loops are faster than filtering. idk, nothing seems to work
if (noamiibo === true) {
jsonlist = jsonlistunfiltered.filter(x =>
!(x.HowToGet === "Impossible"||
x.__RowId.substr(4,3) === "AMB" ||
x.__RowId === "Shs_SHT012" ||
x.__RowId === "Shs_SHI011"||
x.__RowId === "Clt_HAP001"||
x.__RowId === "Clt_TES030" ||
x.__RowId === "Clt_TNK003"));
}
else {
jsonlist = jsonlistunfiltered.filter(x =>
!((x.HowToGet === "Impossible" ||
x.__RowId === "Shs_SHT012" ||
x.__RowId === "Shs_SHI011"||
x.__RowId === "Clt_HAP001"||
x.__RowId === "Clt_TES030" ||
x.__RowId === "Clt_TNK003"
)));
};

const difference = jsonlist.filter(entry1 => !path.some(entry2 => entry1.Id === entry2[Gear+"GearId"]));

for (i=0; i < difference.length; i++) {
div = document.createElement("div");
Expand All @@ -67,71 +89,58 @@ async function missinggear(gearlist, Gear, GearInfo) {
div.alt = translate["CommonMsg/Gear/GearName_"+GearInfo][difference[i]["__RowId"].substr(4,)];
document.getElementById(Gear+String(i)).appendChild(div);

div = document.createElement("p");
div = document.createElement("span");
div.className = "gearname";
div.textContent = (translate["CommonMsg/Gear/GearName_"+GearInfo][difference[i]["__RowId"].substr(4,)]);
document.getElementById(Gear+String(i)).appendChild(div);
document.getElementById(Gear+i).appendChild(div);
}

}

//This function shows gear for a certain star count
async function starcount(gearlist, Gear, GearInfo, Stars) {
var path = gearlist.gear.data[Gear+"s"].nodes;
var jsonlist = await jfetch(`https://raw.githubusercontent.com/Leanny/splat3/main/data/mush/600/${GearInfo}.json`);
const path = gearlist.gear.data[Gear+"s"].nodes;
const jsonlist = await jfetch(`https://raw.githubusercontent.com/Leanny/splat3/main/data/mush/600/${GearInfo}.json`);

for (let i = 0; i < path.length; i++){
if (path[i].rarity === Stars) {
div = document.createElement("div");
div.className = "item";
div.id = String(`${path[i].name}`)
document.getElementById(String(Stars)).appendChild(div);
var gearitem = jsonlist.filter(obj => obj.Id === path[i][Gear+"Id"])
div.id = path[i].name;
document.getElementById(Stars).appendChild(div);

const gearitem = jsonlist[jsonlist.findIndex(obj => obj.Id === path[i][Gear+"Id"])]

div = document.createElement("img");
div.src = `https://raw.githubusercontent.com/Leanny/splat3/main/images/gear/${gearitem[0]["__RowId"]}.png`;
div.src = `https://raw.githubusercontent.com/Leanny/splat3/main/images/gear/${gearitem.__RowId}.png`;
div.alt = path[i].name;
document.getElementById(String(`${path[i].name}`)).appendChild(div);
document.getElementById(path[i].name).appendChild(div);

div = document.createElement("span");
div.className = "gearname";
div.textContent = (path[i].name);
document.getElementById(`${path[i].name}`).appendChild(div);
div.textContent = path[i].name;
document.getElementById(path[i].name).appendChild(div);
}

}
}



async function jfetch(url) {
const response = await fetch(url);
return response.json();
}


//all of this is for the darkmode toggle
function calculateSettingAsThemeString({ localStorageTheme, systemSettingDark }) {
if (localStorageTheme !== null) {
return localStorageTheme;
}

if (systemSettingDark.matches) {
return "dark";
}

return "light";
}

function changetheme() {
var currentThemeSetting = document.querySelector("html").getAttribute("data-theme");
const currentThemeSetting = document.querySelector("html").getAttribute("data-theme");
const newTheme = currentThemeSetting === "dark" ? "light" : "dark";

localStorage.setItem("theme", newTheme);
document.querySelector("html").setAttribute("data-theme", newTheme);

currentThemeSetting = newTheme;
};

function loadpage() {
switch (localStorage.getItem("theme")) {
case null:
Expand Down
9 changes: 7 additions & 2 deletions GearCheckData/gearstyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,14 @@ button {
align-items: center;
justify-content: center;
text-align: center;
height: 40pt;
height: 50pt;
width: 120px;
padding: 0 4px;
margin: 0;
background-color: var(--color-box);
border-radius: 0 0 5pt 5pt;

font-size: 14pt;
line-height: 16pt;
font-family: BlitzMain;
letter-spacing: 0.1px;
Expand All @@ -106,7 +107,7 @@ button {
.gearname {
font-size: 10pt;
line-height: 12pt;
height: 30pt;
height: 40pt;
width: 90px;
padding: 0 3px;
}
Expand All @@ -131,3 +132,7 @@ a:focus {
a:hover {
background-color: white;
}

label {
line-height: 40pt;
}

0 comments on commit 8b1a0b7

Please sign in to comment.