Fossil

Diff
Login

Differences From Artifact [0e9e9e5ed1]:

To Artifact [9c721c6843]:


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
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. */
      //delete this.pos.next;
      btnDown = false;
      btnUp = D.append(
        D.addClass(D.span(), 'button', 'up', 'down'),
        D.span(/*glyph holder*/)
        //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.span(/*glyph holder*/)
          //D.append(D.span(), this.config.glyphDown)
        );
      }
      if(this.pos.next){
        btnUp = D.append(
          D.addClass(D.span(), 'button', 'up'),
          D.span(/*glyph holder*/)
          //D.append(D.span(), this.config.glyphUp)
        );
      }
    }
    if(btnDown){
      D.append(this.e.btnWrapper, btnDown);
      btnDown.addEventListener('click', ()=>this.fetchChunk(1),false);
    }
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
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 = (
      const joinTr = (0===direction && trPrev && trNext);
        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 = [];
        if(doAppend) content.push(td.innerHTML, lineNoTxt);
        else content.push(lineNoTxt, td.innerHTML);
        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...
      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 = [];
          if(doAppend) content.push(e.innerHTML, code);
          else content.push(code, e.innerHTML);
          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 = [];
        if(doAppend) content.push(td.innerHTML, blanks);
        else content.push(blanks, td.innerHTML);
        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 = 0;
        lineno.length = lines.length;
        for( i = startLnR; i < startLnR + lines.length; ++i ){
          /* TODO? space-pad numbers, but we don't know the proper length from here. */
          lineno.push(i);
          lineno[i-startLnR] = i;
        }
        const selector = '.difflnr > pre';
        td = tr.querySelector(selector);
        const lineNoTxt = lineno.join('\n')+'\n';
        lineno.length = 0;
        const content = [];
        if(doAppend) content.push(td.innerHTML, lineNoTxt);
        else content.push(lineNoTxt, td.innerHTML);
        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){
        if(joinTr) D.remove(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
485
486
487
488
489
490
491
492
493
494

495
496
497
498
499
500
501
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;
      }
      console.debug("Going to fetch in direction",direction);
      const fOpt = {
        urlParams:{
          name: this.fileHash, from: 0, to: 0
        },
        aftersend: ()=>delete this.$isFetching
      };
      const self = this;
      if(direction!=0){
        console.debug("Skipping fetch for now.");
        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
526
527
528
529
530
531
532
533
534
535
536
537
520
521
522
523
524
525
526





527
528
529
530
531
532
533







-
-
-
-
-







      });
    });
    return F;
  };
  Diff.addDiffSkipHandlers();
});

/**
   2021-09-07: refactoring the following for use in the higher-level
   fossil.*.js framework is pending. For now it's a copy/paste copy
   of diff.js.
*/
/* 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