[WebHost] weighted-settings: Fix footer style and clean up yaml download

This commit is contained in:
Chris Wilson 2022-01-02 18:45:45 -05:00
parent 74bb057314
commit d4e0347d1d
2 changed files with 21 additions and 1 deletions

View File

@ -444,6 +444,26 @@ const exportSettings = () => {
window.scrollTo(0, 0);
return;
}
// Clean up the settings output
Object.keys(settings.game).forEach((game) => {
// Remove any disabled games
if (settings.game[game] === 0) {
delete settings.game[game];
delete settings[game];
return;
}
// Remove any disabled options
Object.keys(settings[game]).forEach((setting) => {
Object.keys(settings[game][setting]).forEach((option) => {
if (settings[game][setting][option] === 0) {
delete settings[game][setting][option];
}
});
});
});
const yamlText = jsyaml.safeDump(settings, { noCompatMode: true }).replaceAll(/'(\d+)':/g, (x, y) => `${y}:`);
download(`${document.getElementById('player-name').value}.yaml`, yamlText);
};

View File

@ -33,7 +33,7 @@
</div>
<div id="player-settings-button-row">
<div id="weighted-settings-button-row">
<button id="export-settings">Export Settings</button>
<button id="generate-game">Generate Game</button>
<button id="generate-race">Generate Race</button>