Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Trying to get a list of available JavaScript functions/methods

Reply
Thread Tools

Trying to get a list of available JavaScript functions/methods

 
 
thegman
Guest
Posts: n/a
 
      05-10-2008
Hi all,
I'm trying to get list of JavaScript methods/functions in a script
file in much the same a good text editor will, the difference being
that I need to output it to a file or stdout, or some other way of
"getting at it" automatically. I'm not fussy about what language I
use, be it JavaScript or something else. Anyone got any ideas? I've
tried Exuberant Ctags, but that does not seem to work on very advanced
scripts like Ext.

I'm guessing the best way would be to have some kind of interrogation
of a HTMLScriptElement or something, but I can't see how to get a
simple list of functions/methods from that.

Alternatively, any C library for parsing JS might be a good idea, even
Python, Perl, PHP, whatever really, anyone got any recommendations?

Cheers

Garry
 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      05-10-2008
thegman wrote:
> I'm trying to get list of JavaScript methods/functions in a script
> file in much the same a good text editor will, the difference being
> that I need to output it to a file or stdout, or some other way of
> "getting at it" automatically.


You are about the 1337th person to ask that question here. Care to do
a *little* research before you bother other people with your problems?

http://jibbering.com/faq/


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
 
Reply With Quote
 
 
 
 
Dr J R Stockton
Guest
Posts: n/a
 
      05-10-2008
In comp.lang.javascript message <>, Sat,
10 May 2008 16:30:11, Thomas 'PointedEars' Lahn <>
posted:
>thegman wrote:
>> I'm trying to get list of JavaScript methods/functions in a script
>> file in much the same a good text editor will, the difference being
>> that I need to output it to a file or stdout, or some other way of
>> "getting at it" automatically.

>
>You are about the 1337th person to ask that question here. Care to do
>a *little* research before you bother other people with your problems?
>
>http://jibbering.com/faq/


If you had intended to be helpful, you would have given the number of
the relevant section. There is no section which, to the intended
audience, will appear helpful. The OP will realise that, whatever your
intent, your main effect when replying to newcomers is to demonstrate
how obnoxious you are.

--
(c) John Stockton, nr London UK. ???@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Check boilerplate spelling -- error is a public sign of incompetence.
Never fully trust an article from a poster who gives no full real name.
 
Reply With Quote
 
thegman
Guest
Posts: n/a
 
      05-10-2008
On May 10, 3:30*pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
> thegman wrote:
> > I'm trying to get list of JavaScript methods/functions in a script
> > file in much the same a good text editor will, the difference being
> > that I need to output it to a file or stdout, or some other way of
> > "getting at it" automatically.

>
> You are about the 1337th person to ask that question here. *Care to do
> a *little* research before you bother other people with your problems?
>
> http://jibbering.com/faq/
>
> PointedEars
> --
> Anyone who slaps a 'this page is best viewed with Browser X' label on
> a Web page appears to be yearning for the bad old days, before the Web,
> when you had very little chance of reading a document written on another
> computer, another word processor, or another network. -- Tim Berners-Lee



I've looked around quite a lot, maybe I'm the worst Googler in the
world or something, but I can't find what I'm looking for, if
someone's got some links, I'd appreciate it.

Thanks

Garry
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      05-10-2008
thegman wrote:
> [...] Thomas 'PointedEars' Lahn [...] wrote:
>> thegman wrote:
>>> I'm trying to get list of JavaScript methods/functions in a script
>>> file in much the same a good text editor will, the difference being
>>> that I need to output it to a file or stdout, or some other way of
>>> "getting at it" automatically.

>> You are about the 1337th person to ask that question here. Care to do
>> a *little* research before you bother other people with your problems?
>>
>> http://jibbering.com/faq/
>> [...]


Please trim your quotes as also recommended by the FAQ Notes.

> I've looked around quite a lot, maybe I'm the worst Googler in the
> world or something, but I can't find what I'm looking for, if
> someone's got some links, I'd appreciate it.


http://groups.google.com/groups?as_u...ing=d&filter=0


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$>
 
Reply With Quote
 
VK
Guest
Posts: n/a
 
      05-10-2008
On May 10, 6:14 pm, thegman <taylor.ga...@gmail.com> wrote:

> I'm trying to get list of JavaScript methods/functions in a script


1) Top level functions only or all functions together, including
anonymous and nested ones? The latter one is pretty much impossible w/
o operating on a lower level via XPCOM/C (Gecko) or C++ (IE) - just to
let you know in advance.

2) Custom functions only or everything? Say setTimeout should be in
your list or now?

3) For the running script or for the script source treated as plain
text?

With these questions answered the rest should be rather easy.
 
Reply With Quote
 
thegman
Guest
Posts: n/a
 
      05-10-2008
On May 10, 9:25*pm, VK <schools_r...@yahoo.com> wrote:
> On May 10, 6:14 pm, thegman <taylor.ga...@gmail.com> wrote:
>
> > I'm trying to get list of JavaScript methods/functions in a script

>
> 1) Top level functions only or all functions together, including
> anonymous and nested ones? The latter one is pretty much impossible w/
> o operating on a lower level via XPCOM/C (Gecko) or C++ (IE) - just to
> let you know in advance.


All functions, but particularly functions/methods defined in third-
party scripts such as Ext.

>
> 2) Custom functions only or everything? Say setTimeout should be in
> your list or now?


Would be good to have setTimeout and other builtins, but not
essential.

>
> 3) For the running script or for the script source treated as plain
> text?


Not fussy, I don't mind doing this with JavaScript, or pretty much any
other language.

>
> With these questions answered the rest should be rather easy.


