Is it possible to instance a function in a JSON object?
- From: Kashgarinn <steinthor@xxxxxxxxx>
- Date: Wed, 15 Aug 2007 04:25:08 -0700
Hi there. I'm a beginner with Javascript, and was wondering if you
perhaps knew this.
I'm creating a plugin for a wiki, and I'd like to instance the
function I'm modifying, instead of taking it completely over, so that
if the authors of the wiki change anything, what I add won't touch
that.
However, they keep the function in a JSON object
Here's an excerpt of the JSON object:
=======
config.formatters = [
{
name: "table",
match: "^\\|(?:[^\\n]*)\\|(?:[fhck]?)$",
lookaheadRegExp: /^\|([^\n]*)\|([fhck]?)$/mg,
rowTermRegExp: /(\|(?:[fhck]?)$\n?)/mg,
cellRegExp: /(?:\|([^\n\|]*)\|)|(\|[fhck]?$\n?)/mg,
cellTermRegExp: /((?:\x20*)\|)/mg,
rowTypes: {"c":"caption", "h":"thead", "":"tbody", "f":"tfoot"},
handler: function(w)
{
/* some code here */
},
rowHandler: function(w,e,prevColumns)
{
/* some code here */
}
},
{ // next function here
},
];
========================
Now, I'd like to add variables and functions to the table object.. So
I was thinking, I could probably instance the table function, I dug up
the information, and I think that this should work:
==============================================
config.macros.tablePlugin = {}
config.macros.tablePlugin.handler = function(place, macroName, params,
wikifier, paramString, tiddler)
{
/* Code goes here */
}
config.macros.tablePlugin = new config.formatters.table;
==============================================
But.. it isn't working.. and I'm suspecting it's because it's in a
JSON object, as I get the error: "Error: TypeError:
config.formatters.table is not a constructor"
- Can someone help me? I'm in a bit of a pickle..
.
- Follow-Ups:
- Re: Is it possible to instance a function in a JSON object?
- From: Thomas 'PointedEars' Lahn
- Re: Is it possible to instance a function in a JSON object?
- Prev by Date: Re: Dynamically assigning functions with parameters to events
- Next by Date: Re: Dynamically assigning functions with parameters to events
- Previous by thread: cheat proof high score for online Tetris?
- Next by thread: Re: Is it possible to instance a function in a JSON object?
- Index(es):
Relevant Pages
|