Skip to content

Commit

Permalink
Merge pull request #99 from mraron/fix-problemset-category-links
Browse files Browse the repository at this point in the history
Fix category links in problemset
  • Loading branch information
mraron authored May 29, 2024
2 parents 3606739 + b5f765b commit 925cdd1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/web/handlers/problemset/problemset.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func GetProblemList(store problems.Store, ps njudge.Problems, cs njudge.Categori

curr.CategoryLink = templates.Link{
Text: categoryNameByID[cid],
Href: templ.SafeURL(fmt.Sprintf("/task_archive#category%d", p.Category.ID)),
Href: templ.SafeURL(fmt.Sprintf("/task_archive?root=%d#category%d", cid, p.Category.ID)),
}
}

Expand Down
20 changes: 20 additions & 0 deletions internal/web/templates/task_archive.templ
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,25 @@ templ TaskArchive(vm TaskArchiveViewModel) {
</li>
}
</ul>
if vm.Root.Type == njudge.TaskArchiveNodeCategory {
<script>
if(window.location.hash)
{
let elem = $(window.location.hash);
elem.siblings('a').addClass('bg-info text-light');
while(1) {
let par = elem.parent().closest('ul.problemCategoryList');
if(par.length == 0) break ;
/*par.find('li > ul.problemCategoryList').each(function() {
$(this).removeClass('show');
});*/
elem.addClass('show');
elem = par;
}
elem.addClass('show');
elem.scrollIntoView();
}
</script>
}
}
}
6 changes: 6 additions & 0 deletions internal/web/templates/task_archive_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 925cdd1

Please sign in to comment.