Thanks for the reply, I've been looking at this most of the day, and
not come up with any bulletproof solutions yet.

Cheers!

Garry

 
Reply With Quote
 
VK
Guest
Posts: n/a
 
      05-10-2008
> > > I'm trying to get list of JavaScript methods/functions in a script
>
> > 1) Top level functions only or all functions together, including
> > anonymous and nested ones? The latter one is pretty much
> > impossible w/o operating on a lower level via XPCOM/C (Gecko) or
> > C++ (IE) - just to let you know in advance.

>
> All functions, but particularly functions/methods defined in third-
> party scripts such as Ext.


What is your level of programming experience? In the particular how
would you define "all anonymous functions"? All named references to a
function or the initial reference only? If you don't understand the
question I can try to rephrase it with a sample.

> > 2) Custom functions only or everything? Say setTimeout should be
> > in your list or not?

>
> Would be good to have setTimeout and other builtins, but not
> essential.


'k


> > 3) For the running script or for the script source treated
> > as plain text?


> Not fussy, I don't mind doing this with JavaScript,
> or pretty much any other language.


You didn't understand me. My question was: do you want to study a
running code for method references - or you want to parse some text
say library.js to find all occurrences of "function" string in it and
regexp with it?

 
Reply With Quote
 
thegman
Guest
Posts: n/a
 
      05-10-2008
On May 10, 10:52*pm, VK <schools_r...@yahoo.com> wrote:
> > > > I'm trying to get list of JavaScript methods/functions in a script

>
> > > 1) Top level functions only or all functions together, including
> > > anonymous and nested ones? The latter one is pretty much
> > > impossible w/o operating on a lower level via XPCOM/C (Gecko) or
> > > C++ (IE) - just to let you know in advance.

>
> > All functions, but particularly functions/methods defined in third-
> > party scripts such as Ext.

>
> What is your level of programming experience? In the particular how
> would you define "all anonymous functions"? All named references to a
> function or the initial reference only? If you don't understand the
> question I can try to rephrase it with a sample.


My programming experience is longer than I care to remember, but not
JS, not even slightly, which is probably not helping my cause much. I
guess any function/method which is usable, I'd like to list that.


>
> You didn't understand me. My question was: do you want to study a
> running code for method references - or you want to parse some text
> say library.js to find all occurrences of "function" string in it and
> regexp with it?


I understand your question, it's just that I'm not bothered which way
I end up doing this, I can use JavaScript in a running browser, and
capture the output, or indeed run some kind of regex thing and get the
results that way, I'm relatively indifferent about how I get this
done, just so long as it works. My first thought was to use something
like ctags, or maybe a Python parser, but I could not find anything
which was much good. My thoughts then turned to using the DOM tree or
something like that, which I'd expect to be a bit more robust, after
all, what understand JS better than a browser?

Thanks

Garry
 
Reply With Quote
 
VK
Guest
Posts: n/a
 
      05-11-2008
> > What is your level of programming experience? In the particular how
> > would you define "all anonymous functions"? All named references to a
> > function or the initial reference only? If you don't understand the
> > question I can try to rephrase it with a sample.


> My programming experience is longer than I care to remember, but not
> JS, not even slightly, which is probably not helping my cause much. I
> guess any function/method which is usable, I'd like to list that.


You may start with a simple for-in loop to get your feet wet in
Javascript.
Also
if (typeof someProperty == 'object')
will tell you if someProperty is an object by itself with its own
possible set of properties to go on recursion. Ask if you need more
help.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en-US">
<head>
<meta http-equiv="Content-type"
content="text/html; charset=iso-8859-1">
<title>Demo</title>
<script type="text/javascript">
function init() {
var out = document.forms[0].elements['out'];
var arr = new Array;
var probe = window;
for (var p in probe) {
arr.push(''+p);
}
arr.sort();
for (var i=0; i<arr.length; i++) {
out.value+= arr[i] + '=' + probe[arr[i]] + '\n\n';
}
}
function releaseContextAndInit() {
window.setTimeout('init()',10);
}
window.onload = releaseContextAndInit;
</script>
</head>
<body>
<form action="" onsubmit="return false;">
<fieldset>
<legend>Demo</legend>
<textarea name="out" rows="16" cols="64"></textarea>
</fieldset>
</form>
</body>
</html>



> > You didn't understand me. My question was: do you want to study a
> > running code for method references - or you want to parse some text
> > say library.js to find all occurrences of "function" string in it and
> > regexp with it?

>
> I understand your question, it's just that I'm not bothered which way
> I end up doing this, I can use JavaScript in a running browser, and
> capture the output, or indeed run some kind of regex thing and get the
> results that way, I'm relatively indifferent about how I get this
> done, just so long as it works. My first thought was to use something
> like ctags, or maybe a Python parser, but I could not find anything
> which was much good. My thoughts then turned to using the DOM tree or
> something like that, which I'd expect to be a bit more robust, after
> all, what understand JS better than a browser?
>
> Thanks
>
> Garry


 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get ubuntu ! Get ubuntu ! Get ubuntu ! Get ubuntu ! Getubuntu Windows 64bit 1 06-01-2009 08:54 AM
trying to get an understanding of OOP in JavaScript Richard Hollenbeck Javascript 1 05-24-2009 10:43 AM
Trying to get value of a radio button in JavaScript Mufasa ASP .Net 2 10-17-2007 09:16 PM
Trying to get DropDownList to fire a Javascript function John Kotuby ASP .Net 3 04-30-2007 01:03 PM
Tomcat newbie: Trying to set up my own folder - get 'Resource not available' Sam Java 3 01-06-2004 11:08 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57