Преглед на файлове

(feat: tabs) Set up tabs and content divs

tags/v0.3.5
bertieb преди 3 години
родител
ревизия
c4e761e6bd
променени са 1 файла, в които са добавени 24 реда и са изтрити 0 реда
  1. +24
    -0
      src/ts/frontend.ts

+ 24
- 0
src/ts/frontend.ts Целия файл

@@ -504,10 +504,34 @@ async function getResults():Promise<string>{
let maxDice = 10;
let cutoffStart = 6;
let cutoffMax = 9;

/**
* At present, add variants (success cutoffs) to different tabs
* note: this may change to separating classes by tabs
*
* ref: https://getbootstrap.com/docs/5.0/components/navs-tabs/#javascript-behavior
*/

// Add tab navigation container (<ul>) -- id: #resultTabs
let navId = "resultTabs";
$("#results").append(`<ul class="nav nav-tabs" 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";
$(`#${navId}`).append(`<li class="nav-item" role="presentation">
<button class="${buttonClass}" id="tab-nav-c${cutoff}"
data-bs-toggle="tab" data-bs-target="#tab-content-c${cutoff}"
type="button" role="tab">Cutoff ${cutoff}</button>
</li>`);
// Roll the dice for this variant
for (let i = 1; i < maxDice; i++) {
let rsSetup = { numDice: i, diceOptions: { successCutOff: cutoff } };


Зареждане…
Отказ
Запис