ソースを参照

(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 } };


読み込み中…
キャンセル
保存