Open Source


22
Jun 08

JQuery and WordPress

Update: New Post – A better way to use jQuery in WordPress Themes

I was making a new template for my site. I was originally going to make it all curvy and web 2.0… but I figured, since I am not the best at the visual design of things I went with this. I like it.

While I was making it, I was looking at using jQuery to do the curvy web 2.0 things. Now, if you have not used jQuery before, you should check it out, it is simple and there are a million plugins for it. There is one for corners (which I was going to use), there is a lightbox one, so on and so forth. It is also really small, the version included with the latest wordpress install is 1.2.3 which is about 30 KB. The latest version is 1.2.6.

Since I was not going to make it all curvy I decided to add an easter egg to my blog using jQuery.

At first I kept getting the error:

Error: $ is not a function
Source File: http://localhost/blog/
Line: 22

That is apparently because WordPress uses a lot of different javascript libraries and apparently they have done a bit of rewritting. instead of using the $(“”) to start your jQuery javascript, you use jQuery(“”). This took a bit of searching and testing to find out, but in the end I got that figured out. It was then on to the code to make the easter egg work. Here it is:

jQuery(document).ready(function(){
 jQuery("h4").click(function(){
  jQuery(this).fadeOut("fast", function() {
      jQuery(this).html("π").fadeIn("fast");
      });
  });
});

Step by step:
1 -> Load this when the page loads
2 -> Whenever a h4 is clicked (there is only one here so its fine to do it this way)
3 -> Fade out what we clicked on fast
4 -> fade in pi

Nice and easy (and it looks cool too). This could be put to much more practical uses like translations or possibly a slide show of images (fadeIn pause fadeOut, fadeIn next image). For now it will just be a small easter egg that I added to my site.

Oh, and apparently the google syntax highliter has decided not to work in this version of wordpress so, I am now using wp-syntax instead.

Oh ya… and you have to have these lines in your code before you call any of the jQuery functions.

<script src="./wp-includes/js/jquery/jquery.js" type="text/javascript"></script>
<script src="./wp-includes/js/jquery/jquery.corner.js" type="text/javascript"><!--mce:1--></script>

(PI is an inside-ish joke by the way)

Edit: You do not need the jquery.corner.js part… unless you want fancy corners.. you would also have to download it too… if not you will get an error.

Ok, I think there is a bug somewhere, if you click through using the page links, and do a search the pi thing will work. If you rely on the cache (go to the same page by clicking on the title link of a post/page) it does not work at all. (At least in FF3)


23
Mar 08

Why I won’t use Kubuntu (or KDE for that matter)

It is pretty and all, I will give it that. It tries so hard to please the eye that it would be easy to overlook its shortcomings. Alas, I cannot.

First of all, it tries so hard to look like the Windows interface, or at least the bastard offspring of Windows and OS X now with KDE 4 (not that it looks bad). This is where the problem is. It looks like it but when you expect it to act like it (or at least somewhat similar) it doesn’t.

For example, when you have Windows XP installed and you go get yourself a nice media keyboard it allows you to control the Volume, open up programs, put your computer to sleep if you accidentally hit that button and so on. It is very handy. The same thing goes for using it in Gnome which does not even try to resemble a Windows desktop. It is nice to not have to set up hotkeys to do this, or have to use your mouse to change the volume, you can just move your hand up (try to avoid hitting the sleep button) and turn up/down/off the volume, open a calculator or perhaps even an email program. There is probably a way to set it up in the kde control panel, but you should not have to these days it should be detected that it is sending the volume up command (I would even settle for something that noticed that you had attached a media keyboard and asked you if you wanted to set it up). I guess what annoyed me most was that I installed it along side my Ubuntu install which just recognized my media keyboard and I figured that it would do the same in KDE installed over a Ubuntu backend.

Another thing is the single click on an icon to open it up. That is just annoying, it may be more efficient, but if you don’t expect it (coming from OS X, Gnome or Windows you might not) it is one of the most annoying difficult to get used to default behaviours  that there is (aside from not picking up multimedia keyboards).


16
Mar 08

Changing the startup programs in Ubuntu

To do this, all you have to do is go to

System->Preferences->Sessions

You will get a window like this:

Sessions

Then all you have to do is click Add, Edit or Remove to make the changes you want to make.

I am sure this is similar in most forms of the Gnome desktop in Linux.


28
Feb 08

Disabling Autoplay in Gnome

Well, recently I bought a dvd drive for my computer which runs Ubuntu (and Windows XP).  It is kind of annoying that every time that I inserted a dvd or a cd it automagically ran the movie in Totem,which is not a program that I really like, I prefer SMplayer. Anyway, you can stop the drives from autoplaying by going to:

System -> Preferences -> Removable Drives and Media in the Multimedia tab you can either deselect every option, or you can set them to auto-run with a different player if you prefer.

Additionally, if you have an external drive it will automagically mount and then you get to browse it right away without asking for it to happen. I found this feature to be extremely annoying in Windows, and I still found it annoying here, anyway, you can disable that too. Under the Storage tab and you can uncheck Browse removable media when inserted.


12
Nov 07

The don’t mess with it files 1

I was playing around with the settings in the CompizConfig Settings Manager today to see what was there. Who could resist all of the buttons? (Hint: Not me) Apparently I mucked something up pretty bad, because my cursor was disappearing randomly. It was still there, I could see it hovering over links and buttons, but it was invisible. Kind of annoying. So I decided that it was Compiz’ fault, and messed around with more settings (I think I changed this one before, maybe it should be this! No… the cursor is still disappearing crap…). Finally I decided to reset all of the settings to default and rebooted the computer (old habits die hard). That worked. So I started messing with the Compiz settings again. So far I still have a cursor. Maybe I should quit while I am ahead… (I think I may have just lost the mouse again)…

Anyway, here is some eyecandy for you mac fanboys/girls…

ADD HelperNegative

coverflowNegative Window only

Taskbar window previewShow desktop

Multi desktop view