926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
|
**
** The javascript is derived from:
**
** http://www.webtoolkit.info/sortable-html-table.html
**
** This variation allows column types to be expressed using the second
** argument. Each character of the second argument represent a column.
** "t" means sort as text. "n" means sort numerically. "x" means do not
** sort on this column. If there are fewer characters in zColumnTypes[] than
** their are columns, the all extra columns assume type "t" (text).
*/
void output_table_sorting_javascript(const char *zTableId, const char *zColumnTypes){
@ <script>
@ function SortableTable(tableEl,columnTypes){
@ this.tbody = tableEl.getElementsByTagName('tbody');
@ this.sort = function (cell) {
@ var column = cell.cellIndex;
@ var sortFn;
@ switch( cell.sortType ){
@ case "n": sortFn = this.sortNumeric; break;
@ case "t": sortFn = this.sortText; break;
@ case "k": sortFn = this.sortKey; break;
@ case "x": return;
@ }
@ this.sortIndex = column;
@ var newRows = new Array();
@ for (j = 0; j < this.tbody[0].rows.length; j++) {
@ newRows[j] = this.tbody[0].rows[j];
@ }
@ newRows.sort(sortFn);
@ if (cell.getAttribute("sortdir") == 'down') {
@ newRows.reverse();
@ cell.setAttribute('sortdir','up');
@ } else {
@ cell.setAttribute('sortdir','down');
@ }
@ for (i=0;i<newRows.length;i++) {
@ this.tbody[0].appendChild(newRows[i]);
@ }
@ }
@ this.sortText = function(a,b) {
@ var i = thisObject.sortIndex;
|
>
>
|
>
>
>
|
|
>
>
|
<
|
<
|
|
>
|
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
|
**
** The javascript is derived from:
**
** http://www.webtoolkit.info/sortable-html-table.html
**
** This variation allows column types to be expressed using the second
** argument. Each character of the second argument represent a column.
**
** t Sort by text
** n Sort numerically
** k Sort by the data-sortkey property
** x This column is not sortable
**
** If there are fewer characters in zColumnTypes[] than their are columns,
** the all extra columns assume type "t" (text).
**
** Clicking on the same column header twice in a row inverts the sort.
*/
void output_table_sorting_javascript(const char *zTableId, const char *zColumnTypes){
@ <script>
@ function SortableTable(tableEl,columnTypes){
@ this.tbody = tableEl.getElementsByTagName('tbody');
@ this.sort = function (cell) {
@ var column = cell.cellIndex;
@ var sortFn;
@ switch( cell.sortType ){
@ case "n": sortFn = this.sortNumeric; break;
@ case "t": sortFn = this.sortText; break;
@ case "k": sortFn = this.sortKey; break;
@ case "x": return;
@ }
@ this.sortIndex = column;
@ var newRows = new Array();
@ for (j = 0; j < this.tbody[0].rows.length; j++) {
@ newRows[j] = this.tbody[0].rows[j];
@ }
@ if( this.sortIndex==this.prevColumn ){
@ newRows.reverse();
@ }else{
@ newRows.sort(sortFn);
@ this.prevColumn = this.sortIndex;
@ }
@ for (i=0;i<newRows.length;i++) {
@ this.tbody[0].appendChild(newRows[i]);
@ }
@ }
@ this.sortText = function(a,b) {
@ var i = thisObject.sortIndex;
|
984
985
986
987
988
989
990
991
992
993
994
995
996
997
|
@ aa = a.cells[i].getAttribute("data-sortkey");
@ bb = b.cells[i].getAttribute("data-sortkey");
@ if(aa==bb) return 0;
@ if(aa<bb) return -1;
@ return 1;
@ }
@ var thisObject = this;
@ var x = tableEl.getElementsByTagName('thead');
@ if(!(this.tbody && this.tbody[0].rows && this.tbody[0].rows.length>0)){
@ return;
@ }
@ if(x && x[0].rows && x[0].rows.length > 0) {
@ var sortRow = x[0].rows[0];
@ } else {
|
>
|
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
|
@ aa = a.cells[i].getAttribute("data-sortkey");
@ bb = b.cells[i].getAttribute("data-sortkey");
@ if(aa==bb) return 0;
@ if(aa<bb) return -1;
@ return 1;
@ }
@ var thisObject = this;
@ var prevColumn = -1;
@ var x = tableEl.getElementsByTagName('thead');
@ if(!(this.tbody && this.tbody[0].rows && this.tbody[0].rows.length>0)){
@ return;
@ }
@ if(x && x[0].rows && x[0].rows.length > 0) {
@ var sortRow = x[0].rows[0];
@ } else {
|