Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Some JS code simplification and added dark-mode CSS filter to jchunk controls. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | diff-js-refactoring |
| Files: | files | file ages | folders |
| SHA3-256: |
65ae15e0088cf3ff81f13d1c9d13b8bb |
| User & Date: | stephan 2021-09-10 16:08:06.638 |
Context
|
2021-09-10
| ||
| 21:30 | Removed some dead code. Internal cleanups and reorg in prep for upcoming changes. ... (check-in: bc5dc16e55 user: stephan tags: diff-js-refactoring) | |
| 16:08 | Some JS code simplification and added dark-mode CSS filter to jchunk controls. ... (check-in: 65ae15e008 user: stephan tags: diff-js-refactoring) | |
|
2021-09-09
| ||
| 22:41 | When filling a whole gap with loaded jchunk lines, merge the previous and following TR elements together with the new content, providing a seamless fill, eliminating the extraneous scrollbars. This means we cannot style the newly-loaded chunk differently (like github does), but it looks much, much nicer than before. Partial-chunk loads are still pending. ... (check-in: 11a981ead0 user: stephan tags: diff-js-refactoring) | |
Changes
Changes to src/default.css.
| ︙ | ︙ | |||
545 546 547 548 549 550 551 |
vertical-align: top;
}
table.diff pre {
margin: 0 0 0 0;
}
tr.diffskip.jchunk {
/* jchunk gets added from JS to diffskip rows when they are
| | < > > > > > > | 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 |
vertical-align: top;
}
table.diff pre {
margin: 0 0 0 0;
}
tr.diffskip.jchunk {
/* jchunk gets added from JS to diffskip rows when they are
plugged into the /jchunk route. */
background-color: aliceblue;
padding: 0;
}
body.fossil-dark-style tr.diffskip.jchunk {
filter: invert(100%);
}
tr.diffskip.jchunk > td {
padding: 0.25em 0.5em;
margin: 0;
}
tr.diffskip.jchunk:hover {
/*background-color: rgba(127,127,127,0.5);
cursor: pointer;*/
}
tr.diffskip > td.chunkctrl {
text-align: left;
font-family: monospace;
}
tr.diffskip > td.chunkctrl > div {
/* Exists solely for layout purposes. */
}
body.fossil-dark-style tr.diffskip > td.chunkctrl{
filter: inherit;
}
tr.diffskip > td.chunkctrl .button {
min-width: 2.5em;
max-width: 2.5em;
text-align: center;
display: inline-block;
padding: 0.1em 1em;
|
| ︙ | ︙ |
Changes to src/fossil.diff.js.
| ︙ | ︙ | |||
272 273 274 275 276 277 278 |
if((this.pos.startLhs + Diff.config.chunkLoadLines
>= this.pos.endLhs )
|| (this.pos.prev && this.pos.next
&& ((this.pos.next.startLhs - this.pos.prev.endLhs)
<= Diff.config.chunkLoadLines))){
/* Place a single button to load the whole block, rather
than separate up/down buttons. */
| < < < < | 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
if((this.pos.startLhs + Diff.config.chunkLoadLines
>= this.pos.endLhs )
|| (this.pos.prev && this.pos.next
&& ((this.pos.next.startLhs - this.pos.prev.endLhs)
<= Diff.config.chunkLoadLines))){
/* Place a single button to load the whole block, rather
than separate up/down buttons. */
btnDown = false;
btnUp = D.append(
D.addClass(D.span(), 'button', 'up', 'down'),
D.span(/*glyph holder*/)
);
}else{
/* Figure out which chunk-load buttons to add... */
if(this.pos.prev){
btnDown = D.append(
D.addClass(D.span(), 'button', 'down'),
D.span(/*glyph holder*/)
);
}
if(this.pos.next){
btnUp = D.append(
D.addClass(D.span(), 'button', 'up'),
D.span(/*glyph holder*/)
);
}
}
if(btnDown){
D.append(this.e.btnWrapper, btnDown);
btnDown.addEventListener('click', ()=>this.fetchChunk(1),false);
}
|
| ︙ | ︙ | |||
379 380 381 382 383 384 385 |
trNext = this.e.tr.nextElementSibling,
doAppend = !!trPrev /* true to append to previous TR, else prepend to NEXT TR */;
const tr = trPrev || trNext;
if(0!==direction){
console.error("this case is not yet handled",arguments);
return this;
}
| > | > > > > | | | | | | | > | | | > > | < | > | | | | < < | 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 |
trNext = this.e.tr.nextElementSibling,
doAppend = !!trPrev /* true to append to previous TR, else prepend to NEXT TR */;
const tr = trPrev || trNext;
if(0!==direction){
console.error("this case is not yet handled",arguments);
return this;
}
const joinTr = (
0===direction && trPrev && trNext
) ? trNext : false
/* Truthy if we want to combine trPrev, the new content, and
trNext into trPrev and remove trNext. */;
let i, td;
if(1){ // LHS line numbers...
const selector = '.difflnl > pre';
td = tr.querySelector(selector);
for( i = urlParam.from; i <= urlParam.to; ++i ){
lineno.push(i);
}
const lineNoTxt = lineno.join('\n')+'\n';
const content = [td.innerHTML];
if(doAppend) content.push(lineNoTxt);
else content.unshift(lineNoTxt);
if(joinTr){
content.push(trNext.querySelector(selector).innerHTML);
}
td.innerHTML = content.join('');
}
if(1){// code block(s)...
const selector = '.difftxt > pre';
td = tr.querySelectorAll(selector);
const code = D.append(D.div(),lines.join('\n')+'\n').innerText;
let joinNdx = 0;
td.forEach(function(e){
const content = [e.innerHTML];
if(doAppend) content.push(code);
else content.unshift(code);
if(joinTr){
content.push(trNext.querySelectorAll(selector)[joinNdx++].innerHTML)
}
e.innerHTML = content.join('');
});
}
if(1){
// Add blank lines in (.diffsep>pre)
const selector = '.diffsep > pre';
td = tr.querySelector(selector);
for(i = 0; i < lineno.length; ++i) lineno[i] = '';
const blanks = lineno.join('\n')+'\n';
const content = [td.innerHTML];
if(doAppend) content.push(blanks);
else content.unshift(blanks);
if(joinTr){
content.push(trNext.querySelector(selector).innerHTML);
}
td.innerHTML = content.join('');
}
if(0===direction){
/* Closing the whole gap between two chunks or a whole gap
at the start or end of a diff. */
// RHS line numbers...
let startLnR = this.pos.prev
? this.pos.prev.endRhs+1 /* Closing the whole gap between two chunks
or end-of-file gap. */
: this.pos.next.startRhs - lines.length /* start-of-file gap */;
lineno.length = lines.length;
for( i = startLnR; i < startLnR + lines.length; ++i ){
lineno[i-startLnR] = i;
}
const selector = '.difflnr > pre';
td = tr.querySelector(selector);
const lineNoTxt = lineno.join('\n')+'\n';
lineno.length = 0;
const content = [td.innerHTML];
if(doAppend) content.push(lineNoTxt);
else content.unshift(lineNoTxt);
if(joinTr){
content.push(trNext.querySelector(selector).innerHTML);
}
td.innerHTML = content.join('');
if(joinTr) D.remove(joinTr);
Diff.checkTableWidth(true);
this.destroy();
return this;
}else{
console.debug("TODO: handle load of partial next/prev");
this.updatePosDebug();
}
|
| ︙ | ︙ | |||
478 479 480 481 482 483 484 |
if(direction<0/*prev chunk*/ && !this.pos.next){
console.error("Attempt to fetch previous diff lines but don't have any.");
return this;
}else if(direction>0/*next chunk*/ && !this.pos.prev){
console.error("Attempt to fetch next diff lines but don't have any.");
return this;
}
| < | | 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 |
if(direction<0/*prev chunk*/ && !this.pos.next){
console.error("Attempt to fetch previous diff lines but don't have any.");
return this;
}else if(direction>0/*next chunk*/ && !this.pos.prev){
console.error("Attempt to fetch next diff lines but don't have any.");
return this;
}
const fOpt = {
urlParams:{
name: this.fileHash, from: 0, to: 0
},
aftersend: ()=>delete this.$isFetching
};
const self = this;
if(direction!=0){
console.debug("Skipping partial fetch for now.");
return this;
}else{
fOpt.urlParams.from = this.pos.startLhs;
fOpt.urlParams.to = this.pos.endLhs;
fOpt.onload = function(list){
self.injectResponse(direction,fOpt.urlParams,list);
};
|
| ︙ | ︙ | |||
519 520 521 522 523 524 525 |
});
});
return F;
};
Diff.addDiffSkipHandlers();
});
| < < < < < | 520 521 522 523 524 525 526 527 528 529 530 531 532 533 |
});
});
return F;
};
Diff.addDiffSkipHandlers();
});
/* Refinements to the display of unified and side-by-side diffs.
**
** In all cases, the table columns tagged with "difftxt" are expanded,
** where possible, to fill the width of the screen.
**
** For a side-by-side diff, if either column is two wide to fit on the
** display, scrollbars are added. The scrollbars are linked, so that
|
| ︙ | ︙ |