Fossil SCM

Perform table sorting using a separate javascript file rather than using in-line javascript.

drh 2017-12-06 10:01 trunk
Commit 6b645d631d44b94d8e95c011c7bf1e5eafd136b57edde78ab64940e0ab83b769
+3 -2
--- src/branch.c
+++ src/branch.c
@@ -393,11 +393,12 @@
393393
style_submenu_checkbox("colors", "Use Branch Colors", 0, 0);
394394
login_anonymous_available();
395395
396396
db_prepare(&q, brlistQuery/*works-like:""*/);
397397
rNow = db_double(0.0, "SELECT julianday('now')");
398
- @ <div class="brlist"><table id="branchlisttable">
398
+ @ <div class="brlist">
399
+ @ <table class='sortable' data-column-types='tkNtt' data-init-sort='2'>
399400
@ <thead><tr>
400401
@ <th>Branch Name</th>
401402
@ <th>Age</th>
402403
@ <th>Check-ins</th>
403404
@ <th>Status</th>
@@ -439,11 +440,11 @@
439440
}
440441
@ </tr>
441442
}
442443
@ </tbody></table></div>
443444
db_finalize(&q);
444
- output_table_sorting_javascript("branchlisttable","tkNtt",2);
445
+ style_table_sorter();
445446
style_footer();
446447
}
447448
448449
/*
449450
** WEBPAGE: brlist
450451
--- src/branch.c
+++ src/branch.c
@@ -393,11 +393,12 @@
393 style_submenu_checkbox("colors", "Use Branch Colors", 0, 0);
394 login_anonymous_available();
395
396 db_prepare(&q, brlistQuery/*works-like:""*/);
397 rNow = db_double(0.0, "SELECT julianday('now')");
398 @ <div class="brlist"><table id="branchlisttable">
 
399 @ <thead><tr>
400 @ <th>Branch Name</th>
401 @ <th>Age</th>
402 @ <th>Check-ins</th>
403 @ <th>Status</th>
@@ -439,11 +440,11 @@
439 }
440 @ </tr>
441 }
442 @ </tbody></table></div>
443 db_finalize(&q);
444 output_table_sorting_javascript("branchlisttable","tkNtt",2);
445 style_footer();
446 }
447
448 /*
449 ** WEBPAGE: brlist
450
--- src/branch.c
+++ src/branch.c
@@ -393,11 +393,12 @@
393 style_submenu_checkbox("colors", "Use Branch Colors", 0, 0);
394 login_anonymous_available();
395
396 db_prepare(&q, brlistQuery/*works-like:""*/);
397 rNow = db_double(0.0, "SELECT julianday('now')");
398 @ <div class="brlist">
399 @ <table class='sortable' data-column-types='tkNtt' data-init-sort='2'>
400 @ <thead><tr>
401 @ <th>Branch Name</th>
402 @ <th>Age</th>
403 @ <th>Check-ins</th>
404 @ <th>Status</th>
@@ -439,11 +440,11 @@
440 }
441 @ </tr>
442 }
443 @ </tbody></table></div>
444 db_finalize(&q);
445 style_table_sorter();
446 style_footer();
447 }
448
449 /*
450 ** WEBPAGE: brlist
451
+3 -2
--- src/doc.c
+++ src/doc.c
@@ -382,20 +382,21 @@
382382
mimetype_verify();
383383
style_header("Mimetype List");
384384
@ <p>The Fossil <a href="%R/help?cmd=/doc">/doc</a> page uses filename
385385
@ suffixes and the following table to guess at the appropriate mimetype
386386
@ for each document.</p>
387
- @ <table id='mimeTable' border=1 cellpadding=0 class='mimetypetable'>
387
+ @ <table class='sortable mimetypetable' border=1 cellpadding=0 \
388
+ @ data-column-types='tt' data-init-sort='1'>
388389
@ <thead>
389390
@ <tr><th>Suffix<th>Mimetype
390391
@ </thead>
391392
@ <tbody>
392393
for(i=0; i<count(aMime); i++){
393394
@ <tr><td>%h(aMime[i].zSuffix)<td>%h(aMime[i].zMimetype)</tr>
394395
}
395396
@ </tbody></table>
396
- output_table_sorting_javascript("mimeTable","tt",1);
397
+ style_table_sorter();
397398
style_footer();
398399
}
399400
400401
/*
401402
** Check to see if the file in the pContent blob is "embedded HTML". Return
402403
--- src/doc.c
+++ src/doc.c
@@ -382,20 +382,21 @@
382 mimetype_verify();
383 style_header("Mimetype List");
384 @ <p>The Fossil <a href="%R/help?cmd=/doc">/doc</a> page uses filename
385 @ suffixes and the following table to guess at the appropriate mimetype
386 @ for each document.</p>
387 @ <table id='mimeTable' border=1 cellpadding=0 class='mimetypetable'>
 
388 @ <thead>
389 @ <tr><th>Suffix<th>Mimetype
390 @ </thead>
391 @ <tbody>
392 for(i=0; i<count(aMime); i++){
393 @ <tr><td>%h(aMime[i].zSuffix)<td>%h(aMime[i].zMimetype)</tr>
394 }
395 @ </tbody></table>
396 output_table_sorting_javascript("mimeTable","tt",1);
397 style_footer();
398 }
399
400 /*
401 ** Check to see if the file in the pContent blob is "embedded HTML". Return
402
--- src/doc.c
+++ src/doc.c
@@ -382,20 +382,21 @@
382 mimetype_verify();
383 style_header("Mimetype List");
384 @ <p>The Fossil <a href="%R/help?cmd=/doc">/doc</a> page uses filename
385 @ suffixes and the following table to guess at the appropriate mimetype
386 @ for each document.</p>
387 @ <table class='sortable mimetypetable' border=1 cellpadding=0 \
388 @ data-column-types='tt' data-init-sort='1'>
389 @ <thead>
390 @ <tr><th>Suffix<th>Mimetype
391 @ </thead>
392 @ <tbody>
393 for(i=0; i<count(aMime); i++){
394 @ <tr><td>%h(aMime[i].zSuffix)<td>%h(aMime[i].zMimetype)</tr>
395 }
396 @ </tbody></table>
397 style_table_sorter();
398 style_footer();
399 }
400
401 /*
402 ** Check to see if the file in the pContent blob is "embedded HTML". Return
403
+4 -4
--- src/finfo.c
+++ src/finfo.c
@@ -686,14 +686,15 @@
686686
" WHERE mlink.fnid=%d"
687687
" AND event.objid=mlink.mid"
688688
" ORDER BY 1 DESC",
689689
fnid
690690
);
691
+ style_table_sorter();
691692
@ <h1>MLINK table for file
692693
@ <a href='%R/finfo?name=%t(zFName)'>%h(zFName)</a></h1>
693694
@ <div class='brlist'>
694
- @ <table id='mlinktable'>
695
+ @ <table class='sortable' data-column-types='tttxtttt' data-init-sort='1'>
695696
@ <thead><tr>
696697
@ <th>Date</th>
697698
@ <th>Check-in</th>
698699
@ <th>Parent<br>Check-in</th>
699700
@ <th>Merge?</th>
@@ -743,11 +744,10 @@
743744
}
744745
db_finalize(&q);
745746
@ </tbody>
746747
@ </table>
747748
@ </div>
748
- output_table_sorting_javascript("mlinktable","tttxtttt",1);
749749
}else{
750750
int mid = name_to_rid_www("ci");
751751
db_prepare(&q,
752752
"SELECT"
753753
/* 0 */ " (SELECT name FROM filename WHERE fnid=mlink.fnid),"
@@ -761,13 +761,14 @@
761761
" FROM mlink WHERE mid=%d ORDER BY 1",
762762
mid
763763
);
764764
@ <h1>MLINK table for check-in %h(zCI)</h1>
765765
render_checkin_context(mid, 1);
766
+ style_table_sorter();
766767
@ <hr />
767768
@ <div class='brlist'>
768
- @ <table id='mlinktable'>
769
+ @ <table class='sortable' data-column-types='ttxtttt' data-init-sort='1'>
769770
@ <thead><tr>
770771
@ <th>File</th>
771772
@ <th>Parent<br>Check-in</th>
772773
@ <th>Merge?</th>
773774
@ <th>New</th>
@@ -814,9 +815,8 @@
814815
}
815816
db_finalize(&q);
816817
@ </tbody>
817818
@ </table>
818819
@ </div>
819
- output_table_sorting_javascript("mlinktable","ttxtttt",1);
820820
}
821821
style_footer();
822822
}
823823
--- src/finfo.c
+++ src/finfo.c
@@ -686,14 +686,15 @@
686 " WHERE mlink.fnid=%d"
687 " AND event.objid=mlink.mid"
688 " ORDER BY 1 DESC",
689 fnid
690 );
 
691 @ <h1>MLINK table for file
692 @ <a href='%R/finfo?name=%t(zFName)'>%h(zFName)</a></h1>
693 @ <div class='brlist'>
694 @ <table id='mlinktable'>
695 @ <thead><tr>
696 @ <th>Date</th>
697 @ <th>Check-in</th>
698 @ <th>Parent<br>Check-in</th>
699 @ <th>Merge?</th>
@@ -743,11 +744,10 @@
743 }
744 db_finalize(&q);
745 @ </tbody>
746 @ </table>
747 @ </div>
748 output_table_sorting_javascript("mlinktable","tttxtttt",1);
749 }else{
750 int mid = name_to_rid_www("ci");
751 db_prepare(&q,
752 "SELECT"
753 /* 0 */ " (SELECT name FROM filename WHERE fnid=mlink.fnid),"
@@ -761,13 +761,14 @@
761 " FROM mlink WHERE mid=%d ORDER BY 1",
762 mid
763 );
764 @ <h1>MLINK table for check-in %h(zCI)</h1>
765 render_checkin_context(mid, 1);
 
766 @ <hr />
767 @ <div class='brlist'>
768 @ <table id='mlinktable'>
769 @ <thead><tr>
770 @ <th>File</th>
771 @ <th>Parent<br>Check-in</th>
772 @ <th>Merge?</th>
773 @ <th>New</th>
@@ -814,9 +815,8 @@
814 }
815 db_finalize(&q);
816 @ </tbody>
817 @ </table>
818 @ </div>
819 output_table_sorting_javascript("mlinktable","ttxtttt",1);
820 }
821 style_footer();
822 }
823
--- src/finfo.c
+++ src/finfo.c
@@ -686,14 +686,15 @@
686 " WHERE mlink.fnid=%d"
687 " AND event.objid=mlink.mid"
688 " ORDER BY 1 DESC",
689 fnid
690 );
691 style_table_sorter();
692 @ <h1>MLINK table for file
693 @ <a href='%R/finfo?name=%t(zFName)'>%h(zFName)</a></h1>
694 @ <div class='brlist'>
695 @ <table class='sortable' data-column-types='tttxtttt' data-init-sort='1'>
696 @ <thead><tr>
697 @ <th>Date</th>
698 @ <th>Check-in</th>
699 @ <th>Parent<br>Check-in</th>
700 @ <th>Merge?</th>
@@ -743,11 +744,10 @@
744 }
745 db_finalize(&q);
746 @ </tbody>
747 @ </table>
748 @ </div>
 
749 }else{
750 int mid = name_to_rid_www("ci");
751 db_prepare(&q,
752 "SELECT"
753 /* 0 */ " (SELECT name FROM filename WHERE fnid=mlink.fnid),"
@@ -761,13 +761,14 @@
761 " FROM mlink WHERE mid=%d ORDER BY 1",
762 mid
763 );
764 @ <h1>MLINK table for check-in %h(zCI)</h1>
765 render_checkin_context(mid, 1);
766 style_table_sorter();
767 @ <hr />
768 @ <div class='brlist'>
769 @ <table class='sortable' data-column-types='ttxtttt' data-init-sort='1'>
770 @ <thead><tr>
771 @ <th>File</th>
772 @ <th>Parent<br>Check-in</th>
773 @ <th>Merge?</th>
774 @ <th>New</th>
@@ -814,9 +815,8 @@
815 }
816 db_finalize(&q);
817 @ </tbody>
818 @ </table>
819 @ </div>
 
820 }
821 style_footer();
822 }
823
--- src/main.mk
+++ src/main.mk
@@ -199,10 +199,11 @@
199199
$(SRCDIR)/graph.js \
200200
$(SRCDIR)/href.js \
201201
$(SRCDIR)/markdown.md \
202202
$(SRCDIR)/menu.js \
203203
$(SRCDIR)/sbsdiff.js \
204
+ $(SRCDIR)/sorttable.js \
204205
$(SRCDIR)/tree.js \
205206
$(SRCDIR)/wiki.wiki
206207
207208
TRANS_SRC = \
208209
$(OBJDIR)/add_.c \
209210
--- src/main.mk
+++ src/main.mk
@@ -199,10 +199,11 @@
199 $(SRCDIR)/graph.js \
200 $(SRCDIR)/href.js \
201 $(SRCDIR)/markdown.md \
202 $(SRCDIR)/menu.js \
203 $(SRCDIR)/sbsdiff.js \
 
