Jquery Tutorial – Animated Callbacks

Whilst working on my content manager I wanted to create a way to show a user if an action had been successful or not. This tutorial will show you how you can quickly and easily implement success callbacks on your own web projects. The code is very versatile and lightweight, its literally just a couple of lines of Jquery, and it gives an awesome effect. To see the code in action check out the demo.

What You Need

to start you will need a copy of the jQuery library which you can download from the jQuery website. if you aren’t familiar with jQuery check out the documentation for a full brief.

The HTML

To begin we want to create a page. we will call it callback.php put the following code into the page:

<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="callback.js"></script>
<style type="text/css">
body {
	font-family:helvetica;
}
#success {
	background-color:#BDD994;
	border:1px solid #85C329;
	color:#587506;
	display:block;
	font-weight:bold;
	padding:5px;
	text-align:center;
}
#failure {
	background-color:#F04848;
	border:1px solid #C40E0D;
	color:#B01212;
	display:block;
	font-weight:bold;
	padding:5px;
	text-align:center;
}
</style>
</head>
<body>
<?php if($_GET['success'] == true) {?> <div id="success">Successfully done something</div> <?php }?>
<?php if($_GET['failure'] == true) {?> <div id="failure">Failed to do something</div> <?php }?>
</body>
</html>

All we are doing here is attaching a copy of the query library and another javascript file, I will explain shortly. Then we add some styling information (ideally you want to put this into a separate css file).

Further down the page we then have a couple of lines of PHP, all these are very similar, all they are doing is checking is a $_GET parameter is being passed through, either with a value of ?success=true, or of ?failure=true if the parameter is passed through then a dive will be displayed. Of course if nothing is displayed the page will be blank.

The Jquery Code

If we send through one of the specified get parameters, we only want to display the div with the message for a short period of time, then have it disappear again. This is where the jQueys animate() function comes into it own. Create a new js file, call it callback.js then insert the following code.

$(function() {
//show sucess message then fade out
$('#success').animate({ opacity: 1 }, 2000 ).animate({ opacity: 0.0 }, 2000 ).slideUp('fast');
//show failure message then fade out
$('#failure').animate({ opacity: 1 }, 2000 ).animate({ opacity: 0.0 }, 2000 ).slideUp('fast');
});

The code starts with an on load function, then we specify the div we are talking about either “#success” or “#failure“. we then fade the div slowly, then slide up the div.

That’s all their is to it. If you wanna see the code in action check out the demo, or download the sourcecode. Happy coding!


Create Your Own Sound Stream With PHP

If you have looked at my site recently you will see I have added a new feature into the footer. Its something I have nick named “Soundstream“. Basically its a progression on the idea of a twitter feed. But instead of using twitter, it uses XML feeds from Last.fm to create a list of the last 4 tracks I listened to. In this tutorial I will show you how I have created it, and just how easy it is to create one for yourself.

What You Need

In Order to build this you will need a server which runs PHP5, and a last.fm account. If you have not got one you can create an account for free. I personally recommend you do, as its a brilliant way to listen to your favorite music for free.

The RSS Feed

In order for our code to work, first of all we need to get a feed. There are a couple of ways we can do this. The first is using JSON to make a request to the Last.fm API to collect and display the information. However this is a slow way to do business, and and some API’s such as twitter will only allow you to make a certain number of requests per hour. Which is no good if you site is visited by a lot of people.

The second option is to get an XML RSS feed of all your latest tracks, this can then be parsed and used to display all your track info. This is my preferred option as it is much quicker and puts less load in the page, plus all the parsing can be done server side, which will cause browser bugs to be none existent.

In order to get The RSS feed you must talk to last.fm. You are permitted to pass certain parameters after the URL depending on the information you wish to get back. Here is an example.

http://ws.audioscrobbler.com/1.0/user/limitless86/recenttracks.xml?limit=2

here you can see the URL points to audioscrobbler, then passes a couple of directories, then you get to my username ‘limitless86′ then at the end I specify a limit of 2 tracks that I want to have returned. Hey presto the XML I get back looks something like this.

