Author Topic: Readable Javascript  (Read 16878 times)

0 Members and 1 Guest are viewing this topic.

Daren

  • Jr. Member
  • **
  • Posts: 3
Readable Javascript
« on: March 03, 2009, 11:42:02 AM »
Hi, where can I find human-readable versions of the Javascript files (brws.js, chat.js, common.js, users.js)?

I've run them through a few different pretty-printers, and they do an OK job, but obviously aren't very useful for turning things like "nr=this.pq.qr?this.pq.qr:fq;" into readable (thus more easily understood) code.

Since OpenWebIM is open-source, having these files would be helpful. Sorry if they're available and I've just missed the link.


bofh

  • Jr. Member
  • **
  • Posts: 3
Re: Readable Javascript
« Reply #1 on: March 04, 2009, 02:38:17 PM »
Ah, glad somebody else noticed this.  In fact, the javascript code appears to be intentionally obfuscated, making it REALLY hard to modify and improve.  I had to run the javascript through two separate de-obfuscation tools to make it somewhat readable.  Function and variable names are still meaningless two-letter combinations, but with all the strings decoded and indenting added, I think I might be able to make useful changes now.  First, I ran the code through:
http://www.brianfolts.com/un/

That decoded all the strings, but didn't do too well with indenting.  So then I ran it through:
http://www.gosu.pl/JsDecoder/

Which makes it look pretty nice.  Still, why is the javascript so obfuscated?

Daren

  • Jr. Member
  • **
  • Posts: 3
Re: Readable Javascript
« Reply #2 on: March 04, 2009, 03:57:50 PM »
Still, why is the javascript so obfuscated?

I can understand a degree of obfuscation for the purpose of minimising file sizes.

While the obfuscated javascript is clearly available to be read and modified, it's not really in the spirit of open source provisions. One might reasonably expect that the original source files have meaningful names and comments to aid understanding. 

If the author(s) really code their javascript using anonymous 2-letter method and variable names, without any comments, they're clearly far better JS coders than me. =)

Hopefully the author will be along shortly.

Inspirer

  • Mibew Project founder
  • Native
  • *****
  • Posts: 262
    • Mibew Messenger
Re: Readable Javascript
« Reply #3 on: March 09, 2009, 08:23:18 AM »
View:
http://webim.svn.sourceforge.net/viewvc/webim/tags/1.5.2/js/

Checkout and build:
svn co https://webim.svn.sourceforge.net/svnroot/webim/tags/1.5.2 webim
cd webim/js
ant

(obfuscated/minimized files are in webim/webim/js)

PS: Sorry for the late response. Just returned from a vacation.

bofh

  • Jr. Member
  • **
  • Posts: 3
Re: Readable Javascript
« Reply #4 on: March 09, 2009, 01:33:40 PM »
Ok - great to get the unobfuscated javascript!  Still, two issues:
- Why is it obfuscated in the first place?  The space saving is minimal, and string obfuscation actually makes the file larger!
- I think there really should be a true source distribution that includes unobfuscated source

Inspirer

  • Mibew Project founder
  • Native
  • *****
  • Posts: 262
    • Mibew Messenger
Re: Readable Javascript
« Reply #5 on: March 09, 2009, 02:29:31 PM »
Historical reasons :)

I'm switching to jQuery now (current scripts are based on prototype), 1.6 release will be minimized by YUI Compressor.

Uncomment the following argument in build.xml to turn off string obfuscation.
<!-- <arg value="o=0,0"/> -->

(I'll do the same if I need to release it again)

Daren

  • Jr. Member
  • **
  • Posts: 3
Re: Readable Javascript
« Reply #6 on: March 11, 2009, 04:11:51 PM »
Great news, inspirer, thanks. 

Inspirer

  • Mibew Project founder
  • Native
  • *****
  • Posts: 262
    • Mibew Messenger
Re: Readable Javascript
« Reply #7 on: March 12, 2009, 01:04:08 AM »
For version 1.5.2:
Unpack the attachment into /webim/js/ folder. Run ant.