204 $(SRCDIR)/tree.js \
205 $(SRCDIR)/wiki.wiki
206
207 TRANS_SRC = \
208 $(OBJDIR)/add_.c \
209
--- src/main.mk
+++ src/main.mk
@@ -199,10 +199,11 @@
199 $(SRCDIR)/graph.js \
200 $(SRCDIR)/href.js \
201 $(SRCDIR)/markdown.md \
202 $(SRCDIR)/menu.js \
203 $(SRCDIR)/sbsdiff.js \
204 $(SRCDIR)/sorttable.js \
205 $(SRCDIR)/tree.js \
206 $(SRCDIR)/wiki.wiki
207
208 TRANS_SRC = \
209 $(OBJDIR)/add_.c \
210
+3 -2
--- src/name.c
+++ src/name.c
@@ -1115,11 +1115,12 @@
11151115
" datetime(description.ctime)"
11161116
" FROM description, blob LEFT JOIN delta ON delta.rid=blob.rid"
11171117
" WHERE description.rid=blob.rid"
11181118
" ORDER BY length(content) DESC"
11191119
);
1120
- @ <table cellpadding="2" cellspacing="0" border="1" id="bigblobtab">
1120
+ @ <table cellpadding="2" cellspacing="0" border="1" \
1121
+ @ class='sortable' data-column-types='NnnttT' data-init-sort='0'>
11211122
@ <thead><tr><th align="right">Size<th align="right">RID
11221123
@ <th align="right">Delta From<th>Hash<th>Description<th>Date</tr></thead>
11231124
@ <tbody>
11241125
while( db_step(&q)==SQLITE_ROW ){
11251126
int rid = db_column_int(&q,0);
@@ -1136,11 +1137,11 @@
11361137
@ <td align="left">%z(href("%R/timeline?c=%T",zDate))%s(zDate)</a></td>
11371138
@ </tr>
11381139
}
11391140
@ </tbody></table>
11401141
db_finalize(&q);
1141
- output_table_sorting_javascript("bigblobtab", "NnnttT", -1);
1142
+ style_table_sorter();
11421143
style_footer();
11431144
}
11441145
11451146
/*
11461147
** COMMAND: test-unsent
11471148
--- src/name.c
+++ src/name.c
@@ -1115,11 +1115,12 @@
1115 " datetime(description.ctime)"
1116 " FROM description, blob LEFT JOIN delta ON delta.rid=blob.rid"
1117 " WHERE description.rid=blob.rid"
1118 " ORDER BY length(content) DESC"
1119 );
1120 @ <table cellpadding="2" cellspacing="0" border="1" id="bigblobtab">
 
1121 @ <thead><tr><th align="right">Size<th align="right">RID
1122 @ <th align="right">Delta From<th>Hash<th>Description<th>Date</tr></thead>
1123 @ <tbody>
1124 while( db_step(&q)==SQLITE_ROW ){
1125 int rid = db_column_int(&q,0);
@@ -1136,11 +1137,11 @@
1136 @ <td align="left">%z(href("%R/timeline?c=%T",zDate))%s(zDate)</a></td>
1137 @ </tr>
1138 }
1139 @ </tbody></table>
1140 db_finalize(&q);
1141 output_table_sorting_javascript("bigblobtab", "NnnttT", -1);
1142 style_footer();
1143 }
1144
1145 /*
1146 ** COMMAND: test-unsent
1147
--- src/name.c
+++ src/name.c
@@ -1115,11 +1115,12 @@
1115 " datetime(description.ctime)"
1116 " FROM description, blob LEFT JOIN delta ON delta.rid=blob.rid"
1117 " WHERE description.rid=blob.rid"
1118 " ORDER BY length(content) DESC"
1119 );
1120 @ <table cellpadding="2" cellspacing="0" border="1" \
1121 @ class='sortable' data-column-types='NnnttT' data-init-sort='0'>
1122 @ <thead><tr><th align="right">Size<th align="right">RID
1123 @ <th align="right">Delta From<th>Hash<th>Description<th>Date</tr></thead>
1124 @ <tbody>
1125 while( db_step(&q)==SQLITE_ROW ){
1126 int rid = db_column_int(&q,0);
@@ -1136,11 +1137,11 @@
1137 @ <td align="left">%z(href("%R/timeline?c=%T",zDate))%s(zDate)</a></td>
1138 @ </tr>
1139 }
1140 @ </tbody></table>
1141 db_finalize(&q);
1142 style_table_sorter();
1143 style_footer();
1144 }
1145
1146 /*
1147 ** COMMAND: test-unsent
1148
+3 -188
--- src/report.c
+++ src/report.c
@@ -945,195 +945,10 @@
945945
}
946946
rc = sqlite3_finalize(pStmt);
947947
fossil_free((void *)azVals);
948948
return rc;
949949
}
950
-
951
-/*
952
-** Output Javascript code that will enables sorting of the table with
953
-** the id zTableId by clicking.
954
-**
955
-** The javascript was originally derived from:
956
-**
957
-** http://www.webtoolkit.info/sortable-html-table.html
958
-**
959
-** But there have been extensive modifications.
960
-**
961
-** This variation allows column types to be expressed using the second
962
-** argument. Each character of the second argument represent a column.
963
-**
964
-** t Sort by text
965
-** n Sort numerically
966
-** k Sort by the data-sortkey property
967
-** x This column is not sortable
968
-**
969
-** Capital letters mean sort in reverse order.
970
-** If there are fewer characters in zColumnTypes[] than their are columns,
971
-** then all extra columns assume type "t" (text).
972
-**
973
-** The third parameter is the column that was initially sorted (using 1-based
974
-** column numbers, like SQL). Make this value 0 if none of the columns are
975
-** initially sorted. Make the value negative if the column is initially sorted
976
-** in reverse order.
977
-**
978
-** Clicking on the same column header twice in a row inverts the sort.
979
-*/
980
-void output_table_sorting_javascript(
981
- const char *zTableId, /* ID of table to sort */
982
- const char *zColumnTypes, /* String for column types */
983
- int iInitSort /* Initially sorted column. Leftmost is 1. 0 for NONE */
984
-){
985
- @ <script>
986
- @ function SortableTable(tableEl,columnTypes,initSort){
987
- @ this.tbody = tableEl.getElementsByTagName('tbody');
988
- @ this.columnTypes = columnTypes;
989
- @ var ncols = tableEl.rows[0].cells.length;
990
- @ for(var i = columnTypes.length; i<=ncols; i++){this.columnTypes += 't';}
991
- @ this.sort = function (cell) {
992
- @ var column = cell.cellIndex;
993
- @ var sortFn;
994
- @ switch( cell.sortType ){
995
- if( strchr(zColumnTypes,'n') ){
996
- @ case "n": sortFn = this.sortNumeric; break;
997
- }
998
- if( strchr(zColumnTypes,'N') ){
999
- @ case "N": sortFn = this.sortReverseNumeric; break;
1000
- }
1001
- @ case "t": sortFn = this.sortText; break;
1002
- if( strchr(zColumnTypes,'T') ){
1003
- @ case "T": sortFn = this.sortReverseText; break;
1004
- }
1005
- if( strchr(zColumnTypes,'k') ){
1006
- @ case "k": sortFn = this.sortKey; break;
1007
- }
1008
- if( strchr(zColumnTypes,'K') ){
1009
- @ case "K": sortFn = this.sortReverseKey; break;
1010
- }
1011
- @ default: return;
1012
- @ }
1013
- @ this.sortIndex = column;
1014
- @ var newRows = new Array();
1015
- @ for (j = 0; j < this.tbody[0].rows.length; j++) {
1016
- @ newRows[j] = this.tbody[0].rows[j];
1017
- @ }
1018
- @ if( this.sortIndex==Math.abs(this.prevColumn)-1 ){
1019
- @ newRows.reverse();
1020
- @ this.prevColumn = -this.prevColumn;
1021
- @ }else{
1022
- @ newRows.sort(sortFn);
1023
- @ this.prevColumn = this.sortIndex+1;
1024
- @ }
1025
- @ for (i=0;i<newRows.length;i++) {
1026
- @ this.tbody[0].appendChild(newRows[i]);
1027
- @ }
1028
- @ this.setHdrIcons();
1029
- @ }
1030
- @ this.setHdrIcons = function() {
1031
- @ for (var i=0; i<this.hdrRow.cells.length; i++) {
1032
- @ if( this.columnTypes[i]=='x' ) continue;
1033
- @ var sortType;
1034
- @ if( this.prevColumn==i+1 ){
1035
- @ sortType = 'asc';
1036
- @ }else if( this.prevColumn==(-1-i) ){
1037
- @ sortType = 'desc'
1038
- @ }else{
1039
- @ sortType = 'none';
1040
- @ }
1041
- @ var hdrCell = this.hdrRow.cells[i];
1042
- @ var clsName = hdrCell.className.replace(/\s*\bsort\s*\w+/, '');
1043
- @ clsName += ' sort ' + sortType;
1044
- @ hdrCell.className = clsName;
1045
- @ }
1046
- @ }
1047
- @ this.sortText = function(a,b) {
1048
- @ var i = thisObject.sortIndex;
1049
- @ aa = a.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
1050
- @ bb = b.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
1051
- @ if(aa<bb) return -1;
1052
- @ if(aa==bb) return a.rowIndex-b.rowIndex;
1053
- @ return 1;
1054
- @ }
1055
- if( strchr(zColumnTypes,'T') ){
1056
- @ this.sortReverseText = function(a,b) {
1057
- @ var i = thisObject.sortIndex;
1058
- @ aa = a.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
1059
- @ bb = b.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
1060
- @ if(aa<bb) return +1;
1061
- @ if(aa==bb) return a.rowIndex-b.rowIndex;
1062
- @ return -1;
1063
- @ }
1064
- }
1065
- if( strchr(zColumnTypes,'n') ){
1066
- @ this.sortNumeric = function(a,b) {
1067
- @ var i = thisObject.sortIndex;
1068
- @ aa = parseFloat(a.cells[i].textContent);
1069
- @ if (isNaN(aa)) aa = 0;
1070
- @ bb = parseFloat(b.cells[i].textContent);
1071
- @ if (isNaN(bb)) bb = 0;
1072
- @ if(aa==bb) return a.rowIndex-b.rowIndex;
1073
- @ return aa-bb;
1074
- @ }
1075
- }
1076
- if( strchr(zColumnTypes,'N') ){
1077
- @ this.sortReverseNumeric = function(a,b) {
1078
- @ var i = thisObject.sortIndex;
1079
- @ aa = parseFloat(a.cells[i].textContent);
1080
- @ if (isNaN(aa)) aa = 0;
1081
- @ bb = parseFloat(b.cells[i].textContent);
1082
- @ if (isNaN(bb)) bb = 0;
1083
- @ if(aa==bb) return a.rowIndex-b.rowIndex;
1084
- @ return bb-aa;
1085
- @ }
1086
- }
1087
- if( strchr(zColumnTypes,'k') ){
1088
- @ this.sortKey = function(a,b) {
1089
- @ var i = thisObject.sortIndex;
1090
- @ aa = a.cells[i].getAttribute("data-sortkey");
1091
- @ bb = b.cells[i].getAttribute("data-sortkey");
1092
- @ if(aa<bb) return -1;
1093
- @ if(aa==bb) return a.rowIndex-b.rowIndex;
1094
- @ return 1;
1095
- @ }
1096
- }
1097
- if( strchr(zColumnTypes,'K') ){
1098
- @ this.sortReverseKey = function(a,b) {
1099
- @ var i = thisObject.sortIndex;
1100
- @ aa = a.cells[i].getAttribute("data-sortkey");
1101
- @ bb = b.cells[i].getAttribute("data-sortkey");
1102
- @ if(aa<bb) return +1;
1103
- @ if(aa==bb) return a.rowIndex-b.rowIndex;
1104
- @ return -1;
1105
- @ }
1106
- }
1107
- @ var x = tableEl.getElementsByTagName('thead');
1108
- @ if(!(this.tbody && this.tbody[0].rows && this.tbody[0].rows.length>0)){
1109
- @ return;
1110
- @ }
1111
- @ if(x && x[0].rows && x[0].rows.length > 0) {
1112
- @ this.hdrRow = x[0].rows[0];
1113
- @ } else {
1114
- @ return;
1115
- @ }
1116
- @ var thisObject = this;
1117
- @ this.prevColumn = initSort;
1118
- @ for (var i=0; i<this.hdrRow.cells.length; i++) {
1119
- @ if( columnTypes[i]=='x' ) continue;
1120
- @ var hdrcell = this.hdrRow.cells[i];
1121
- @ hdrcell.sTable = this;
1122
- @ hdrcell.style.cursor = "pointer";
1123
- @ hdrcell.sortType = columnTypes[i] || 't';
1124
- @ hdrcell.onclick = function () {
1125
- @ this.sTable.sort(this);
1126
- @ return false;
1127
- @ }
1128
- @ }
1129
- @ this.setHdrIcons()
1130
- @ }
1131
- @ var t = new SortableTable(gebi("%s(zTableId)"),"%s(zColumnTypes)",%d(iInitSort));
1132
- @ </script>
1133
-}
1134
-
1135950
1136951
/*
1137952
** WEBPAGE: rptview
1138953
**
1139954
** Generate a report. The rn query parameter is the report number
@@ -1211,12 +1026,12 @@
12111026
style_submenu_element("New Ticket", "%s/tktnew", g.zTop);
12121027
}
12131028
style_header("%s", zTitle);
12141029
output_color_key(zClrKey, 1,
12151030
"border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"report\"");
1216
- @ <table border="1" cellpadding="2" cellspacing="0" class="report"
1217
- @ id="reportTable">
1031
+ @ <table border="1" cellpadding="2" cellspacing="0" class="report sortable"
1032
+ @ data-column-types='' data-init-sort='0'>
12181033
sState.rn = rn;
12191034
sState.nCount = 0;
12201035
report_restrict_sql(&zErr1);
12211036
db_exec_readonly(g.db, zSql, generate_html, &sState, &zErr2);
12221037
report_unrestrict_sql();
@@ -1224,11 +1039,11 @@
12241039
if( zErr1 ){
12251040
@ <p class="reportError">Error: %h(zErr1)</p>
12261041
}else if( zErr2 ){
12271042
@ <p class="reportError">Error: %h(zErr2)</p>
12281043
}
1229
- output_table_sorting_javascript("reportTable","",0);
1044
+ style_table_sorter();
12301045
style_footer();
12311046
}else{
12321047
report_restrict_sql(&zErr1);
12331048
db_exec_readonly(g.db, zSql, output_tab_separated, &count, &zErr2);
12341049
report_unrestrict_sql();
12351050
--- src/report.c
+++ src/report.c
@@ -945,195 +945,10 @@
945 }
946 rc = sqlite3_finalize(pStmt);
947 fossil_free((void *)azVals);
948 return rc;
949 }
950
951 /*
952 ** Output Javascript code that will enables sorting of the table with
953 ** the id zTableId by clicking.
954 **
955 ** The javascript was originally derived from:
956 **
957 ** http://www.webtoolkit.info/sortable-html-table.html
958 **
959 ** But there have been extensive modifications.
960 **
961 ** This variation allows column types to be expressed using the second
962 ** argument. Each character of the second argument represent a column.
963 **
964 ** t Sort by text
965 ** n Sort numerically
966 ** k Sort by the data-sortkey property
967 ** x This column is not sortable
968 **
969 ** Capital letters mean sort in reverse order.
970 ** If there are fewer characters in zColumnTypes[] than their are columns,
971 ** then all extra columns assume type "t" (text).
972 **
973 ** The third parameter is the column that was initially sorted (using 1-based
974 ** column numbers, like SQL). Make this value 0 if none of the columns are
975 ** initially sorted. Make the value negative if the column is initially sorted
976 ** in reverse order.
977 **
978 ** Clicking on the same column header twice in a row inverts the sort.
979 */
980 void output_table_sorting_javascript(
981 const char *zTableId, /* ID of table to sort */
982 const char *zColumnTypes, /* String for column types */
983 int iInitSort /* Initially sorted column. Leftmost is 1. 0 for NONE */
984 ){
985 @ <script>
986 @ function SortableTable(tableEl,columnTypes,initSort){
987 @ this.tbody = tableEl.getElementsByTagName('tbody');
988 @ this.columnTypes = columnTypes;
989 @ var ncols = tableEl.rows[0].cells.length;
990 @ for(var i = columnTypes.length; i<=ncols; i++){this.columnTypes += 't';}
991 @ this.sort = function (cell) {
992 @ var column = cell.cellIndex;
993 @ var sortFn;
994 @ switch( cell.sortType ){
995 if( strchr(zColumnTypes,'n') ){
996 @ case "n": sortFn = this.sortNumeric; break;
997 }
998 if( strchr(zColumnTypes,'N') ){
999 @ case "N": sortFn = this.sortReverseNumeric; break;
1000 }
1001 @ case "t": sortFn = this.sortText; break;
1002 if( strchr(zColumnTypes,'T') ){
1003 @ case "T": sortFn = this.sortReverseText; break;
1004 }
1005 if( strchr(zColumnTypes,'k') ){
1006 @ case "k": sortFn = this.sortKey; break;
1007 }
1008 if( strchr(zColumnTypes,'K') ){
1009 @ case "K": sortFn = this.sortReverseKey; break;
1010 }
1011 @ default: return;
1012 @ }
1013 @ this.sortIndex = column;
1014 @ var newRows = new Array();
1015 @ for (j = 0; j < this.tbody[0].rows.length; j++) {
1016 @ newRows[j] = this.tbody[0].rows[j];
1017 @ }
1018 @ if( this.sortIndex==Math.abs(this.prevColumn)-1 ){
1019 @ newRows.reverse();
1020 @ this.prevColumn = -this.prevColumn;
1021 @ }else{
1022 @ newRows.sort(sortFn);
1023 @ this.prevColumn = this.sortIndex+1;
1024 @ }
1025 @ for (i=0;i<newRows.length;i++) {
1026 @ this.tbody[0].appendChild(newRows[i]);
1027 @ }
1028 @ this.setHdrIcons();
1029 @ }
1030 @ this.setHdrIcons = function() {
1031 @ for (var i=0; i<this.hdrRow.cells.length; i++) {
1032 @ if( this.columnTypes[i]=='x' ) continue;
1033 @ var sortType;
1034 @ if( this.prevColumn==i+1 ){
1035 @ sortType = 'asc';
1036 @ }else if( this.prevColumn==(-1-i) ){
1037 @ sortType = 'desc'
1038 @ }else{
1039 @ sortType = 'none';
1040 @ }
1041 @ var hdrCell = this.hdrRow.cells[i];
1042 @ var clsName = hdrCell.className.replace(/\s*\bsort\s*\w+/, '');
1043 @ clsName += ' sort ' + sortType;
1044 @ hdrCell.className = clsName;
1045 @ }
1046 @ }
1047 @ this.sortText = function(a,b) {
1048 @ var i = thisObject.sortIndex;
1049 @ aa = a.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
1050 @ bb = b.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
1051 @ if(aa<bb) return -1;
1052 @ if(aa==bb) return a.rowIndex-b.rowIndex;
1053 @ return 1;
1054 @ }
1055 if( strchr(zColumnTypes,'T') ){
1056 @ this.sortReverseText = function(a,b) {
1057 @ var i = thisObject.sortIndex;
1058 @ aa = a.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
1059 @ bb = b.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
1060 @ if(aa<bb) return +1;
1061 @ if(aa==bb) return a.rowIndex-b.rowIndex;
1062 @ return -1;
1063 @ }
1064 }
1065 if( strchr(zColumnTypes,'n') ){
1066 @ this.sortNumeric = function(a,b) {
1067 @ var i = thisObject.sortIndex;
1068 @ aa = parseFloat(a.cells[i].textContent);
1069 @ if (isNaN(aa)) aa = 0;
1070 @ bb = parseFloat(b.cells[i].textContent);
1071 @ if (isNaN(bb)) bb = 0;
1072 @ if(aa==bb) return a.rowIndex-b.rowIndex;
1073 @ return aa-bb;
1074 @ }
1075 }
1076 if( strchr(zColumnTypes,'N') ){
1077 @ this.sortReverseNumeric = function(a,b) {
1078 @ var i = thisObject.sortIndex;
1079 @ aa = parseFloat(a.cells[i].textContent);
1080 @ if (isNaN(aa)) aa = 0;
1081 @ bb = parseFloat(b.cells[i].textContent);
1082 @ if (isNaN(bb)) bb = 0;
1083 @ if(aa==bb) return a.rowIndex-b.rowIndex;
1084 @ return bb-aa;
1085 @ }
1086 }
1087 if( strchr(zColumnTypes,'k') ){
1088 @ this.sortKey = function(a,b) {
1089 @ var i = thisObject.sortIndex;
1090 @ aa = a.cells[i].getAttribute("data-sortkey");
1091 @ bb = b.cells[i].getAttribute("data-sortkey");
1092 @ if(aa<bb) return -1;
1093 @ if(aa==bb) return a.rowIndex-b.rowIndex;
1094 @ return 1;
1095 @ }
1096 }
1097 if( strchr(zColumnTypes,'K') ){
1098 @ this.sortReverseKey = function(a,b) {
1099 @ var i = thisObject.sortIndex;
1100 @ aa = a.cells[i].getAttribute("data-sortkey");
1101 @ bb = b.cells[i].getAttribute("data-sortkey");
1102 @ if(aa<bb) return +1;
1103 @ if(aa==bb) return a.rowIndex-b.rowIndex;
1104 @ return -1;
1105 @ }
1106 }
1107 @ var x = tableEl.getElementsByTagName('thead');
1108 @ if(!(this.tbody && this.tbody[0].rows && this.tbody[0].rows.length>0)){
1109 @ return;
1110 @ }
1111 @ if(x && x[0].rows && x[0].rows.length > 0) {
1112 @ this.hdrRow = x[0].rows[0];
1113 @ } else {
1114 @ return;
1115 @ }
1116 @ var thisObject = this;
1117 @ this.prevColumn = initSort;
1118 @ for (var i=0; i<this.hdrRow.cells.length; i++) {
1119 @ if( columnTypes[i]=='x' ) continue;
1120 @ var hdrcell = this.hdrRow.cells[i];
1121 @ hdrcell.sTable = this;
1122 @ hdrcell.style.cursor = "pointer";
1123 @ hdrcell.sortType = columnTypes[i] || 't';
1124 @ hdrcell.onclick = function () {
1125 @ this.sTable.sort(this);
1126 @ return false;
1127 @ }
1128 @ }
1129 @ this.setHdrIcons()
1130 @ }
1131 @ var t = new SortableTable(gebi("%s(zTableId)"),"%s(zColumnTypes)",%d(iInitSort));
1132 @ </script>
1133 }
1134
1135
1136 /*
1137 ** WEBPAGE: rptview
1138 **
1139 ** Generate a report. The rn query parameter is the report number
@@ -1211,12 +1026,12 @@
1211 style_submenu_element("New Ticket", "%s/tktnew", g.zTop);
1212 }
1213 style_header("%s", zTitle);
1214 output_color_key(zClrKey, 1,
1215 "border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"report\"");
1216 @ <table border="1" cellpadding="2" cellspacing="0" class="report"
1217 @ id="reportTable">
1218 sState.rn = rn;
1219 sState.nCount = 0;
1220 report_restrict_sql(&zErr1);
1221 db_exec_readonly(g.db, zSql, generate_html, &sState, &zErr2);
1222 report_unrestrict_sql();
@@ -1224,11 +1039,11 @@
1224 if( zErr1 ){
1225 @ <p class="reportError">Error: %h(zErr1)</p>
1226 }else if( zErr2 ){
1227 @ <p class="reportError">Error: %h(zErr2)</p>
1228 }
1229 output_table_sorting_javascript("reportTable","",0);
1230 style_footer();
1231 }else{
1232 report_restrict_sql(&zErr1);
1233 db_exec_readonly(g.db, zSql, output_tab_separated, &count, &zErr2);
1234 report_unrestrict_sql();
1235
--- src/report.c
+++ src/report.c
@@ -945,195 +945,10 @@
945 }
946 rc = sqlite3_finalize(pStmt);
947 fossil_free((void *)azVals);
948 return rc;
949 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
950
951 /*
952 ** WEBPAGE: rptview
953 **
954 ** Generate a report. The rn query parameter is the report number
@@ -1211,12 +1026,12 @@
1026 style_submenu_element("New Ticket", "%s/tktnew", g.zTop);
1027 }
1028 style_header("%s", zTitle);
1029 output_color_key(zClrKey, 1,
1030 "border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"report\"");
1031 @ <table border="1" cellpadding="2" cellspacing="0" class="report sortable"
1032 @ data-column-types='' data-init-sort='0'>
1033 sState.rn = rn;
1034 sState.nCount = 0;
1035 report_restrict_sql(&zErr1);
1036 db_exec_readonly(g.db, zSql, generate_html, &sState, &zErr2);
1037 report_unrestrict_sql();
@@ -1224,11 +1039,11 @@
1039 if( zErr1 ){
1040 @ <p class="reportError">Error: %h(zErr1)</p>
1041 }else if( zErr2 ){
1042 @ <p class="reportError">Error: %h(zErr2)</p>
1043 }
1044 style_table_sorter();
1045 style_footer();
1046 }else{
1047 report_restrict_sql(&zErr1);
1048 db_exec_readonly(g.db, zSql, output_tab_separated, &count, &zErr2);
1049 report_unrestrict_sql();
1050
+8 -8
--- src/setup.c
+++ src/setup.c
@@ -208,11 +208,12 @@
208208
}else{
209209
style_header("Users With Capabilities \"%h\"", zWith);
210210
}
211211
@ </tbody></table>
212212
@ <div class='section'>Users</div>
213
- @ <table border=1 cellpadding=2 cellspacing=0 class='userTable' id='userlist'>
213
+ @ <table border=1 cellpadding=2 cellspacing=0 class='userTable sortable' \
214
+ @ data-column-types='nktxTTK' data-init-sort='2'>
214215
@ <thead><tr>
215216
@ <th>ID<th>Login Name<th>Caps<th>Info<th>Date<th>Expire<th>Last Login</tr></thead>
216217
@ <tbody>
217218
db_multi_exec(
218219
"CREATE TEMP TABLE lastAccess(uname TEXT PRIMARY KEY, atime REAL) WITHOUT ROWID;"
@@ -267,11 +268,11 @@
267268
@ </tr>
268269
fossil_free(zAge);
269270
}
270271
@ </tbody></table>
271272
db_finalize(&s);
272
- output_table_sorting_javascript("userlist","nktxTTK",2);
273
+ style_table_sorter();
273274
style_footer();
274275
}
275276
276277
/*
277278
** Render the user-capability table
@@ -1410,11 +1411,11 @@
14101411
@ IP octets</a> in the login cookie across all repositories in the
14111412
@ same Login Group.
14121413
@ <hr /><h2>Implementation Details</h2>
14131414
@ <p>The following are fields from the CONFIG table related to login-groups,
14141415
@ provided here for instructional and debugging purposes:</p>
1415
- @ <table border='1' id='configTab'>
1416
+ @ <table border='1' class='sortable' data-column-types='ttt' data-init-sort='1'>
14161417
@ <thead><tr>
14171418
@ <th>Config.Name<th>Config.Value<th>Config.mtime</tr>
14181419
@ </thead><tbody>
14191420
db_prepare(&q, "SELECT name, value, datetime(mtime,'unixepoch') FROM config"
14201421
" WHERE name GLOB 'peer-*'"
@@ -1426,11 +1427,11 @@
14261427
@ <td>%h(db_column_text(&q,1))</td>
14271428
@ <td>%h(db_column_text(&q,2))</td></tr>
14281429
}
14291430
db_finalize(&q);
14301431
@ </tbody></table>
1431
- output_table_sorting_javascript("configTab","ttt",1);
1432
+ style_table_sorter();
14321433
}
14331434
style_footer();
14341435
}
14351436
14361437
/*
@@ -2242,12 +2243,13 @@
22422243
}
22432244
db_prepare(&stLog,
22442245
"SELECT datetime(time,'unixepoch'), who, page, what "
22452246
"FROM admin_log "
22462247
"ORDER BY time DESC");
2247
-
2248
- @ <table id="adminLogTable" class="adminLogTable" width="100%%">
2248
+ style_table_sorter();
2249
+ @ <table class="sortable adminLogTable" width="100%%" \
2250
+ @ data-column-types='Tttx' data-init-sort='1'>
22492251
@ <thead>
22502252
@ <th>Time</th>
22512253
@ <th>User</th>
22522254
@ <th>Page</th>
22532255
@ <th width="60%%">Message</th>
@@ -2269,12 +2271,10 @@
22692271
}
22702272
@ </tbody></table>
22712273
if( counter>ofst+limit ){
22722274
@ <p><a href="admin_log?n=%d(limit)&x=%d(limit+ofst)">[Older]</a></p>
22732275
}
2274
-
2275
- output_table_sorting_javascript("adminLogTable", "Tttx", 1);
22762276
style_footer();
22772277
}
22782278
22792279
/*
22802280
** WEBPAGE: srchsetup
22812281
22822282
ADDED src/sorttable.js
--- src/setup.c
+++ src/setup.c
@@ -208,11 +208,12 @@
208 }else{
209 style_header("Users With Capabilities \"%h\"", zWith);
210 }
211 @ </tbody></table>
212 @ <div class='section'>Users</div>
213 @ <table border=1 cellpadding=2 cellspacing=0 class='userTable' id='userlist'>
 
214 @ <thead><tr>
215 @ <th>ID<th>Login Name<th>Caps<th>Info<th>Date<th>Expire<th>Last Login</tr></thead>
216 @ <tbody>
217 db_multi_exec(
218 "CREATE TEMP TABLE lastAccess(uname TEXT PRIMARY KEY, atime REAL) WITHOUT ROWID;"
@@ -267,11 +268,11 @@
267 @ </tr>
268 fossil_free(zAge);
269 }
270 @ </tbody></table>
271 db_finalize(&s);
272 output_table_sorting_javascript("userlist","nktxTTK",2);
273 style_footer();
274 }
275
276 /*
277 ** Render the user-capability table
@@ -1410,11 +1411,11 @@
1410 @ IP octets</a> in the login cookie across all repositories in the
1411 @ same Login Group.
1412 @ <hr /><h2>Implementation Details</h2>
1413 @ <p>The following are fields from the CONFIG table related to login-groups,
1414 @ provided here for instructional and debugging purposes:</p>
1415 @ <table border='1' id='configTab'>
1416 @ <thead><tr>
1417 @ <th>Config.Name<th>Config.Value<th>Config.mtime</tr>
1418 @ </thead><tbody>
1419 db_prepare(&q, "SELECT name, value, datetime(mtime,'unixepoch') FROM config"
1420 " WHERE name GLOB 'peer-*'"
@@ -1426,11 +1427,11 @@
1426 @ <td>%h(db_column_text(&q,1))</td>
1427 @ <td>%h(db_column_text(&q,2))</td></tr>
1428 }
1429 db_finalize(&q);
1430 @ </tbody></table>
1431 output_table_sorting_javascript("configTab","ttt",1);
1432 }
1433 style_footer();
1434 }
1435
1436 /*
@@ -2242,12 +2243,13 @@
2242 }
2243 db_prepare(&stLog,
2244 "SELECT datetime(time,'unixepoch'), who, page, what "
2245 "FROM admin_log "
2246 "ORDER BY time DESC");
2247
2248 @ <table id="adminLogTable" class="adminLogTable" width="100%%">
 
2249 @ <thead>
2250 @ <th>Time</th>
2251 @ <th>User</th>
2252 @ <th>Page</th>
2253 @ <th width="60%%">Message</th>
@@ -2269,12 +2271,10 @@
2269 }
2270 @ </tbody></table>
2271 if( counter>ofst+limit ){
2272 @ <p><a href="admin_log?n=%d(limit)&x=%d(limit+ofst)">[Older]</a></p>
2273 }
2274
2275 output_table_sorting_javascript("adminLogTable", "Tttx", 1);
2276 style_footer();
2277 }
2278
2279 /*
2280 ** WEBPAGE: srchsetup
2281
2282 DDED src/sorttable.js
--- src/setup.c
+++ src/setup.c
@@ -208,11 +208,12 @@
208 }else{
209 style_header("Users With Capabilities \"%h\"", zWith);
210 }
211 @ </tbody></table>
212 @ <div class='section'>Users</div>
213 @ <table border=1 cellpadding=2 cellspacing=0 class='userTable sortable' \
214 @ data-column-types='nktxTTK' data-init-sort='2'>
215 @ <thead><tr>
216 @ <th>ID<th>Login Name<th>Caps<th>Info<th>Date<th>Expire<th>Last Login</tr></thead>
217 @ <tbody>
218 db_multi_exec(
219 "CREATE TEMP TABLE lastAccess(uname TEXT PRIMARY KEY, atime REAL) WITHOUT ROWID;"
@@ -267,11 +268,11 @@
268 @ </tr>
269 fossil_free(zAge);
270 }
271 @ </tbody></table>
272 db_finalize(&s);
273 style_table_sorter();
274 style_footer();
275 }
276
277 /*
278 ** Render the user-capability table
@@ -1410,11 +1411,11 @@
1411 @ IP octets</a> in the login cookie across all repositories in the
1412 @ same Login Group.
1413 @ <hr /><h2>Implementation Details</h2>
1414 @ <p>The following are fields from the CONFIG table related to login-groups,
1415 @ provided here for instructional and debugging purposes:</p>
1416 @ <table border='1' class='sortable' data-column-types='ttt' data-init-sort='1'>
1417 @ <thead><tr>
1418 @ <th>Config.Name<th>Config.Value<th>Config.mtime</tr>
1419 @ </thead><tbody>
1420 db_prepare(&q, "SELECT name, value, datetime(mtime,'unixepoch') FROM config"
1421 " WHERE name GLOB 'peer-*'"
@@ -1426,11 +1427,11 @@
1427 @ <td>%h(db_column_text(&q,1))</td>
1428 @ <td>%h(db_column_text(&q,2))</td></tr>
1429 }
1430 db_finalize(&q);
1431 @ </tbody></table>
1432 style_table_sorter();
1433 }
1434 style_footer();
1435 }
1436
1437 /*
@@ -2242,12 +2243,13 @@
2243 }
2244 db_prepare(&stLog,
2245 "SELECT datetime(time,'unixepoch'), who, page, what "
2246 "FROM admin_log "
2247 "ORDER BY time DESC");
2248 style_table_sorter();
2249 @ <table class="sortable adminLogTable" width="100%%" \
2250 @ data-column-types='Tttx' data-init-sort='1'>
2251 @ <thead>
2252 @ <th>Time</th>
2253 @ <th>User</th>
2254 @ <th>Page</th>
2255 @ <th width="60%%">Message</th>
@@ -2269,12 +2271,10 @@
2271 }
2272 @ </tbody></table>
2273 if( counter>ofst+limit ){
2274 @ <p><a href="admin_log?n=%d(limit)&x=%d(limit+ofst)">[Older]</a></p>
2275 }
 
 
2276 style_footer();
2277 }
2278
2279 /*
2280 ** WEBPAGE: srchsetup
2281
2282 DDED src/sorttable.js
--- a/src/sorttable.js
+++ b/src/sorttable.js
@@ -0,0 +1,49 @@
1
+: sortFn = this.sortReverseText; b1;
2
+ aa = a.cells[i]. = columnTypes.length; i<=ncols; i++){this.columnTypes += 't';}
3
+ this.sort = function (cell) {
4
+ var column = cell.cellIndex;
5
+ var sortFn;
6
+ switch( cell.sortType ){
7
+ case "n": sortFn = this.sortNumeric; break;
8
+ case "N": sortFn = this.sortReverseNumeric; break;
9
+ : sortFn = this.sortReverseText; break;
10
+ case "k": sortFn = this.sortKey; break;
11
+ case "K": sortFn = this.sortReverseKey; break;
12
+ default: return;
13
+ }
14
+ this.sortIndex = column;
15
+ var newRows = new Array();
16
+ for (j = 0; j < this.tbody[0].rows.length; j++) {
17
+ newRows[j] = this.tbody[0].rows[j];
18
+ }
19
+ if( this.sortIndex==Math.abs(this.prevColumn)-1 ){
20
+ newRows.reverse();
21
+ this.prevColumn = -this.prevColumn;
22
+ }else{
23
+ newRows.sort(sortFn);
24
+ this.prevColumn = this.sortIndex+1;
25
+ }
26
+ for (i=0;i<newRows.length;i++) {
27
+ this.tbody[0].appendChild(newRows[i]);
28
+ }
29
+ this.setHdrIcons();
30
+ }
31
+ this.setHdrIcons = function() {
32
+ for (var i=0; i<this.hdrRow.cells.length; i++) {
33
+ if( this.columnTypes[i]=='x' ) continue;
34
+ var sortType;
35
+ if( this.prevColumn==i+1 ){
36
+ sortType = 'asc';
37
+ }else if( this.prevColumn==(-1-i) ){
38
+ sortType = 'desc'
39
+ }else{
40
+ sortType = 'none';
41
+ }
42
+ var hdrCell = this.hdrRow.cells[i];
43
+ var clsName = hdrCell.className.replace(/\s*\bsort\s*\w+/, '');
44
+ clsName += ' sort ' + sortType;
45
+ hdrCell.className = clsName;
46
+ }
47
+ }
48
+ this.sortject.sor9710b1ab5d4 */
49
+ if
--- a/src/sorttable.js
+++ b/src/sorttable.js
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/src/sorttable.js
+++ b/src/sorttable.js
@@ -0,0 +1,49 @@
1 : sortFn = this.sortReverseText; b1;
2 aa = a.cells[i]. = columnTypes.length; i<=ncols; i++){this.columnTypes += 't';}
3 this.sort = function (cell) {
4 var column = cell.cellIndex;
5 var sortFn;
6 switch( cell.sortType ){
7 case "n": sortFn = this.sortNumeric; break;
8 case "N": sortFn = this.sortReverseNumeric; break;
9 : sortFn = this.sortReverseText; break;
10 case "k": sortFn = this.sortKey; break;
11 case "K": sortFn = this.sortReverseKey; break;
12 default: return;
13 }
14 this.sortIndex = column;
15 var newRows = new Array();
16 for (j = 0; j < this.tbody[0].rows.length; j++) {
17 newRows[j] = this.tbody[0].rows[j];
18 }
19 if( this.sortIndex==Math.abs(this.prevColumn)-1 ){
20 newRows.reverse();
21 this.prevColumn = -this.prevColumn;
22 }else{
23 newRows.sort(sortFn);
24 this.prevColumn = this.sortIndex+1;
25 }
26 for (i=0;i<newRows.length;i++) {
27 this.tbody[0].appendChild(newRows[i]);
28 }
29 this.setHdrIcons();
30 }
31 this.setHdrIcons = function() {
32 for (var i=0; i<this.hdrRow.cells.length; i++) {
33 if( this.columnTypes[i]=='x' ) continue;
34 var sortType;
35 if( this.prevColumn==i+1 ){
36 sortType = 'asc';
37 }else if( this.prevColumn==(-1-i) ){
38 sortType = 'desc'
39 }else{
40 sortType = 'none';
41 }
42 var hdrCell = this.hdrRow.cells[i];
43 var clsName = hdrCell.className.replace(/\s*\bsort\s*\w+/, '');
44 clsName += ' sort ' + sortType;
45 hdrCell.className = clsName;
46 }
47 }
48 this.sortject.sor9710b1ab5d4 */
49 if
+24 -20
--- src/statrep.c
+++ src/statrep.c
@@ -202,12 +202,18 @@
202202
@ by year%s(includeMonth ? "/month" : "")
203203
if( zUserName ){
204204
@ for user %h(zUserName)
205205
}
206206
@ </h1>
207
- @ <table class='statistics-report-table-events' border='0' cellpadding='2'
208
- @ cellspacing='0' id='statsTable'>
207
+ @ <table border='0' cellpadding='2' cellspacing='0' \
208
+ if( !includeMonth ){
209
+ @ class='statistics-report-table-events sortable' \
210
+ @ data-column-types='tnx' data-init-sort='0'>
211
+ style_table_sorter();
212
+ }else{
213
+ @ class='statistics-report-table-events'>
214
+ }
209215
@ <thead>
210216
@ <th>%s(zTimeLabel)</th>
211217
@ <th>Events</th>
212218
@ <th width='90%%'><!-- relative commits graph --></th>
213219
@ </thead><tbody>
@@ -315,13 +321,10 @@
315321
int nAvg = iterations ? (nEventTotal/iterations) : 0;
316322
@ <br /><div>Total events: %d(nEventTotal)
317323
@ <br />Average per active %s(zAvgLabel): %d(nAvg)
318324
@ </div>
319325
}
320
- if( !includeMonth ){
321
- output_table_sorting_javascript("statsTable","tnx",-1);
322
- }
323326
}
324327
325328
/*
326329
** Implements the "byuser" view for /reports.
327330
*/
@@ -344,12 +347,13 @@
344347
if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){
345348
@ <center><svg width=700 height=400>
346349
piechart_render(700, 400, PIE_OTHER|PIE_PERCENT);
347350
@ </svg></centre><hr />
348351
}
349
- @ <table class='statistics-report-table-events' border='0'
350
- @ cellpadding='2' cellspacing='0' id='statsTable'>
352
+ style_table_sorter();
353
+ @ <table class='statistics-report-table-events sortable' border='0' \
354
+ @ cellpadding='2' cellspacing='0' data-column-types='tkx' data-init-sort='2'>
351355
@ <thead><tr>
352356
@ <th>User</th>
353357
@ <th>Events</th>
354358
@ <th width='90%%'><!-- relative commits graph --></th>
355359
@ </tr></thead><tbody>
@@ -390,11 +394,10 @@
390394
use percent-based graph bars.
391395
*/
392396
}
393397
@ </tbody></table>
394398
db_finalize(&query);
395
- output_table_sorting_javascript("statsTable","tkx",2);
396399
}
397400
398401
/*
399402
** Implements the "byfile" view for /reports. If zUserName is not NULL then the
400403
** report is restricted to events created by the named user account.
@@ -421,12 +424,13 @@
421424
@ <h1>Check-ins Per File
422425
if( zUserName ){
423426
@ for user %h(zUserName)
424427
}
425428
@ </h1>
426
- @ <table class='statistics-report-table-events' border='0'
427
- @ cellpadding='2' cellspacing='0' id='statsTable'>
429
+ style_table_sorter();
430
+ @ <table class='statistics-report-table-events sortable' border='0' \
431
+ @ cellpadding='2' cellspacing='0' data-column-types='tNx' data-init-sort='2'>
428432
@ <thead><tr>
429433
@ <th>File</th>
430434
@ <th>Check-ins</th>
431435
@ <th width='90%%'><!-- relative commits graph --></th>
432436
@ </tr></thead><tbody>
@@ -446,11 +450,11 @@
446450
@ </td>
447451
@</tr>
448452
}
449453
@ </tbody></table>
450454
db_finalize(&query);
451
- output_table_sorting_javascript("statsTable","tNx",2);
455
+
452456
}
453457
454458
/*
455459
** Implements the "byweekday" view for /reports. If zUserName is not NULL then
456460
** the report is restricted to events created by the named user account.
@@ -505,12 +509,13 @@
505509
if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){
506510
@ <center><svg width=700 height=400>
507511
piechart_render(700, 400, PIE_OTHER|PIE_PERCENT);
508512
@ </svg></centre><hr />
509513
}
510
- @ <table class='statistics-report-table-events' border='0'
511
- @ cellpadding='2' cellspacing='0' id='statsTable'>
514
+ style_table_sorter();
515
+ @ <table class='statistics-report-table-events sortable' border='0' \
516
+ @ cellpadding='2' cellspacing='0' data-column-types='ntnx' data-init-sort='1'>
512517
@ <thead><tr>
513518
@ <th>DoW</th>
514519
@ <th>Day</th>
515520
@ <th>Events</th>
516521
@ <th width='90%%'><!-- relative commits graph --></th>
@@ -542,11 +547,10 @@
542547
@ </td>
543548
@</tr>
544549
}
545550
@ </tbody></table>
546551
db_finalize(&query);
547
- output_table_sorting_javascript("statsTable","ntnx",1);
548552
}
549553
550554
551555
/*
552556
** Helper for stats_report_by_month_year(), which generates a list of
@@ -586,13 +590,14 @@
586590
@ for the calendar weeks of %h(zYear)
587591
if( zUserName ){
588592
@ for user %h(zUserName)
589593
}
590594
@ </h1>
591
- cgi_printf("<table class='statistics-report-table-events' "
595
+ style_table_sorter();
596
+ cgi_printf("<table class='statistics-report-table-events sortable' "
592597
"border='0' cellpadding='2' width='100%%' "
593
- "cellspacing='0' id='statsTable'>");
598
+ "cellspacing='0' data-column-types='tnx' data-init-sort='0'>");
594599
cgi_printf("<thead><tr>"
595600
"<th>Week</th>"
596601
"<th>Events</th>"
597602
"<th width='90%%'><!-- relative commits graph --></th>"
598603
"</tr></thead>"
@@ -637,11 +642,10 @@
637642
int nAvg = iterations ? (total/iterations) : 0;
638643
cgi_printf("<br /><div>Total events: %d<br />"
639644
"Average per active week: %d</div>",
640645
total, nAvg);
641646
}
642
- output_table_sorting_javascript("statsTable","tnx",-1);
643647
}
644648
645649
646650
/*
647651
** Generate a report that shows the most recent change for each user.
@@ -650,14 +654,15 @@
650654
Stmt s;
651655
double rNow;
652656
char *zBaseUrl;
653657
654658
stats_report_init_view();
659
+ style_table_sorter();
655660
@ <h1>Event Summary
656661
@ (%s(stats_report_label_for_type())) by User</h1>
657
- @ <table border=1 class='statistics-report-table-events'
658
- @ cellpadding=2 cellspacing=0 id='lastchng'>
662
+ @ <table border=1 class='statistics-report-table-events sortable' \
663
+ @ cellpadding=2 cellspacing=0 data-column-types='tNK' data-init-sort='3'>
659664
@ <thead><tr>
660665
@ <th>User<th>Total Changes<th>Last Change</tr></thead>
661666
@ <tbody>
662667
zBaseUrl = mprintf("%R/timeline?y=%t&u=", PD("type","ci"));
663668
db_prepare(&s,
@@ -681,11 +686,10 @@
681686
@ </tr>
682687
fossil_free(zAge);
683688
}
684689
@ </tbody></table>
685690
db_finalize(&s);
686
- output_table_sorting_javascript("lastchng","tNK",3);
687691
}
688692
689693
690694
/* Report types
691695
*/
692696
--- src/statrep.c
+++ src/statrep.c
@@ -202,12 +202,18 @@
202 @ by year%s(includeMonth ? "/month" : "")
203 if( zUserName ){
204 @ for user %h(zUserName)
205 }
206 @ </h1>
207 @ <table class='statistics-report-table-events' border='0' cellpadding='2'
208 @ cellspacing='0' id='statsTable'>
 
 
 
 
 
 
209 @ <thead>
210 @ <th>%s(zTimeLabel)</th>
211 @ <th>Events</th>
212 @ <th width='90%%'><!-- relative commits graph --></th>
213 @ </thead><tbody>
@@ -315,13 +321,10 @@
315 int nAvg = iterations ? (nEventTotal/iterations) : 0;
316 @ <br /><div>Total events: %d(nEventTotal)
317 @ <br />Average per active %s(zAvgLabel): %d(nAvg)
318 @ </div>
319 }
320 if( !includeMonth ){
321 output_table_sorting_javascript("statsTable","tnx",-1);
322 }
323 }
324
325 /*
326 ** Implements the "byuser" view for /reports.
327 */
@@ -344,12 +347,13 @@
344 if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){
345 @ <center><svg width=700 height=400>
346 piechart_render(700, 400, PIE_OTHER|PIE_PERCENT);
347 @ </svg></centre><hr />
348 }
349 @ <table class='statistics-report-table-events' border='0'
350 @ cellpadding='2' cellspacing='0' id='statsTable'>
 
