I have spent 1/2 hour looking for a Javascript formatter with no luck.
I am using a tool that produces Javascript statements in one long string
and it's hard to read.
Any recommendations ? I see a .NET tool at codeproject but that site is
down.
On Sun, 15 Feb 2004 13:47:44 -0800, John Dalberg <john_dd@hotmai l.com>
wrote:
[color=blue]
>
>I have spent 1/2 hour looking for a Javascript formatter with no luck.
>I am using a tool that produces Javascript statements in one long string
>and it's hard to read.
>
>Any recommendations ?[/color]
On Sun, 15 Feb 2004 20:48:14 -0800, John Dalberg <john_dd@hotmai l.com>
wrote:
[color=blue]
>On Sun, 15 Feb 2004 22:24:26 GMT, Jim Ley wrote:
>[color=green]
>> On Sun, 15 Feb 2004 13:47:44 -0800, John Dalberg <john_dd@hotmai l.com>
>> wrote:
>>[color=darkred]
>>> [6 quoted line(s) supressed][/color]
>>
>> IE does a good job:
>>
>> alert(function( ) { /* LongString*/ })[/color]
>
>It doesn't work. Long string as in a few lines in Wordpad.[/color]
It does for me....
Perhaps you should provide an example which demonstrates your problem.
astyle is of course perhaps a more normal recommendation, but it's a
little pointless when you already have something that does the job.
On Mon, 16 Feb 2004 18:31:52 GMT, Jim Ley wrote:
[color=blue]
> On Sun, 15 Feb 2004 20:48:14 -0800, John Dalberg <john_dd@hotmai l.com>
> wrote:
>[color=green]
>> [12 quoted line(s) supressed][/color]
>
> It does for me....
>
> Perhaps you should provide an example which demonstrates your problem.
>
> astyle is of course perhaps a more normal recommendation, but it's a
> little pointless when you already have something that does the job.
>[/color]
Here's one:
John Dalberg <john_dd@hotmai l.com> writes:
[color=blue]
> Here's one:[/color]
Not a very good example, because your news client broke the
lines. That means that the code we see is not even syntactically
correct Javascript, and we will have to work harder to just make it
correct again, before we can start solving the problem.
As for the method:
Take that code, and put it into another file. Write these lines before
the code:
<script type="text/javascript">
function foo(){
and this after:
};
document.write( "<pre>"+foo.toS tring()+"<\/pre>");
</script>
and load it into your browser as an HTML file. Use cut'n'paste to
pick out the area between
function foo() {
and
}
In Opera it makes the blocks structure much clearer. In IE it doesn't
help that much. Mozilla FireFox is by far the prettiest, with
indentation and everything. Your code, as displayed by FireFox, is
here (if the lines are broken, check your newsreader):
---
var cspbDetectedBro wser = "IE5DHTML";
var cspbVS = "cspbPanelBarLo ading";
var cspbGD = new Object();
var cspbFO = true;
var cspbTL = 0;
var cspbTD = 0;
var cspbGDH = 0;
var cspbEIA = false;
function cspbShowSection () {
if (cspbEIA) {
return;
}
if (cspbVS == "cspbPanelBarLo ading") {
document.all.cs pbButtons.style .display = "inline";
document.all[cspbVS].style.display = "none";
cspbVS = "";
}
var count = 0;
for (count = 0; count < arguments.lengt h; count++) {
var id = arguments[count];
if (typeof (id) == "string") {
id = cspbGetGroupInd ex(id);
}
if (document.all["cspbGroup" + id]) {
cspbGD = document.all["cspbGroup" + id];
if (cspbGD.style.d isplay == "inline") {
document.all["cspbBtnCel l" + id].className = "cspbBtnCel l";
if (navigator.plat form != "MacPPC") {
cspbGDH = cspbGD.offsetHe ight;
cspbEC(0);
} else {
cspbGD.style.di splay = "none";
}
} else {
document.all["cspbBtnCel l" + id].className = "cspbBtnCellSlt ";
cspbGD.style.di splay = "inline";
if (!cspbFO && navigator.platf orm != "MacPPC") {
cspbGDH = cspbGD.offsetHe ight;
cspbGD.style.he ight = 1;
cspbEO(cspbGDH) ;
}
}
}
}
cspbFO = false;
}
function cspbGetGroupInd ex(caption) {
var aCaptions = new Array();
aCaptions[0] = "Customers" ;
aCaptions[1] = "Orders";
aCaptions[2] = "Orders2";
aCaptions[3] = "About Us";
var count = 0;
for (count = 0; count < aCaptions.lengt h; count++) {
if (aCaptions[count] == caption) {
return count;
}
}
return 0;
}
function cspbASH() {
var e = window.onscroll ;
if (typeof (e) == "function") {
e = e.toString();
e = e.substring(e.i ndexOf("{") + 1, e.lastIndexOf(" }"));
var f = cspbWindowScrol l.toString();
f = f.substring(f.i ndexOf("{") + 1, f.lastIndexOf(" }"));
var sh = new Function(f + e);
window.onscroll = sh;
} else {
window.onscroll = cspbWSEH;
}
}
if (navigator.plat form != "MacPPC") {
this.attachEven t("onscroll", cspbWSEH);
}
---
Good luck
/L
--
Lasse Reichstein Nielsen - lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
"John Dalberg" <john_dd@hotmai l.com> wrote in message
news:zw30p2luas o4$.1hnbuil6c24 rz$.dlg@40tude. net...[color=blue]
>
> I have spent 1/2 hour looking for a Javascript formatter with no luck.
> I am using a tool that produces Javascript statements in one long string
> and it's hard to read.[/color]
Did you try Googling for "JavaScript Formatter"?
The first 20 entries or so like like perfectly good formatters to me.
-- IDB
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Ira Baxter wrote:[color=blue]
> "John Dalberg" <john_dd@hotmai l.com> wrote in message
> news:zw30p2luas o4$.1hnbuil6c24 rz$.dlg@40tude. net...
>[color=green]
>>I have spent 1/2 hour looking for a Javascript formatter with no luck.
>>I am using a tool that produces Javascript statements in one long string
>>and it's hard to read.[/color]
>
>
> Did you try Googling for "JavaScript Formatter"?
> The first 20 entries or so like like perfectly good formatters to me.[/color]
Your answer, of course, is not related to the SEMDesigns purchase of the
#1 hit now would it? But whats the point in paying 50 dollars US for
something that can be done for free? Sheesh.
Randy Webb <hikksnotathome @aol.com> writes:
[color=blue]
> Your answer, of course, is not related to the SEMDesigns purchase of
> the #1 hit now would it?[/color]
I'd say he was very nice about not pointing to it. :)
[color=blue]
> But whats the point in paying 50 dollars US for something that can
> be done for free? Sheesh.[/color]
Like this one:
---
<textarea id="input" style="width:10 0%;height:10em" >Enter code here</textarea>
<input type="button" value="format"
onclick="var inp=document.ge tElementById('i nput');
var str=Function(in p.value).toStri ng();
str=str.substri ng(str.indexOf( '{')+1);
str=str.substri ng(0,str.lastIn dexOf('}'));
inp.value=str;" >
---
run in (preferably) Mozilla. Unless you like your comments ofcourse :)
/L
--
Lasse Reichstein Nielsen - lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Comment