X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2Fweb%2Ftabsort;h=ad25f86b9ab981d58ed2e740cd91cc9d7d6ba23e;hb=83d1b778c07bc89ab7142a3c46fa6698a494c164;hp=e690ac8df740d2535ecc56425452e79ab4463305;hpb=608bc9e07b5c8a961325fd1b8d5b92f65418b949;p=ypp-sc-tools.web-live.git diff --git a/yarrg/web/tabsort b/yarrg/web/tabsort index e690ac8..ad25f86 100644 --- a/yarrg/web/tabsort +++ b/yarrg/web/tabsort @@ -38,6 +38,7 @@ <%args> $table => 'ts_table' $sortkeys => 'ts_sortkeys' +$throw => undef $cols @@ -60,6 +61,9 @@ function <% $sortfn %>(compar) { var row= rows.item(rowix); debug('process row '+rowix+' [[ '+row+' ]] id='+row.id) if (!row.id) continue; +% if (defined $throw) { + if (row.id == '<% $throw %>') continue; +% } if (row.tagName != 'TR') continue; newrows.push(row); } @@ -83,7 +87,12 @@ function <% $mapfn %>(rowelement) { % if ($col->{SortKey}) { return <% $col->{SortKey} %>; % } else { - return <% $sortkeys %>[<% $cix %>][rowid]; +% my $sk= "$sortkeys"."[$cix][rowid]"; +% if ($col->{MapFn}) { + return <% $col->{MapFn} %>(<% $sk %>); +% } else { + return <% $sk %>; +% } % } } @@ -116,8 +125,8 @@ function <% $tcomparefn %>(a,b) { return -<% $comparefn %>(a,b); } function ts_onload__<% $table %>() { var ts_add_heads= <% to_json_protecttags(\%add_heads) %>; - var table= document.getElementById('<% $table %>'); - var firstth= table.getElementsByTagName('th').item(0); + var ctr= document.getElementById('<% defined($throw) ? $throw : $table %>'); + var firstth= ctr.getElementsByTagName('th').item(0); var thlist= firstth.parentNode.getElementsByTagName('th'); debug('thlist='+thlist); debug('thlist.item(2)=' + thlist.item(2));