[llvm-commits] [LNT] r161418 - /lnt/trunk/lnt/server/ui/static/sorttable.js
Michael Gottesman
mgottesman at apple.com
Tue Aug 7 08:17:19 PDT 2012
Author: mgottesman
Date: Tue Aug 7 10:17:18 2012
New Revision: 161418
URL: http://llvm.org/viewvc/llvm-project?rev=161418&view=rev
Log:
[LNT] Added code to lnt/server/ui/static/sorttable.js so that DOM elements with class name sorttable_rev
are sorted in reverse.
Modified:
lnt/trunk/lnt/server/ui/static/sorttable.js
Modified: lnt/trunk/lnt/server/ui/static/sorttable.js
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/static/sorttable.js?rev=161418&r1=161417&r2=161418&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/static/sorttable.js (original)
+++ lnt/trunk/lnt/server/ui/static/sorttable.js Tue Aug 7 10:17:18 2012
@@ -33,13 +33,22 @@
forEach(document.getElementsByTagName('table'), function(table) {
if (table.className.search(/\bsortable\b/) != -1) {
- sorttable.makeSortable(table);
+ sorttable.makeSortable(table, false);
+ }
+ if (table.className.search(/\bsortable_rev\b/) != -1) {
+ sorttable.makeSortable(table, true);
}
});
},
- makeSortable: function(table) {
+ makeSortable: function(table, sort_reversed) {
+ // If sort_reversed is not set, just set to false to preserve
+ // legacy calls.
+ if (typeof sort_reversed === "undefined") {
+ sort_reversed = false;
+ }
+
if (table.getElementsByTagName('thead').length == 0) {
// table doesn't have a tHead. Since it should have, create one and
// put the first table row in it.
@@ -88,6 +97,15 @@
} else {
headrow[i].sorttable_sortfunction = sorttable.guessType(table,i);
}
+ // If sort_reversed is set, reverse the sort function by wrapping the
+ // actual sort function and calling the actual sort function with its
+ // arguments reversed.
+ if (sort_reversed) {
+ var original_sortfunction = headrow[i].sorttable_sortfunction;
+ headrow[i].sorttable_sortfunction = function(a,b) {
+ return original_sortfunction(b,a);
+ };
+ }
// make it clickable to sort
var index = i;
if (headrow[i].getAttribute("sorttable_index") != null)
More information about the llvm-commits
mailing list