Tucker McKnight <tucker@pangolin.lan> | Sun Dec 14 2025
make searching word and add branch last committed date to dropdown
78 79 80 81 82
element.addEventListener("click", copyPull)
})
const bootstrap = window.bootstrap
const jsVars = window.jsVars
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
element.addEventListener("click", copyPull)
})
const dropdownBranchesResults = document.getElementById('dropdown-branches-results')
document.getElementById('dropdownBranchSearch')?.addEventListener('input', (event) => {
const searchTerm = event.target.value
console.log(searchTerm)
let branches = window.branchesWithHrefs.filter((branch) => {
return branch.name.includes(searchTerm)
})
dropdownBranchesResults.innerHTML = branchesListItems(branches, window.defaultBranch)
})
const bootstrap = window.bootstrap
const jsVars = window.jsVars
1 2 3 4 5 6 7 8 9
import { type ReposConfiguration } from '../src/configTypes.ts'
import { type Repository } from '../src/dataTypes.ts'
export const branchesListItems = (branches: Array<{name: string, href: string}>, defaultBranch: string): string => {
return branches.map((branch) => {
const badge = defaultBranch === branch.name ? '<div class="badge rounded-pill bg-primary ms-2">default</div>' : ''
return `<span class='dropdown-item'><a href='${branch.href}'>${branch.name}</a>${badge}</span>`
}).join('')
}
1 2 3 4 5 6 7 8 9
import { type ReposConfiguration } from '../src/configTypes.ts'
import { type Repository } from '../src/dataTypes.ts'
export const branchesListItems = (branches: Array<{name: string, href: string, date: string}>, defaultBranch: string): string => {
return branches.map((branch) => {
const badge = defaultBranch === branch.name ? '<div class="badge rounded-pill bg-primary ms-2">default</div>' : ''
return `<span class='dropdown-item my-1'><a href='${branch.href}'>${branch.name}</a>${badge}<span class="d-block ms-2">updated ${branch.date}</span></span>`
}).join('')
}
26 27 28 29 30
return {
name: branch.name,
href: nav.repoBranchHome(branch.name),
}
})
26 27 28 29 30 31
return {
name: branch.name,
href: nav.repoBranchHome(branch.name),
date: repo.commits.get(branch.head).date.toDateString(),
}
})
75 76 77 78 79 80
<div class="sortRadioButton pe-1">
<input class="form-check-input" type="radio" name="branchSort" id="branchSortByDate" checked>
<label class="form-check-label" for="branchSortByDate">
Date
</label>
</div>
<div class="sortRadioButton ps-1">75 76 77 78 79 80
<div class="sortRadioButton pe-1">
<input class="form-check-input" type="radio" name="branchSort" id="branchSortByDate" checked>
<label class="form-check-label" for="branchSortByDate">
Last commit
</label>
</div>
<div class="sortRadioButton ps-1">88 89 90 91 92 93
</div>
</form>
<div class="dropdown-divider"></div>
<div class="dropdown-branches">
${branchesListItems(branchesWithHrefs, repo.defaultBranch)}
</div>
</div>88 89 90 91 92 93
</div>
</form>
<div class="dropdown-divider"></div>
<div id="dropdown-branches-results" class="dropdown-branches">
${branchesListItems(branchesWithHrefs, repo.defaultBranch)}
</div>
</div>