Fossil SCM

Attempt to make the stats_report?type=byuser tabls sortable by clicking on the column labels. Only works for the "User" column. Further debugging needed.

drh 2013-05-05 20:05 trunk
Commit d0ce29b031e148aa0724d89383eb6a2fd3ba078a
2 files changed +1 -1 +13 -7
+1 -1
--- src/report.c
+++ src/report.c
@@ -924,11 +924,11 @@
924924
** The javascript is derived from:
925925
**
926926
** http://www.webtoolkit.info/sortable-html-table.html
927927
**
928928
*/
929
-static void output_table_sorting_javascript(const char *zTableId){
929
+void output_table_sorting_javascript(const char *zTableId){
930930
@ <script>
931931
@ function SortableTable(tableEl){
932932
@ this.tbody = tableEl.getElementsByTagName('tbody');
933933
@ this.sort = function (cell) {
934934
@ var column = cell.cellIndex;
935935
--- src/report.c
+++ src/report.c
@@ -924,11 +924,11 @@
924 ** The javascript is derived from:
925 **
926 ** http://www.webtoolkit.info/sortable-html-table.html
927 **
928 */
929 static void output_table_sorting_javascript(const char *zTableId){
930 @ <script>
931 @ function SortableTable(tableEl){
932 @ this.tbody = tableEl.getElementsByTagName('tbody');
933 @ this.sort = function (cell) {
934 @ var column = cell.cellIndex;
935
--- src/report.c
+++ src/report.c
@@ -924,11 +924,11 @@
924 ** The javascript is derived from:
925 **
926 ** http://www.webtoolkit.info/sortable-html-table.html
927 **
928 */
929 void output_table_sorting_javascript(const char *zTableId){
930 @ <script>
931 @ function SortableTable(tableEl){
932 @ this.tbody = tableEl.getElementsByTagName('tbody');
933 @ this.sort = function (cell) {
934 @ var column = cell.cellIndex;
935
+13 -7
--- src/timeline.c
+++ src/timeline.c
@@ -1870,11 +1870,12 @@
18701870
" ORDER BY timeframe DESC",
18711871
-1);
18721872
db_prepare(&query, blob_str(&sql));
18731873
blob_reset(&sql);
18741874
@ <h1>%b(&header)</h1>
1875
- @ <table class='statistics-report-table-events' border='0' cellpadding='2' cellspacing='0'>
1875
+ @ <table class='statistics-report-table-events' border='0' cellpadding='2'
1876
+ @ cellspacing='0' id='statsTable'>
18761877
@ <thead>
18771878
@ <th>%s(zTimeLabel)</th>
18781879
@ <th>Events</th>
18791880
@ <th><!-- relative commits graph --></th>
18801881
@ </thead><tbody>
@@ -1909,17 +1910,19 @@
19091910
nEventTotal += nCount;
19101911
nEventsPerYear += nCount;
19111912
@<tr class='row%d(rowClass)'>
19121913
@ <td>
19131914
if(includeMonth){
1914
- @ <a href="%s(g.zTop)/timeline?ym=%s(zTimeframe)&n=%d(nCount)" target="_new">%s(zTimeframe)</a>
1915
+ @ <a href="%s(g.zTop)/timeline?ym=%s(zTimeframe)&n=%d(nCount)"
1916
+ @ target="_new">%s(zTimeframe)</a>
19151917
}else {
19161918
@ %s(zTimeframe)
19171919
}
19181920
@ </td><td>%d(nCount)</td>
19191921
@ <td>
1920
- @ <div class='statistics-report-graph-line' style='height:16px; width:%d(nSize)px;'>
1922
+ @ <div class='statistics-report-graph-line'
1923
+ @ style='height:16px;width:%d(nSize)px;'>
19211924
@ </div></td>
19221925
@</tr>
19231926
19241927
/*
19251928
Potential improvement: calculate the min/max event counts and
@@ -1959,16 +1962,17 @@
19591962
"GROUP BY user ORDER BY user",
19601963
-1);
19611964
db_prepare(&query, blob_str(&sql));
19621965
blob_reset(&sql);
19631966
@ <h1>Timeline Events by User</h1>
1964
- @ <table class='statistics-report-table-events' border='0' cellpadding='2' cellspacing='0'>
1965
- @ <thead>
1967
+ @ <table class='statistics-report-table-events' border='0'
1968
+ @ cellpadding='2' cellspacing='0' id='statsTable'>
1969
+ @ <thead><tr>
19661970
@ <th>User</th>
19671971
@ <th>Events</th>
19681972
@ <th><!-- relative commits graph --></th>
1969
- @ </thead><tbody>
1973
+ @ </tr></thead><tbody>
19701974
while( SQLITE_ROW == db_step(&query) ){
19711975
char const * zUser = db_column_text(&query, 0);
19721976
int const nCount = db_column_int(&query, 1);
19731977
int const nSize = 1+((nPixelsPerEvent * nCount) / 10);
19741978
if(!nCount) continue;
@@ -1977,11 +1981,12 @@
19771981
@<tr class='row%d(rowClass)'>
19781982
@ <td>
19791983
@ <a href="?view=byyear&user=%h(zUser)" target="_new">%s(zUser)</a>
19801984
@ </td><td>%d(nCount)</td>
19811985
@ <td>
1982
- @ <div class='statistics-report-graph-line' style='height:16px; width:%d(nSize)px;'>
1986
+ @ <div class='statistics-report-graph-line'
1987
+ @ style='height:16px;width:%d(nSize)px;'>
19831988
@ </div></td>
19841989
@</tr>
19851990
/*
19861991
Potential improvement: calculate the min/max event counts and
19871992
use percent-based graph bars.
@@ -1992,10 +1997,11 @@
19921997
@ <tr class='row%d(rowClass)'>
19931998
@ <td colspan='3'>Total events: %d(nEventTotal)</td>
19941999
@ </tr>
19952000
@ </tbody></table>
19962001
db_finalize(&query);
2002
+ output_table_sorting_javascript("statsTable");
19972003
}
19982004
19992005
/*
20002006
** WEBPAGE: stats_report
20012007
**
20022008
--- src/timeline.c
+++ src/timeline.c
@@ -1870,11 +1870,12 @@
1870 " ORDER BY timeframe DESC",
1871 -1);
1872 db_prepare(&query, blob_str(&sql));
1873 blob_reset(&sql);
1874 @ <h1>%b(&header)</h1>
1875 @ <table class='statistics-report-table-events' border='0' cellpadding='2' cellspacing='0'>
 
1876 @ <thead>
1877 @ <th>%s(zTimeLabel)</th>
1878 @ <th>Events</th>
1879 @ <th><!-- relative commits graph --></th>
1880 @ </thead><tbody>
@@ -1909,17 +1910,19 @@
1909 nEventTotal += nCount;
1910 nEventsPerYear += nCount;
1911 @<tr class='row%d(rowClass)'>
1912 @ <td>
1913 if(includeMonth){
1914 @ <a href="%s(g.zTop)/timeline?ym=%s(zTimeframe)&n=%d(nCount)" target="_new">%s(zTimeframe)</a>
 
1915 }else {
1916 @ %s(zTimeframe)
1917 }
1918 @ </td><td>%d(nCount)</td>
1919 @ <td>
1920 @ <div class='statistics-report-graph-line' style='height:16px; width:%d(nSize)px;'>
 
1921 @ </div></td>
1922 @</tr>
1923
1924 /*
1925 Potential improvement: calculate the min/max event counts and
@@ -1959,16 +1962,17 @@
1959 "GROUP BY user ORDER BY user",
1960 -1);
1961 db_prepare(&query, blob_str(&sql));
1962 blob_reset(&sql);
1963 @ <h1>Timeline Events by User</h1>
1964 @ <table class='statistics-report-table-events' border='0' cellpadding='2' cellspacing='0'>
1965 @ <thead>
 
1966 @ <th>User</th>
1967 @ <th>Events</th>
1968 @ <th><!-- relative commits graph --></th>
1969 @ </thead><tbody>
1970 while( SQLITE_ROW == db_step(&query) ){
1971 char const * zUser = db_column_text(&query, 0);
1972 int const nCount = db_column_int(&query, 1);
1973 int const nSize = 1+((nPixelsPerEvent * nCount) / 10);
1974 if(!nCount) continue;
@@ -1977,11 +1981,12 @@
1977 @<tr class='row%d(rowClass)'>
1978 @ <td>
1979 @ <a href="?view=byyear&user=%h(zUser)" target="_new">%s(zUser)</a>
1980 @ </td><td>%d(nCount)</td>
1981 @ <td>
1982 @ <div class='statistics-report-graph-line' style='height:16px; width:%d(nSize)px;'>
 
1983 @ </div></td>
1984 @</tr>
1985 /*
1986 Potential improvement: calculate the min/max event counts and
1987 use percent-based graph bars.
@@ -1992,10 +1997,11 @@
1992 @ <tr class='row%d(rowClass)'>
1993 @ <td colspan='3'>Total events: %d(nEventTotal)</td>
1994 @ </tr>
1995 @ </tbody></table>
1996 db_finalize(&query);
 
1997 }
1998
1999 /*
2000 ** WEBPAGE: stats_report
2001 **
2002
--- src/timeline.c
+++ src/timeline.c
@@ -1870,11 +1870,12 @@
1870 " ORDER BY timeframe DESC",
1871 -1);
1872 db_prepare(&query, blob_str(&sql));
1873 blob_reset(&sql);
1874 @ <h1>%b(&header)</h1>
1875 @ <table class='statistics-report-table-events' border='0' cellpadding='2'
1876 @ cellspacing='0' id='statsTable'>
1877 @ <thead>
1878 @ <th>%s(zTimeLabel)</th>
1879 @ <th>Events</th>
1880 @ <th><!-- relative commits graph --></th>
1881 @ </thead><tbody>
@@ -1909,17 +1910,19 @@
1910 nEventTotal += nCount;
1911 nEventsPerYear += nCount;
1912 @<tr class='row%d(rowClass)'>
1913 @ <td>
1914 if(includeMonth){
1915 @ <a href="%s(g.zTop)/timeline?ym=%s(zTimeframe)&n=%d(nCount)"
1916 @ target="_new">%s(zTimeframe)</a>
1917 }else {
1918 @ %s(zTimeframe)
1919 }
1920 @ </td><td>%d(nCount)</td>
1921 @ <td>
1922 @ <div class='statistics-report-graph-line'
1923 @ style='height:16px;width:%d(nSize)px;'>
1924 @ </div></td>
1925 @</tr>
1926
1927 /*
1928 Potential improvement: calculate the min/max event counts and
@@ -1959,16 +1962,17 @@
1962 "GROUP BY user ORDER BY user",
1963 -1);
1964 db_prepare(&query, blob_str(&sql));
1965 blob_reset(&sql);
1966 @ <h1>Timeline Events by User</h1>
1967 @ <table class='statistics-report-table-events' border='0'
1968 @ cellpadding='2' cellspacing='0' id='statsTable'>
1969 @ <thead><tr>
1970 @ <th>User</th>
1971 @ <th>Events</th>
1972 @ <th><!-- relative commits graph --></th>
1973 @ </tr></thead><tbody>
1974 while( SQLITE_ROW == db_step(&query) ){
1975 char const * zUser = db_column_text(&query, 0);
1976 int const nCount = db_column_int(&query, 1);
1977 int const nSize = 1+((nPixelsPerEvent * nCount) / 10);
1978 if(!nCount) continue;
@@ -1977,11 +1981,12 @@
1981 @<tr class='row%d(rowClass)'>
1982 @ <td>
1983 @ <a href="?view=byyear&user=%h(zUser)" target="_new">%s(zUser)</a>
1984 @ </td><td>%d(nCount)</td>
1985 @ <td>
1986 @ <div class='statistics-report-graph-line'
1987 @ style='height:16px;width:%d(nSize)px;'>
1988 @ </div></td>
1989 @</tr>
1990 /*
1991 Potential improvement: calculate the min/max event counts and
1992 use percent-based graph bars.
@@ -1992,10 +1997,11 @@
1997 @ <tr class='row%d(rowClass)'>
1998 @ <td colspan='3'>Total events: %d(nEventTotal)</td>
1999 @ </tr>
2000 @ </tbody></table>
2001 db_finalize(&query);
2002 output_table_sorting_javascript("statsTable");
2003 }
2004
2005 /*
2006 ** WEBPAGE: stats_report
2007 **
2008

Keyboard Shortcuts

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