Skip to content

Last night I became a jQuery fan

You know how it’s like. You start to use a javascript library and you tend to stick with it. I’ve been drifting between Prototype.js and Moo. I’ve looked at jQuery but stuck to Prototype/Moo since I “knew it”.

Last night I decided to rewrite my old check for new ImageManager version routine. Being a script junkie, I thought I give jQuery a chance. It was a joy .. I really like jQuery!

BTW, here’s the result:

<pre><script type="text/javascript">
/**
* @desc ImageManager check for new version script
* @author Per Soderlind - soderlind.no
*/
jQuery(document).ready(function() {
    jQuery.get('http://soderlind.no/imagemanagerversion.txt', function(newversion){
        if (251 < newversion) { // 251 is the version number for the installed plugin, I set number this using PHP
            jQuery('#plugins td.name').filter(':contains(ImageManager)').append('<small>new version available').css('color','red');
        }
    });
});
</script></pre>

Explained:

jQuery(document).ready(function() {
Wait until the DOM is loaded
jQuery.get(‘http://soderlind.no/imagemanagerversion.txt’, function(newversion){
Get http://soderlind.no/imagemanagerversion.txt, and put its content into the variable newversion
jQuery(‘#plugins td.name’).filter(‘:contains(ImageManager)’).append(‘<small>new version available</small>’).css(‘color’,'red’);
In the <div id=plugins>, find <td class=name> which contains the text ImageManager
and append <small>new version available</small>. Using css, set the text color to red.

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*

@soderlind on Twitter:

Powered by Twitter Tools

Rodney's 404 Handler Plugin plugged in.