Fossil

Check-in [a11d245478]
Login

Check-in [a11d245478]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Diff toggles: add a label to the checkbox to make it easier to click, add an 'all' button which toggles all diffs, and remove the toggle from the /fdiff page because it only has a single diff block.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: a11d24547826591f0521308560fd174a46edd405683a2df2a2d55bfb0c2b0deb
User & Date: stephan 2024-12-11 23:09:44.886
References
2025-04-18
12:25
Amend [a11d245478]: Fix positioning of 'show/hide' checkboxes for /ci pages. ... (check-in: 2b59fcd475 user: florian tags: trunk)
2025-03-12
21:39
Fix positioning of 'show/hide' checkboxes for the /vinfo pages. This amends [a11d24547826] ... (check-in: e21f096c61 user: george tags: trunk)
2024-12-12
03:37
Fix DOM element pairing when diff=0 is used in /vdiff and friends. Problem introduced in [a11d2454782]. ... (check-in: d463c7eea5 user: stephan tags: trunk)
Context
2024-12-12
03:37
Fix DOM element pairing when diff=0 is used in /vdiff and friends. Problem introduced in [a11d2454782]. ... (check-in: d463c7eea5 user: stephan tags: trunk)
2024-12-11
23:09
Diff toggles: add a label to the checkbox to make it easier to click, add an 'all' button which toggles all diffs, and remove the toggle from the /fdiff page because it only has a single diff block. ... (check-in: a11d245478 user: stephan tags: trunk)
23:02
Diff toggles: add a label to the checkbox to make it easier to click, add an 'all' button which toggles all diffs, and remove the toggle from the /fdiff page because it only has a single diff block. ... (Closed-Leaf check-in: 419756c6fd user: stephan tags: diff-toggle-all)
20:52
Tweaked language a bit. ... (check-in: 2c0714f8d5 user: brickviking tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/default.css.
746
747
748
749
750
751
752









753
754
755
756
757
758
759
}
body.tkt div.content ol.tkt-changes > li:target > p > span {
  border-bottom: 3px solid gold;
}
body.tkt div.content ol.tkt-changes > li:target > ol {
  border-left: 1px solid gold;
}










span.modpending {
  color: #b03800;
  font-style: italic;
}
pre.th1result {
  white-space: pre-wrap;







>
>
>
>
>
>
>
>
>







746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
}
body.tkt div.content ol.tkt-changes > li:target > p > span {
  border-bottom: 3px solid gold;
}
body.tkt div.content ol.tkt-changes > li:target > ol {
  border-left: 1px solid gold;
}
body.cpage-info .file-change-line,
body.cpage-vdiff .file-change-line {
  margin-top: 16px;
  margin-bottom: 16px;
  margin-right: 1em /* keep it from nudging right up against the scrollbar-reveal zone */;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}