351 @ <thead><tr>
352 @ <th>User</th>
353 @ <th>Events</th>
354 @ <th width='90%%'><!-- relative commits graph --></th>
355 @ </tr></thead><tbody>
@@ -390,11 +394,10 @@
390 use percent-based graph bars.
391 */
392 }
393 @ </tbody></table>
394 db_finalize(&query);
395 output_table_sorting_javascript("statsTable","tkx",2);
396 }
397
398 /*
399 ** Implements the "byfile" view for /reports. If zUserName is not NULL then the
400 ** report is restricted to events created by the named user account.
@@ -421,12 +424,13 @@
421 @ <h1>Check-ins Per File
422 if( zUserName ){
423 @ for user %h(zUserName)
424 }
425 @ </h1>
426 @ <table class='statistics-report-table-events' border='0'
427 @ cellpadding='2' cellspacing='0' id='statsTable'>
 
428 @ <thead><tr>
429 @ <th>File</th>
430 @ <th>Check-ins</th>
431 @ <th width='90%%'><!-- relative commits graph --></th>
432 @ </tr></thead><tbody>
@@ -446,11 +450,11 @@
446 @ </td>
447 @</tr>
448 }
449 @ </tbody></table>
450 db_finalize(&query);
451 output_table_sorting_javascript("statsTable","tNx",2);
452 }
453
454 /*
455 ** Implements the "byweekday" view for /reports. If zUserName is not NULL then
456 ** the report is restricted to events created by the named user account.
@@ -505,12 +509,13 @@
505 if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){
506 @ <center><svg width=700 height=400>
507 piechart_render(700, 400, PIE_OTHER|PIE_PERCENT);
508 @ </svg></centre><hr />
509 }
510 @ <table class='statistics-report-table-events' border='0'
511 @ cellpadding='2' cellspacing='0' id='statsTable'>
 
512 @ <thead><tr>
513 @ <th>DoW</th>
514 @ <th>Day</th>
515 @ <th>Events</th>
516 @ <th width='90%%'><!-- relative commits graph --></th>
@@ -542,11 +547,10 @@
542 @ </td>
543 @</tr>
544 }
545 @ </tbody></table>
546 db_finalize(&query);
547 output_table_sorting_javascript("statsTable","ntnx",1);
548 }
549
550
551 /*
552 ** Helper for stats_report_by_month_year(), which generates a list of
@@ -586,13 +590,14 @@
586 @ for the calendar weeks of %h(zYear)
587 if( zUserName ){
588 @ for user %h(zUserName)
589 }
590 @ </h1>
591 cgi_printf("<table class='statistics-report-table-events' "
 
592 "border='0' cellpadding='2' width='100%%' "
593 "cellspacing='0' id='statsTable'>");
594 cgi_printf("<thead><tr>"
595 "<th>Week</th>"
596 "<th>Events</th>"
597 "<th width='90%%'><!-- relative commits graph --></th>"
598 "</tr></thead>"
@@ -637,11 +642,10 @@
637 int nAvg = iterations ? (total/iterations) : 0;
638 cgi_printf("<br /><div>Total events: %d<br />"
639 "Average per active week: %d</div>",
640 total, nAvg);
641 }
642 output_table_sorting_javascript("statsTable","tnx",-1);
643 }
644
645
646 /*
647 ** Generate a report that shows the most recent change for each user.
@@ -650,14 +654,15 @@
650 Stmt s;
651 double rNow;
652 char *zBaseUrl;
653
654 stats_report_init_view();
 
655 @ <h1>Event Summary
656 @ (%s(stats_report_label_for_type())) by User</h1>
657 @ <table border=1 class='statistics-report-table-events'
658 @ cellpadding=2 cellspacing=0 id='lastchng'>
659 @ <thead><tr>
660 @ <th>User<th>Total Changes<th>Last Change</tr></thead>
661 @ <tbody>
662 zBaseUrl = mprintf("%R/timeline?y=%t&u=", PD("type","ci"));
663 db_prepare(&s,
@@ -681,11 +686,10 @@
681 @ </tr>
682 fossil_free(zAge);
683 }
684 @ </tbody></table>
685 db_finalize(&s);
686 output_table_sorting_javascript("lastchng","tNK",3);
687 }
688
689
690 /* Report types
691 */
692
--- src/statrep.c
+++ src/statrep.c
@@ -202,12 +202,18 @@
202 @ by year%s(includeMonth ? "/month" : "")
203 if( zUserName ){
204 @ for user %h(zUserName)
205 }
206 @ </h1>
207 @ <table border='0' cellpadding='2' cellspacing='0' \
208 if( !includeMonth ){
209 @ class='statistics-report-table-events sortable' \
210 @ data-column-types='tnx' data-init-sort='0'>
211 style_table_sorter();
212 }else{
213 @ class='statistics-report-table-events'>
214 }
215 @ <thead>
216 @ <th>%s(zTimeLabel)</th>
217 @ <th>Events</th>
218 @ <th width='90%%'><!-- relative commits graph --></th>
219 @ </thead><tbody>
@@ -315,13 +321,10 @@
321 int nAvg = iterations ? (nEventTotal/iterations) : 0;
322 @ <br /><div>Total events: %d(nEventTotal)
323 @ <br />Average per active %s(zAvgLabel): %d(nAvg)
324 @ </div>
325 }
 
 
 
