(event)
| 524 | //--------------------------------------------------------- |
| 525 | |
| 526 | function 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 | |
| 545 | window.addEventListener("hashchange", onHashChange); |
| 546 |
no test coverage detected