Browse Source

(feat: tabs) Remove obsolete 'jump to' buttons

Also, hide status / control box once done as we no longer need a global
status box post-rolls (it might come back for stats?)
tags/v0.3.5
bertieb 3 years ago
parent
commit
734aed8ba7
1 changed files with 9 additions and 15 deletions
  1. +9
    -15
      src/ts/frontend.ts

+ 9
- 15
src/ts/frontend.ts View File

@@ -441,7 +441,7 @@ function addResults(resultProperties: ResultProperties): void {
* Card with status and hide-show all control
*/
function resultsControlCard(): string {
let resultsControl = `<div id="resultsControl" class="card my-3 mx-2 border border-2 border-info">`;
let resultsControl = `<div id="resultsControl" class="card my-2 mx-2 border border-2 border-info">`;
resultsControl += `<h2 class="card-title mx-3 my-2">Results</h5>`;

resultsControl += `<div class="progress mx-3">
@@ -519,17 +519,13 @@ async function getResults():Promise<string>{

// Add tab navigation container (<ul>) -- id: #resultTabs
let navId = "resultTabs";
$("#results").append(`<ul class="nav nav-tabs" id="${navId}" role="tablist"></ul>`);
$("#results").append(`<ul class="nav nav-tabs my-3" id="${navId}" role="tablist"></ul>`);

// Add tab content container (<div>) -- id: #resultTabContent
let tabContentId = "resultTabContent"
$("#results").append(`<div class="tab-content" id="${tabContentId}">`)

for (let cutoff = cutoffStart; cutoff <= cutoffMax; cutoff++) {
let variantControlAdded = false;
// Start of cutoff, add navigation anchor for variant
$("#results").append(variantNavAnchor(cutoff));

// Add navigation for this variant (<li>)
// NB: first one gets 'active', otherwise it doesn't
let buttonClass = (cutoff === cutoffStart) ? "nav-link active" : "nav-link";
@@ -557,17 +553,10 @@ async function getResults():Promise<string>{
});
rollstats.doRolls();
addResults(resultProperties);
// Add control for variant if it doesn't exist
if (!variantControlAdded) {
addVariantControl(controlCardBody, resultProperties);
variantControlAdded = true;

// also add navigation to that anchor on the control card navigation section
controlCardNav.append(` <a class="btn btn-primary" href="#variant-c${String(cutoff)}">Jump to ${resultProperties.diceVariant}</a> `);

}
// Update progress
numDone++;
let progress = ((numDone) / ( maxDice * cutoffMax ) * 100).toFixed(2);
let progress = ((numDone) / ( (maxDice+2) * (cutoffMax-cutoffStart) ) * 100).toFixed(2);
$("#resultsProgress").width(`${progress}%`);
$("#resultsProgress").text(`${progress}%`);
await(sleep(50));
@@ -576,6 +565,11 @@ async function getResults():Promise<string>{
console.log("Results done!");
$("#resultsProgress").width("100%");
$("#resultsProgress").text("100%");

await(sleep(3000))
$("#resultsControl").hide(500);


return "Done";
}



Loading…
Cancel
Save