Hello guys.
Hello guys. I have very simple(I hope) problem. I recently started self learning JavaScript. I’m trying to write a simple script for my phone launcher (lightning).
I have a main folder and subfolders within it on my desktop. I’m trying to get my script to close other subfolders that are open when I press a subfolder but not close the main folder. This is what I have so far –
var fr = LL.getEvent().getContainer(); var sib = fr.getItemByLabel(“sb”); var f=LL.getOpenFolders(),fll=f.getLength(); if(fll>0) for(var i=0;i sb is the name of my main folder, I don’t know how to define the current folder I am pressing or remove them both from the last function. Thanks
That problem is not so simple!
The main problem is: you need to first check the folders you don’t want to close, and then close all the others. The best way to solve this is to recursively navigate from the current folder to the desktop checking the intermediate folders.
Then you also need to be careful when comparing things, because the folder opener (item) is not the same as the folder container (container).
If you want to try yourself go for it, and ask questions if necessary.
But if you prefer, this should be a final script(to be run in the resumed event of the folders), check it and don’t hesitate to ask any question about it if you need.
—————-
var keep=[];
addRecursive(LL.getEvent().getContainer().getOpener());
var f=LL.getOpenFolders();
for(var i=0;i
f.getAt(i).close();
function addRecursive(folder){
if(folder==null) return;
keep.push(folder.getId());
addRecursive(folder.getParent().getOpener());
}
TrianguloY thank you so much for the help, I learnt alot