Browser frustrations

Earlier on I was writing some code that inserted some text into a textarea on a webpage. After the text has been inserted I needed the cursor to be at the end of the textarea so that the user could then type more text in afterwards without any messing around.

I thought it would be a simple matter, but it turned out to be quite frustrating.

Needed for all
var t = document.getElementById('add-comment');

Gecko (Firefox, Mozilla, etc.)
t.focus();

Webkit (Chrome, Safari, etc.)
t.selectionStart(t.value.length);
t.selectionEnd(t.value.length);

Internet Explorer
t.setSelectionRange(t.value.length, t.value.length);
t.focus();

Is there some standard way of doing this that I’m unaware of? I think jQuery would be overkill for this one purpose.

Drinks, bad news, movies, Android apps

On Saturday night Cheryl and I went out with Holly and then Len met up with us in The Social. We had a bunch of drinks and ended up spending the whole night in there, leaving at about 2 in the morning. It was a really fun evening, and I was very tired by the end of it.

I got woken up by Cheryl at about 5 in the morning because she’d just had some really bad news about her uncle back in Singapore. 🙁 After a bit more sleep I commenced operation Cheer Up Cheryl. I made some American-style pancakes with chocolate chips in. Then I fell back to sleep again while Cheryl was speaking to her mum on the phone.

After 4pm we headed to town to the cinema to watch The Karate Kid. It was a good film. Jaden Smith is a pretty good actor and is somewhat like his dad at times, which is quite a compliment, I think. The name of the film doesn’t really fit any more since the entire thing is about Kung Fu, but oh well. Jackie Chan is always appreciated in any movie. 🙂

After the movie we went to Tamatanga where I discovered that they don’t know how to use capital letters on their menu (is that really stylish?). The food was nice enough, but we couldn’t take what we left because we were heading back to the cinema to watch Knight and Day. We had a bit of time to kill so we played on the IT Box again. We’re beginning to dominate the score board for Word Up. 🙂

I had very low expectations for the film, but I was quite pleasantly surprised by how not-shit it was. There were enough funny moments to make it light-hearted, and enough action to keep anyone interested. It was a bit like a Jason Bourne comedy, starring an crazy midget and Cameron Diaz. It could have been a lot worse…

When we got back I was updating some apps on my phone when I noticed that Google were publicising Sky’s app on the marketplace. I took a quick look and saw that it has between 10 and 50 thousand downloads already. It makes me so sad to know that the audience for my app was so large, but I hardly tapped it at all. Oh well.

WordPress upgrades can be easy

I manage a couple of WordPress installations here and there. I obviously do everything on this blog, but on the other one I only really handle upgrades and changes to the underlying code. The style is done by a proper designer, and then entries are written by proper marketing people.

Before I had anything to do with the other blog the styles and modifications were simply placed into the existing default theme. This meant that every time there was a WordPress upgrade the changes got overwritten and the blog lost all branding. This meant that updates weren’t being applied quickly, which is a security problem.

When I took over the maintenance the first thing I did was to create a theme for the various CSS changes. The second thing I did was learn how to write a WordPress plugin to turn our code modifications into widgets. It may sound a bit complicated, but it’s not actually that hard if you know even the most basic PHP. The theme itself is just a zip file containing a few fairly standard PHP files and a stylesheet. The plugin is just a simple PHP file that (in this case) spits out some random sections of markup that we want, in the form of a widget that can be managed through WordPress itself.

Now when it comes to making an upgrade I have a test installation that I keep up-to-date with the current one (plugins, posts, comments, etc.) and I test it on there first. Today I upgraded the blog from the last 2.9 version to WordPress 3.0.1 and encountered absolutely no problems whatsoever. That’s how it should be! 🙂

Another two films at the cinema

I met Cheryl on old market square after work yesterday and we went to the cinema in time for the 17:30 showing of The A-Team. It was every bit as silly as I imagined it would be. Some bits are even more ridiculous than I expected (flying a tank, etc.). It was also as full of explosions and shooting as I hoped it would be. 🙂 It’s worth going to watch if you fancy a funny action movie.

After the film we went to pick up our tickets for the 9pm showing of Twilight: Eclipse. when we had the tickets we headed to Chiquito to get some Mexican food. I tried another sub-par quesadilla while Cheryl had macaroni and cheese (yes, really).

Eclipse itself was kind of like this for me:

First 90 minutes
Bella looks just to the left of Edward with a pained expression on her face looking slightly confused by something in the distance.
Bella looks just to the left of Jacob with a pained expression on her face looking slightly confused by something in the distance, then breaks her hand punching him in the face after he kisses her.
Edward does his necessary macho thing to Jacob, then they both pull back with pained expressions on their faces.
Bella looks upset, still.
Bella kisses Jacob, Edward doesn’t mind because he knows Bella loves him more than Jacob.

The next 20 minutes
There’s an awesome fight scene with werewolves and vampires all over the place!

The last 10 minutes
Teenage girl heaven.

Cinemaness

Cheryl and I were talking about how many films we wanted to watch at the cinema yesterday, so we decided it would be worth investing in an unlimited card for Cineworld. It costs £13.50 and you use the card to go to as many films as you like.

We ordered our cards online yesterday and then printed the temporary passes out. We met near the cinema in time to watch Toy Story 3 in 3D. It was a really good film. It was sad in parts, hilarious in parts, and just plain great overall.

After that had finished we went to get our tickets for Inception. After getting the tickets we went to Subway for a quick sandwich. We sat upstairs and had to listen to chavs talking about their illegitimate children, or whatever it is chavs talk about these days. We left there as soon as possible to go play on the IT Box in the cinema. We ended up playing on Word Soup about 6 times. We did fairly well, but couldn’t seem to be consistent enough to win money.

We went into the screen to watch Inception and sat down. When the film was ready to start the lights came up to full brightness for some reason. They stayed like that until someone went to speak to the people. Then the lights dulled, then flashed bright again. Stupid lights or stupid staff, I’m not sure. Eventually they turned off and we could see the screen properly.

Inception itself can be a bit confusing with the timeline changes, but the film itself isn’t that complicated. I’m sure it could be difficult to follow if you have a short attention span, or if you lost concentration for a few minutes, but it’s still enjoyable. It’s jumped into IMDb’s Top 250 at number 3, which is ridiculous. I’m sure it’ll get lower and lower over the coming weeks, but I imagine it’ll stay in the middle of the list for a fairly long time.

We got out of the cinema at 11:50pm after arriving there at about 5:30pm. It was a long evening in the cinema, and there will be many more to follow. 🙂