Fossil

Check-in [dd465796]
Login

Check-in [dd465796]

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

Overview
Comment:Modernized sbsdiff.js a tiny bit, adapted it to optionally be callable multiple times via fossil.page.tweakSbsDiffs(), and activate that when fileedit's sbs diff is refreshed.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fileedit-ajaxify
Files: files | file ages | folders
SHA3-256: dd46579617c5c46db856e49aca14cfe3f67d6e3fb442bc45304013ae743b0a62
User & Date: stephan 2020-05-15 04:40:08
Context
2020-05-15
18:43
/fileedit now uses fileStorage or sessionStorage, if available, to store unsaved local edits to the 7 most recently edited checkin/file combinations. TODO: make that configurable and offer a widget to manage that stash and quickly switch between those files. It warns loudly if persistent storage is not available. ... (check-in: d130f356 user: stephan tags: fileedit-ajaxify)
04:40
Modernized sbsdiff.js a tiny bit, adapted it to optionally be callable multiple times via fossil.page.tweakSbsDiffs(), and activate that when fileedit's sbs diff is refreshed. ... (check-in: dd465796 user: stephan tags: fileedit-ajaxify)
04:20
Internally rearranged how diff flags are passed around, in anticipation of having to refactor for wiki/forum diffs. Added annotate/blame links to /fileedit's first tab. ... (check-in: 39a5241b user: stephan tags: fileedit-ajaxify)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/fileedit.c.

2104
2105
2106
2107
2108
2109
2110

2111
2112
2113
2114
2115
2116
2117
    }
    blob_appendf(&endScript,", false);\n");
  }

  blob_reset(&err);
  CheckinMiniInfo_cleanup(&cimi);
  style_emit_script_fossil_bootstrap(0);

  style_emit_script_fetch(0);
  style_emit_script_tabs(0)/*also emits fossil.dom*/;
  style_emit_script_confirmer(0);
  style_emit_script_builtin(0, "fossil.page.fileedit.js");
  if(blob_size(&endScript)>0){
    style_emit_script_tag(0,0);
    CX("(function(){\n");







>







2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
    }
    blob_appendf(&endScript,", false);\n");
  }

  blob_reset(&err);
  CheckinMiniInfo_cleanup(&cimi);
  style_emit_script_fossil_bootstrap(0);
  append_diff_javascript(1);
  style_emit_script_fetch(0);
  style_emit_script_tabs(0)/*also emits fossil.dom*/;
  style_emit_script_confirmer(0);
  style_emit_script_builtin(0, "fossil.page.fileedit.js");
  if(blob_size(&endScript)>0){
    style_emit_script_tag(0,0);
    CX("(function(){\n");

Changes to src/fossil.page.fileedit.js.

681
682
683
684
685
686
687

688
689
690
691
692
693
694
      onload: function(c){
        f.target.innerHTML = [
          "<div>Diff <code>[",
          self.finfo.checkin,
          "]</code> &rarr; Local Edits</div>",
          c||'No changes.'
        ].join('');

        F.message('Updated diff.');
        self.tabs.switchToTab(self.e.tabs.diff);
      }
    });
    return this;
  };








>







681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
      onload: function(c){
        f.target.innerHTML = [
          "<div>Diff <code>[",
          self.finfo.checkin,
          "]</code> &rarr; Local Edits</div>",
          c||'No changes.'
        ].join('');
        if(sbs) P.tweakSbsDiffs();
        F.message('Updated diff.');
        self.tabs.switchToTab(self.e.tabs.diff);
      }
    });
    return this;
  };

Changes to src/sbsdiff.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
/* The javascript in this file was added by Joel Bruick on 2013-07-06,
** originally as in-line javascript.  It does some kind of setup for
** side-by-side diff display, but I'm not really sure what.
*/
(function(){
  var SCROLL_LEN = 25;
  function initSbsDiff(diff){
    var txtCols = diff.querySelectorAll('.difftxtcol');
    var txtPres = diff.querySelectorAll('.difftxtcol pre');
    var width = Math.max(txtPres[0].scrollWidth, txtPres[1].scrollWidth);

    for(var i=0; i<2; i++){
      txtPres[i].style.width = width + 'px';
      txtCols[i].onscroll = function(e){
        txtCols[0].scrollLeft = txtCols[1].scrollLeft = this.scrollLeft;
      };
    }
    diff.tabIndex = 0;
    diff.onkeydown = function(e){
      e = e || event;
      var len = {37: -SCROLL_LEN, 39: SCROLL_LEN}[e.keyCode];
      if( !len ) return;
      txtCols[0].scrollLeft += len;
      return false;
    };
  }
  var diffs = document.querySelectorAll('.sbsdiffcols');
  for(var i=0; i<diffs.length; i++){

    initSbsDiff(diffs[i]);

  }
}())










>
|














|
|
>
|
>

|
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
/* The javascript in this file was added by Joel Bruick on 2013-07-06,
** originally as in-line javascript.  It does some kind of setup for
** side-by-side diff display, but I'm not really sure what.
*/
(function(){
  var SCROLL_LEN = 25;
  function initSbsDiff(diff){
    var txtCols = diff.querySelectorAll('.difftxtcol');
    var txtPres = diff.querySelectorAll('.difftxtcol pre');
    var width = Math.max(txtPres[0].scrollWidth, txtPres[1].scrollWidth);
    var i;
    for(i=0; i<2; i++){
      txtPres[i].style.width = width + 'px';
      txtCols[i].onscroll = function(e){
        txtCols[0].scrollLeft = txtCols[1].scrollLeft = this.scrollLeft;
      };
    }
    diff.tabIndex = 0;
    diff.onkeydown = function(e){
      e = e || event;
      var len = {37: -SCROLL_LEN, 39: SCROLL_LEN}[e.keyCode];
      if( !len ) return;
      txtCols[0].scrollLeft += len;
      return false;
    };
  }
  document.querySelectorAll('.sbsdiffcols').forEach(initSbsDiff);
  if(window.fossil && fossil.page){
    fossil.page.tweakSbsDiffs = function(){
      document.querySelectorAll('.sbsdiffcols').forEach(initSbsDiff);
    };
  }
})();