Fossil SCM

Enhance the table sorting javascript to support initial reverse-order sorting. Add table sorting to the user log.

drh 2015-01-22 23:45 trunk
Commit 0cdec7d290da52b472d3a4e0e4997203a4e7e673
3 files changed +2 -2 +8 -4 +5 -4
+2 -2
--- src/branch.c
+++ src/branch.c
@@ -367,11 +367,11 @@
367367
sqlite3_int64 iMtime = (sqlite3_int64)(rMtime*86400.0);
368368
if( zMergeTo && zMergeTo[0]==0 ) zMergeTo = 0;
369369
@ <tr>
370370
@ <td>%z(href("%R/timeline?n=100&r=%T",zBranch))%h(zBranch)</a></td>
371371
@ <td data-sortkey="%016llx(-iMtime)">%s(zAge)</td>
372
- @ <td data-sortkey="%08x(-nCkin)">%d(nCkin)</td>
372
+ @ <td>%d(nCkin)</td>
373373
fossil_free(zAge);
374374
@ <td>%s(isClosed?"closed":"")</td>
375375
if( zMergeTo ){
376376
@ <td>merged into
377377
@ %z(href("%R/timeline?f=%s",zLastCkin))%h(zMergeTo)</a></td>
@@ -380,11 +380,11 @@
380380
}
381381
@ </tr>
382382
}
383383
@ </tbody></table></div>
384384
db_finalize(&q);
385
- output_table_sorting_javascript("branchlisttable","tkktt",2);
385
+ output_table_sorting_javascript("branchlisttable","tkNtt",2);
386386
style_footer();
387387
}
388388
389389
/*
390390
** WEBPAGE: brlist
391391
--- src/branch.c
+++ src/branch.c
@@ -367,11 +367,11 @@
367 sqlite3_int64 iMtime = (sqlite3_int64)(rMtime*86400.0);
368 if( zMergeTo && zMergeTo[0]==0 ) zMergeTo = 0;
369 @ <tr>
370 @ <td>%z(href("%R/timeline?n=100&r=%T",zBranch))%h(zBranch)</a></td>
371 @ <td data-sortkey="%016llx(-iMtime)">%s(zAge)</td>
372 @ <td data-sortkey="%08x(-nCkin)">%d(nCkin)</td>
373 fossil_free(zAge);
374 @ <td>%s(isClosed?"closed":"")</td>
375 if( zMergeTo ){
376 @ <td>merged into
377 @ %z(href("%R/timeline?f=%s",zLastCkin))%h(zMergeTo)</a></td>
@@ -380,11 +380,11 @@
380 }
381 @ </tr>
382 }
383 @ </tbody></table></div>
384 db_finalize(&q);
385 output_table_sorting_javascript("branchlisttable","tkktt",2);
386 style_footer();
387 }
388
389 /*
390 ** WEBPAGE: brlist
391
--- src/branch.c
+++ src/branch.c
@@ -367,11 +367,11 @@
367 sqlite3_int64 iMtime = (sqlite3_int64)(rMtime*86400.0);
368 if( zMergeTo && zMergeTo[0]==0 ) zMergeTo = 0;
369 @ <tr>
370 @ <td>%z(href("%R/timeline?n=100&r=%T",zBranch))%h(zBranch)</a></td>
371 @ <td data-sortkey="%016llx(-iMtime)">%s(zAge)</td>
372 @ <td>%d(nCkin)</td>
373 fossil_free(zAge);
374 @ <td>%s(isClosed?"closed":"")</td>
375 if( zMergeTo ){
376 @ <td>merged into
377 @ %z(href("%R/timeline?f=%s",zLastCkin))%h(zMergeTo)</a></td>
@@ -380,11 +380,11 @@
380 }
381 @ </tr>
382 }
383 @ </tbody></table></div>
384 db_finalize(&q);
385 output_table_sorting_javascript("branchlisttable","tkNtt",2);
386 style_footer();
387 }
388
389 /*
390 ** WEBPAGE: brlist
391
+8 -4
--- src/report.c
+++ src/report.c
@@ -933,10 +933,11 @@
933933
** t Sort by text
934934
** n Sort numerically
935935
** k Sort by the data-sortkey property
936936
** x This column is not sortable
937937
**
938
+** Capital letters mean sort in reverse order.
938939
** If there are fewer characters in zColumnTypes[] than their are columns,
939940
** the all extra columns assume type "t" (text).
940941
**
941942
** The third parameter is the column that was initially sorted (using 1-based
942943
** column numbers, like SQL). Make this value 0 if none of the columns are
@@ -956,14 +957,14 @@
956957
@ this.columnTypes = columnTypes;
957958
@ this.sort = function (cell) {
958959
@ var column = cell.cellIndex;
959960
@ var sortFn;
960961
@ switch( cell.sortType ){
961
- @ case "n": sortFn = this.sortNumeric; break;
962
- @ case "t": sortFn = this.sortText; break;
963
- @ case "k": sortFn = this.sortKey; break;
964
- @ case "x": return;
962
+ @ case "N": case "n": sortFn = this.sortNumeric; break;
963
+ @ case "T": case "t": sortFn = this.sortText; break;
964
+ @ case "K": case "k": sortFn = this.sortKey; break;
965
+ @ default: return;
965966
@ }
966967
@ this.sortIndex = column;
967968
@ var newRows = new Array();
968969
@ for (j = 0; j < this.tbody[0].rows.length; j++) {
969970
@ newRows[j] = this.tbody[0].rows[j];
@@ -972,10 +973,13 @@
972973
@ newRows.reverse();
973974
@ this.prevColumn = -this.prevColumn;
974975
@ }else{
975976
@ newRows.sort(sortFn);
976977
@ this.prevColumn = this.sortIndex+1;
978
+ @ if( cell.sortType>="A" && cell.sortType<="Z" ){
979
+ @ newRows.reverse();
980
+ @ }
977981
@ }
978982
@ for (i=0;i<newRows.length;i++) {
979983
@ this.tbody[0].appendChild(newRows[i]);
980984
@ }
981985
@ this.setHdrIcons();
982986
--- src/report.c
+++ src/report.c
@@ -933,10 +933,11 @@
933 ** t Sort by text
934 ** n Sort numerically
935 ** k Sort by the data-sortkey property
936 ** x This column is not sortable
937 **
 
938 ** If there are fewer characters in zColumnTypes[] than their are columns,
939 ** the all extra columns assume type "t" (text).
940 **
941 ** The third parameter is the column that was initially sorted (using 1-based
942 ** column numbers, like SQL). Make this value 0 if none of the columns are
@@ -956,14 +957,14 @@
956 @ this.columnTypes = columnTypes;
957 @ this.sort = function (cell) {
958 @ var column = cell.cellIndex;
959 @ var sortFn;
960 @ switch( cell.sortType ){
961 @ case "n": sortFn = this.sortNumeric; break;
962 @ case "t": sortFn = this.sortText; break;
963 @ case "k": sortFn = this.sortKey; break;
964 @ case "x": return;
965 @ }
966 @ this.sortIndex = column;
967 @ var newRows = new Array();
968 @ for (j = 0; j < this.tbody[0].rows.length; j++) {
969 @ newRows[j] = this.tbody[0].rows[j];
@@ -972,10 +973,13 @@
972 @ newRows.reverse();
973 @ this.prevColumn = -this.prevColumn;
974 @ }else{
975 @ newRows.sort(sortFn);
976 @ this.prevColumn = this.sortIndex+1;
 
 
 
977 @ }
978 @ for (i=0;i<newRows.length;i++) {
979 @ this.tbody[0].appendChild(newRows[i]);
980 @ }
981 @ this.setHdrIcons();
982
--- src/report.c
+++ src/report.c
@@ -933,10 +933,11 @@
933 ** t Sort by text
934 ** n Sort numerically
935 ** k Sort by the data-sortkey property
936 ** x This column is not sortable
937 **
938 ** Capital letters mean sort in reverse order.
939 ** If there are fewer characters in zColumnTypes[] than their are columns,
940 ** the all extra columns assume type "t" (text).
941 **
942 ** The third parameter is the column that was initially sorted (using 1-based
943 ** column numbers, like SQL). Make this value 0 if none of the columns are
@@ -956,14 +957,14 @@
957 @ this.columnTypes = columnTypes;
958 @ this.sort = function (cell) {
959 @ var column = cell.cellIndex;
960 @ var sortFn;
961 @ switch( cell.sortType ){
962 @ case "N": case "n": sortFn = this.sortNumeric; break;
963 @ case "T": case "t": sortFn = this.sortText; break;
964 @ case "K": case "k": sortFn = this.sortKey; break;
965 @ default: return;
966 @ }
967 @ this.sortIndex = column;
968 @ var newRows = new Array();
969 @ for (j = 0; j < this.tbody[0].rows.length; j++) {
970 @ newRows[j] = this.tbody[0].rows[j];
@@ -972,10 +973,13 @@
973 @ newRows.reverse();
974 @ this.prevColumn = -this.prevColumn;
975 @ }else{
976 @ newRows.sort(sortFn);
977 @ this.prevColumn = this.sortIndex+1;
978 @ if( cell.sortType>="A" && cell.sortType<="Z" ){
979 @ newRows.reverse();
980 @ }
981 @ }
982 @ for (i=0;i<newRows.length;i++) {
983 @ this.tbody[0].appendChild(newRows[i]);
984 @ }
985 @ this.setHdrIcons();
986
+5 -4
--- src/user.c
+++ src/user.c
@@ -467,13 +467,13 @@
467467
style_submenu_element("Newer", "Newer entries",
468468
"%s/access_log?o=%d&n=%d&y=%d", g.zTop, skip>=n ? skip-n : 0,
469469
n, y);
470470
}
471471
rc = db_prepare_ignore_error(&q, "%s", blob_sql_text(&sql));
472
- @ <center><table border="1" cellpadding="5">
473
- @ <tr><th width="33%%">Date</th><th width="34%%">User</th>
474
- @ <th width="33%%">IP Address</th></tr>
472
+ @ <center><table border="1" cellpadding="5" id='logtable'>
473
+ @ <thead><tr><th width="33%%">Date</th><th width="34%%">User</th>
474
+ @ <th width="33%%">IP Address</th></tr></thead><tbody>
475475
while( rc==SQLITE_OK && db_step(&q)==SQLITE_ROW ){
476476
const char *zName = db_column_text(&q, 0);
477477
const char *zIP = db_column_text(&q, 1);
478478
const char *zDate = db_column_text(&q, 2);
479479
int bSuccess = db_column_int(&q, 3);
@@ -492,11 +492,11 @@
492492
}
493493
if( skip>0 || cnt>n ){
494494
style_submenu_element("All", "All entries",
495495
"%s/access_log?n=10000000", g.zTop);
496496
}
497
- @ </table></center>
497
+ @ </tbody></table></center>
498498
db_finalize(&q);
499499
@ <hr>
500500
@ <form method="post" action="%s(g.zTop)/access_log">
501501
@ <label><input type="checkbox" name="delold">
502502
@ Delete all but the most recent 200 entries</input></label>
@@ -515,7 +515,8 @@
515515
@ <form method="post" action="%s(g.zTop)/access_log">
516516
@ <label><input type="checkbox" name="delall">
517517
@ Delete all entries</input></label>
518518
@ <input type="submit" name="delallbtn" value="Delete"></input>
519519
@ </form>
520
+ output_table_sorting_javascript("logtable", "Ttt", 1);
520521
style_footer();
521522
}
522523
--- src/user.c
+++ src/user.c
@@ -467,13 +467,13 @@
467 style_submenu_element("Newer", "Newer entries",
468 "%s/access_log?o=%d&n=%d&y=%d", g.zTop, skip>=n ? skip-n : 0,
469 n, y);
470 }
471 rc = db_prepare_ignore_error(&q, "%s", blob_sql_text(&sql));
472 @ <center><table border="1" cellpadding="5">
473 @ <tr><th width="33%%">Date</th><th width="34%%">User</th>
474 @ <th width="33%%">IP Address</th></tr>
475 while( rc==SQLITE_OK && db_step(&q)==SQLITE_ROW ){
476 const char *zName = db_column_text(&q, 0);
477 const char *zIP = db_column_text(&q, 1);
478 const char *zDate = db_column_text(&q, 2);
479 int bSuccess = db_column_int(&q, 3);
@@ -492,11 +492,11 @@
492 }
493 if( skip>0 || cnt>n ){
494 style_submenu_element("All", "All entries",
495 "%s/access_log?n=10000000", g.zTop);
496 }
497 @ </table></center>
498 db_finalize(&q);
499 @ <hr>
500 @ <form method="post" action="%s(g.zTop)/access_log">
501 @ <label><input type="checkbox" name="delold">
502 @ Delete all but the most recent 200 entries</input></label>
@@ -515,7 +515,8 @@
515 @ <form method="post" action="%s(g.zTop)/access_log">
516 @ <label><input type="checkbox" name="delall">
517 @ Delete all entries</input></label>
518 @ <input type="submit" name="delallbtn" value="Delete"></input>
519 @ </form>
 
520 style_footer();
521 }
522
--- src/user.c
+++ src/user.c
@@ -467,13 +467,13 @@
467 style_submenu_element("Newer", "Newer entries",
468 "%s/access_log?o=%d&n=%d&y=%d", g.zTop, skip>=n ? skip-n : 0,
469 n, y);
470 }
471 rc = db_prepare_ignore_error(&q, "%s", blob_sql_text(&sql));
472 @ <center><table border="1" cellpadding="5" id='logtable'>
473 @ <thead><tr><th width="33%%">Date</th><th width="34%%">User</th>
474 @ <th width="33%%">IP Address</th></tr></thead><tbody>
475 while( rc==SQLITE_OK && db_step(&q)==SQLITE_ROW ){
476 const char *zName = db_column_text(&q, 0);
477 const char *zIP = db_column_text(&q, 1);
478 const char *zDate = db_column_text(&q, 2);
479 int bSuccess = db_column_int(&q, 3);
@@ -492,11 +492,11 @@
492 }
493 if( skip>0 || cnt>n ){
494 style_submenu_element("All", "All entries",
495 "%s/access_log?n=10000000", g.zTop);
496 }
497 @ </tbody></table></center>
498 db_finalize(&q);
499 @ <hr>
500 @ <form method="post" action="%s(g.zTop)/access_log">
501 @ <label><input type="checkbox" name="delold">
502 @ Delete all but the most recent 200 entries</input></label>
@@ -515,7 +515,8 @@
515 @ <form method="post" action="%s(g.zTop)/access_log">
516 @ <label><input type="checkbox" name="delall">
517 @ Delete all entries</input></label>
518 @ <input type="submit" name="delallbtn" value="Delete"></input>
519 @ </form>
520 output_table_sorting_javascript("logtable", "Ttt", 1);
521 style_footer();
522 }
523

Keyboard Shortcuts

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