Question about addRowById()

jith45

Member
May 25, 2018
960
0
16
Hello

Maybe someone of the veterans here can help me with addRowById() it's used in rutorrent to make tables, a very handy system.

But can you somehow tell it to always keep a row up top even if you sort the table on other columns and order?

I have been trying to figure out how the redrawFiles() in webui.js keeps the dir and files separated. But i cant really figure out how they do it.
 

somus1735

Member
May 25, 2018
833
0
16
I have been trying to figure out how the redrawFiles() in webui.js keeps the dir and files separated. But i cant really figure out how they do it.
See to sort hooks. Lines in method theWebUI.config
Code:
var table = this.getTable("fls");
table.oldFilesSortAlphaNumeric = table.sortAlphaNumeric;
table.sortAlphaNumeric = function(x, y)
{
if(!theWebUI.settings["webui.fls.view"] && theWebUI.dID)
{
var dir = theWebUI.dirs[theWebUI.dID];
var a = dir.dirs[dir.current][x.key];
var b = dir.dirs[dir.current][y.key];
if((a.data.name=="..") ||
((a.link!=null) && (b.link==null)))
return(this.reverse ? 1 : -1);
if((b.data.name=="..") ||
((b.link!=null) && (a.link==null)))
return(this.reverse ? -1 : 1);
}
return(this.oldFilesSortAlphaNumeric(x,y));
}
table.oldFilesSortNumeric = table.sortNumeric;
table.sortNumeric = function(x, y)
{
if(!theWebUI.settings["webui.fls.view"] && theWebUI.dID)
{
var dir = theWebUI.dirs[theWebUI.dID];
var a = dir.dirs[dir.current][x.key];
var b = dir.dirs[dir.current][y.key];
if((a.data.name=="..") ||
((a.link!=null) && (b.link==null)))
return(this.reverse ? 1 : -1);
if((b.data.name=="..") ||
((b.link!=null) && (a.link==null)))
return(this.reverse ? -1 : 1);
}
return(this.oldFilesSortNumeric(x,y));
}
 

shwetha17

Member
May 24, 2018
785
0
16
Ah thank you, that helped a lot!

I'm starting to figure out how things are connected now smiley.gif

My little adjustment to use in my plugin smiley.gif

Code:
table.oldFilesSortAlphaNumeric = table.sortAlphaNumeric;
table.sortAlphaNumeric = function(x, y)
{
if(!theWebUI.settings["webui.fli.view"] )
{
if ( x.key == '..')
return(this.reverse ? 1 : -1);
var r = theSort.AlphaNumeric(x.v, y.v);
return( (r == 0) ? this.sortSecondary(x, y) : r );
}
return(this.oldFilesSortAlphaNumeric(x,y));
},

table.oldFilesSortNumeric = table.sortNumeric;
table.sortNumeric = function(x, y)
{
if(!theWebUI.settings["webui.fli.view"] )
{
if ( x.key == '..')
return(this.reverse ? 1 : -1);
var r = theSort.Numeric(x.v, y.v);
return( (r == 0) ? this.sortSecondary(x, y) : r );
}
return(this.oldFilesSortNumeric(x,y));
},
Working on a simple filebrowser for the server, starts to work pretty nice. Buts its always hard to know if I do things right when you cut and paste much of the code from another plugin. I have been using the RSS plugin since it replace the torrent list and I wanted the same for my filebrowser.

Thank you!