I have a Firefox extension that implements a bunch of little functions that can be called from a context menu in Firefox. I made a preferences window that shows a radiogroup for each preference, allowing the function to be shown in the main Firefox menu, to be shown in a submenu created by the extension, or to be hidden. This works exactly the same way for each extension function with only the following things changing: the preference id, the preference name, the called function name, and the label of each radio group. Is it possible to create an array containing those four strings for each function and then to define all of the preferences dynamically, rather than copying and pasting the same code for each preference?
I am pretty sure it is possible to define the XUL in my preferences window dynamically. However, I am not sure about defining the default preferences in the defaults folder using the pref() command (I am not sure how to access strings defined somewhere else in the extension). I am also not sure if the definitions of the preferences.xul file can be defined dynamically or if they need to be typed out.
Also, do you think this is a good or bad idea? I was thinking it would make adding/removing functions easier.