dooza.tv
The online adventures of dooza
The online adventures of dooza
Dec 8th
This is the first bit of code that I have created that I think is good enough to share. I didn’t come up with this on my own, I drew inspiration from this blog post, and had some help from V1 over at the Adobe Spry Forum.
This simple bit of JavaScript will give your external links on your page an icon to indicate that you will be leaving the site. I previously would have done this using a CSS selector that targeted all links in a paragraph that had the target attribute set to “_blank”, but I wanted a fool-proof way of doing this without having to remember to set the target.
It works by manipulating the DOM using the Spry Dom Utils JS. It creates an observer that on page load adds the class called “external” to all links that are on a different domain.
To use it, just put this in your head section:
<script src="SpryAssets/SpryDOMUtils.js" type="text/javascript"></script> <script src="SpryAssets/SpryExternalLinkIcon.js" type="text/javascript"></script> <link href="SpryAssets/SpryExternalLinkIcon.css" rel="stylesheet" type="text/css" />
The first file is from the current Spry library.
The second is my custom code, and the third is a small bit of CSS.
This is SpryExternalLinkIcon.js:
function externalLinkIcon(){
Spry.$$("a").forEach(function(href) {
if( href.hostname != window.location.host ){
Spry.Utils.addClassName( href, 'external');}
});
}
Spry.Utils.addLoadListener(externalLinkIcon);
This is SpryExternalLinkIcon.css
.external {
background: url('external.png') 100% 60% no-repeat;
padding: 0 15px 0 0;
}
Now any link that is on a different domain will get assigned the class “external”, which in turns puts an external link icon at the end of it.
You can see what I have been talking about here: http://www.dooza.tv/spry/SpryExternalLinkIcon.html
You can download the files here: http://www.dooza.tv/spry/SpryExternalLinkIcon.zip
Using JavaScript to add this icon is progressive enhancement, the page doesn’t break, the link still works, but in browsers with JavaScript support you get the added functionality of an icon that helps the visitor recognise an external link. The visitor might want to open the link in another tab or window, knowing its an external link before having to click it will save time.
I would love to hear your opinions on this little bit of code that I have presented here. There aren’t many Spry tutorials or blogs about, which is a shame, its got potential.
Dec 6th
A little bit late posting this (whats new!) but this was my Mo for Movember on the last day of November. I raised £190 online, with another £15 collected in cash. I want to thank everyone for helping me raise this money for Prostate Cancer Charity, but mostly I want to thank my wife Louise for the support, and putting up with my Mo.
You can still donate to the cause, its not too late. Just pop along to my page over at Movember and give as much as you like.
Nov 22nd
Its now been a year since I replaced my Blogger powered blog with one powered by Wordpress. The transition was very easy, I didn’t lose any Google Juice and have now seen my traffic increase.
Wordpress as a platform is very easy to learn, and was much more flexible that Blogger. It has jumped in functionality with numerous new releases, more than I ever counted on. I had previously toyed with Joomla but it never worked the way I wanted it too, and was very frustrating.
To celebrate the year of use, I have changed template, and will be fine tuning it to my liking. One day I will make my own from scratch, but need more time to get my head around what is possible.
Nov 9th
This is a bit of an odd post, but sometimes you find something and just have to share it.
Most techies involved in lighting or computing are aware of the standard IEC power cable. Its a bit like what you have in kettles, but lower power, and is found everywhere. Your computer will have one, all my lights have one, my lighting desk has one. I have loads and loads of these IEC cables, you can never have enough, and most of the time they do the job perfectly, but sometimes you need one that is a little bit more secure.
The standard IEC power cable can be knocked out of its socket, or might just be a little loose. When this happens you might lose control over your lights, your computer might turn off and you lose what you were working on. Its these times that the IEC-Lock is worth having.
It is simple to use, as its just the same as a normal IEC power cable, but with one slight difference. It has a gripping mechanism on the earth pin. So when you plug it in, it holds on tight and won’t let go until you press the little red button on the plug. It is such a great idea, you can see the manufacturer’s website for more information on how it works and the patens.
If your intersted in buying less than 100 (thats what the manufacturer sells) then you might want to check out AC Entertainment Technologies (yeah I know, I work for them, so its a blatant plug) , they come in three versions: IEC-Lock to 13Amp, IEC-Lock to Schuko, and IEC-Lock to bare ends. The last one is good as you can fit to any plug you like, like a 16Amp CEE Form. I am surprised this one isn’t in the range already!
Nov 1st
I am growing a moustache this year for Movember. I have decided to put down my razor for one month (November) and help raise awareness and funds for men’s health – specifically prostate cancer.
What many people don’t appreciate is that one man dies every hour of prostate cancer in the UK, more than 35,000 men will be diagnosed this year and that prostate cancer is the most common cancer in men in the UK. Facts like these have convinced me I should get involved and I am hoping that you will support me.
To donate to my Mo, you can either:
• Click this link http://uk.movember.com/mospace/248012/ and donate online using your credit card, debit card or PayPal account
• Write a cheque payable to ‘The Prostate Cancer Charity – Movember’, referencing my Registration Number 248012 and mailing it to: Movember – The Prostate Cancer Charity, First Floor, Cambridge House, Cambridge Grove, London, W6 0LE.
Movember is now in its third year here in the UK and, to date, has achieved some pretty amazing results by working alongside The Prostate Cancer Charity. Check out further details at: http://uk.movemberfoundation.com/research-and-programs.
If you are interested in following the progress of my Mo, click here http://uk.movember.com/mospace/248012/. Also, http://uk.movember.com has heaps of useful information.
Thank you