MozillaZine

Preferences, Logging and Javascript question

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

Post Posted March 12th, 2006, 2:24 pm

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 Posted March 12th, 2006, 6:31 pm

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 Posted March 12th, 2006, 6:53 pm

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 Posted March 12th, 2006, 8:53 pm

Thanks.

Is there a complete example for Preferences?

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

Post Posted March 13th, 2006, 12:22 pm

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 Posted March 13th, 2006, 3:16 pm

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 Posted March 13th, 2006, 3:20 pm

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 Posted March 15th, 2006, 4:27 pm

-
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 Posted March 17th, 2006, 4:21 pm

-
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 Posted March 17th, 2006, 5:02 pm

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 Posted March 17th, 2006, 9:59 pm

-
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 Posted March 17th, 2006, 11:40 pm

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 Posted March 18th, 2006, 2:51 am

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 Posted March 18th, 2006, 8:18 pm

-
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 Posted March 18th, 2006, 11:08 pm

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.

Return to Extension Development


Who is online

Users browsing this forum: No registered users and 2 guests