Wednesday, July 20, 2011 6:27:40 AM
While writing Opera extensions, it occurred to me that there is no standard way to write options pages. The closest thing would be the options page example on dev.opera, but that only handles the simplest of HTML input types. A couple hours' layover at an airport and a few more at home and I put together a library that aims to remedy this problem. It is based on the code I have been using in my extensions, which is in turn based on an old dev.opera example that I can't find any more. I dub it, OperaExtOptions.
You can also give OperaExtOptions a list of settings with default values and you can add "Reset to Default" buttons to your settings. It will also initialize those settings to their defaults the first time your extension is run and automatically initialize any new settings you add in new versions of your extension. Settings are saved as JSON encoded strings, so you can either get your settings directly from widget.preferences and use JSON.parse() on them, or you can use the library's SettingStorage class, which handles this automatically.
tl;dr: OperaExtOptions makes options.html work, so you don't have to.
Get OperaExtOptions at Github
As with any new piece of software, there are bound to be a few bugs. I would prefer it if you submit those to the Issues section of the Github page, but you can post bugs in the comments here too. Please tell me what you think!
Oh, and here's a picture. Styling your options page is your job.