<pre id="line1"><span class="pi"><?xml version="1.0" encoding="UTF-8"?></span>
<<span class="start-tag">recenttracks</span><span class="attribute-name"> user</span>=<span class="attribute-value">"limitless86"</span>>
<<span class="start-tag">track</span><span class="attribute-name"> streamable</span>=<span class="attribute-value">"true"</span>>
<<span class="start-tag">artist</span><span class="attribute-name"> mbid</span>=<span class="attribute-value">"c33c2065-b1c3-4406-b066-d33a9e2ea71a"</span>>OneRepublic</<span class="end-tag">artist</span>>
<<span class="start-tag">name</span>>Someone To Save You</<span class="end-tag">name</span>>
<<span class="start-tag">mbid</span>></<span class="end-tag">mbid</span>>
<<span class="start-tag">album</span><span class="attribute-name"> mbid</span>=<span class="attribute-value">""</span>>Dreaming Out Loud</<span class="end-tag">album</span>>
<<span class="start-tag">url</span>>http://www.last.fm/music/OneRepublic/_/Someone+To+Save+You</<span class="end-tag">url</span>></pre>
<pre id="line9">                <<span class="start-tag">date</span><span class="attribute-name"> uts</span>=<span class="attribute-value">"1231262615"</span>>6 Jan 2009, 17:23</<span class="end-tag">date</span>>
</<span class="end-tag">track</span>>
<<span class="start-tag">track</span><span class="attribute-name"> streamable</span>=<span class="attribute-value">"true"</span>>
<<span class="start-tag">artist</span><span class="attribute-name"> mbid</span>=<span class="attribute-value">"516cef4d-0718-4007-9939-f9b38af3f784"</span>>Fall Out Boy</<span class="end-tag">artist</span>>
<<span class="start-tag">name</span>>Thnks Fr Th Mmrs</<span class="end-tag">name</span>>
<<span class="start-tag">mbid</span>></<span class="end-tag">mbid</span>>
<<span class="start-tag">album</span><span class="attribute-name"> mbid</span>=<span class="attribute-value">""</span>>Infinity On High</<span class="end-tag">album</span>>
<<span class="start-tag">url</span>>http://www.last.fm/music/Fall+Out+Boy/_/Thnks+Fr+Th+Mmrs</<span class="end-tag">url</span>></pre>
<pre id="line17">                <<span class="start-tag">date</span><span class="attribute-name"> uts</span>=<span class="attribute-value">"1231262409"</span>>6 Jan 2009, 17:20</<span class="end-tag">date</span>>
</<span class="end-tag">track</span>>
</<span class="end-tag">recenttracks</span>></pre>

For a full view of the different types of request you want to do check out the API.

The Code

So now you get the principle lets create a new page, name it soundStream.php. Inside this file we want to write the following code;

<html>
<head></head>
<body>
<h2>Soundstream</h2>
<?php
//get XML feed and assign
$LastFeed = new SimpleXMLElement("http://ws.audioscrobbler.com/1.0/user/limitless86/recenttracks.xml?limit=10", NULL, true);
//loop through XML and display track name and artists
foreach ($LastFeed->track as $LastTrackInfo) {
echo '<div class="SoundStream"><span class="artistName">' . $LastTrackInfo->artist[0] . '</span><span class="TrackName"><i>'. $LastTrackInfo->name[0] . '</i></span></div>';
}
?>
</body>
</html>

First we break into PHP and assign a new variable called $lastFeed and use PHP5′s SimpleXMLElement() to get the XML feed out. You will of course need to change the limit and your username to suit your own needs.

Once we have the XML feed assigned we want to loop through the returned results. What better way to do this than to use a foreach loop, which simply iterates over the returned XML array and puts the artists name and into the artistName span and the track name into the TrackName span. This is all wrapped in an echo statement which will put the spans onto the page, allowing you to style the output as you see fit.

That’s All Folks

That really is all their is to it. If you want to see the code in action check out the footer of this page, or better still look at this demo page. If your feeling adventurous why not try amalgamating your twitter and last.fm feeds into 1, to create a lifestream.


Tips On Logo Design

I recently decided to re-design my website logo. Its part of a long term plan to go freelance on the side. But before I could go ahead and design the business cards, create the headed paper and ultimately spend a lot of money I needed to be 100% satisfied with the way I represent myself. This isn’t a definitive guide, I don’t claim to be a guru. I’m just sharing my experience and things I have learned along the way.

Before You Begin

Before firing up photoshop, or doodling sketches, I had a long hard think about what I wanted “The Odin” to be. This sounds obvious, I mean I design and develop websites,  but its really something you should take your time over. This is important because how the logo looks will set the theme for what your company or site is about. I knew I wanted something subtle and understated, but at the same time it needed to be sophisticated enough to show any potential clients I mean business and I know what Im doing. Once your comfortable with what you want your direction to be, you should start think about the logo.