span.modpending {
  color: #b03800;
  font-style: italic;
}
pre.th1result {
  white-space: pre-wrap;
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
.settings-icon:hover {
  border: 1px outset rgba(127,127,127,1);
}
body.fossil-dark-style .settings-icon {
  filter: invert(100%);
}

input[type="checkbox"].diff-toggle {
  float: right;
}

body.branch .brlist > table > tbody > tr:hover:not(.selected),
body.branch .brlist > table > tbody > tr.selected {
  background-color: #ffc;
}
body.branch .brlist > table > tbody td:first-child > input {
  cursor: pointer;
}







<
<
<
<







1825
1826
1827
1828
1829
1830
1831




1832
1833
1834
1835
1836
1837
1838
.settings-icon:hover {
  border: 1px outset rgba(127,127,127,1);
}
body.fossil-dark-style .settings-icon {
  filter: invert(100%);
}





body.branch .brlist > table > tbody > tr:hover:not(.selected),
body.branch .brlist > table > tbody > tr.selected {
  background-color: #ffc;
}
body.branch .brlist > table > tbody td:first-child > input {
  cursor: pointer;
}
Changes to src/fossil.diff.js.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17



18



19




20


21
22



23

24
25
26
27
28
29
30
/**
   diff-related JS APIs for fossil.
*/
"use strict";
window.fossil.onPageLoad(function(){
  /**
     Adds toggle checkboxes to each file entry in the diff views for
     /info and similar pages.
  */
  const D = window.fossil.dom;
  const isFdiff = !!document.querySelector('body.fdiff');
  const addToggle = function(diffElem){
    const sib = diffElem.previousElementSibling,
          btn = sib ? D.addClass(D.checkbox(true), 'diff-toggle') : 0;
    if(!sib) return;
    if(isFdiff) sib.parentElement.insertBefore(
                  D.append(D.div(),btn),sib.nextElementSibling);



    else D.append(sib,btn);



    btn.addEventListener('click', function(){




      diffElem.classList.toggle('hidden');


    }, false);
  };



  document.querySelectorAll('table.diff').forEach(addToggle);

});

window.fossil.onPageLoad(function(){
  const F = window.fossil, D = F.dom;
  const Diff = F.diff = {
    e:{/*certain cached DOM elements*/},
    config: {










|


|

|
|
>
>
>
|
>
>
>
|
>
>
>
>
|
>
>


>
>
>
|
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
   diff-related JS APIs for fossil.
*/
"use strict";
window.fossil.onPageLoad(function(){
  /**
     Adds toggle checkboxes to each file entry in the diff views for
     /info and similar pages.
  */
  const D = window.fossil.dom;
  const allToggles = [/*collection of all diff-toggle checkboxes */];
  const addToggle = function(diffElem){
    const sib = diffElem.previousElementSibling,
          btnOne = sib ? D.addClass(D.checkbox(true), 'diff-toggle') : 0;
    if(!sib) return;
    const lblToggle = D.append(D.label(null, " Toggle "), btnOne);
    const wrapper = D.append(D.span(), lblToggle);
    const btnAll = D.button("all");
    btnAll.$cb = btnOne;
    allToggles.push(btnOne);
    D.append(sib, D.append(wrapper, lblToggle, D.text(" "), btnAll));
    btnOne.addEventListener('change', function(){
      diffElem.classList[this.checked ? 'remove' : 'add']('hidden');
    }, false);
    btnAll.addEventListener('click', function(){
      /* Toggle all entries to match this line's new state. Note that
         we use click() instead of cb.checked=... so that the
         on-change event handler fires. */
      const checked = !this.$cb.checked;
      allToggles.forEach( (cb)=>{
        if(cb.checked!==checked) cb.click();
      });
    }, false);
  };
  if( !document.querySelector('body.fdiff') ){
    /* Don't show the diff toggle button for /fdiff because it only
       has a single file to show (and also a different DOM layout). */
    document.querySelectorAll('table.diff').forEach(addToggle);
  }
});

window.fossil.onPageLoad(function(){
  const F = window.fossil, D = F.dom;
  const Diff = F.diff = {
    e:{/*certain cached DOM elements*/},
    config: {
Changes to src/fossil.dom.js.
85
86
87
88
89
90
91

92

93
94
95
96
97
98
99
  */
  dom.label = function(forElem, text){
    const rc = document.createElement('label');
    if(forElem){
      if(forElem instanceof HTMLElement){
        forElem = this.attr(forElem, 'id');
      }

      dom.attr(rc, 'for', forElem);

    }
    if(text) this.append(rc, text);
    return rc;
  };
  /**
     Returns an IMG element with an optional src
     attribute value.







>
|
>







85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
  */
  dom.label = function(forElem, text){
    const rc = document.createElement('label');
    if(forElem){
      if(forElem instanceof HTMLElement){
        forElem = this.attr(forElem, 'id');
      }
      if(forElem){
        dom.attr(rc, 'for', forElem);
      }
    }
    if(text) this.append(rc, text);
    return rc;
  };
  /**
     Returns an IMG element with an optional src
     attribute value.
Changes to src/info.c.
370
371
372
373
374
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
  const char *zName,    /* Name of the file that has changed */
  const char *zOld,     /* blob.uuid before change.  NULL for added files */
  const char *zNew,     /* blob.uuid after change.  NULL for deletes */
  const char *zOldName, /* Prior name.  NULL if no name change. */
  DiffConfig *pCfg,     /* Flags for text_diff() or NULL to omit all */
  int mperm             /* executable or symlink permission for zNew */
){
  @ <p>


  if( !g.perm.Hyperlink ){
    if( zNew==0 ){
      @ Deleted %h(zName).
    }else if( zOld==0 ){
      @ Added %h(zName).
    }else if( zOldName!=0 && fossil_strcmp(zName,zOldName)!=0 ){
      @ Name change from %h(zOldName) to %h(zName).
    }else if( fossil_strcmp(zNew, zOld)==0 ){
      if( mperm==PERM_EXE ){
        @ %h(zName) became executable.
      }else if( mperm==PERM_LNK ){
        @ %h(zName) became a symlink.
      }else{
        @ %h(zName) became a regular file.
      }
    }else{
      @ Changes to %h(zName).
    }

    if( pCfg ){
      append_diff(zOld, zNew, pCfg);
    }
  }else{
    if( zOld && zNew ){
      if( fossil_strcmp(zOld, zNew)!=0 ){
        if( zOldName!=0 && fossil_strcmp(zName,zOldName)!=0 ){







|
>
>


















>







370
371
372
373
374
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
  const char *zName,    /* Name of the file that has changed */
  const char *zOld,     /* blob.uuid before change.  NULL for added files */
  const char *zNew,     /* blob.uuid after change.  NULL for deletes */
  const char *zOldName, /* Prior name.  NULL if no name change. */
  DiffConfig *pCfg,     /* Flags for text_diff() or NULL to omit all */
  int mperm             /* executable or symlink permission for zNew */
){
  @ <div class='file-change-line'><span>
    /* Maintenance reminder: the extra level of SPAN is for
    ** arranging new elements via JS. */
  if( !g.perm.Hyperlink ){
    if( zNew==0 ){
      @ Deleted %h(zName).
    }else if( zOld==0 ){
      @ Added %h(zName).
    }else if( zOldName!=0 && fossil_strcmp(zName,zOldName)!=0 ){
      @ Name change from %h(zOldName) to %h(zName).
    }else if( fossil_strcmp(zNew, zOld)==0 ){
      if( mperm==PERM_EXE ){
        @ %h(zName) became executable.
      }else if( mperm==PERM_LNK ){
        @ %h(zName) became a symlink.
      }else{
        @ %h(zName) became a regular file.
      }
    }else{
      @ Changes to %h(zName).
    }
    @ </span></div>
    if( pCfg ){
      append_diff(zOld, zNew, pCfg);
    }
  }else{
    if( zOld && zNew ){
      if( fossil_strcmp(zOld, zNew)!=0 ){
        if( zOldName!=0 && fossil_strcmp(zName,zOldName)!=0 ){
434
435
436
437
438
439
440

441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
    }else if( zOld ){
      @ Deleted %z(href("%R/finfo?name=%T&m=%!S&ci=%!S",zName,zOld,zCkin))\
      @ %h(zName)</a> version %z(href("%R/artifact/%!S",zOld))[%S(zOld)]</a>.
    }else{
      @ Added %z(href("%R/finfo?name=%T&m=%!S&ci=%!S",zName,zNew,zCkin))\
      @ %h(zName)</a> version %z(href("%R/artifact/%!S",zNew))[%S(zNew)]</a>.
    }

    if( zOld && zNew && fossil_strcmp(zOld,zNew)!=0 ){
      if( pCfg ){
        append_diff(zOld, zNew, pCfg);
      }else{ 
        @ &nbsp;&nbsp;
        @ %z(href("%R/fdiff?v1=%!S&v2=%!S",zOld,zNew))[diff]</a>
      }
    }
  }
  @ </p>
}

/*
** Generate javascript to enhance HTML diffs.
*/
void append_diff_javascript(int diffType){
  if( diffType==0 ) return;







>



|





<







437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453

454
455
456
457
458
459
460
    }else if( zOld ){
      @ Deleted %z(href("%R/finfo?name=%T&m=%!S&ci=%!S",zName,zOld,zCkin))\
      @ %h(zName)</a> version %z(href("%R/artifact/%!S",zOld))[%S(zOld)]</a>.
    }else{
      @ Added %z(href("%R/finfo?name=%T&m=%!S&ci=%!S",zName,zNew,zCkin))\
      @ %h(zName)</a> version %z(href("%R/artifact/%!S",zNew))[%S(zNew)]</a>.
    }
    @ </span></div>
    if( zOld && zNew && fossil_strcmp(zOld,zNew)!=0 ){
      if( pCfg ){
        append_diff(zOld, zNew, pCfg);
      }else{
        @ &nbsp;&nbsp;
        @ %z(href("%R/fdiff?v1=%!S&v2=%!S",zOld,zNew))[diff]</a>
      }
    }
  }

}

/*
** Generate javascript to enhance HTML diffs.
*/
void append_diff_javascript(int diffType){
  if( diffType==0 ) return;