326 }
327
328 /*
329 ** Implements the "byuser" view for /reports.
330 */
@@ -344,12 +347,13 @@
347 if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){
348 @ <center><svg width=700 height=400>
349 piechart_render(700, 400, PIE_OTHER|PIE_PERCENT);
350 @ </svg></centre><hr />
351 }
352 style_table_sorter();
353 @ <table class='statistics-report-table-events sortable' border='0' \
354 @ cellpadding='2' cellspacing='0' data-column-types='tkx' data-init-sort='2'>
355 @ <thead><tr>
356 @ <th>User</th>
357 @ <th>Events</th>
358 @ <th width='90%%'><!-- relative commits graph --></th>
359 @ </tr></thead><tbody>
@@ -390,11 +394,10 @@
394 use percent-based graph bars.
395 */
396 }
397 @ </tbody></table>
398 db_finalize(&query);
 
399 }
400
401 /*
402 ** Implements the "byfile" view for /reports. If zUserName is not NULL then the
403 ** report is restricted to events created by the named user account.
@@ -421,12 +424,13 @@
424 @ <h1>Check-ins Per File
425 if( zUserName ){
426 @ for user %h(zUserName)
427 }
428 @ </h1>
429 style_table_sorter();
430 @ <table class='statistics-report-table-events sortable' border='0' \
431 @ cellpadding='2' cellspacing='0' data-column-types='tNx' data-init-sort='2'>
432 @ <thead><tr>
433 @ <th>File</th>
434 @ <th>Check-ins</th>
435 @ <th width='90%%'><!-- relative commits graph --></th>
436 @ </tr></thead><tbody>
@@ -446,11 +450,11 @@
450 @ </td>
451 @</tr>
452 }
453 @ </tbody></table>
454 db_finalize(&query);
455
456 }
457
458 /*
459 ** Implements the "byweekday" view for /reports. If zUserName is not NULL then
460 ** the report is restricted to events created by the named user account.
@@ -505,12 +509,13 @@
509 if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){
510 @ <center><svg width=700 height=400>
511 piechart_render(700, 400, PIE_OTHER|PIE_PERCENT);
512 @ </svg></centre><hr />
513 }
514 style_table_sorter();
515 @ <table class='statistics-report-table-events sortable' border='0' \
516 @ cellpadding='2' cellspacing='0' data-column-types='ntnx' data-init-sort='1'>
517 @ <thead><tr>
518 @ <th>DoW</th>
519 @ <th>Day</th>
520 @ <th>Events</th>
521 @ <th width='90%%'><!-- relative commits graph --></th>
@@ -542,11 +547,10 @@
547 @ </td>
548 @</tr>
549 }
550 @ </tbody></table>
551 db_finalize(&query);
 
552 }
553
554
555 /*
556 ** Helper for stats_report_by_month_year(), which generates a list of
@@ -586,13 +590,14 @@
590 @ for the calendar weeks of %h(zYear)
591 if( zUserName ){
592 @ for user %h(zUserName)
593 }
594 @ </h1>
595 style_table_sorter();
596 cgi_printf("<table class='statistics-report-table-events sortable' "
597 "border='0' cellpadding='2' width='100%%' "
598 "cellspacing='0' data-column-types='tnx' data-init-sort='0'>");
599 cgi_printf("<thead><tr>"
600 "<th>Week</th>"
601 "<th>Events</th>"
602 "<th width='90%%'><!-- relative commits graph --></th>"
603 "</tr></thead>"
@@ -637,11 +642,10 @@
642 int nAvg = iterations ? (total/iterations) : 0;
643 cgi_printf("<br /><div>Total events: %d<br />"
644 "Average per active week: %d</div>",
645 total, nAvg);
646 }
 
647 }
648
649
650 /*
651 ** Generate a report that shows the most recent change for each user.
@@ -650,14 +654,15 @@
654 Stmt s;
655 double rNow;
656 char *zBaseUrl;
657
658 stats_report_init_view();
659 style_table_sorter();
660 @ <h1>Event Summary
661 @ (%s(stats_report_label_for_type())) by User</h1>
662 @ <table border=1 class='statistics-report-table-events sortable' \
663 @ cellpadding=2 cellspacing=0 data-column-types='tNK' data-init-sort='3'>
664 @ <thead><tr>
665 @ <th>User<th>Total Changes<th>Last Change</tr></thead>
666 @ <tbody>
667 zBaseUrl = mprintf("%R/timeline?y=%t&u=", PD("type","ci"));
668 db_prepare(&s,
@@ -681,11 +686,10 @@
686 @ </tr>
687 fossil_free(zAge);
688 }
689 @ </tbody></table>
690 db_finalize(&s);
 
691 }
692
693
694 /* Report types
695 */
696
+13 -3
--- src/style.c
+++ src/style.c
@@ -81,14 +81,14 @@
8181
** Ad-unit styles.
8282
*/
8383
static unsigned adUnitFlags = 0;
8484
8585
/*
86
-** True if the "href.js" javascript file is required.
86
+** Flags for various javascript files needed prior to </body>
8787
*/
88
-static int needHrefJs = 0;
89
-
88
+static int needHrefJs = 0; /* href.js */
89
+static int needSortJs = 0; /* sorttable.js */
9090
9191
/*
9292
** Generate and return a anchor tag like this:
9393
**
9494
** <a href="URL">
@@ -497,10 +497,17 @@
497497
}else if( !fossil_all_whitespace(zAd = db_get("adunit",0)) ){
498498
return zAd;
499499
}
500500
return 0;
501501
}
502
+
503
+/*
504
+** Indicate that the table-sorting javascript is needed.
505
+*/
506
+void style_table_sorter(void){
507
+ needSortJs = 1;
508
+}
502509
503510
/*
504511
** Generate code to load a single javascript file
505512
*/
506513
void style_load_one_js_file(const char *zFile){
@@ -519,10 +526,13 @@
519526
&& db_get_boolean("auto-hyperlink-mouseover",0);
520527
@ <script id='href-data' type='application/json'>\
521528
@ {"delay":%d(nDelay),"mouseover":%d(bMouseover)}</script>
522529
style_load_one_js_file("href.js");
523530
}
531
+ if( needSortJs ){
532
+ style_load_one_js_file("sorttable.js");
533
+ }
524534
}
525535
526536
/*
527537
** Draw the footer at the bottom of the page.
528538
*/
529539
--- src/style.c
+++ src/style.c
@@ -81,14 +81,14 @@
81 ** Ad-unit styles.
82 */
83 static unsigned adUnitFlags = 0;
84
85 /*
86 ** True if the "href.js" javascript file is required.
87 */
88 static int needHrefJs = 0;
89
90
91 /*
92 ** Generate and return a anchor tag like this:
93 **
94 ** <a href="URL">
@@ -497,10 +497,17 @@
497 }else if( !fossil_all_whitespace(zAd = db_get("adunit",0)) ){
498 return zAd;
499 }
500 return 0;
501 }
 
 
 
 
 
 
 
502
503 /*
504 ** Generate code to load a single javascript file
505 */
506 void style_load_one_js_file(const char *zFile){
@@ -519,10 +526,13 @@
519 && db_get_boolean("auto-hyperlink-mouseover",0);
520 @ <script id='href-data' type='application/json'>\
521 @ {"delay":%d(nDelay),"mouseover":%d(bMouseover)}</script>
522 style_load_one_js_file("href.js");
523 }
 
 
 
