Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Got jchunk loader buttons in place but they're currently non-functional. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | diff-js-refactoring |
| Files: | files | file ages | folders |
| SHA3-256: |
365ef58b8c108473eee300563f261d4b |
| User & Date: | stephan 2021-09-09 18:28:58.182 |
Context
|
2021-09-09
| ||
| 18:31 | Doc typos. ... (check-in: fa654e947a user: stephan tags: diff-js-refactoring) | |
| 18:28 | Got jchunk loader buttons in place but they're currently non-functional. ... (check-in: 365ef58b8c user: stephan tags: diff-js-refactoring) | |
| 15:06 | Refactored tr.diffsplit to hold enough information to allow partial chunk loads in either direction and to know where the next/previous chunks (if any) start/end. Actual loading is currently disabled, pending addition of controls which make use of this new state. ... (check-in: cedcd3585b user: stephan tags: diff-js-refactoring) | |
Changes
Changes to src/default.css.
| ︙ | ︙ | |||
545 546 547 548 549 550 551 |
table.diff pre {
margin: 0 0 0 0;
}
tr.diffskip.jchunk:hover {
/* jchunk gets added from JS to diffskip rows when they are
plugged into the /jchunk route and removed after that data
is fetched. */
| > > | | > > > | | < | < > > > > > > > > > > > > > > > > > > > > > > > > > | 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 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 |
table.diff pre {
margin: 0 0 0 0;
}
tr.diffskip.jchunk:hover {
/* jchunk gets added from JS to diffskip rows when they are
plugged into the /jchunk route and removed after that data
is fetched. */
}
tr.diffskip.jchunk:hover {
/*background-color: rgba(127,127,127,0.5);
cursor: pointer;*/
}
tr.diffskip > td.chunkctrl {
text-align: left;
font-family: monospace;
/* Border is only for visibility during development. Remove it when done. */
border-width: 1px;
border-style: dotted;
}
tr.diffskip > td.chunkctrl > div {
/* Exists solely for layout purposes. */
}
tr.diffskip > td.chunkctrl > div > .button {
min-width: 2.5em;
max-width: 2.5em;
text-align: center;
display: inline-block;
padding: 0.1em 1em;
margin: 0 1em 0 0;
background-color: rgba(127,127,127,0.3);
border-style: outset;
border-width: 1px;
border-color: rgba(0,0,0,0);
border-radius: 0.5em;
}
tr.diffskip > td.chunkctrl > div > .button > span {
/* In order to increase the glyph size w/o increasing the button size,
we need an extra layer of DOM element for the glyph. */
font-size: 150%;
}
tr.diffskip > td.chunkctrl > div > .button.up:not(.down){
/* Simulate an error pointing up */
border-radius: 3em 3em 0.25em 0.25em;
}
tr.diffskip > td.chunkctrl > div > .button.down:not(.up){
/* Simulate an error pointing down */
border-radius: 0.25em 0.25em 3em 3em;
}
tr.diffskip > td.chunkctrl > div > .button:hover {
border-color: rgba(0,0,0,1);
cursor: pointer;
}
td.diffln {
width: 1px;
text-align: right;
padding: 0 1em 0 0;
}
td.difflne {
|
| ︙ | ︙ |
Changes to src/fossil.diff.js.
| ︙ | ︙ | |||
204 205 206 207 208 209 210 |
}
});
};
/**
Installs chunk-loading controls into TR element tr. isSplit is true
if the parent table is a split diff, else false.)
| > > > > > > | > > > | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
}
});
};
/**
Installs chunk-loading controls into TR element tr. isSplit is true
if the parent table is a split diff, else false.)
The goal is to base these controls closely on github's, a good example
of which, for use as a model, is:
https://github.com/msteveb/autosetup/commit/235925e914a52a542
*/
Diff.ChunkLoadControls = function(isSplit, tr){
this.isSplit = isSplit;
this.e = {/*DOM elements*/};
this.pos = {
start: +tr.dataset.startln,
end: +tr.dataset.endln
};
tr.$chunker = this /* keep GC from reaping this */;
this.e.tr = tr;
D.clearElement(tr);
this.e.td = D.addClass(
D.attr(D.td(tr), 'colspan', isSplit ? 5 : 4),
'chunkctrl'
);
this.e.btnWrapper = D.div();
D.append(this.e.td, this.e.btnWrapper);
/**
Depending on various factors, we need one of:
- A single button to load all lines then remove this control
- A single button to load the initial chunk
|
| ︙ | ︙ | |||
239 240 241 242 243 244 245 |
}
if(tr.previousElementSibling){
this.pos.prev = {
endLhs: extractLineNo(true, false, tr.previousElementSibling, isSplit),
endRhs: extractLineNo(false, false, tr.previousElementSibling, isSplit)
};
}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | > > > > > > > > > > > > > > > > > > > > > > > > > < < < | < < < < | < < < < < < < < < < < < < < < < | 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 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 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
}
if(tr.previousElementSibling){
this.pos.prev = {
endLhs: extractLineNo(true, false, tr.previousElementSibling, isSplit),
endRhs: extractLineNo(false, false, tr.previousElementSibling, isSplit)
};
}
let btnUp = false, btnDown = false;
if(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.append(D.span(), this.config.glyphDown, this.config.glyphUp)
);
}else{
/* Figure out which chunk-load buttons to add... */
if(this.pos.prev){
btnDown = D.append(
D.addClass(D.span(), 'button', 'down'),
D.append(D.span(), this.config.glyphDown)
);
}
if(this.pos.next){
btnUp = D.append(
D.addClass(D.span(), 'button', 'up'),
D.append(D.span(), this.config.glyphUp)
);
}
}
if(btnDown) D.append(this.e.btnWrapper, btnDown);
if(btnUp) D.append(this.e.btnWrapper, btnUp);
D.append(this.e.btnWrapper, D.append(D.span(), JSON.stringify(this.pos)));
};
Diff.ChunkLoadControls.prototype = {
config: {
glyphUp: '⇡', //'&#uarr;',
glyphDown: '⇣' //'&#darr;'
},
destroy: function(){
delete this.tr.$chunker;
D.remove(this.tr);
},
/**
Creates and returns a new TR element, including its TD elements (depending
on this.isSplit), but does not fill it with any information nor inject it
into the table (it doesn't know where to do so).
*/
newTR: function(){
const tr = D.tr();
if(this.isSplit){
D.append(D.addClass( D.td(tr), 'diffln', 'difflnl' ), D.pre());
D.append(D.addClass( D.td(tr), 'difftxt', 'difftxtl' ), D.pre());
D.addClass( D.td(tr), 'diffsep' );
D.append(D.addClass( D.td(tr), 'diffln', 'difflnr' ), D.pre());
D.append(D.addClass( D.td(tr), 'difftxt', 'difftxtr' ), D.pre());
}else{
D.append(D.addClass( D.td(tr), 'diffln', 'difflnl' ), D.pre());
D.append(D.addClass( D.td(tr), 'diffln', 'difflnr' ), D.pre());
D.addClass( D.td(tr), 'diffsep' );
D.append(D.addClass( D.td(tr), 'difftxt', 'difftxtu' ), D.pre());
}
return tr;
}
};
Diff.addDiffSkipHandlers = function(){
const tables = document.querySelectorAll('table.diff[data-lefthash]');
if(!tables.length) return F;
const addDiffSkipToTr = function f(isSplit, tr){
D.addClass(tr, 'jchunk');
//tr.addEventListener('click', f._handler, false);
/* TODO/in progress... */
new Diff.ChunkLoadControls(isSplit, tr);
};
tables.forEach(function(table){
table.querySelectorAll('tr.diffskip[data-startln]').forEach(function(tr){
addDiffSkipToTr(table.classList.contains('splitdiff')/*else udiff*/, tr);
});
});
|
| ︙ | ︙ |