be unique
header

Javascript Libraries

April 29th, 2007

2 Javascript libraries that I use all the time are: prototype and scriptaculous.

Prototype make things like ajax calls a breeze. Look at how easy it becomes:

var ajax = new Ajax.Request(url,{      
    
method: 'post',
     parameters: params,
     onLoading: function(){$('workingMsg').show()},
     onLoaded: $('workingMsg').hide()},1000)
    });

that’s it!. Here i’m posting an ajax call to the url (set in the variable url before this), posting the params (again set before). It will show the hidden div with the id of workingMsg while it is posting and hide it when its done. It will work in all browsers. Simple.

Also notice the following line:

$(’workingMsg’)

that alone is the same as the document.getElementById() and it works in all browsers as well. Save a lot of typing.

scriptaculous is a library of functions for javascript effect and neat things like letting you drag and drop to order items with a list. It uses the above protype library. (which is what turned me on to it in the first place).

Lets say you have a list, styled however you like, with the id of productlist. This is all you need write to turn it into a drag and drop ordering list.

Sortable.create(’productlist’,{scroll: window,scrollSpeed: 40,scrollSensitivity: 20});

I’ve used some options above to tell it to scroll the window when you try to drag and drop outside of what’s currently viewable. There all sorts of options and other great things you can do.

To wrap it all up, if you use Javascript and want to do neat Ajax and visual effects and you are not using the above two libraries, you need to start using them now.

 



Moving your web site

December 18th, 2006

People are often moving their web site from one server to another. A lot of times if this is not planned correctly it might not go as expected. So I thought I would share some tips.

  1. Make sure you have the full login to the domain’s registrar. Don’t take your clients word that they have it. Don’t assume they have it. Test it yourself before you even think about starting or scheduling the process.
  2. Copy files from one server to the other. If you are lucky they both have shell access and you can do a scp. (server to server copy, very fast). If you must, you have to use ftp.
  3. Copy over all databases.
  4. Change all configuration information in all scripts. Including: database connection information, paths etc..
  5. Make sure all paths that need to be set to special permissions. (usually upload paths need to be set to 777). If you are lucky and got to use scp, odds are the file permissions stayed.
  6. Make sure there are no absolute links to the domain (for example http://www.domain.com/). If found, change them to relative links. Reason is that during testing, you’ll click on these links and end up on the old server. You want make sure you are testing on the new server at all times.
  7. Start testing. Test everything. Make sure you use the new servers temporary address. Be sure to look at the URL as you test and make sure it stays at that address. If it changes to the domain name, you didn’t get rid of all absolute links in #5
  8. Make sure to set up all email accounts on the old server so they are exactly the same as the old server. IF you forget any, odds are this person will lose some email. (if you are just changing email or just the web site see blelow)
  9. Once you are sure everything is working, then and only then change the domain name’s nameserver. It will take up to 72 hrs for everything to move over, so make sure to tell your users to check both the new and old emails accounts untill after 72 hrs (usually you can give them a direct web address to access the email that doesn’t use the domain name.. check with the hosting companies)

IF you are just changing MX records. You only need to setup the email accounts.  If you are only changing the web site, just change the A names.