Tweak display of build save/load buttons and base spellcost

This commit is contained in:
b 2021-09-25 10:22:04 -07:00
parent a42db4128a
commit 9a0a040145
3 changed files with 18 additions and 13 deletions

View file

@ -890,17 +890,21 @@ function saveBuild() {
let savedBuilds = window.localStorage.getItem("builds") === null ? {} : JSON.parse(window.localStorage.getItem("builds"));
let saveName = document.getElementById("build-name").value;
let encodedBuild = encodeBuild();
if ((!Object.keys(savedBuilds).includes(saveName) || document.getElementById("saved-error").textContent !== "") && encodedBuild !== "") {
if ((!Object.keys(savedBuilds).includes(saveName)
|| document.getElementById("saved-error").textContent !== "") && encodedBuild !== "") {
savedBuilds[saveName] = encodedBuild.replace("#", "");
window.localStorage.setItem("builds", JSON.stringify(savedBuilds));
document.getElementById("saved-error").textContent = "";
document.getElementById("saved-build").textContent = "Build saved";
document.getElementById("saved-build").textContent = "Build saved Locally";
} else {
if (encodedBuild === "")
document.getElementById("saved-build").textContent = "";
if (encodedBuild === "") {
document.getElementById("saved-error").textContent = "Empty build";
else
}
else {
document.getElementById("saved-error").textContent = "Exists. Overwrite?";
}
}
}
}
@ -909,12 +913,14 @@ function loadBuild() {
let savedBuilds = window.localStorage.getItem("builds") === null ? {} : JSON.parse(window.localStorage.getItem("builds"));
let saveName = document.getElementById("build-name").value;
document.getElementById("loaded-error").textContent = "";
if (Object.keys(savedBuilds).includes(saveName)) {
decodeBuild(savedBuilds[saveName])
document.getElementById("loaded-error").textContent = "";
document.getElementById("loaded-build").textContent = "Build loaded";
} else
} else {
document.getElementById("loaded-build").textContent = "";
document.getElementById("loaded-error").textContent = "Build doesn't exist";
}
}
function resetFields(){

View file

@ -2020,8 +2020,10 @@ function displaySpellDamage(parent_elem, overallparent_elem, build, spell, spell
let third = document.createElement("b");
third.textContent = ") [Base: " + build.getBaseSpellCost(spellIdx, spell.cost) + " ]";
title_elem.appendChild(third.cloneNode(true));
title_elemavg.appendChild(third);
title_elem.appendChild(third);
let third_summary = document.createElement("b");
third_summary.textContent = ")";
title_elemavg.appendChild(third_summary);
}
else {
title_elem.textContent = spell.title;

View file

@ -47,9 +47,6 @@
<th class="center smalltitle">
<label>Accessories</label>
</th>
<th class="center smalltitle">
<label>Build</label>
</th>
</tr>
<tr>
<td class="left">
@ -168,7 +165,7 @@
<td class="left">
<br/>
<button style="font-size: 100%" class="button" id="save-button" onclick="saveBuild()">
Save Build
Save Locally
</button>
<p id="saved-build" style="color: green; top: 30px; font-size: 10px; padding: 0; margin: 0; height: 5px; font-family: 'Nunito', sans-serif; white-space: nowrap; word-break:break-word;"></p>
<p id="saved-error" style="color: red; top: 30px; font-size: 10px; padding: 0; margin: 0; height: 5px; font-family: 'Nunito', sans-serif; word-break:break-word;"></p>
@ -176,7 +173,7 @@
<td class="left">
<br/>
<button style="font-size: 100%" class="button" id="load-button" onclick="loadBuild()">
Load Build
Load Locally
</button>
<p id="loaded-build" style="color: green; top: 30px; font-size: 10px; padding: 0; margin: 0; height: 5px; font-family: 'Nunito', sans-serif; white-space: nowrap; word-break:break-word;"></p>
<p id="loaded-error" style="color: red; top: 30px; font-size: 10px; padding: 0; margin: 0; height: 5px; font-family: 'Nunito', sans-serif; word-break:break-word;"></p>