Fossil SCM

Corrected the JS-side recursive argument handling for the multiple-numbered-tables case.

stephan 2020-08-14 12:28 line-number-selection
Commit a54fa928e2b86b3dfc64cdee1cf00f817617426456b565b291b2c962ac03349f
--- src/fossil.numbered-lines.js
+++ src/fossil.numbered-lines.js
@@ -1,16 +1,18 @@
11
(function callee(arg){
22
/* JS counterpart of info.c:output_text_with_line_numbers()
33
which ties an event handler to the line numbers to allow
44
selection of individual lines or ranges. */
55
var tbl = arg || document.querySelectorAll('table.numbered-lines');
6
- if(!tbl) return;
7
- else if(tbl.length>1){
8
- tbl.forEach( (t)=>callee(t) );
9
- return;
10
- }else{
11
- tbl = tbl[0];
6
+ if(!tbl) return /* no matching elements */;
7
+ else if(!arg){
8
+ if(tbl.length>1){ /* multiple query results: recurse */
9
+ tbl.forEach( (t)=>callee(t) );
10
+ return;
11
+ }else{/* single query result */
12
+ tbl = tbl[0];
13
+ }
1214
}
1315
const tdLn = tbl.querySelector('td'),
1416
urlArgs = (window.location.search||'').replace(/&?\bln=[^&]*/,'');
1517
console.debug("urlArgs =",urlArgs);
1618
tdLn.addEventListener('click', function f(ev){
1719
--- src/fossil.numbered-lines.js
+++ src/fossil.numbered-lines.js
@@ -1,16 +1,18 @@
1 (function callee(arg){
2 /* JS counterpart of info.c:output_text_with_line_numbers()
3 which ties an event handler to the line numbers to allow
4 selection of individual lines or ranges. */
5 var tbl = arg || document.querySelectorAll('table.numbered-lines');
6 if(!tbl) return;
7 else if(tbl.length>1){
8 tbl.forEach( (t)=>callee(t) );
9 return;
10 }else{
11 tbl = tbl[0];
 
 
12 }
13 const tdLn = tbl.querySelector('td'),
14 urlArgs = (window.location.search||'').replace(/&?\bln=[^&]*/,'');
15 console.debug("urlArgs =",urlArgs);
16 tdLn.addEventListener('click', function f(ev){
17
--- src/fossil.numbered-lines.js
+++ src/fossil.numbered-lines.js
@@ -1,16 +1,18 @@
1 (function callee(arg){
2 /* JS counterpart of info.c:output_text_with_line_numbers()
3 which ties an event handler to the line numbers to allow
4 selection of individual lines or ranges. */
5 var tbl = arg || document.querySelectorAll('table.numbered-lines');
6 if(!tbl) return /* no matching elements */;
7 else if(!arg){
8 if(tbl.length>1){ /* multiple query results: recurse */
9 tbl.forEach( (t)=>callee(t) );
10 return;
11 }else{/* single query result */
12 tbl = tbl[0];
13 }
14 }
15 const tdLn = tbl.querySelector('td'),
16 urlArgs = (window.location.search||'').replace(/&?\bln=[^&]*/,'');
17 console.debug("urlArgs =",urlArgs);
18 tdLn.addEventListener('click', function f(ev){
19

Keyboard Shortcuts

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