The Day

Feb. 25th, 2010 02:01 pm
andrewducker: (Default)
[personal profile] andrewducker
Morning spent tidying stuff up in anticipation of the engineer, who has of course not arrived as yet.

The afternoon has been spent faffing with javascript. Julie was tempted by the idea of randomized links, so I had a quick play, and have ended up with something workable.

So far I've only encountered two annoying things - lack of autocomplete meant I spent twenty minutes trying to work out what I was doing wrong before discovering that getElementByID should be getElementById, and I also discovered that editing the value of a textarea in a loop is a bad idea - putting together the string separately and then updating the textarea at the end is vastly faster.

I doubt I'll need javascript skills very often, but it's been fun to have a play around with it.

Date: 2010-02-25 02:53 pm (UTC)
From: [identity profile] bracknellexile.livejournal.com
Glad the idea of a random link was a good one rather than her having to go change the link every time 25 were filled in :)

Date: 2010-02-25 02:59 pm (UTC)
From: [identity profile] momentsmusicaux.livejournal.com
Oh drat, I should have told you about jQuery.

Nearly anything you want to do in JS is made 10 thousand times easier with JQ.

Date: 2010-02-25 04:05 pm (UTC)
From: [identity profile] draconid.livejournal.com
I get had by getElementById every bloody time!

Date: 2010-02-25 05:59 pm (UTC)
From: [identity profile] skington.livejournal.com
The thing is, JQuery is much easier than normal Javascript, so if you think "Hey, can I make it better than what I have already?" the answer is "Sure, it's a cinch" rather than "Possibly, but I don't really know Javascript"

Date: 2010-02-25 09:31 pm (UTC)
From: [identity profile] drdoug.livejournal.com
getElementByID should be getElementById

I see: Javascript prefers to retrieve elements via the deepest, unorganised part of its consciousness, rather than routing via Idaho.

Date: 2010-02-26 02:10 am (UTC)
From: [identity profile] meaningrequired.livejournal.com
Yay for Simon :)

And its much easier to explain to an ethics committee "oh, the computer just does it" :D

Date: 2010-02-26 07:27 am (UTC)
From: [identity profile] momentsmusicaux.livejournal.com
Hmmm well...

Instead of having to put an onload (which isn't reliable if you have images btw, but not your case here), you just start your JQ off with:

$('document').ready(
// everything goes here
);

and you can also say:

$('#random').href = chosenLink; // or somesuch IIRC, pre-breakfast

The beauty of JQ is it all works with CSS selectors. Oh and it's an object-chaining pattern, so it's $(get JQ).do().another().andsomemore().

Date: 2010-02-26 07:34 am (UTC)
From: [identity profile] momentsmusicaux.livejournal.com
Which is why we use JQuery and never have to worry about it again.

Date: 2010-02-26 11:51 am (UTC)
From: [identity profile] momentsmusicaux.livejournal.com
Oh and the correct pronunciation of that $ function is 'bling'. Really. It's called the bling operator.

Date: 2010-02-26 02:25 pm (UTC)
From: [identity profile] 0olong.livejournal.com
I do wish that case-sensitive languages would be consistent and sensible about their own capitalisation.

March 2026

S M T W T F S
1 2 3 4 56 7
8 9 10 11 12 13 14
15161718192021
22232425262728
293031    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Mar. 15th, 2026 01:58 pm
Powered by Dreamwidth Studios