Fossil SCM

Use URLSearchParams API instead use custom GetQueryStringValue() function. URLSearchParams is support by most browser since 2017.

mgagnon 2021-04-26 15:36 vdiff-context-glob
Commit fab81968d1b56670a00c4d666ab0adc0d1951676967676e48c79858b969a67ec
1 file changed +3 -15
+3 -15
--- src/graph.js
+++ src/graph.js
@@ -82,22 +82,10 @@
8282
style.textContent = css;
8383
document.querySelector("head").appendChild(style);
8484
}
8585
amendCssOnce = 0;
8686
}
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
-}
9987
10088
/* The <span> object that holds the tooltip */
10189
var tooltipObj = document.createElement("span");
10290
tooltipObj.className = "tl-tooltip";
10391
tooltipObj.style.display = "none";
@@ -583,18 +571,18 @@
583571
}else{
584572
if( tx.fileDiff ){
585573
location.href=tx.baseUrl + "/fdiff?v1="+selRow.h+"&v2="+p.h;
586574
}else{
587575
var href = tx.baseUrl + "/vdiff?from="+selRow.h+"&to="+p.h;
588
-
576
+ let params = (new URL(document.location)).searchParams;
589577
/* When called from /timeline page, If chng=str was specified in the
590578
** QueryString, specify glob=str on the /vdiff page */
591
- var glob = getQueryStringValue("chng");
579
+ let glob = params.get("chng");
592580
if( !glob ){
593581
/* When called from /vdiff page, keep the glob= QueryString if
594582
** present. */
595
- glob = getQueryStringValue("glob");
583
+ glob = params.get("glob");
596584
}
597585
if( glob ){
598586
href += "&glob=" + glob;
599587
}
600588
601589
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button