MCPcopy Index your code
hub / github.com/witheve/Eve / onHashChange

Function onHashChange

src/client.ts:526–543  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

524//---------------------------------------------------------
525
526function onHashChange(event) {
527 if(client.ide && client.ide.loaded) changeDocument();
528 let hash = window.location.hash.split("#/")[2];
529 let queryParam = window.location.hash.split('?')[1];
530
531 if(hash || queryParam) {
532 let segments = (hash||'').split("/").map(function(seg, ix) {
533 return {id: uuid(), index: ix + 1, value: seg};
534 }), queries = (queryParam||'').split('&').map(function (kv) {
535 let [k, v] = kv.split('=',2);
536 return {id: uuid(), key: k, value: v};
537 });
538
539 client.sendEvent([
540 {tag: "url-change", "hash-segment": segments, "query-param": queries}
541 ]);
542 }
543}
544
545window.addEventListener("hashchange", onHashChange);
546

Callers 1

_initProgramMethod · 0.85

Calls 3

uuidFunction · 0.90
changeDocumentFunction · 0.85
sendEventMethod · 0.80

Tested by

no test coverage detected