Fossil SCM
Some JS code simplification and added dark-mode CSS filter to jchunk controls.
Commit
65ae15e0088cf3ff81f13d1c9d13b8bbf49beacc98c48594945d3e00a70d18db
Parent
11a981ead041010…
2 files changed
+7
-2
+27
-31
+7
-2
| --- src/default.css | ||
| +++ src/default.css | ||
| @@ -547,14 +547,16 @@ | ||
| 547 | 547 | table.diff pre { |
| 548 | 548 | margin: 0 0 0 0; |
| 549 | 549 | } |
| 550 | 550 | tr.diffskip.jchunk { |
| 551 | 551 | /* jchunk gets added from JS to diffskip rows when they are |
| 552 | - plugged into the /jchunk route and removed after that data | |
| 553 | - is fetched. */ | |
| 552 | + plugged into the /jchunk route. */ | |
| 554 | 553 | background-color: aliceblue; |
| 555 | 554 | padding: 0; |
| 555 | +} | |
| 556 | +body.fossil-dark-style tr.diffskip.jchunk { | |
| 557 | + filter: invert(100%); | |
| 556 | 558 | } |
| 557 | 559 | tr.diffskip.jchunk > td { |
| 558 | 560 | padding: 0.25em 0.5em; |
| 559 | 561 | margin: 0; |
| 560 | 562 | } |
| @@ -566,10 +568,13 @@ | ||
| 566 | 568 | text-align: left; |
| 567 | 569 | font-family: monospace; |
| 568 | 570 | } |
| 569 | 571 | tr.diffskip > td.chunkctrl > div { |
| 570 | 572 | /* Exists solely for layout purposes. */ |
| 573 | +} | |
| 574 | +body.fossil-dark-style tr.diffskip > td.chunkctrl{ | |
| 575 | + filter: inherit; | |
| 571 | 576 | } |
| 572 | 577 | tr.diffskip > td.chunkctrl .button { |
| 573 | 578 | min-width: 2.5em; |
| 574 | 579 | max-width: 2.5em; |
| 575 | 580 | text-align: center; |
| 576 | 581 |
| --- src/default.css | |
| +++ src/default.css | |
| @@ -547,14 +547,16 @@ | |
| 547 | table.diff pre { |
| 548 | margin: 0 0 0 0; |
| 549 | } |
| 550 | tr.diffskip.jchunk { |
| 551 | /* jchunk gets added from JS to diffskip rows when they are |
| 552 | plugged into the /jchunk route and removed after that data |
| 553 | is fetched. */ |
| 554 | background-color: aliceblue; |
| 555 | padding: 0; |
| 556 | } |
| 557 | tr.diffskip.jchunk > td { |
| 558 | padding: 0.25em 0.5em; |
| 559 | margin: 0; |
| 560 | } |
| @@ -566,10 +568,13 @@ | |
| 566 | text-align: left; |
| 567 | font-family: monospace; |
| 568 | } |
| 569 | tr.diffskip > td.chunkctrl > div { |
| 570 | /* Exists solely for layout purposes. */ |
| 571 | } |
| 572 | tr.diffskip > td.chunkctrl .button { |
| 573 | min-width: 2.5em; |
| 574 | max-width: 2.5em; |
| 575 | text-align: center; |
| 576 |
| --- src/default.css | |
| +++ src/default.css | |
| @@ -547,14 +547,16 @@ | |
| 547 | table.diff pre { |
| 548 | margin: 0 0 0 0; |
| 549 | } |
| 550 | tr.diffskip.jchunk { |
| 551 | /* jchunk gets added from JS to diffskip rows when they are |
| 552 | plugged into the /jchunk route. */ |
| 553 | background-color: aliceblue; |
| 554 | padding: 0; |
| 555 | } |
| 556 | body.fossil-dark-style tr.diffskip.jchunk { |
| 557 | filter: invert(100%); |
| 558 | } |
| 559 | tr.diffskip.jchunk > td { |
| 560 | padding: 0.25em 0.5em; |
| 561 | margin: 0; |
| 562 | } |
| @@ -566,10 +568,13 @@ | |
| 568 | text-align: left; |
| 569 | font-family: monospace; |
| 570 | } |
| 571 | tr.diffskip > td.chunkctrl > div { |
| 572 | /* Exists solely for layout purposes. */ |
| 573 | } |
| 574 | body.fossil-dark-style tr.diffskip > td.chunkctrl{ |
| 575 | filter: inherit; |
| 576 | } |
| 577 | tr.diffskip > td.chunkctrl .button { |
| 578 | min-width: 2.5em; |
| 579 | max-width: 2.5em; |
| 580 | text-align: center; |
| 581 |
+27
-31
| --- src/fossil.diff.js | ||
| +++ src/fossil.diff.js | ||
| @@ -274,31 +274,27 @@ | ||
| 274 | 274 | || (this.pos.prev && this.pos.next |
| 275 | 275 | && ((this.pos.next.startLhs - this.pos.prev.endLhs) |
| 276 | 276 | <= Diff.config.chunkLoadLines))){ |
| 277 | 277 | /* Place a single button to load the whole block, rather |
| 278 | 278 | than separate up/down buttons. */ |
| 279 | - //delete this.pos.next; | |
| 280 | 279 | btnDown = false; |
| 281 | 280 | btnUp = D.append( |
| 282 | 281 | D.addClass(D.span(), 'button', 'up', 'down'), |
| 283 | 282 | D.span(/*glyph holder*/) |
| 284 | - //D.append(D.span(), this.config.glyphDown, this.config.glyphUp) | |
| 285 | 283 | ); |
| 286 | 284 | }else{ |
| 287 | 285 | /* Figure out which chunk-load buttons to add... */ |
| 288 | 286 | if(this.pos.prev){ |
| 289 | 287 | btnDown = D.append( |
| 290 | 288 | D.addClass(D.span(), 'button', 'down'), |
| 291 | 289 | D.span(/*glyph holder*/) |
| 292 | - //D.append(D.span(), this.config.glyphDown) | |
| 293 | 290 | ); |
| 294 | 291 | } |
| 295 | 292 | if(this.pos.next){ |
| 296 | 293 | btnUp = D.append( |
| 297 | 294 | D.addClass(D.span(), 'button', 'up'), |
| 298 | 295 | D.span(/*glyph holder*/) |
| 299 | - //D.append(D.span(), this.config.glyphUp) | |
| 300 | 296 | ); |
| 301 | 297 | } |
| 302 | 298 | } |
| 303 | 299 | if(btnDown){ |
| 304 | 300 | D.append(this.e.btnWrapper, btnDown); |
| @@ -381,82 +377,88 @@ | ||
| 381 | 377 | const tr = trPrev || trNext; |
| 382 | 378 | if(0!==direction){ |
| 383 | 379 | console.error("this case is not yet handled",arguments); |
| 384 | 380 | return this; |
| 385 | 381 | } |
| 386 | - const joinTr = (0===direction && trPrev && trNext); | |
| 382 | + const joinTr = ( | |
| 383 | + 0===direction && trPrev && trNext | |
| 384 | + ) ? trNext : false | |
| 385 | + /* Truthy if we want to combine trPrev, the new content, and | |
| 386 | + trNext into trPrev and remove trNext. */; | |
| 387 | 387 | let i, td; |
| 388 | + | |
| 388 | 389 | if(1){ // LHS line numbers... |
| 389 | 390 | const selector = '.difflnl > pre'; |
| 390 | 391 | td = tr.querySelector(selector); |
| 391 | 392 | for( i = urlParam.from; i <= urlParam.to; ++i ){ |
| 392 | 393 | lineno.push(i); |
| 393 | 394 | } |
| 394 | 395 | const lineNoTxt = lineno.join('\n')+'\n'; |
| 395 | - const content = []; | |
| 396 | - if(doAppend) content.push(td.innerHTML, lineNoTxt); | |
| 397 | - else content.push(lineNoTxt, td.innerHTML); | |
| 396 | + const content = [td.innerHTML]; | |
| 397 | + if(doAppend) content.push(lineNoTxt); | |
| 398 | + else content.unshift(lineNoTxt); | |
| 398 | 399 | if(joinTr){ |
| 399 | 400 | content.push(trNext.querySelector(selector).innerHTML); |
| 400 | 401 | } |
| 401 | 402 | td.innerHTML = content.join(''); |
| 402 | 403 | } |
| 403 | 404 | |
| 404 | - if(1){// code block... | |
| 405 | + if(1){// code block(s)... | |
| 405 | 406 | const selector = '.difftxt > pre'; |
| 406 | 407 | td = tr.querySelectorAll(selector); |
| 407 | 408 | const code = D.append(D.div(),lines.join('\n')+'\n').innerText; |
| 408 | 409 | let joinNdx = 0; |
| 409 | 410 | td.forEach(function(e){ |
| 410 | - const content = []; | |
| 411 | - if(doAppend) content.push(e.innerHTML, code); | |
| 412 | - else content.push(code, e.innerHTML); | |
| 411 | + const content = [e.innerHTML]; | |
| 412 | + if(doAppend) content.push(code); | |
| 413 | + else content.unshift(code); | |
| 413 | 414 | if(joinTr){ |
| 414 | 415 | content.push(trNext.querySelectorAll(selector)[joinNdx++].innerHTML) |
| 415 | 416 | } |
| 416 | 417 | e.innerHTML = content.join(''); |
| 417 | 418 | }); |
| 418 | 419 | } |
| 420 | + | |
| 419 | 421 | if(1){ |
| 420 | 422 | // Add blank lines in (.diffsep>pre) |
| 421 | 423 | const selector = '.diffsep > pre'; |
| 422 | 424 | td = tr.querySelector(selector); |
| 423 | 425 | for(i = 0; i < lineno.length; ++i) lineno[i] = ''; |
| 424 | 426 | const blanks = lineno.join('\n')+'\n'; |
| 425 | - const content = []; | |
| 426 | - if(doAppend) content.push(td.innerHTML, blanks); | |
| 427 | - else content.push(blanks, td.innerHTML); | |
| 427 | + const content = [td.innerHTML]; | |
| 428 | + if(doAppend) content.push(blanks); | |
| 429 | + else content.unshift(blanks); | |
| 428 | 430 | if(joinTr){ |
| 429 | 431 | content.push(trNext.querySelector(selector).innerHTML); |
| 430 | 432 | } |
| 431 | 433 | td.innerHTML = content.join(''); |
| 432 | 434 | } |
| 435 | + | |
| 433 | 436 | if(0===direction){ |
| 434 | 437 | /* Closing the whole gap between two chunks or a whole gap |
| 435 | 438 | at the start or end of a diff. */ |
| 439 | + // RHS line numbers... | |
| 436 | 440 | let startLnR = this.pos.prev |
| 437 | 441 | ? this.pos.prev.endRhs+1 /* Closing the whole gap between two chunks |
| 438 | 442 | or end-of-file gap. */ |
| 439 | 443 | : this.pos.next.startRhs - lines.length /* start-of-file gap */; |
| 440 | - lineno.length = 0; | |
| 444 | + lineno.length = lines.length; | |
| 441 | 445 | for( i = startLnR; i < startLnR + lines.length; ++i ){ |
| 442 | - /* TODO? space-pad numbers, but we don't know the proper length from here. */ | |
| 443 | - lineno.push(i); | |
| 446 | + lineno[i-startLnR] = i; | |
| 444 | 447 | } |
| 445 | 448 | const selector = '.difflnr > pre'; |
| 446 | 449 | td = tr.querySelector(selector); |
| 447 | 450 | const lineNoTxt = lineno.join('\n')+'\n'; |
| 448 | - const content = []; | |
| 449 | - if(doAppend) content.push(td.innerHTML, lineNoTxt); | |
| 450 | - else content.push(lineNoTxt, td.innerHTML); | |
| 451 | + lineno.length = 0; | |
| 452 | + const content = [td.innerHTML]; | |
| 453 | + if(doAppend) content.push(lineNoTxt); | |
| 454 | + else content.unshift(lineNoTxt); | |
| 451 | 455 | if(joinTr){ |
| 452 | 456 | content.push(trNext.querySelector(selector).innerHTML); |
| 453 | 457 | } |
| 454 | 458 | td.innerHTML = content.join(''); |
| 455 | - if(joinTr){ | |
| 456 | - D.remove(joinTr); | |
| 457 | - } | |
| 459 | + if(joinTr) D.remove(joinTr); | |
| 458 | 460 | Diff.checkTableWidth(true); |
| 459 | 461 | this.destroy(); |
| 460 | 462 | return this; |
| 461 | 463 | }else{ |
| 462 | 464 | console.debug("TODO: handle load of partial next/prev"); |
| @@ -480,20 +482,19 @@ | ||
| 480 | 482 | return this; |
| 481 | 483 | }else if(direction>0/*next chunk*/ && !this.pos.prev){ |
| 482 | 484 | console.error("Attempt to fetch next diff lines but don't have any."); |
| 483 | 485 | return this; |
| 484 | 486 | } |
| 485 | - console.debug("Going to fetch in direction",direction); | |
| 486 | 487 | const fOpt = { |
| 487 | 488 | urlParams:{ |
| 488 | 489 | name: this.fileHash, from: 0, to: 0 |
| 489 | 490 | }, |
| 490 | 491 | aftersend: ()=>delete this.$isFetching |
| 491 | 492 | }; |
| 492 | 493 | const self = this; |
| 493 | 494 | if(direction!=0){ |
| 494 | - console.debug("Skipping fetch for now."); | |
| 495 | + console.debug("Skipping partial fetch for now."); | |
| 495 | 496 | return this; |
| 496 | 497 | }else{ |
| 497 | 498 | fOpt.urlParams.from = this.pos.startLhs; |
| 498 | 499 | fOpt.urlParams.to = this.pos.endLhs; |
| 499 | 500 | fOpt.onload = function(list){ |
| @@ -521,15 +522,10 @@ | ||
| 521 | 522 | return F; |
| 522 | 523 | }; |
| 523 | 524 | Diff.addDiffSkipHandlers(); |
| 524 | 525 | }); |
| 525 | 526 | |
| 526 | -/** | |
| 527 | - 2021-09-07: refactoring the following for use in the higher-level | |
| 528 | - fossil.*.js framework is pending. For now it's a copy/paste copy | |
| 529 | - of diff.js. | |
| 530 | -*/ | |
| 531 | 527 | /* Refinements to the display of unified and side-by-side diffs. |
| 532 | 528 | ** |
| 533 | 529 | ** In all cases, the table columns tagged with "difftxt" are expanded, |
| 534 | 530 | ** where possible, to fill the width of the screen. |
| 535 | 531 | ** |
| 536 | 532 |
| --- src/fossil.diff.js | |
| +++ src/fossil.diff.js | |
| @@ -274,31 +274,27 @@ | |
| 274 | || (this.pos.prev && this.pos.next |
| 275 | && ((this.pos.next.startLhs - this.pos.prev.endLhs) |
| 276 | <= Diff.config.chunkLoadLines))){ |
| 277 | /* Place a single button to load the whole block, rather |
| 278 | than separate up/down buttons. */ |
| 279 | //delete this.pos.next; |
| 280 | btnDown = false; |
| 281 | btnUp = D.append( |
| 282 | D.addClass(D.span(), 'button', 'up', 'down'), |
| 283 | D.span(/*glyph holder*/) |
| 284 | //D.append(D.span(), this.config.glyphDown, this.config.glyphUp) |
| 285 | ); |
| 286 | }else{ |
| 287 | /* Figure out which chunk-load buttons to add... */ |
| 288 | if(this.pos.prev){ |
| 289 | btnDown = D.append( |
| 290 | D.addClass(D.span(), 'button', 'down'), |
| 291 | D.span(/*glyph holder*/) |
| 292 | //D.append(D.span(), this.config.glyphDown) |
| 293 | ); |
| 294 | } |
| 295 | if(this.pos.next){ |
| 296 | btnUp = D.append( |
| 297 | D.addClass(D.span(), 'button', 'up'), |
| 298 | D.span(/*glyph holder*/) |
| 299 | //D.append(D.span(), this.config.glyphUp) |
| 300 | ); |
| 301 | } |
| 302 | } |
| 303 | if(btnDown){ |
| 304 | D.append(this.e.btnWrapper, btnDown); |
| @@ -381,82 +377,88 @@ | |
| 381 | const tr = trPrev || trNext; |
| 382 | if(0!==direction){ |
| 383 | console.error("this case is not yet handled",arguments); |
| 384 | return this; |
| 385 | } |
| 386 | const joinTr = (0===direction && trPrev && trNext); |
| 387 | let i, td; |
| 388 | if(1){ // LHS line numbers... |
| 389 | const selector = '.difflnl > pre'; |
| 390 | td = tr.querySelector(selector); |
| 391 | for( i = urlParam.from; i <= urlParam.to; ++i ){ |
| 392 | lineno.push(i); |
| 393 | } |
| 394 | const lineNoTxt = lineno.join('\n')+'\n'; |
| 395 | const content = []; |
| 396 | if(doAppend) content.push(td.innerHTML, lineNoTxt); |
| 397 | else content.push(lineNoTxt, td.innerHTML); |
| 398 | if(joinTr){ |
| 399 | content.push(trNext.querySelector(selector).innerHTML); |
| 400 | } |
| 401 | td.innerHTML = content.join(''); |
| 402 | } |
| 403 | |
| 404 | if(1){// code block... |
| 405 | const selector = '.difftxt > pre'; |
| 406 | td = tr.querySelectorAll(selector); |
| 407 | const code = D.append(D.div(),lines.join('\n')+'\n').innerText; |
| 408 | let joinNdx = 0; |
| 409 | td.forEach(function(e){ |
| 410 | const content = []; |
| 411 | if(doAppend) content.push(e.innerHTML, code); |
| 412 | else content.push(code, e.innerHTML); |
| 413 | if(joinTr){ |
| 414 | content.push(trNext.querySelectorAll(selector)[joinNdx++].innerHTML) |
| 415 | } |
| 416 | e.innerHTML = content.join(''); |
| 417 | }); |
| 418 | } |
| 419 | if(1){ |
| 420 | // Add blank lines in (.diffsep>pre) |
| 421 | const selector = '.diffsep > pre'; |
| 422 | td = tr.querySelector(selector); |
| 423 | for(i = 0; i < lineno.length; ++i) lineno[i] = ''; |
| 424 | const blanks = lineno.join('\n')+'\n'; |
| 425 | const content = []; |
| 426 | if(doAppend) content.push(td.innerHTML, blanks); |
| 427 | else content.push(blanks, td.innerHTML); |
| 428 | if(joinTr){ |
| 429 | content.push(trNext.querySelector(selector).innerHTML); |
| 430 | } |
| 431 | td.innerHTML = content.join(''); |
| 432 | } |
| 433 | if(0===direction){ |
| 434 | /* Closing the whole gap between two chunks or a whole gap |
| 435 | at the start or end of a diff. */ |
| 436 | let startLnR = this.pos.prev |
| 437 | ? this.pos.prev.endRhs+1 /* Closing the whole gap between two chunks |
| 438 | or end-of-file gap. */ |
| 439 | : this.pos.next.startRhs - lines.length /* start-of-file gap */; |
| 440 | lineno.length = 0; |
| 441 | for( i = startLnR; i < startLnR + lines.length; ++i ){ |
| 442 | /* TODO? space-pad numbers, but we don't know the proper length from here. */ |
| 443 | lineno.push(i); |
| 444 | } |
| 445 | const selector = '.difflnr > pre'; |
| 446 | td = tr.querySelector(selector); |
| 447 | const lineNoTxt = lineno.join('\n')+'\n'; |
| 448 | const content = []; |
| 449 | if(doAppend) content.push(td.innerHTML, lineNoTxt); |
| 450 | else content.push(lineNoTxt, td.innerHTML); |
| 451 | if(joinTr){ |
| 452 | content.push(trNext.querySelector(selector).innerHTML); |
| 453 | } |
| 454 | td.innerHTML = content.join(''); |
| 455 | if(joinTr){ |
| 456 | D.remove(joinTr); |
| 457 | } |
| 458 | Diff.checkTableWidth(true); |
| 459 | this.destroy(); |
| 460 | return this; |
| 461 | }else{ |
| 462 | console.debug("TODO: handle load of partial next/prev"); |
| @@ -480,20 +482,19 @@ | |
| 480 | return this; |
| 481 | }else if(direction>0/*next chunk*/ && !this.pos.prev){ |
| 482 | console.error("Attempt to fetch next diff lines but don't have any."); |
| 483 | return this; |
| 484 | } |
| 485 | console.debug("Going to fetch in direction",direction); |
| 486 | const fOpt = { |
| 487 | urlParams:{ |
| 488 | name: this.fileHash, from: 0, to: 0 |
| 489 | }, |
| 490 | aftersend: ()=>delete this.$isFetching |
| 491 | }; |
| 492 | const self = this; |
| 493 | if(direction!=0){ |
| 494 | console.debug("Skipping fetch for now."); |
| 495 | return this; |
| 496 | }else{ |
| 497 | fOpt.urlParams.from = this.pos.startLhs; |
| 498 | fOpt.urlParams.to = this.pos.endLhs; |
| 499 | fOpt.onload = function(list){ |
| @@ -521,15 +522,10 @@ | |
| 521 | return F; |
| 522 | }; |
| 523 | Diff.addDiffSkipHandlers(); |
| 524 | }); |
| 525 | |
| 526 | /** |
| 527 | 2021-09-07: refactoring the following for use in the higher-level |
| 528 | fossil.*.js framework is pending. For now it's a copy/paste copy |
| 529 | of diff.js. |
| 530 | */ |
| 531 | /* Refinements to the display of unified and side-by-side diffs. |
| 532 | ** |
| 533 | ** In all cases, the table columns tagged with "difftxt" are expanded, |
| 534 | ** where possible, to fill the width of the screen. |
| 535 | ** |
| 536 |
| --- src/fossil.diff.js | |
| +++ src/fossil.diff.js | |
| @@ -274,31 +274,27 @@ | |
| 274 | || (this.pos.prev && this.pos.next |
| 275 | && ((this.pos.next.startLhs - this.pos.prev.endLhs) |
| 276 | <= Diff.config.chunkLoadLines))){ |
| 277 | /* Place a single button to load the whole block, rather |
| 278 | than separate up/down buttons. */ |
| 279 | btnDown = false; |
| 280 | btnUp = D.append( |
| 281 | D.addClass(D.span(), 'button', 'up', 'down'), |
| 282 | D.span(/*glyph holder*/) |
| 283 | ); |
| 284 | }else{ |
| 285 | /* Figure out which chunk-load buttons to add... */ |
| 286 | if(this.pos.prev){ |
| 287 | btnDown = D.append( |
| 288 | D.addClass(D.span(), 'button', 'down'), |
| 289 | D.span(/*glyph holder*/) |
| 290 | ); |
| 291 | } |
| 292 | if(this.pos.next){ |
| 293 | btnUp = D.append( |
| 294 | D.addClass(D.span(), 'button', 'up'), |
| 295 | D.span(/*glyph holder*/) |
| 296 | ); |
| 297 | } |
| 298 | } |
| 299 | if(btnDown){ |
| 300 | D.append(this.e.btnWrapper, btnDown); |
| @@ -381,82 +377,88 @@ | |
| 377 | const tr = trPrev || trNext; |
| 378 | if(0!==direction){ |
| 379 | console.error("this case is not yet handled",arguments); |
| 380 | return this; |
| 381 | } |
| 382 | const joinTr = ( |
| 383 | 0===direction && trPrev && trNext |
| 384 | ) ? trNext : false |
| 385 | /* Truthy if we want to combine trPrev, the new content, and |
| 386 | trNext into trPrev and remove trNext. */; |
| 387 | let i, td; |
| 388 | |
| 389 | if(1){ // LHS line numbers... |
| 390 | const selector = '.difflnl > pre'; |
| 391 | td = tr.querySelector(selector); |
| 392 | for( i = urlParam.from; i <= urlParam.to; ++i ){ |
| 393 | lineno.push(i); |
| 394 | } |
| 395 | const lineNoTxt = lineno.join('\n')+'\n'; |
| 396 | const content = [td.innerHTML]; |
| 397 | if(doAppend) content.push(lineNoTxt); |
| 398 | else content.unshift(lineNoTxt); |
| 399 | if(joinTr){ |
| 400 | content.push(trNext.querySelector(selector).innerHTML); |
| 401 | } |
| 402 | td.innerHTML = content.join(''); |
| 403 | } |
| 404 | |
| 405 | if(1){// code block(s)... |
| 406 | const selector = '.difftxt > pre'; |
| 407 | td = tr.querySelectorAll(selector); |
| 408 | const code = D.append(D.div(),lines.join('\n')+'\n').innerText; |
| 409 | let joinNdx = 0; |
| 410 | td.forEach(function(e){ |
| 411 | const content = [e.innerHTML]; |
| 412 | if(doAppend) content.push(code); |
| 413 | else content.unshift(code); |
| 414 | if(joinTr){ |
| 415 | content.push(trNext.querySelectorAll(selector)[joinNdx++].innerHTML) |
| 416 | } |
| 417 | e.innerHTML = content.join(''); |
| 418 | }); |
| 419 | } |
| 420 | |
| 421 | if(1){ |
| 422 | // Add blank lines in (.diffsep>pre) |
| 423 | const selector = '.diffsep > pre'; |
| 424 | td = tr.querySelector(selector); |
| 425 | for(i = 0; i < lineno.length; ++i) lineno[i] = ''; |
| 426 | const blanks = lineno.join('\n')+'\n'; |
| 427 | const content = [td.innerHTML]; |
| 428 | if(doAppend) content.push(blanks); |
| 429 | else content.unshift(blanks); |
| 430 | if(joinTr){ |
| 431 | content.push(trNext.querySelector(selector).innerHTML); |
| 432 | } |
| 433 | td.innerHTML = content.join(''); |
| 434 | } |
| 435 | |
| 436 | if(0===direction){ |
| 437 | /* Closing the whole gap between two chunks or a whole gap |
| 438 | at the start or end of a diff. */ |
| 439 | // RHS line numbers... |
| 440 | let startLnR = this.pos.prev |
| 441 | ? this.pos.prev.endRhs+1 /* Closing the whole gap between two chunks |
| 442 | or end-of-file gap. */ |
| 443 | : this.pos.next.startRhs - lines.length /* start-of-file gap */; |
| 444 | lineno.length = lines.length; |
| 445 | for( i = startLnR; i < startLnR + lines.length; ++i ){ |
| 446 | lineno[i-startLnR] = i; |
| 447 | } |
| 448 | const selector = '.difflnr > pre'; |
| 449 | td = tr.querySelector(selector); |
| 450 | const lineNoTxt = lineno.join('\n')+'\n'; |
| 451 | lineno.length = 0; |
| 452 | const content = [td.innerHTML]; |
| 453 | if(doAppend) content.push(lineNoTxt); |
| 454 | else content.unshift(lineNoTxt); |
| 455 | if(joinTr){ |
| 456 | content.push(trNext.querySelector(selector).innerHTML); |
| 457 | } |
| 458 | td.innerHTML = content.join(''); |
| 459 | if(joinTr) D.remove(joinTr); |
| 460 | Diff.checkTableWidth(true); |
| 461 | this.destroy(); |
| 462 | return this; |
| 463 | }else{ |
| 464 | console.debug("TODO: handle load of partial next/prev"); |
| @@ -480,20 +482,19 @@ | |
| 482 | return this; |
| 483 | }else if(direction>0/*next chunk*/ && !this.pos.prev){ |
| 484 | console.error("Attempt to fetch next diff lines but don't have any."); |
| 485 | return this; |
| 486 | } |
| 487 | const fOpt = { |
| 488 | urlParams:{ |
| 489 | name: this.fileHash, from: 0, to: 0 |
| 490 | }, |
| 491 | aftersend: ()=>delete this.$isFetching |
| 492 | }; |
| 493 | const self = this; |
| 494 | if(direction!=0){ |
| 495 | console.debug("Skipping partial fetch for now."); |
| 496 | return this; |
| 497 | }else{ |
| 498 | fOpt.urlParams.from = this.pos.startLhs; |
| 499 | fOpt.urlParams.to = this.pos.endLhs; |
| 500 | fOpt.onload = function(list){ |
| @@ -521,15 +522,10 @@ | |
| 522 | return F; |
| 523 | }; |
| 524 | Diff.addDiffSkipHandlers(); |
| 525 | }); |
| 526 | |
| 527 | /* Refinements to the display of unified and side-by-side diffs. |
| 528 | ** |
| 529 | ** In all cases, the table columns tagged with "difftxt" are expanded, |
| 530 | ** where possible, to fill the width of the screen. |
| 531 | ** |
| 532 |