chiark / gitweb /
Abbreviate some variable names in tabsort
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Mon, 21 Sep 2009 01:43:44 +0000 (02:43 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Mon, 21 Sep 2009 01:43:44 +0000 (02:43 +0100)
yarrg/web/tabsort

index e114319a0254f4780bfcaa6071093d39f016f23f..45d5e69e3763f56cbd2a1e1b888ad26261094116 100644 (file)
@@ -56,7 +56,7 @@ $cols
 
 % print $m->content();
 
 
 % print $m->content();
 
-%      my $sortfn= "ts_sort__$table";
+%      my $sortfn= "ts_s_$table";
 function <% $sortfn %>(compar) {
   debug('sorting compar='+compar);
   var table= document.getElementById('<% $table %>');
 function <% $sortfn %>(compar) {
   debug('sorting compar='+compar);
   var table= document.getElementById('<% $table %>');
@@ -115,9 +115,9 @@ function <% $sortfn %>(compar) {
 %      my $thhtml= '';
 %      next if $col->{NoSort};
 
 %      my $thhtml= '';
 %      next if $col->{NoSort};
 
-%      my $mapfn= "ts_compar${cix}_map__$table";
-function <% $mapfn %>(rowelement) {
-  var rowid = rowelement.id;
+%      my $mapfn= "ts_${cix}m_$table";
+function <% $mapfn %>(re) {
+  var rowid = re.id;
 %      if ($col->{SortKey}) {
   return <% $col->{SortKey} %>;
 %      } else {
 %      if ($col->{SortKey}) {
   return <% $col->{SortKey} %>;
 %      } else {
@@ -130,24 +130,25 @@ function <% $mapfn %>(rowelement) {
 %      }
 }
 
 %      }
 }
 
-%      my $comparefn= "ts_compar${cix}_cmp0__$table";
+%      my $comparefn= "ts_${cix}c0_$table";
 function <% $comparefn %>(a,b) {
 function <% $comparefn %>(a,b) {
-  var a_key = <% $mapfn %>(a);
-  var b_key = <% $mapfn %>(b);
+  var ak = <% $mapfn %>(a);
+  var bk = <% $mapfn %>(b);
 %      if ($col->{Numeric}) {
 %      if ($col->{Numeric}) {
-  return a_key - b_key
+  return ak - bk
 %      } else {
 %      } else {
-  if (a_key < b_key) return -1;
-  if (a_key > b_key) return +1;
+  if (ak < bk) return -1;
+  if (ak > bk) return +1;
   return 0;
 %      }
 }
 
 %      foreach my $reverse (qw(1 0)) {
   return 0;
 %      }
 }
 
 %      foreach my $reverse (qw(1 0)) {
-%              my $tcomparefn= "ts_compar${cix}_cmp${reverse}__$table";
+%              my $tcomparefn= "ts_${cix}c${reverse}_$table";
 %              if ($reverse) {
 %                      next unless $col->{DoReverse};
 function <% $tcomparefn %>(a,b) { return -<% $comparefn %>(a,b); }
 %              if ($reverse) {
 %                      next unless $col->{DoReverse};
 function <% $tcomparefn %>(a,b) { return -<% $comparefn %>(a,b); }
+
 %              }
 %              $thhtml .= "<a href=\"javascript:$sortfn($tcomparefn)\">".
 %                              ($reverse ? '&or;' : '&and;'). '</a>';
 %              }
 %              $thhtml .= "<a href=\"javascript:$sortfn($tcomparefn)\">".
 %                              ($reverse ? '&or;' : '&and;'). '</a>';