Use own javascript (jQuery) to colorize directories from part of their name

Hi,
I would like to colorize directories if a special word is included in the directory name.

For example the directory name is “1 Grün Peter Müller”. If I find the word “Grün” in the name, the directory background-color should be set to the color green.

I try the app “jsloader”. Some Javascripts work. But some jQuery-sources not. I would like to read the attribute “data-file” which contains the name of the directory. But this is not working.

Have someone an idea how to solve this mission?

Thanks a lot

Michael

Hi Michael,
you probably tried to access the folder-elements, when they were not loaded yet.
You could use an interval as a workaround like this:

setInterval(function(){
  $("tr[data-file*=grün]").css("background-color", "green");
  $("tr[data-file*=rot]").css("background-color", "red");
  $("tr[data-file*=blau]").css("background-color", "blue");
},300);

This searches for folders every 300ms, but that shouldn’t be a problem for the performance.

Hi Cloudy1,
that works perfect. Thanks a lot!
Michael

1 Like