Get Some Inspiration

Logo inspiration

Before I got too far down the line, I looked at what the big boys were doing, and what made them stand out, I took examples from logos I liked, such as carsonified, FUEL and my personal favorite Function. They all have distinctive designed logos and their is a lot to be said for observation. I find this practice extremely useful and until you have completely deconstructed something, you cannot fully understand and appreciate it.

Its All About The Typography

typography

There are a million things you can do with typography, there are entire sites and blog rolls dedicated to this art form, If you want some inspiration check out typographica and i love typography. The key to having a unique logo, is to think about the way the letters in your logo fit together, Certain letters do this, veryy well, try to explore the possibilities, with letter spacing and line kerning. There are a few places you can go to get great fonts, fontcubes is a brilliant resource, da font is another, both of which offer you a massive range of free fonts to download and use.

The logo I have used started with a simple font, which I modified, in to what became the final product. But the only real way to achieve this is by trial and error, use a lot of fonts and try everything, you may come up with something you love by the chance of putting together something you would not have expected to work. I wont lie, this can be a long and arduous process, but it will present you with results, you just have to stick at it.

To Suffix Or Not To Suffix

This was a question I spend a lot of time researching. It became somewhat clear to me however that most online companies these days have dropped the .com or .co.uk or whatever the suffix may be. Although there are many reasons for this, I personally believe that its down to the very way people search the Internet, its no longer about memorable URL’s in the taxonomy of web its about tagging, and searching and SEO and all those things which make your website so much easier to find, For that reason I left out the suffix as a bold move towards the future.

Trial Is Not An Error

I have a saying that I often use in the face of defeat, and although sometimes I question it myself. I always stick to it. “failure is the long way round to success”. I went through numerous attempts at designs before I got close to any that I thought were worth pursuing as you can see; but sticking with it did pay off,

Use Illustrator

I must admit I myself am guilty of creating everything in photoshop, but its especially important when you are designing logos, to use a vector based program such as Adobe Illustrator for the final product. It will make the design look much cleaner and will save you all sorts of hassle when you come to re-size the design for different media.

The Final Product

Probably one of the most important, if not the most important tips I can give, is to get feedback. It may not always be what you want to hear, and so don’t take it to heart, but if you listen to what people are telling you, and act upon their advise, you may well end up with something that looks even better. On that note I would like to present you with my final design, and call upon anyone reading this, to leave their feedback and suggestions, so that The Odin can move forward and grow from this experience.


Create Your Own Online Company

I have finally decided to take the plunge and get The Odin registered as an official company. Whats supervised me most about the experience is just how easy it has been to take action. I the inland revenue were surprisingly helpful, giving great advice. The formation of the company was also an easy step to achieve. I looked high and low for a website which looked vaguely trust worthy, only to decide that I would stick with switch media the same company I set up my domain name with.

Of course It is not as simple as just registering and paying. Having your own company comes with its responsibilities. I have put my experience into a guide which you may find useful if you are thinking of embarking on a similar endeavor.

Getting Ready

Before you get too far into the process you want to make sure that you are ready to make the phone call You will be asked when you want to declare yourself self employed. This is the important bit, you will be asked if you wish to make yourself self employed, or a company that you own. So make sure that you have decided what you want, to do. If its a company you will need to get the company formed before you make the phone call. The HMRC will ask for a month and take it from the start of that month. So make sure you know when that Is, to save yourself panicking. Its worth noting that you do not need to declare yourself self employed until after you are working, but this must be done within the first 3 months of working for yourself.

Form the Company

Now that the ground work is complete you are all set to form your company. All this really means is you will have the legal documentation to create your business, meaning you will be a recognised company with a VAT number as so on. It doesn’t matter if you have no premises at this point. But you will be able to fill this out later on. there are a lot of companies out there which will offer this service. I have only tried switch media. The process may take a couple of days to complete although if your in a hurry you can pay more to have things speeded up.

Office Equipment

When you first start out, the temptation is go buy buy buy. But be reasonable, if you don’t absolutely need it, don’t go out and buy it. you will save yourself a lot of money this way, only treat yourself when you are reaping the rewards for your hard work.

Business Cards

