make cookiemanager sort strings case-insensitively.

thanks to smanux@lfjr.net for the patch. r=dwitte, sr=darin, b=220067
This commit is contained in:
dwitte%stanford.edu 2003-10-15 09:41:40 +00:00
Родитель 189bbda3e5
Коммит e7d5f11d73
2 изменённых файлов: 42 добавлений и 20 удалений

Просмотреть файл

@ -126,19 +126,11 @@ function SortTree(tree, view, table, column, lastSortColumn, lastSortAscending,
var compareFunc;
if (ascending) {
compareFunc = function compare(first, second) {
if (first[column] < second[column])
return -1;
if (first[column] > second[column])
return 1;
return 0;
return CompareLowerCase(first[column], second[column]);
}
} else {
compareFunc = function compare(first, second) {
if (first[column] < second[column])
return 1;
if (first[column] > second[column])
return -1;
return 0;
return CompareLowerCase(second[column], first[column]);
}
}
table.sort(compareFunc);
@ -166,3 +158,22 @@ function SortTree(tree, view, table, column, lastSortColumn, lastSortAscending,
return ascending;
}
/**
* Case insensitive string comparator.
*/
function CompareLowerCase(first, second) {
var firstLower = first.toLowerCase();
var secondLower = second.toLowerCase();
if (firstLower < secondLower) {
return -1;
}
if (firstLower > secondLower) {
return 1;
}
return 0;
}

Просмотреть файл

@ -126,19 +126,11 @@ function SortTree(tree, view, table, column, lastSortColumn, lastSortAscending,
var compareFunc;
if (ascending) {
compareFunc = function compare(first, second) {
if (first[column] < second[column])
return -1;
if (first[column] > second[column])
return 1;
return 0;
return CompareLowerCase(first[column], second[column]);
}
} else {
compareFunc = function compare(first, second) {
if (first[column] < second[column])
return 1;
if (first[column] > second[column])
return -1;
return 0;
return CompareLowerCase(second[column], first[column]);
}
}
table.sort(compareFunc);
@ -166,3 +158,22 @@ function SortTree(tree, view, table, column, lastSortColumn, lastSortAscending,
return ascending;
}
/**
* Case insensitive string comparator.
*/
function CompareLowerCase(first, second) {
var firstLower = first.toLowerCase();
var secondLower = second.toLowerCase();
if (firstLower < secondLower) {
return -1;
}
if (firstLower > secondLower) {
return 1;
}
return 0;
}