524 }
525
526 /*
527 ** Draw the footer at the bottom of the page.
528 */
529
--- src/style.c
+++ src/style.c
@@ -81,14 +81,14 @@
81 ** Ad-unit styles.
82 */
83 static unsigned adUnitFlags = 0;
84
85 /*
86 ** Flags for various javascript files needed prior to </body>
87 */
88 static int needHrefJs = 0; /* href.js */
89 static int needSortJs = 0; /* sorttable.js */
90
91 /*
92 ** Generate and return a anchor tag like this:
93 **
94 ** <a href="URL">
@@ -497,10 +497,17 @@
497 }else if( !fossil_all_whitespace(zAd = db_get("adunit",0)) ){
498 return zAd;
499 }
500 return 0;
501 }
502
503 /*
504 ** Indicate that the table-sorting javascript is needed.
505 */
506 void style_table_sorter(void){
507 needSortJs = 1;
508 }
509
510 /*
511 ** Generate code to load a single javascript file
512 */
513 void style_load_one_js_file(const char *zFile){
@@ -519,10 +526,13 @@
526 && db_get_boolean("auto-hyperlink-mouseover",0);
527 @ <script id='href-data' type='application/json'>\
528 @ {"delay":%d(nDelay),"mouseover":%d(bMouseover)}</script>
529 style_load_one_js_file("href.js");
530 }
531 if( needSortJs ){
532 style_load_one_js_file("sorttable.js");
533 }
534 }
535
536 /*
537 ** Draw the footer at the bottom of the page.
538 */
539
+3 -2
--- src/timeline.c
+++ src/timeline.c
@@ -2515,11 +2515,13 @@
25152515
const char *zStatus = db_column_int(&q,2) ? "Open"
25162516
: "Resolved by editing date";
25172517
const char *zUser = db_column_text(&q, 3);
25182518
char *zHref = href("%R/timeline?c=%S", zCkin);
25192519
if( cnt==0 ){
2520
- @ <div class="brlist"><table id="timewarptable">
2520
+ style_table_sorter();
2521
+ @ <div class="brlist">
2522
+ @ <table class='sortable' data-column-types='tttt' data-init-sort='2'>
25212523
@ <thead><tr>
25222524
@ <th>Check-in</th>
25232525
@ <th>Date</th>
25242526
@ <th>User</th>
25252527
@ <th>Status</th>
@@ -2537,9 +2539,8 @@
25372539
db_finalize(&q);
25382540
if( cnt==0 ){
25392541
@ <p>No timewarps in this repository</p>
25402542
}else{
25412543
@ </tbody></table></div>
2542
- output_table_sorting_javascript("timewarptable","tttt",2);
25432544
}
25442545
style_footer();
25452546
}
25462547
--- src/timeline.c
+++ src/timeline.c
@@ -2515,11 +2515,13 @@
2515 const char *zStatus = db_column_int(&q,2) ? "Open"
2516 : "Resolved by editing date";
2517 const char *zUser = db_column_text(&q, 3);
2518 char *zHref = href("%R/timeline?c=%S", zCkin);
2519 if( cnt==0 ){
2520 @ <div class="brlist"><table id="timewarptable">
 
 
2521 @ <thead><tr>
2522 @ <th>Check-in</th>
2523 @ <th>Date</th>
2524 @ <th>User</th>
2525 @ <th>Status</th>
@@ -2537,9 +2539,8 @@
2537 db_finalize(&q);
2538 if( cnt==0 ){
2539 @ <p>No timewarps in this repository</p>
2540 }else{
2541 @ </tbody></table></div>
2542 output_table_sorting_javascript("timewarptable","tttt",2);
2543 }
2544 style_footer();
2545 }
2546
--- src/timeline.c
+++ src/timeline.c
@@ -2515,11 +2515,13 @@
2515 const char *zStatus = db_column_int(&q,2) ? "Open"
2516 : "Resolved by editing date";
2517 const char *zUser = db_column_text(&q, 3);
2518 char *zHref = href("%R/timeline?c=%S", zCkin);
2519 if( cnt==0 ){
2520 style_table_sorter();
2521 @ <div class="brlist">
2522 @ <table class='sortable' data-column-types='tttt' data-init-sort='2'>
2523 @ <thead><tr>
2524 @ <th>Check-in</th>
2525 @ <th>Date</th>
2526 @ <th>User</th>
2527 @ <th>Status</th>
@@ -2537,9 +2539,8 @@
2539 db_finalize(&q);
2540 if( cnt==0 ){
2541 @ <p>No timewarps in this repository</p>
2542 }else{
2543 @ </tbody></table></div>
 
2544 }
2545 style_footer();
2546 }
2547
--- src/unversioned.c
+++ src/unversioned.c
@@ -508,12 +508,14 @@
508508
char *zAge = human_readable_age((iNow - mtime)/86400.0);
509509
const char *zLogin = db_column_text(&q, 4);
510510
int rcvid = db_column_int(&q,5);
511511
if( zLogin==0 ) zLogin = "";
512512
if( (n++)==0 ){
513
+ style_table_sorter();
513514
@ <div class="uvlist">
514
- @ <table cellpadding="2" cellspacing="0" border="1" id="uvtab">
515
+ @ <table cellpadding="2" cellspacing="0" border="1" class='sortable' \
516
+ @ data-column-types='tkKttn' data-init-sort='1'>
515517
@ <thead><tr>
516518
@ <th> Name
517519
@ <th> Age
518520
@ <th> Size
519521
@ <th> User
@@ -559,11 +561,10 @@
559561
if( g.perm.Admin ){
560562
@ <td>
561563
}
562564
@ </tfoot>
563565
@ </table></div>
564
- output_table_sorting_javascript("uvtab","tkKttN",1);
565566
}else{
566567
@ No unversioned files on this server.
567568
}
568569
style_footer();
569570
}
570571
--- src/unversioned.c
+++ src/unversioned.c
@@ -508,12 +508,14 @@
508 char *zAge = human_readable_age((iNow - mtime)/86400.0);
509 const char *zLogin = db_column_text(&q, 4);
510 int rcvid = db_column_int(&q,5);
511 if( zLogin==0 ) zLogin = "";
512 if( (n++)==0 ){
 
513 @ <div class="uvlist">
514 @ <table cellpadding="2" cellspacing="0" border="1" id="uvtab">
 
515 @ <thead><tr>
516 @ <th> Name
517 @ <th> Age
518 @ <th> Size
519 @ <th> User
@@ -559,11 +561,10 @@
559 if( g.perm.Admin ){
560 @ <td>
561 }
562 @ </tfoot>
563 @ </table></div>
564 output_table_sorting_javascript("uvtab","tkKttN",1);
565 }else{
566 @ No unversioned files on this server.
567 }
568 style_footer();
569 }
570
--- src/unversioned.c
+++ src/unversioned.c
@@ -508,12 +508,14 @@
508 char *zAge = human_readable_age((iNow - mtime)/86400.0);
509 const char *zLogin = db_column_text(&q, 4);
510 int rcvid = db_column_int(&q,5);
511 if( zLogin==0 ) zLogin = "";
512 if( (n++)==0 ){
513 style_table_sorter();
514 @ <div class="uvlist">
515 @ <table cellpadding="2" cellspacing="0" border="1" class='sortable' \
516 @ data-column-types='tkKttn' data-init-sort='1'>
517 @ <thead><tr>
518 @ <th> Name
519 @ <th> Age
520 @ <th> Size
521 @ <th> User
@@ -559,11 +561,10 @@
561 if( g.perm.Admin ){
562 @ <td>
563 }
564 @ </tfoot>
565 @ </table></div>
 
566 }else{
567 @ No unversioned files on this server.
568 }
569 style_footer();
570 }
571
+3 -2
--- src/user.c
+++ src/user.c
@@ -687,11 +687,12 @@
687687
}
688688
rc = db_prepare_ignore_error(&q, "%s", blob_sql_text(&sql));
689689
fLogEnabled = db_get_boolean("access-log", 0);
690690
@ <div align="center">Access logging is %s(fLogEnabled?"on":"off").
691691
@ (Change this on the <a href="setup_settings">settings</a> page.)</div>
692
- @ <table border="1" cellpadding="5" id="logtable" align="center">
692
+ @ <table border="1" cellpadding="5" class="sortable" align="center" \
693
+ @ data-column-types='Ttt' data-init-sort='1'>
693694
@ <thead><tr><th width="33%%">Date</th><th width="34%%">User</th>
694695
@ <th width="33%%">IP Address</th></tr></thead><tbody>
695696
while( rc==SQLITE_OK && db_step(&q)==SQLITE_ROW ){
696697
const char *zName = db_column_text(&q, 0);
697698
const char *zIP = db_column_text(&q, 1);
@@ -734,8 +735,8 @@
734735
@ <form method="post" action="%s(g.zTop)/access_log">
735736
@ <label><input type="checkbox" name="delall">
736737
@ Delete all entries</input></label>
737738
@ <input type="submit" name="delallbtn" value="Delete"></input>
738739
@ </form>
739
- output_table_sorting_javascript("logtable", "Ttt", 1);
740
+ style_table_sorter();
740741
style_footer();
741742
}
742743
--- src/user.c
+++ src/user.c
@@ -687,11 +687,12 @@
687 }
688 rc = db_prepare_ignore_error(&q, "%s", blob_sql_text(&sql));
689 fLogEnabled = db_get_boolean("access-log", 0);
690 @ <div align="center">Access logging is %s(fLogEnabled?"on":"off").
691 @ (Change this on the <a href="setup_settings">settings</a> page.)</div>
692 @ <table border="1" cellpadding="5" id="logtable" align="center">
 
