Forum Moderators: open

Message Too Old, No Replies

formatting javascript

         

AffiliateDreamer

8:24 pm on Jul 21, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,
Trying to learn some advanced javascript, but the file i'm looking at is all jumbled up.

Is there a way I can format the code so its easier to read?

eelixduppy

10:00 pm on Jul 21, 2008 (gmt 0)



I'm assuming you mean automatically, right? Some editors allow you to add the tabs automatically however I cannot name any off the top of my head. If might also be what you are viewing the file in - what app are you using?

Oh, and is the source all over the place or is it just missing its whitespace?

AffiliateDreamer

11:01 pm on Jul 21, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am using the firefox webdeveloper addon to get an idea of how others are doing fancy ajax work.

if the site has their javascript file compressed, it looks like:

var a=0;b=[];c=function d(){return false;]

You can the idea, so I want to basically paste the javascript in some editor, so it formats the javascript into a more readable state.

So make the above like:

var a = 0;
var b = [];
c = function() {
return false;
}

Is this possible or am I dreaming? hehe

Fotiman

3:43 am on Jul 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Try Googling for javascript beautifier. There are online versions which do the trick nicely.