Posts Tagged ‘javascript’

Fighting with WebSockets

Monday, April 18th, 2011

Overview

A long, rambly and very geeky post without a proper ending about some of the challenges I recently had getting WebSockets to work with mobile Safari on the iPhone/iPad.

Background

I wrote last week about a recent project of mine – a proof-of-concept using a custom WebSockets server implementation to push messages to web apps.

A target platform for one of the demos that I wrote to go with this was the iPhone. But it wasn’t as straightforward as I’d hoped. And I’ve ranted enough about it to friends and colleagues and on twitter. About time that I did a bit of moaning here 😉

(more…)

Making YouTube (very slightly) more child-safe with a Firefox extension

Tuesday, November 16th, 2010

Kids stuff on YouTubeOur six year old daughter, Grace, has lost interest in kids TV recently – she’s discovered the joys of YouTube!

She can happily spend a half-hour sat in front of the TV on Firefox (our TV set-up is a Linux-based media centre, so it’s proper Firefox with a keyboard and mouse) clicking from video to video.

I’m fine with this. It’s good: she’s getting more familiar with how to use a web browser, getting used to starting the browser, typing “youtube” into the address bar, using the search box to search for what she wants, using the ‘Back’ button to go back to the search results if it’s not what she wanted, and so on. This is all good stuff, let alone the fact that there is a lot of content on YouTube that is actually ideal for kids.

But…

Well, she’s six. Not every video on YouTube is suitable for her. I’m not just talking about the stuff for over-18s. I don’t even want her to come across stuff with, for example, more swearing and violence – such as stuff that you might be happy to show a 12 year old.

The real solution to this is what we do now – she’s doing this in the sitting room on the TV, while we’re in the room watching stuff with her. I’m not saying I want to give her a laptop, send her up to her room, and say “here’s YouTube – off you go, have fun!”.

Even so, I wanted something to help out a little.

(more…)

Making the RTM cow more sympathetic

Tuesday, June 15th, 2010

I am a big fan of Remember The Milk (RTM), the online to-do list manager. It’s one of the few sites (like flickr) that I’m happy to pay for.

For some reason, the logo for RTM is a cow’s face. Which means that I get a cow staring at me when I’m deciding what I need to do next.

I had a random thought this evening – that the cow should really look more sympathetic when my task list is so full. Because he’s really quite heartless, even when I’m manically busy. 😉

And once I had the idea, I kinda had to give it a quick try. (And I wonder why I’m busy…)

So I’ve knocked up a quick Greasemonkey script – which should work with Firefox with the Greasemonkey add-on, or with Google Chrome.

rememberthemilkcow.user.js

(more…)

Capturing page loaded events from a Firefox extension

Sunday, April 6th, 2008

One of my hacks at Over The Air was an attempt to sync browser histories between desktop and mobile. A part of this was a Firefox extension which listens for when I go to a new webpage, gets the URL from the Firefox address bar and sends it to a connected mobile.

As my first attempt at a Firefox extension, I was surprised by how easy this was. I’ve made it, so if anyone wants to learn or build on it, downloading the source may be useful. (Remembering it was thrown together in a bit of a hurry!) But I wanted to highlight a couple of quick points.

Firstly – getting started. Owen pointed me at a brilliant Firefox extension wizard. Fill in the simple form – telling it stuff like whether you want to add an options dialog and preferences, or a context menu item, or a toolbar button, and so on. And it generates you a skeleton Firefox extension ready for you to fill in with code. This probably saved me an hour or two of reading about how to create Firefox extensions!

Secondly – capturing new pages. This was done by adding a listener for DOMContentLoaded events:

var appcontent = window.document.getElementById("appcontent");
appcontent.addEventListener("DOMContentLoaded", 
                            myContentLoadedFunction, 
                            false);

And in my content loaded function, I got the URL like this:

var urlbar = document.getElementById('urlbar');