Preferences, Logging and Javascript question

Talk about add-ons and extension development.
testetestjdklj
Posts: 45
Joined: December 3rd, 2005, 9:14 am

Preferences, Logging and Javascript question

Post by testetestjdklj »

I have some questions (for the 1.0 version of my extension):

Preferences: I need help creating a preferences pane in the options menu. How would I add my own buttons to it, and how would I retrieve the values?

Logging: How would I create a logging file?

Javascript: What Javascript is commonly used in extensions? Also, could someone provide me with a sample code of a dialog box? (Eg. Accept and Reject, etc)

Thanks.
ericjung
Posts: 846
Joined: August 4th, 2003, 9:32 am

Post by ericjung »

Here are answers to two of your three questions:

http://kb.mozillazine.org/Creating_dialogs
http://kb.mozillazine.org/File_IO

-grimholtz
asqueella
Posts: 4019
Joined: November 16th, 2003, 3:05 am
Location: Russia, Moscow

Post by asqueella »

Re preferences: you shouldn't mess with Firefox's Options window. Provide your own by creating a window (or a <prefwindow>) and pointing to it from install.rdf. You'll have to read documentation on those at developer.mozilla.org
testetestjdklj
Posts: 45
Joined: December 3rd, 2005, 9:14 am

Post by testetestjdklj »

Thanks.

Is there a complete example for Preferences?
asqueella
Posts: 4019
Joined: November 16th, 2003, 3:05 am
Location: Russia, Moscow

Post by asqueella »

Look at extensions that have preferences.

http://kb.mozillazine.org/Dev_:_Using_preferences - working with prefs from a script
http://developer.mozilla.org/en/docs/Preferences_System - prefwindow (see also xulplanet references)
testetestjdklj
Posts: 45
Joined: December 3rd, 2005, 9:14 am

Post by testetestjdklj »

Um, one last question:

How would I create a file on a Macintosh? It doesn't really cover it on the File IO page.
ericjung
Posts: 846
Joined: August 4th, 2003, 9:32 am

Post by ericjung »

The code on that page is OS-independent. It will work on all platforms under which Firefox/Mozilla/TB run.
testetestjdklj
Posts: 45
Joined: December 3rd, 2005, 9:14 am

Post by testetestjdklj »

-
Last edited by testetestjdklj on July 6th, 2014, 3:19 pm, edited 1 time in total.
testetestjdklj
Posts: 45
Joined: December 3rd, 2005, 9:14 am

Post by testetestjdklj »

-
Last edited by testetestjdklj on July 6th, 2014, 3:19 pm, edited 1 time in total.
ericjung
Posts: 846
Joined: August 4th, 2003, 9:32 am

Post by ericjung »

How would I get a site to check if Firefox has a particular extension?

I don't think this is possible. At least, I don't know how.

what would be the code for the preference to edit the user-agent string?

This is just a standard preference -- general.useragent.override

Also, if I create a Preferences file, do I need to add any other code to other files?

Not sure I understand. If you create a preferences file in your extension, no, you don't have to write any code to have that file processed. As long as you place it in the right directory within the xpi, it will automatically be processed.
testetestjdklj
Posts: 45
Joined: December 3rd, 2005, 9:14 am

Post by testetestjdklj »

-
Last edited by testetestjdklj on July 6th, 2014, 3:19 pm, edited 1 time in total.
ericjung
Posts: 846
Joined: August 4th, 2003, 9:32 am

Post by ericjung »

Well, one thing you can do is in your extension watch every web page that loads. When your page loads, you can call some JS function on your webpage or on your server which lets you know someone with your extension is visiting. Look at nsIWebProgressListener for this.
old zeniko
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post by old zeniko »

grimholtz wrote:
what would be the code for the preference to edit the user-agent string?

This is just a standard preference -- general.useragent.override

For Firefox 1.5, it is better to set the pref general.useragent.extra.your_extensions_name_here to the string you want to have appended to the regular user agent. This allows several extensions to add their identifiers without overwriting each others' settings.

Web pages can then simply parse navigator.userAgent for the extension's identifier and behave accordingly (no need for further extension code - and the pref mentioned above can simply be set in the extension's preferences file).
testetestjdklj
Posts: 45
Joined: December 3rd, 2005, 9:14 am

Post by testetestjdklj »

-
Last edited by testetestjdklj on July 6th, 2014, 3:20 pm, edited 1 time in total.
ericjung
Posts: 846
Joined: August 4th, 2003, 9:32 am

Post by ericjung »

What errors do you see in the JS console?
Why is the 4th statement inside the if clause a return--the rest of the code afterwards will never be executed.
Locked