693 @ <thead><tr><th width="33%%">Date</th><th width="34%%">User</th>
694 @ <th width="33%%">IP Address</th></tr></thead><tbody>
695 while( rc==SQLITE_OK && db_step(&q)==SQLITE_ROW ){
696 const char *zName = db_column_text(&q, 0);
697 const char *zIP = db_column_text(&q, 1);
@@ -734,8 +735,8 @@
734 @ <form method="post" action="%s(g.zTop)/access_log">
735 @ <label><input type="checkbox" name="delall">
736 @ Delete all entries</input></label>
737 @ <input type="submit" name="delallbtn" value="Delete"></input>
738 @ </form>
739 output_table_sorting_javascript("logtable", "Ttt", 1);
740 style_footer();
741 }
742
--- src/user.c
+++ src/user.c
@@ -687,11 +687,12 @@
687 }
688 rc = db_prepare_ignore_error(&q, "%s", blob_sql_text(&sql));
689 fLogEnabled = db_get_boolean("access-log", 0);
690 @ <div align="center">Access logging is %s(fLogEnabled?"on":"off").
691 @ (Change this on the <a href="setup_settings">settings</a> page.)</div>
692 @ <table border="1" cellpadding="5" class="sortable" align="center" \
693 @ data-column-types='Ttt' data-init-sort='1'>
694 @ <thead><tr><th width="33%%">Date</th><th width="34%%">User</th>
695 @ <th width="33%%">IP Address</th></tr></thead><tbody>
696 while( rc==SQLITE_OK && db_step(&q)==SQLITE_ROW ){
697 const char *zName = db_column_text(&q, 0);
698 const char *zIP = db_column_text(&q, 1);
@@ -734,8 +735,8 @@
735 @ <form method="post" action="%s(g.zTop)/access_log">
736 @ <label><input type="checkbox" name="delall">
737 @ Delete all entries</input></label>
738 @ <input type="submit" name="delallbtn" value="Delete"></input>
739 @ </form>
740 style_table_sorter();
741 style_footer();
742 }
743
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -608,10 +608,11 @@
608608
$(SRCDIR)/graph.js \
609609
$(SRCDIR)/href.js \
610610
$(SRCDIR)/markdown.md \
611611
$(SRCDIR)/menu.js \
612612
$(SRCDIR)/sbsdiff.js \
613
+ $(SRCDIR)/sorttable.js \
613614
$(SRCDIR)/tree.js \
614615
$(SRCDIR)/wiki.wiki
615616
616617
TRANS_SRC = \
617618
$(OBJDIR)/add_.c \
618619
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -608,10 +608,11 @@
608 $(SRCDIR)/graph.js \
609 $(SRCDIR)/href.js \
610 $(SRCDIR)/markdown.md \
611 $(SRCDIR)/menu.js \
612 $(SRCDIR)/sbsdiff.js \
 
