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

     1  import moment from "moment";
     2  
     3  const DATE_FORMAT = 'YYYY-MM-DD HH:mm:ss ZZ';
     4  
     5  const handleClick = (e: MouseEvent): void => {
     6    e.preventDefault();
     7    const button = document.getElementById('show-table-link')!;
     8    const table = document.getElementById('data-table')!;
     9    table.classList.toggle('hidden');
    10    if (table.classList.contains('hidden')) {
    11      button.innerText = 'more info';
    12    } else {
    13      button.innerText = 'less info';
    14    }
    15    spyglass.contentUpdated();
    16  };
    17  
    18  const getLocalStartTime = (): void => {
    19    document.getElementById('show-table-link')!.onclick = handleClick;
    20    const elem = document.getElementById("summary-start-time")!;
    21    elem.innerText = moment(elem.innerText, DATE_FORMAT).calendar().replace(/Last|Yesterday|Today|Tomorrow/,
    22      (m) => m.charAt(0).toLowerCase() + m.substr(1));
    23  };
    24  
    25  window.onload = getLocalStartTime;