labels column

dsouvik215

Member
May 25, 2018
896
0
16
if you guys can't tell, i'm kind of an organization fiend. thus, it's only natural that I make another plugin pertaining to labels. my previous plugin loaded all previous labels into a dropdown menu for easy access on new torrents, allowing me to easily manage a list of category/subcategory based labels. now, i'd like to nest the labels in the left column. i've developed a jquery plugin that, when initialized, encapsulates the entire category with a div, prepends a LI with the name of the category, and unwraps the group. this serves the function of automatically sorting the list into categories and adding a label. however, once the status is updated in rutorrent, the added LI disappears. this action also seems to nullify the listener on the LI's that get wrapped and unwrapped, as they do not do anything when clicked (whereas anything without subcategories can be clicked)

any ideas on how to inject this into the update mechanism/support the listeners? sorry i'm a bit new at this

this is the code:
Code:
//
// ruTorrent Nested Categorical Label-Sorter
// Version 0.1
// by thezwallrus
//

var theLbl;
var lblArray = [];
var lblExists;
var theLIs = '';
var liCheck;
var removeMe;

theWebUI.initSortLabels = function()
{
setTimeout( function() {
$('#lbll li').each( function() {
theLbl = $(this).attr("id").replace(/-_-_-/g,'');
splitLbl = theLbl.split('/');
lblExists = $.inArray(splitLbl[0], lblArray);
if (lblExists == -1) {
lblArray.push(splitLbl[0]);
};
});
$.each(lblArray, function(i, val) {
liCheck = $('#lbll li:contains(' + val + '/")').attr('id');
if ( liCheck != undefined ) {
$('#lbll li:contains(' + val + '/")').wrapAll( $('<div></div>').attr('id','-' + val) );
removeMe = $('div[id="-' + val + '"]')
$(removeMe).prepend( $('<li></li>').attr('id','+' + val).html(val) );
$(removeMe).after(removeMe.html()).remove();
};
});
}, 3000 );

plugin.markLoaded();
};

theWebUI.initSortLabels();
 

das329717

Member
May 25, 2018
928
0
16
hi

If i right understand, labels previously show like this :

movies/sd
movies/hd
movies/dvdr
series/lost
series/himym
series/dh

with your plugin, they will be shown like this :
-movies
sd
hd
dvdr
-series
lost
himym
dh

It's a great idea, i like that ^^ I hope you will be able to fix it wink.gif
 

jith45

Member
May 25, 2018
960
0
16
you would be correct, but i don't exactly know how to access the update mechanism.
 

somus1735

Member
May 25, 2018
833
0
16
You can't make that by such way. You must overwrite methods theWebUI.loadLabels,theWebUI.updateLabels,theWebUI.switchLabel,theWebUI.filterByLabel and work with your structures inside its. This is a not simple task.
 

shwetha17

Member
May 24, 2018
785
0
16
I have a question. If I override certain functions such as "filterbylabel" and "updatelabels", will my plugin conflict with other plugins such as TrackLabels which also override these commands, or does rutorrent load this as a chain, going through each plugin one at a time?
 

dsouvik215

Member
May 25, 2018
896
0
16
I have a question. If I override certain functions such as "filterbylabel" and "updatelabels", will my plugin conflict with other plugins such as TrackLabels which also override these commands, or does rutorrent load this as a chain, going through each plugin one at a time?
No, if you make this by correct way. For example:
Code:
plugin.filterByLabel = theWebUI.filterByLabel; // save original handler
theWebUI.filterByLabel = function(hash)
{
if(plugin.enabled)
{
// your code here
}
else
plugin.filterByLabel.call(theWebUI,hash); // call original handler
}