github.com/zppinho/prow@v0.0.0-20240510014325-1738badeb017/pkg/spyglass/lenses/restcoverage/restcoverage.ts (about)

     1  const addReportExpander = (): void => {
     2    const reportBtn = document.querySelector<HTMLSpanElement>('span#report-expander')!;
     3    const report = document.querySelector<HTMLDivElement>('div#report')!;
     4    const icon = document.querySelector<HTMLElement>('div#report-brief i.material-icons')!;
     5    reportBtn.onclick = () => {
     6      if (report.classList.toggle('hidden')) {
     7        icon.textContent = "unfold_more";
     8      } else {
     9        icon.textContent = "unfold_less";
    10      }
    11      spyglass.contentUpdated();
    12    };
    13  };
    14  
    15  const addParamsExpander = (): void => {
    16    const methods = document.querySelectorAll<HTMLLIElement>('ul.methods li.method');
    17    for (const method of Array.from(methods)) {
    18      const icon = method.querySelector<HTMLElement>('i.material-icons')!;
    19      if (icon == null) {
    20        method.style.cursor = "default";
    21        continue;
    22      }
    23      const sibling = method.nextElementSibling;
    24      method.onclick = () => {
    25        if (sibling.classList.toggle('hidden')) {
    26          icon.textContent = "arrow_drop_down";
    27        } else {
    28          icon.textContent = "arrow_drop_up";
    29        }
    30        spyglass.contentUpdated();
    31      };
    32    }
    33  };
    34  
    35  const loaded = (): void => {
    36    addReportExpander();
    37    addParamsExpander();
    38  };
    39  
    40  window.addEventListener('DOMContentLoaded', loaded);