This is another none essential requirement, especially if you have not settled on a logo or other such important issues. However if you feel you need them, check out moo.com for a cheap solution.

Logo

This is another none essential part of the setup, as long as you are decided on the name, the rest is not as important.this is something you can think about when your building the website.

Website

To start with if you don’t already this is something which can be setup very easily, all you will need is a domain and hosting, Its up to you how your build your site, there are a lot of solutions out there, one of the best is wordpress which is a blogging tool which is very easy to install and you can even get free hotsing.

Create A Paper Trail

The best way to account for your transactions is to buy yourself a receipt and an Invoice book. Make sure you keep receipts of everything work related. Buy a folder to put things in, I found it easiest to keep reciepts by month, but its up to you how you choose to organize yourself. Receipts should include the amount you paid/earned without tax and the VAT amount. This will make life easier if you need to check anything at a later date.

Use a spread Sheet

Although creating a paper trail is important I cannot stress how useful setting up a spreadsheet will be. I would go as far as saying it is essential if you want to run your business properly. It will also save you the headaches in April when the end of the financial year creeps round and you need to fill out your tax return.

If you don’t have any spreadsheet software you can use google docs for free. It does everything you need it to and there is lots of documentation to help you. I set up 2 documents,

  1. profit and loss sheet
  2. Taxable Income sheet.

The first helps you see your income and your outgoings this will tell you if you are making any money or loosing it, very useful whatever your circumstance. The second will help you keep track of your tax to date. i tend to do this from 1 financial year to the next, April – April, it just makes life a lot easier. The spreadsheets format looks something like this:

Profit and loss:

Taxable Income:


Aside from this you are pretty much ready to rock and roll. Running a business can be tricky. The key is devotion. Look after your business and your business will look after you.


The Plight Of Online Business

I read a well written article on warspire, which described the way new start up businesses are struggling to stay afloat due to a rise in the ridiculous business models, which have had no thought put into them and always run at a loss.

I did a bit of research into this and to my shock, I realized a lot of the ‘big’ companies out there, such as youTube, Facebook, twitter and so on, may be doing very well as online applications, with a strong user base, however in terms of actual profit, well.. there is none. It seems to me that the business model has become, the notion of setting up a new innovative product, pushing it out there, then praying to God that Google decides to buy you out.

Even when this happens it still may mean that that business will not be a success. Take YouTube for example, even though it has been bought out by Google, it still doesn’t turn a profit. Its a lost leader in that respect. Its not really a surprise when you consider the massive costs incurred in buying and running the servers, plus the cost of employees to keep everything ticking over. The statistics truly are shocking to look at.

This isn’t to say there is no profit to be made. If you are clever about the kind of business you setup, take for example paypal, or google checkout with very small running costs, then you can make money. But the dot com boom is and the term easy money, is a thing of the distant past, maybe the web businesses of tomorrow will learn from the mistakes being made today.


PlayStation Home, First look

I Was extremely excited last night when I sat down to play Warhawk only to notice something was very different, above the PlayStation store icon was something new, something I have been waiting for, for a very long time. It was of course PS3′s release of home (beta). I say beta because it really is beta, not like googles idea, of beta where everything works perfectly. There are glitches, and you should expect to find problems. But overall Home is a very accomplished online world, which I have to say, blew me away.

Graphics

Graphically PS3′s home is outstanding. They really have taken full advantage of the graphics engine, and it shows. More than this the attention to detail is incredible. I must have spent 40 mins going through all the settings for my avatar, making home look just the way I wanted. The customization here is amazing, you can adjust almost everything from the size of your mouth, to the depth of your brow. Of course we all knew that home was going to need to make revenue, so the lack of clothing is not real surprise, however saying that if you got the cash you can already buy an ever increasing number of threads.

Social Life

Of course home is all about The social networking side of things. There are a multitude of places you can go to meet people, from the shopping mall, to the square, all of which are set in rich atmospheric environments, where there is a wealth of things to do and people to meet.

Interaction

The way in which you interact has also had a lot of time put into it. The usability of home is impeccable, by Using emotions, you can convey a range of feelings at the touch of a button. This is fun, although if you want a proper chat you may find it useful to have a keyboard. I don’t currently own one, but after playing Home I will definitely consider getting a USB one.

Summary

There are a range more features that home has to offer, from your own personal pad, to going to a friends villa, the world of home is ever expanding, and definitely something you should indulge in if you are a PS3 Owner, I promise you will not be disappointed.