.js file garbled and unreadable(yet it works!)

B

Byron

Hi,

I need to remove some items from a Javascript drop down menu coded by
someone else. The menu is contained within a single .js file. I'm not
very fluent in javascript, but I know what it looks like and can usually
edit pre-existing code effectively.

When I open this particular .js file in either Dreamweaver (MX) or
notepad, even if I rename the extension, the code has no line breaks and
the part of it that writes the menu's html is full of squares, making it
very difficult to wade into and take out the parts I need to remove. For
example, I can't tell where one menu item stops and another one starts.
However, it still seems to work on the web site, despite all these funky
characters.

Is there a utility or editor that can properly format or parse a large
chunk of Javascript code like this:

!Partners
125px;+177px Partnersfrmt
125px;+177px EFEFEF;border-%8 4&8 4(8 4bottom:8 4 solid 
$%0px;(0px;)127;+24;>;14;normal;normal3F3F3F-.
EFEFEF#29_ _/partners/index.aspself9px;(5px;)105px;+
14-4;%0px$Overview%0px;(22px;)127;+
24;>;14;normal;normal3F3F3F-. EFEFEF#30_
_/microsoftself9px;(5px;)105px;+14-4;%0px$Microsoft%
0px;(44px;)127;+24;>;14;normal;normal3F3F3F-. EFEFEF#
31_ _/partners/featured/index.aspself9px;(5px;)105px;+14-
4;%0px$Featured partner%0px;(66px;)127;+
24;>;14;normal;normal3F3F3F-. EFEFEF#32_
_/partners/services.aspself9px;(5px;)105px;+14-4;%0px
$Services%0px;(86;)127;+24;>;14;normal;normal3F3F3F-
. EFEFEF#33_ _/partners/reseller.aspself9px;(5px;)
105px;+14-4;%0px$Reseller%0px;(110px;)127;+
24;>;14;normal;normal3F3F3F-. EFEFEF#34_
_/partners/business.aspself9px;(5px;)105px;+14-4;%0px
$Business%0px;(132px;)127;+
24;>;14;normal;normal3F3F3F-. EFEFEF#35_
_/partners/technology.aspself9px;(5px;)105px;+14-4;%0px
$Technology%0px;(154px;)127;+
24;>;14;normal;normal3F3F3F-. EFEFEF#36_
_/contact/contact_partners.aspself9px;(5px;)105px;+14-4;%
0px$Contact!


It's much much longer than that, but you get the idea.

What's up?

Thanks.
 
I

Ivo

"Byron" said
I need to remove some items from a Javascript drop down menu coded
by someone else. <snip> the code has no line breaks and
the part of it that writes the menu's html is full of squares, making it
very difficult to wade into and take out the parts I need to remove. For
example, I can't tell where one menu item stops and another one starts.
However, it still seems to work on the web site, despite all these funky
characters.

$Technology%0px;(154px;)127;+
24;>;14;normal;normal3F3F3F-. EFEFEF#36_
_/contact/contact_partners.aspself9px;(5px;)105px;+14-4;%
0px$Contact!

It's much much longer than that, but you get the idea.
What's up?

The original author was probably working on a different platform than you
are. His or her linebreaks and who knows what other characters render as
those funky squares when viewed on your system. IIRC this happens when
translating from Linux to Windows. See if you can find out the name of the
menuwriting function, then load a page which uses it into your browser, and
type in the addressbar:

javascript: document.open( 'text/plain' ); document.write( functionname );

That should give the complete code, correctly encoded for your system.

hth - if not, can you post the url to the .js file here?
ivo
http://4umi.com/web/javascript/
 
B

Byron

"Byron" said

The original author was probably working on a different platform than you
are. His or her linebreaks and who knows what other characters render as
those funky squares when viewed on your system. IIRC this happens when
translating from Linux to Windows. See if you can find out the name of the
menuwriting function, then load a page which uses it into your browser, and
type in the addressbar:
javascript: document.open( 'text/plain' ); document.write( functionname );
That should give the complete code, correctly encoded for your system.
hth - if not, can you post the url to the .js file here?
ivo
http://4umi.com/web/javascript/


Thanks ivo. That partially helped, but there's so much within the .js
file that I need to reformat, that the command you gave me only helped
with a fraction of it. It looks like its divided into many functions and
subfunctions. Anyway to run a command like that on an entire js file?
 
D

Dr John Stockton

JRS: In article <[email protected]
om>, dated Thu, 7 Jul 2005 14:18:21, seen in
Byron said:
Thanks ivo. That partially helped, but there's so much within the .js
file that I need to reformat, that the command you gave me only helped
with a fraction of it. It looks like its divided into many functions and
subfunctions. Anyway to run a command like that on an entire js file?

Try opening the .js file in better editors; if it looks OK, save it,
perhaps after making an unimportant change to "dirty" it.
Otherwise, run it through, for example, MiniTrue; example 14 of the Help
should do what is needed.
 
T

Thomas 'PointedEars' Lahn

Byron said:
[...] Anyway to run a command like that on an entire js file?

Use an editor capable of handling UNIX line breaks, like Metapad or
any Eclipse plugin. Even Microsoft Wordpad can be used to read such
text files.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top