Fossil SCM
Use URLSearchParams API instead use custom GetQueryStringValue() function. URLSearchParams is support by most browser since 2017.
Commit
fab81968d1b56670a00c4d666ab0adc0d1951676967676e48c79858b969a67ec
Parent
3e588c822ca1019…
1 file changed
+3
-15
+3
-15
| --- src/graph.js | ||
| +++ src/graph.js | ||
| @@ -82,22 +82,10 @@ | ||
| 82 | 82 | style.textContent = css; |
| 83 | 83 | document.querySelector("head").appendChild(style); |
| 84 | 84 | } |
| 85 | 85 | amendCssOnce = 0; |
| 86 | 86 | } |
| 87 | - | |
| 88 | -/* Legacy function to get a single key in the QueryString. */ | |
| 89 | -function getQueryStringValue (key) { | |
| 90 | - return decodeURIComponent( | |
| 91 | - window.location.search.replace( | |
| 92 | - new RegExp( | |
| 93 | - "^(?:.*[&\\?]" + encodeURIComponent(key).replace( | |
| 94 | - /[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i" | |
| 95 | - ), "$1" | |
| 96 | - ) | |
| 97 | - ); | |
| 98 | -} | |
| 99 | 87 | |
| 100 | 88 | /* The <span> object that holds the tooltip */ |
| 101 | 89 | var tooltipObj = document.createElement("span"); |
| 102 | 90 | tooltipObj.className = "tl-tooltip"; |
| 103 | 91 | tooltipObj.style.display = "none"; |
| @@ -583,18 +571,18 @@ | ||
| 583 | 571 | }else{ |
| 584 | 572 | if( tx.fileDiff ){ |
| 585 | 573 | location.href=tx.baseUrl + "/fdiff?v1="+selRow.h+"&v2="+p.h; |
| 586 | 574 | }else{ |
| 587 | 575 | var href = tx.baseUrl + "/vdiff?from="+selRow.h+"&to="+p.h; |
| 588 | - | |
| 576 | + let params = (new URL(document.location)).searchParams; | |
| 589 | 577 | /* When called from /timeline page, If chng=str was specified in the |
| 590 | 578 | ** QueryString, specify glob=str on the /vdiff page */ |
| 591 | - var glob = getQueryStringValue("chng"); | |
| 579 | + let glob = params.get("chng"); | |
| 592 | 580 | if( !glob ){ |
| 593 | 581 | /* When called from /vdiff page, keep the glob= QueryString if |
| 594 | 582 | ** present. */ |
| 595 | - glob = getQueryStringValue("glob"); | |
| 583 | + glob = params.get("glob"); | |
| 596 | 584 | } |
| 597 | 585 | if( glob ){ |
| 598 | 586 | href += "&glob=" + glob; |
| 599 | 587 | } |
| 600 | 588 | |
| 601 | 589 |
| --- src/graph.js | |
| +++ src/graph.js | |
| @@ -82,22 +82,10 @@ | |
| 82 | style.textContent = css; |
| 83 | document.querySelector("head").appendChild(style); |
| 84 | } |
| 85 | amendCssOnce = 0; |
| 86 | } |
| 87 | |
| 88 | /* Legacy function to get a single key in the QueryString. */ |
| 89 | function getQueryStringValue (key) { |
| 90 | return decodeURIComponent( |
| 91 | window.location.search.replace( |
| 92 | new RegExp( |
| 93 | "^(?:.*[&\\?]" + encodeURIComponent(key).replace( |
| 94 | /[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i" |
| 95 | ), "$1" |
| 96 | ) |
| 97 | ); |
| 98 | } |
| 99 | |
| 100 | /* The <span> object that holds the tooltip */ |
| 101 | var tooltipObj = document.createElement("span"); |
| 102 | tooltipObj.className = "tl-tooltip"; |
| 103 | tooltipObj.style.display = "none"; |
| @@ -583,18 +571,18 @@ | |
| 583 | }else{ |
| 584 | if( tx.fileDiff ){ |
| 585 | location.href=tx.baseUrl + "/fdiff?v1="+selRow.h+"&v2="+p.h; |
| 586 | }else{ |
| 587 | var href = tx.baseUrl + "/vdiff?from="+selRow.h+"&to="+p.h; |
| 588 | |
| 589 | /* When called from /timeline page, If chng=str was specified in the |
| 590 | ** QueryString, specify glob=str on the /vdiff page */ |
| 591 | var glob = getQueryStringValue("chng"); |
| 592 | if( !glob ){ |
| 593 | /* When called from /vdiff page, keep the glob= QueryString if |
| 594 | ** present. */ |
| 595 | glob = getQueryStringValue("glob"); |
| 596 | } |
| 597 | if( glob ){ |
| 598 | href += "&glob=" + glob; |
| 599 | } |
| 600 | |
| 601 |
| --- src/graph.js | |
| +++ src/graph.js | |
| @@ -82,22 +82,10 @@ | |
| 82 | style.textContent = css; |
| 83 | document.querySelector("head").appendChild(style); |
| 84 | } |
| 85 | amendCssOnce = 0; |
| 86 | } |
| 87 | |
| 88 | /* The <span> object that holds the tooltip */ |
| 89 | var tooltipObj = document.createElement("span"); |
| 90 | tooltipObj.className = "tl-tooltip"; |
| 91 | tooltipObj.style.display = "none"; |
| @@ -583,18 +571,18 @@ | |
| 571 | }else{ |
| 572 | if( tx.fileDiff ){ |
| 573 | location.href=tx.baseUrl + "/fdiff?v1="+selRow.h+"&v2="+p.h; |
| 574 | }else{ |
| 575 | var href = tx.baseUrl + "/vdiff?from="+selRow.h+"&to="+p.h; |
| 576 | let params = (new URL(document.location)).searchParams; |
| 577 | /* When called from /timeline page, If chng=str was specified in the |
| 578 | ** QueryString, specify glob=str on the /vdiff page */ |
| 579 | let glob = params.get("chng"); |
| 580 | if( !glob ){ |
| 581 | /* When called from /vdiff page, keep the glob= QueryString if |
| 582 | ** present. */ |
| 583 | glob = params.get("glob"); |
| 584 | } |
| 585 | if( glob ){ |
| 586 | href += "&glob=" + glob; |
| 587 | } |
| 588 | |
| 589 |