January 31, 2009 10:16 am GMT

DefiThis un-minified Javascript and code explanation

by Gary Illyes


We published a while ago a small WordPress plugin which enables the users to look up words in a specific database, by highlighting with the mouse the word they want to look up then following a link to an administrator set online database (like Google Definition service or Dictionary.com) which will do the rest of the job.

Worthless to say that this plugin is based on JavaScript in almost 80%, the rest is a bit of PHP which hooks the Javascript code to the WordPress engine and a bit of CSS to style the plugin.

A few words about our coding style: we almost always minify the code made by us. This means that we run a code through a compressor software which strips the unnecessary white spaces and other characters. This applies to both Javascript and CSS. This is not meant to obfuscate the code, but to preserve the bandwidth.
It’s also good to know that we never use longwinded function names or variables. It’s likely that you will never see in code released by us function or variable names like:

function this_is_a_cool_function_used_for_nothing(){
}
/*or variable like*/
var this_is_a_useless_variable = '';

Instead, we use function and variable names like this:

function c_D(){
}
/*or variable like*/
var A = '';

The explanation for this habit is that long variable and function names only eats up unnecessary bandwidth, which we don’t like, and javascript understands both forms of declaration.

If you want to understand the functions we use, you may want to know that each function name is an abbreviation. For example the R_D() function is used for Rendering Defithis, the c() function is used for Centering the widget, aph() for fixing Alpha transparency in Internet Explorer, and so on.

So, as requested by Fernando Ramirez, here’s the unminified javascript code from Defithis. Unobfuscated version does not exist since we believe it’s not obfuscated. Follow this link to the script: http://devoracles.com/examples/defithis.js

If you need explanation regarding anything from within the code, feel free to ask. We listen and will answer.


Comments

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

If you want to use your OpenID, fill out the field labeled "Website" with the OpenID URL. The other fields may remain empty.
Note that comments are pre-moderated.

Subscribe without commenting





:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: More smilies »