613 $(SRCDIR)/tree.js \
614 $(SRCDIR)/wiki.wiki
615
616 TRANS_SRC = \
617 $(OBJDIR)/add_.c \
618
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -608,10 +608,11 @@
608 $(SRCDIR)/graph.js \
609 $(SRCDIR)/href.js \
610 $(SRCDIR)/markdown.md \
611 $(SRCDIR)/menu.js \
612 $(SRCDIR)/sbsdiff.js \
613 $(SRCDIR)/sorttable.js \
614 $(SRCDIR)/tree.js \
615 $(SRCDIR)/wiki.wiki
616
617 TRANS_SRC = \
618 $(OBJDIR)/add_.c \
619
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -534,10 +534,11 @@
534534
$(SRCDIR)\graph.js \
535535
$(SRCDIR)\href.js \
536536
$(SRCDIR)\markdown.md \
537537
$(SRCDIR)\menu.js \
538538
$(SRCDIR)\sbsdiff.js \
539
+ $(SRCDIR)\sorttable.js \
539540
$(SRCDIR)\tree.js \
540541
$(SRCDIR)\wiki.wiki
541542
542543
OBJ = $(OX)\add$O \
543544
$(OX)\allrepo$O \
544545
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -534,10 +534,11 @@
534 $(SRCDIR)\graph.js \
535 $(SRCDIR)\href.js \
536 $(SRCDIR)\markdown.md \
537 $(SRCDIR)\menu.js \
538 $(SRCDIR)\sbsdiff.js \
 
539 $(SRCDIR)\tree.js \
540 $(SRCDIR)\wiki.wiki
541
542 OBJ = $(OX)\add$O \
543 $(OX)\allrepo$O \
544
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -534,10 +534,11 @@
534 $(SRCDIR)\graph.js \
535 $(SRCDIR)\href.js \
536 $(SRCDIR)\markdown.md \
537 $(SRCDIR)\menu.js \
538 $(SRCDIR)\sbsdiff.js \
539 $(SRCDIR)\sorttable.js \
540 $(SRCDIR)\tree.js \
541 $(SRCDIR)\wiki.wiki
542
543 OBJ = $(OX)\add$O \
544 $(OX)\allrepo$O \
545

Keyboard Shortcuts

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