Skip to content
Snippets Groups Projects
Commit 8781cdcb authored by deuce's avatar deuce
Browse files

More optimizations and cleanup. The paging thing is still a bit off since

the offset is in user number, not in number of users.
parent e292e0e4
Branches
Tags
No related merge requests found
...@@ -18,19 +18,15 @@ ...@@ -18,19 +18,15 @@
}; };
var pageSize = 500; var pageSize = 500;
var offset = 1;
// Most people won't need to edit below this line // Most people won't need to edit below this line
load("sbbsdefs.js"); load("sbbsdefs.js");
if( typeof http_request.query.offset == "undefined" if(typeof http_request.query.offset != "undefined") {
|| offset = parseInt(http_request.query.offset[0]);
isNaN(parseInt(http_request.query.offset[0])) if(isNaN(offset) || offset < 1)
|| offset = 1;
http_request.query.offset[0] < 1
) {
var offset = 1;
} else {
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));
...@@ -50,11 +46,6 @@ ...@@ -50,11 +46,6 @@
|| ||
typeof http_request.query.sortorder == "undefined" typeof http_request.query.sortorder == "undefined"
|| ||
( http_request.query.sortorder != "ascending"
&&
http_request.query.sortorder != "descending"
)
||
columns[http_request.query.sortby[0].toLowerCase()] == undefined columns[http_request.query.sortby[0].toLowerCase()] == undefined
|| ||
columns[http_request.query.sortby[0].toLowerCase()].type == undefined columns[http_request.query.sortby[0].toLowerCase()].type == undefined
...@@ -114,6 +105,8 @@ ...@@ -114,6 +105,8 @@
var copyProperties = function(source, dest) { var copyProperties = function(source, dest) {
for(var property in source) { for(var property in source) {
if(columns[property] == undefined)
continue;
if(typeof source[property] == "string" || typeof source[property] == "number") if(typeof source[property] == "string" || typeof source[property] == "number")
dest[property] = source[property]; dest[property] = source[property];
} }
...@@ -128,8 +121,7 @@ ...@@ -128,8 +121,7 @@
if(usr1.settings&USER_DELETED || usr1.compare_ars("REST Q")) if(usr1.settings&USER_DELETED || usr1.compare_ars("REST Q"))
continue; continue;
var usr2 = copyProperties(usr1, {}); var usr2 = copyProperties(usr1, {});
usr2 = copyProperties(usr1.stats, usr2); users.push(copyProperties(usr1.stats, usr2));
users.push(usr2);
} }
users.sort(sortUsers); users.sort(sortUsers);
...@@ -146,7 +138,7 @@ ...@@ -146,7 +138,7 @@
<?xjs <?xjs
for(var u = 0; u < users.length; u++) { for(var u in users) {
print(format("<tr class='%s'>", (u % 2 == 0) ? "row1" : "row2")); print(format("<tr class='%s'>", (u % 2 == 0) ? "row1" : "row2"));
for(var c in columns) { for(var c in columns) {
print( print(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment