Fossil SCM

Move the in-line javascript used to initialize side-by-side diffs into a separately loaded script file.

drh 2017-12-05 20:33 trunk
Commit 138dbc98ffe6a420d58d130b9baec064dc51adff0f563ea819d0bc6abfa9d2df
+1 -27
--- src/info.c
+++ src/info.c
@@ -523,37 +523,11 @@
523523
/*
524524
** Generate javascript to enhance HTML diffs.
525525
*/
526526
void append_diff_javascript(int sideBySide){
527527
if( !sideBySide ) return;
528
- @ <script>(function(){
529
- @ var SCROLL_LEN = 25;
530
- @ function initSbsDiff(diff){
531
- @ var txtCols = diff.querySelectorAll('.difftxtcol');
532
- @ var txtPres = diff.querySelectorAll('.difftxtcol pre');
533
- @ var width = Math.max(txtPres[0].scrollWidth, txtPres[1].scrollWidth);
534
- @ for(var i=0; i<2; i++){
535
- @ txtPres[i].style.width = width + 'px';
536
- @ txtCols[i].onscroll = function(e){
537
- @ txtCols[0].scrollLeft = txtCols[1].scrollLeft = this.scrollLeft;
538
- @ };
539
- @ }
540
- @ diff.tabIndex = 0;
541
- @ diff.onkeydown = function(e){
542
- @ e = e || event;
543
- @ var len = {37: -SCROLL_LEN, 39: SCROLL_LEN}[e.keyCode];
544
- @ if( !len ) return;
545
- @ txtCols[0].scrollLeft += len;
546
- @ return false;
547
- @ };
548
- @ }
549
- @
550
- @ var diffs = document.querySelectorAll('.sbsdiffcols');
551
- @ for(var i=0; i<diffs.length; i++){
552
- @ initSbsDiff(diffs[i]);
553
- @ }
554
- @ }())</script>
528
+ style_load_one_js_file("sbsdiff.js");
555529
}
556530
557531
/*
558532
** Construct an appropriate diffFlag for text_diff() based on query
559533
** parameters and the to boolean arguments.
560534
--- src/info.c
+++ src/info.c
@@ -523,37 +523,11 @@
523 /*
524 ** Generate javascript to enhance HTML diffs.
525 */
526 void append_diff_javascript(int sideBySide){
527 if( !sideBySide ) return;
528 @ <script>(function(){
529 @ var SCROLL_LEN = 25;
530 @ function initSbsDiff(diff){
531 @ var txtCols = diff.querySelectorAll('.difftxtcol');
532 @ var txtPres = diff.querySelectorAll('.difftxtcol pre');
533 @ var width = Math.max(txtPres[0].scrollWidth, txtPres[1].scrollWidth);
534 @ for(var i=0; i<2; i++){
535 @ txtPres[i].style.width = width + 'px';
536 @ txtCols[i].onscroll = function(e){
537 @ txtCols[0].scrollLeft = txtCols[1].scrollLeft = this.scrollLeft;
538 @ };
539 @ }
540 @ diff.tabIndex = 0;
541 @ diff.onkeydown = function(e){
542 @ e = e || event;
543 @ var len = {37: -SCROLL_LEN, 39: SCROLL_LEN}[e.keyCode];
544 @ if( !len ) return;
545 @ txtCols[0].scrollLeft += len;
546 @ return false;
547 @ };
548 @ }
549 @
550 @ var diffs = document.querySelectorAll('.sbsdiffcols');
551 @ for(var i=0; i<diffs.length; i++){
552 @ initSbsDiff(diffs[i]);
553 @ }
554 @ }())</script>
555 }
556
557 /*
558 ** Construct an appropriate diffFlag for text_diff() based on query
559 ** parameters and the to boolean arguments.
560
--- src/info.c
+++ src/info.c
@@ -523,37 +523,11 @@
523 /*
524 ** Generate javascript to enhance HTML diffs.
525 */
526 void append_diff_javascript(int sideBySide){
527 if( !sideBySide ) return;
528 style_load_one_js_file("sbsdiff.js");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
529 }
530
531 /*
532 ** Construct an appropriate diffFlag for text_diff() based on query
533 ** parameters and the to boolean arguments.
534
--- src/main.mk
+++ src/main.mk
@@ -197,10 +197,11 @@
197197
$(SRCDIR)/../skins/xekri/header.txt \
198198
$(SRCDIR)/diff.tcl \
199199
$(SRCDIR)/graph.js \
200200
$(SRCDIR)/href.js \
201201
$(SRCDIR)/markdown.md \
202
+ $(SRCDIR)/sbsdiff.js \
202203
$(SRCDIR)/wiki.wiki
203204
204205
TRANS_SRC = \
205206
$(OBJDIR)/add_.c \
206207
$(OBJDIR)/allrepo_.c \
207208
208209
ADDED src/sbsdiff.js
--- src/main.mk
+++ src/main.mk
@@ -197,10 +197,11 @@
197 $(SRCDIR)/../skins/xekri/header.txt \
198 $(SRCDIR)/diff.tcl \
199 $(SRCDIR)/graph.js \
200 $(SRCDIR)/href.js \
201 $(SRCDIR)/markdown.md \
 
202 $(SRCDIR)/wiki.wiki
203
204 TRANS_SRC = \
205 $(OBJDIR)/add_.c \
206 $(OBJDIR)/allrepo_.c \
207
208 DDED src/sbsdiff.js
--- src/main.mk
+++ src/main.mk
@@ -197,10 +197,11 @@
197 $(SRCDIR)/../skins/xekri/header.txt \
198 $(SRCDIR)/diff.tcl \
199 $(SRCDIR)/graph.js \
200 $(SRCDIR)/href.js \
201 $(SRCDIR)/markdown.md \
202 $(SRCDIR)/sbsdiff.js \
203 $(SRCDIR)/wiki.wiki
204
205 TRANS_SRC = \
206 $(OBJDIR)/add_.c \
207 $(OBJDIR)/allrepo_.c \
208
209 DDED src/sbsdiff.js
--- a/src/sbsdiff.js
+++ b/src/sbsdiff.js
@@ -0,0 +1,27 @@
1
+/* The javascript in this file was added by Joel Bruick on 2013-07-06,
2
+** originally does some kind of setup for
3
+** side-by-side diff display, but I'm not really sure what sync on side-by-side diffs.
4
+*/
5
+(function(){
6
+ var SCROLL_LEN = 25;
7
+ function initSbsDiff(diff){
8
+ var txtCols = diff.querySelectorAll('.difftxtcol');
9
+ var txtPres = diff.querySelectorAll('.difftxtcol pre');
10
+ var width = Math.max(txtPres[0].scrollWidth, txtPres[1].scrollWidth);
11
+ for(var i=0; i<2; i++){
12
+ txtPres[i].style.width = width + 'px';
13
+ txtCols[i].onscroll = function(e){
14
+ txtCols[0].scrollLeft = txtCols[1].scrollLeft = this.scrollLeft;
15
+ };
16
+ }
17
+ diff.tabIndex = 0;
18
+ diff.onkeydown = function(e){
19
+ e = e || event;
20
+ var len = {37: -SCROLL_LEN, 39: SCROLL_LEN}[e.keyCode];
21
+ if( !len ) return;
22
+ txtCols[0].scrollLeft += len;
23
+ var diffs =;
24
+ for(var i=0; i<diffs.length; i++){
25
+ initSbsDiff(diffs[i]);
26
+ }
27
+}())
--- a/src/sbsdiff.js
+++ b/src/sbsdiff.js
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/src/sbsdiff.js
+++ b/src/sbsdiff.js
@@ -0,0 +1,27 @@
1 /* The javascript in this file was added by Joel Bruick on 2013-07-06,
2 ** originally does some kind of setup for
3 ** side-by-side diff display, but I'm not really sure what sync on side-by-side diffs.
4 */
5 (function(){
6 var SCROLL_LEN = 25;
7 function initSbsDiff(diff){
8 var txtCols = diff.querySelectorAll('.difftxtcol');
9 var txtPres = diff.querySelectorAll('.difftxtcol pre');
10 var width = Math.max(txtPres[0].scrollWidth, txtPres[1].scrollWidth);
11 for(var i=0; i<2; i++){
12 txtPres[i].style.width = width + 'px';
13 txtCols[i].onscroll = function(e){
14 txtCols[0].scrollLeft = txtCols[1].scrollLeft = this.scrollLeft;
15 };
16 }
17 diff.tabIndex = 0;
18 diff.onkeydown = function(e){
19 e = e || event;
20 var len = {37: -SCROLL_LEN, 39: SCROLL_LEN}[e.keyCode];
21 if( !len ) return;
22 txtCols[0].scrollLeft += len;
23 var diffs =;
24 for(var i=0; i<diffs.length; i++){
25 initSbsDiff(diffs[i]);
26 }
27 }())
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -606,10 +606,11 @@
606606
$(SRCDIR)/../skins/xekri/header.txt \
607607
$(SRCDIR)/diff.tcl \
608608
$(SRCDIR)/graph.js \
609609
$(SRCDIR)/href.js \
610610
$(SRCDIR)/markdown.md \
611
+ $(SRCDIR)/sbsdiff.js \
611612
$(SRCDIR)/wiki.wiki
612613
613614
TRANS_SRC = \
614615
$(OBJDIR)/add_.c \
615616
$(OBJDIR)/allrepo_.c \
616617
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -606,10 +606,11 @@
606 $(SRCDIR)/../skins/xekri/header.txt \
607 $(SRCDIR)/diff.tcl \
608 $(SRCDIR)/graph.js \
609 $(SRCDIR)/href.js \
610 $(SRCDIR)/markdown.md \
 
611 $(SRCDIR)/wiki.wiki
612
613 TRANS_SRC = \
614 $(OBJDIR)/add_.c \
615 $(OBJDIR)/allrepo_.c \
616
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -606,10 +606,11 @@
606 $(SRCDIR)/../skins/xekri/header.txt \
607 $(SRCDIR)/diff.tcl \
608 $(SRCDIR)/graph.js \
609 $(SRCDIR)/href.js \
610 $(SRCDIR)/markdown.md \
611 $(SRCDIR)/sbsdiff.js \
612 $(SRCDIR)/wiki.wiki
613
614 TRANS_SRC = \
615 $(OBJDIR)/add_.c \
616 $(OBJDIR)/allrepo_.c \
617
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -532,10 +532,11 @@
532532
$(SRCDIR)\../skins/xekri/header.txt \
533533
$(SRCDIR)\diff.tcl \
534534
$(SRCDIR)\graph.js \
535535
$(SRCDIR)\href.js \
536536
$(SRCDIR)\markdown.md \
537
+ $(SRCDIR)\sbsdiff.js \
537538
$(SRCDIR)\wiki.wiki
538539
539540
OBJ = $(OX)\add$O \
540541
$(OX)\allrepo$O \
541542
$(OX)\attach$O \
542543
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -532,10 +532,11 @@
532 $(SRCDIR)\../skins/xekri/header.txt \
533 $(SRCDIR)\diff.tcl \
534 $(SRCDIR)\graph.js \
535 $(SRCDIR)\href.js \
536 $(SRCDIR)\markdown.md \
 
537 $(SRCDIR)\wiki.wiki
538
539 OBJ = $(OX)\add$O \
540 $(OX)\allrepo$O \
541 $(OX)\attach$O \
542
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -532,10 +532,11 @@
532 $(SRCDIR)\../skins/xekri/header.txt \
533 $(SRCDIR)\diff.tcl \
534 $(SRCDIR)\graph.js \
535 $(SRCDIR)\href.js \
536 $(SRCDIR)\markdown.md \
537 $(SRCDIR)\sbsdiff.js \
538 $(SRCDIR)\wiki.wiki
539
540 OBJ = $(OX)\add$O \
541 $(OX)\allrepo$O \
542 $(OX)\attach$O \
543

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button