Files
xrpl-dev-portal/content/static/js/use-cases.js
mDuo13 e4ceb8b37b Temporary: move static files into content
During migration, while we launch Redocly with -d content, the static
files need to be in content. Eventually, when we stop using -d, we need
to move the files again.

Previously:
/assets : static assets used by templates
/img : images used in documentation (mostly)

Now:
/content/static : static assets used by templates
/img : images used in documentation (mostly)

Eventually:
/static : static assets used by templates
/docs/img : images used in documentation
2024-01-31 16:04:58 -08:00

69 lines
1.9 KiB
JavaScript

$(document).ready(() => {
//show these featured on load.
const show_cats_arr = ["infrastructure", "developer_tooling"]
function refreshList() {
$("#use_case_companies_list .card-uses").hide()
for (const category of show_cats_arr) {
$(`#use_case_companies_list .card-uses.category_${category}`).show()
}
const featured_count = show_cats_arr.filter( (current) => {
return current == "infrastructure" || current == "developer_tooling"
})
const other_count = show_cats_arr.filter( (current) => {
if ( current !== "infrastructure" && current !== "developer_tooling" ){
return current
}
})
// update category counts
if (featured_count.length === 0) {
$(".featured_count").hide()
}else {
$(".featured_count").html(featured_count.length)
$(".featured_count").show()
}
if (other_count.length === 0) {
$(".other_count").hide()
}else{
$(".other_count").html(other_count.length)
$(".other_count").show()
}
if(show_cats_arr.length === 0) {
$(".total_count").hide()
}else {
$(".total_count").html(show_cats_arr.length)
$(".total_count").show()
}
}
$(".cat_checkbox input").change((event) => {
const lang = $(event.target).val()
const lang_checked = $(event.target).prop("checked")
$(".input_"+lang).prop("checked", lang_checked)
if (lang_checked) {
if ( show_cats_arr.indexOf(lang) === -1){
show_cats_arr.push(lang)
}
} else {
show_cats_arr.indexOf(lang) !== -1 && show_cats_arr.splice(show_cats_arr.indexOf(lang), 1)
}
// refresh all visible.
refreshList()
})
// on first load show the featured cats.
refreshList()
})