Giu
14
Posted on 14-06-2008
Filed Under (ajax, javascript, sviluppo, test, tool, validazione, web 2.0) by Mat on 14-06-2008

JSLint is probably the most powerful Javascript online syntax checker. It finds errors you have never thinked they could be exist. In fact the author gives you a warning: JSLint will hurt your feelings. It’s damn true, but it’s also a js tool you can’t live without more.
Just paste your code and push JSLint button, you’ll get all errors, warnings, and a detailed list of your variables and functions. You can customize your inspection, disabling some unwanted checks, just read the documentation. Inspection is all client-side (of course made with javascript), so don’t worry about your code privacy.

(0) Comments    Read More   
Feb
04
Posted on 04-02-2008
Filed Under (ajax, css, hack, javascript, validazione) by Mat on 04-02-2008

19/7/2008 UPDATE
The code isn’t valid anymore. Read the comments.

In Thickbox css code there are some hacks that doesn’t validate the code (only css, rather xhtml is valid).
Invalid code is javascript inline css document. So, I changed invalid code with a js function call. Take an example:

* html #TB_overlay { /* ie6 hack */
position: absolute;
/*height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + ‘px’); NOT VALID*/
height: expression(fixHeight(document.body.scrollHeight, document.body.offsetHeight)); //VALID
}* html #TB_window { /* ie6 hack */
position: absolute;
/* margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + ‘px’); NOT VALID */
margin-top:expression(fixMarginTop(this.offsetHeight,document.documentElement,document.body.scrollTop)); //VALID
}

So substitute expression inline in css file with calls to fuctions externally defined, and load the following file whenever you’re using thickbox in your site:

expressions.js:

function fixHeight(scrollHeight, offsetHeight)
{
return (scrollHeight > offsetHeight ? scrollHeight : offsetHeight + ‘px’);
}
function fixMarginTop(offsetHeight,documentElement,scrollTop)
{
return (0 - parseInt(offsetHeight / 2) + (TBWindowMargin = documentElement && documentElement.scrollTop || scrollTop) + ‘px’);
}

To use Thickbox now you need these loadings:

<script src="/lib/thickbox/jquery.js" type="text/javascript"></script>
<script src="/lib/thickbox/thickbox.js" type="text/javascript"></script>
<script src="/lib/thickbox/expressions.js" type="text/javascript"></script>
<style type="text/css"> @import "/lib/thickbox/thickbox.css"; </style>

Download Thickbox 3.1 editated sources:
thickbox.css (editated)
expressions.js (added)

(13) Comments    Read More