I’ve always seen it done. Clearing the input field on focus.

JQuery seems to be pretty simple. Its just the syntax you have to get used to.

First the html markup

Sign up

Notice that for each input field I have an id, name, and alt attribute

Next integrating JQuery


Notice that I’m using googleapis to host the javascript. It seems that this is a better/faster alternative to hosting it directly on your host, plus google servers are most likely cached and will provide a better experience for the client.

Next building the JQuery plugin

		$.fn.clearSetFocus = function(iAttr)
		{
		}

We’re gonna create a namespace for ourselves. In my case, I named my function clearSetFocus. The $ creates a new JQuery object. you could also use jQuery(). So, I’ve created a new function named clearSetFocus and I’m taking in one parameter, called iAttr.

To actually attach this plugin to an element all I have to do is to call it.

Calling the plugin

$(document).ready(function(){
			$('#newsName').clearSetFocus('alt');
			$('#newsEmail').clearSetFocus('alt');
		});

Notice that I call the document.ready function before I add my plugin to the elements. I’ve found that if I don’t do that then the js could execute before the elements are loaded and make the script fail. So what I’ve done is create a new jQuery object for the element #newsName and attached the plugin clearSetFocus with the parameter alt.

Back to writing the plugin.

The plugin

//name my function clearSetFocus
		$.fn.clearSetFocus = function(iAttr)
		{
			//on focus
			this.focus(function()
			{
				if ($(this).val() == $(this).attr(iAttr))
				{
					$(this).val("");
				}
				
			//on blur - chained functionality	
			}).blur(function()
			{
				//get the value currently in the input
				if($(this).val().length==0)
				{
					//replace the value with the alt value
					$(this).val($(this).attr(iAttr));
				}
			});
		};

The this refers to my element that I’ve attached the plugin to. so in this case the element #newsName. I attach the function focus() – which allows me to add a function to when the user focus’ on the element. In this case, my logic is simply, if my value is the same as my alt value, then clear it. on blur() – which means to navigate away from the element, my logic is if the value’s length is 0, but the alt value back in.

Couple things to note.
.val() – this allows me to either get the value associated with the element
.val(“test”) – allows me to set the value of the element
.attr(“id”) – allows me to retrieve the value of the attribute of the element. so if the markup was

, I would get test

All done!

Vtiger is a great open source Customer Relations Management System (CRM). Its built in PHP, MySQL and does almost everything.

For some reason when I install vTiger, I always have to correct the file permissions. So here is a file to help streamline that process.

take this code and create a new file, call it .xshmod and copy this into the file. then run it using ./xshmod

# script to chmod all the vtiger files
# must exist in the root of the vtiger install

chmod 777 config.inc.php
chmod 777 tabdata.php
chmod 777 install.php
chmod 777 parent_tabdata.php
chmod 777 cache/
chmod 777 cache/images/
chmod 777 cache/import/
chmod 777 storage/
chmod 777 install/
chmod 777 user_privileges/
chmod 777 Smarty/cache/
chmod 777 Smarty/templates_c/
chmod 777 modules/Emails/templates/
chmod 777 modules/
chmod 777 cron/modules/
chmod 777 test/vtlib/
chmod 777 backup/
chmod 777 Smarty/templates/modules/
chmod 777 test/wordtemplatedownload/
chmod 777 test/product/
chmod 777 test/user/
chmod 777 test/contact
chmod 777 test/logo
chmod 777 logs/
chmod 777 modules/Webmails/tmp/

Problem
While working on a project, I had left my computer on to go grab some dinner and when I came back, I attempted to use the Rectangular Marquee Tool, but all I could see was a hand. I tried switching tools, for some reason I was still able to lay down guides, but I couldn’t move them, closing/re-opening the file, restarting the application, and then I finally searched online and found the solution.

Solution
Try changing the workspace from the Window menu. I changed it to “Essential” and that brought back all my functionality

Disney Photopass Logo

So its summer and you went to disneyland, you got a few pictures taken by the Disney folk, they sent you an email with a link to DisneyPhotoPass where you can view your pictures. Well this hack will help you retrieve that picture. Its gonna be low resolution, but hey a picture is better than no picture.

Each picture has an unique id, its a long sequence of numbers and letters and what Disney tries to do is to obfuscate it so that its very difficult to get to. Off of the preview, there is no right click functionality, so you have to be creative.

The hard part is getting the image id. I’ve already took the liberty of finding you the link to get the image, so all you need to do is fill in the image id.

1. Make sure your using firefox 3.x, if your not go download it here
2. Your gonna install a plugin/add-on called Firebug, you can get it here
3. Goto the first page where you see your first picture, goto Firefox > Tools > Firebug > Open Firebug
4. From there you will see this complicated mess of data, what we will be looking for is under the “DOM” tab.
5. From there go all the way down to where it says “PhotoInfo” on the left hand side directly across from it you will see “ObjectImageId” – That is the magic key to each individual image.
6. Copy that and open a new window and use this url:

http://www.disneyphotopass.com/API/photostore/previewEdits.pix?ImageID=

alternate url:

http://www.disneyphotopass.com/API/photostore/Getlowresimage.pix?ImageID=

7. Paste the id at the end of this string. so your resulting URL should look something like:

http://www.disneyphotopass.com/API/photostore/previewEdits.pix?ImageID=c21a90dc-6415-43a2-96e1-e8940eb71f16