Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-04-2013, 05:36 AM   PM User | #1
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 453 Times in 451 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
add word to firefox's dictionary programatically

when you click on the "add to dictionary" label in firefox's context menu, it calls this function:
Code:
oncommand="InlineSpellCheckerUI.addToDictionary();"/>
I'm trying to replicate that programmatically in a firefox extension. So it seems the first step is including this file in the xul:

chrome://global/content/inlineSpellCheckUI.js

which basically is just an include of this file:

resource://gre/modules/InlineSpellChecker.jsm

(these links both need to be opened in firefox, obviously)

so then in the jsm file we find the function:

Code:
// callback for adding the current misspelling to the user-defined dictionary
  addToDictionary: function()
  {
    // Prevent the undo stack from growing over the max depth
    if (this.mAddedWordStack.length == MAX_UNDO_STACK_DEPTH)
      this.mAddedWordStack.shift();

    this.mAddedWordStack.push(this.mMisspelling);
    this.mInlineSpellChecker.addWordToDictionary(this.mMisspelling);
  }
But what I want to do is add a word to the dictionary on a button click (or oncommand as xul would have it). So I was thinking this might work:

Code:
<button id="SpellcheckerAddButton" label="&addbutton.label;" oncommand="InlineSpellCheckerUI.mInlineSpellChecker.addWordToDictionary('fuzzlebuzz')"/>
I've included the chrome://global/content/inlineSpellCheckUI.js in the xul file where the button is, but I suspect that I'm misunderstanding the "this" from the original jsm file, because it doesn't work (and because it's xul, debugging is a nightmare).

Any suggestions?
xelawho is offline   Reply With Quote
Old 02-04-2013, 01:42 PM   PM User | #2
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 941
Thanks: 7
Thanked 95 Times in 95 Posts
WolfShade is an unknown quantity at this point
I've no experience with plugins, but it seems to me that if you could do this in JavaScript, that would be a security issue.

Anyone else know more about this?
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Old 02-04-2013, 02:16 PM   PM User | #3
Airblader
Regular Coder

 
Join Date: Jan 2013
Location: Germany
Posts: 348
Thanks: 3
Thanked 43 Times in 43 Posts
Airblader can only hope to improve
@ WolfShade

For sure it would be a security issue – for normal websites. Plugins are provided with extended APIs by the browser, so I think this could be possible. I don't know for sure, though, I too have never worked with browser plugins.
Airblader is offline   Reply With Quote
Old 02-05-2013, 02:33 AM   PM User | #4
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 453 Times in 451 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
in case anybody is looking at this in the future, I haven't tried it yet, but it seems like this is what I was looking for:
https://developer.mozilla.org/en-US/...onalDictionary

@ WolfShade:
as Airblader says, you can't get at any of this stuff with just javascript, but with add-on extensions you can do all sorts of funky stuff (as long as the user agrees to install your extension)

Last edited by xelawho; 02-05-2013 at 02:35 AM..
xelawho is offline   Reply With Quote
Old 02-05-2013, 11:55 AM   PM User | #5
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,452
Thanks: 9
Thanked 466 Times in 450 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
for debugging you can run privileged/XUL code in firebug in about:config, but typically it's sealed-off.
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.8% IE9:11.4% IE10:6.5%
rnd me is offline   Reply With Quote
Old 02-05-2013, 07:50 PM   PM User | #6
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 453 Times in 451 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
Quote:
Originally Posted by rnd me View Post
for debugging you can run privileged/XUL code in firebug in about:config, but typically it's sealed-off.
oh, now you tell me

thanks for the tip. I'll keep it in mind for the next one
xelawho is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:25 PM.


Advertisement
Log in to turn off these ads.