That code doesn't do anything on its own. It just retrieves the array of OCGs (layers) in the file.
To make a specific layer visible (or invisible) you need to access it via that array and then change its state property to true or false, resp.
I believe it's all explained in that tutorial you found.
I don't want to make a specific layer invisible. I want to make the layer name in the layers palette invisible.
If I place a watermark with the watermark function of Acrobat, then I can make the layer name in the layers palette visible with the JS-code
this.setOCGOrder(this.getOCGs()); // (and not: this.getOCGs(); sorry, I was wrong)
But what is the code to make the layer name in the layers palette invisible again?
That code doesn't have anything to do with showing the layers palette or making a layer's name in it hidden or visible. It just sets the order of the layers (to the current order, which is useless).
As far as I know, it's not possible to do any of those things using a script.
Too bad, I was hoping I could do it with JS.
Thank you very much.
The point is you can have an OCG that doesn't show up in the list, such as when you add a watermark. The code:
has the effect of making the OCG names that aren't visible in the Layers pane visible, which then allows a user to manipulate it via the user interface.