Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
817932bf
Commit
817932bf
authored
11 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Make the sort function VASTLY simpler in an effort to make the userlist work
for large user lists.
parent
84b0eaae
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
web/root/ecwebv3/pages/003-userlist.xjs
+50
-49
50 additions, 49 deletions
web/root/ecwebv3/pages/003-userlist.xjs
with
50 additions
and
49 deletions
web/root/ecwebv3/pages/003-userlist.xjs
+
50
−
49
View file @
817932bf
...
@@ -24,13 +24,13 @@
...
@@ -24,13 +24,13 @@
if( typeof http_request.query.offset == "undefined"
if( typeof http_request.query.offset == "undefined"
||
||
isNaN(parseInt(http_request.query.offset))
isNaN(parseInt(http_request.query.offset
[0]
))
||
||
http_request.query.offset < 1
http_request.query.offset
[0]
< 1
) {
) {
var offset = 1;
var offset = 1;
} else {
} else {
var offset = parseInt(http_request.query.offset);
var offset = parseInt(http_request.query.offset
[0]
);
}
}
var previousOffset = Math.max(1, offset - pageSize);
var previousOffset = Math.max(1, offset - pageSize);
var nextOffset = Math.min(offset + pageSize, offset + (system.lastuser - offset));
var nextOffset = Math.min(offset + pageSize, offset + (system.lastuser - offset));
...
@@ -42,56 +42,57 @@
...
@@ -42,56 +42,57 @@
http_request.request_string.split("&")[0]
http_request.request_string.split("&")[0]
);
);
var sortUser = function(a, b, sortOrder, type) {
var sortUsers;
if(type == "string") {
var sortBy;
a = a.toUpperCase();
var sortOrder;
b = b.toUpperCase();
ret = (a < b)
?
((sortOrder == "ascending") ? 1 : -1)
:
( (a > b)
?
((sortOrder == "ascending") ? -1 : 1)
:
0
);
} else if(type == "number" || type == "date") {
ret = (a < b)
?
((sortOrder == "ascending") ? -1 : 1)
:
( (a > b)
?
((sortOrder == "ascending") ? 1 : -1)
:
0
);
}
return ret;
}
var sortUsers
=
f
un
ction(a, b) {
if( typeof http_request.query.sortby =
=
"
un
defined"
var ret = 0;
||
if(
typeof http_request.query.sort
by !
= "undefined"
typeof http_request.query.sort
order =
= "undefined"
&&
||
typeof
http_request.query.sortorder != "
undefined
"
(
http_request.query.sortorder != "
ascending
"
&&
&&
( http_request.query.sortorder == "ascending"
http_request.query.sortorder != "descending"
||
)
http_request.query.sortorder == "descending"
||
)
columns[http_request.query.sortby[0].toLowerCase()] == undefined
) {
||
var sortBy = http_request.query.sortby.toString().toLowerCase();
columns[http_request.query.sortby[0].toLowerCase()].type == undefined
var sortOrder = http_request.query.sortorder.toString().toLowerCase();
) {
for(var c in columns) {
sortUsers = function(a,b) { return 0; }
if(sortBy != c)
}
continue;
else {
ret = sortUser(a[c], b[c], sortOrder, columns[c].type);
sortBy = http_request.query.sortby[0].toLowerCase()
sortOrder = http_request.query.sortorder[0];
switch(columns[sortBy].type) {
case 'string':
if(sortOrder == "ascending")
sortUsers = function(a,b) {
if(a[sortBy].toLowerCase() < b[sortBy].toLowerCase())
return -1;
if(a[sortBy].toLowerCase() > b[sortBy].toLowerCase())
return 1;
return 0;
};
else
sortUsers = function(a,b) {
if(a[sortBy].toLowerCase() > b[sortBy].toLowerCase())
return -1;
if(a[sortBy].toLowerCase() < b[sortBy].toLowerCase())
return 1;
return 0;
};
break;
case 'date':
case 'number':
if(sortOrder == "ascending")
sortUsers = function(a,b) { return a[sortBy]-b[sortBy]; };
else
sortUsers = function(a,b) { return b[sortBy]-a[sortBy]; };
break;
break;
}
default:
sortUsers = function(a,b) { return 0; }
}
}
return ret;
}
}
var makeSortURLs = function(field, order) {
var makeSortURLs = function(field, order) {
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment