MCPcopy Create free account
hub / github.com/google/pprof / makeSearchLinkDynamic

Function makeSearchLinkDynamic

internal/driver/html/common.js:572–610  ·  view source on GitHub ↗
(id)

Source from the content-addressed store, hash-verified

570 // Update id's href to reflect current selection whenever it is
571 // liable to be followed.
572 function makeSearchLinkDynamic(id) {
573 const elem = document.getElementById(id);
574 if (elem == null) return;
575
576 // Most links copy current selection into the 'f' parameter,
577 // but Refine menu links are different.
578 let param = 'f';
579 if (id == 'ignore') param = 'i';
580 if (id == 'hide') param = 'h';
581 if (id == 'show') param = 's';
582 if (id == 'show-from') param = 'sf';
583
584 // We update on mouseenter so middle-click/right-click work properly.
585 elem.addEventListener('mouseenter', updater);
586 elem.addEventListener('touchstart', updater);
587
588 function updater() {
589 // The selection can be in one of two modes: regexp-based or
590 // list-based. Construct regular expression depending on mode.
591 let re = regexpActive
592 ? search.value
593 : Array.from(getSelection().keys()).map(key => pprofQuoteMeta(nodes[key])).join('|');
594
595 setHrefParams(elem, function (params) {
596 if (re != '') {
597 // For focus/show/show-from, forget old parameter. For others, add to re.
598 if (param != 'f' && param != 's' && param != 'sf' && params.has(param)) {
599 const old = params.get(param);
600 if (old != '') {
601 re += '|' + old;
602 }
603 }
604 params.set(param, re);
605 } else {
606 params.delete(param);
607 }
608 });
609 }
610 }
611
612 function setHrefParams(elem, paramSetter) {
613 let url = new URL(elem.href);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…