Add JavaScript and VCS content and fix rendering issue

This commit is contained in:
Kamran Ahmed
2021-12-10 00:52:40 +01:00
parent 56816d15f8
commit 6e451ef5cf
7 changed files with 50 additions and 85 deletions

View File

@ -1,3 +1,21 @@
export function queryGroupElementsById(groupId: string) {
const elements = document.querySelectorAll(
`[data-group-id$="-${groupId}"]`
) as any;
const matchingElements: HTMLElement[] = [];
elements.forEach((element: HTMLElement) => {
const foundGroupId = element?.dataset?.groupId || '';
const validGroupRegex = new RegExp(`^\\d+-${groupId}$`);
if (validGroupRegex.test(foundGroupId)) {
matchingElements.push(element);
}
});
return matchingElements;
}
export function removeSortingInfo(groupId: string) {
return (groupId || '').replace(/^\d+-/, '');
}