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.
Post a Comment