Eat my shorts! AJAX drag-and-drop baby!

New article on Piper’s Pages:

In my neverending quest to learn (everything?) AJAX, I decided to dip my fingertips into the pond that is drag-and-drop.

Probably the most famous of AJAX techniques, it allows you to grab something on a page and move it somewhere else – either because you like to assert your creativity, or because you want to Do Something(tm) (like add an item to shopping cart).

Well ladies and gents, we’ve taken our implementation of drag-and-drop to a Whole New Level(tm).

You may recall that we’ve had AJAX popups for ages now (ages <= 1 year) and you could grab those popups and move ’em around, just cause they might be covering stuff you want to see. Cool, but… that didn’t DO anything really.

So here’s what I envisioned.

I envisioned an interface with multiple panes – one for browsing, one may contain a zone, and another may contain a list. It would be wicked and wild if you could drag an album on your list or onto the zone to queue that album.

This obviously requires more kung-fu than just moving popups around the screen.

So…. if I’m not mistaken I’ve been using Scriptaculous for the popup dragging, and after trying to bake my own more-advanced solution I realized that Scriptaculous could do what I wanted (and it was even using the same terminology I was using – “draggables” and “droppables”).

So the first crack at this yielded the ability to drag stuff from the browse view onto the link that indicates your working list. That causes the album/song to be added (or removed) from said list, which also happens to flick the checkmark for that item (this happens as a result of existing code).

Okay, so that’s cool I guess, but said checkmark could simply be clicked to achieve the same results. Nothing really new here folks, so move along!

My pleasure. My next effort was to enable drag-and-drop table reordering. Currently, in list view, you’ve got teeny weeny icons that you can use to move a row up or down, one at a time. Sure, you can select a bunch of rows and move them all up or down at once, but again they’ll move one at a time.

With these handy dandy scrolling tables, it sure would be nice to grab a row by the scruff of its neck and manhandle it into a new position, right?

Yes, it would. And while Scriptaculous provides an easy breezy way to get this done, fact is that my implementation of dynamic tables is slightly incompatible with Scriptaculous. If I had to actually take time to explain why, I would say that it has to do with my padding process – which means that in any given table, some of the rows have actual data and some do not. I use different DOM ID prefixes to track this, but even if I used a seperate array to do the same thing I’m pretty sure we’d run into context issues: does it make sense to reorder a row that hasn’t been filled in yet?

Sure, the way I’m registering draggable items means those rows wouldn’t be considered draggable by Scriptaculous until they were force-fed useable data by backend, but… why are you trying to convince me to use Scriptaculous for this??? Look, the fact is I wanted to keep my DOM ID convention, and I don’t like the way Scriptaculous reports the new ordering to the backend. When you’ve got a table that can contain, oh, 30000 rows the last thing you want to do is iterate through a serialized list of row IDs and tell a DBMS to reorder based on that list. Ugh.

So I baked my own solution, which was based on the work I did (and partially abandoned) for effort 1.

And… it works!

At least in Firefox. It looks like it wants to work in Chrome and Opera, but I’ve got stoopid text selection issues to overcome still. But at least the concept works, and admittedly it’s quite handy.

So ya – drag-and-drop/table-reordering with backend updates. Funky fresh.

Michael Jackson: Healing the World

Just wanted to provide a link to this article I posted on Piper’s Pages back in Feb 2003 (log in as guest).

Excerpted below.

Let me be perfectly clear: I DO believe that Michael Jackson is a little “off”.

BUT – I do NOT think that he’s crazy, and I do believe that his convictions are strong and he stands by his beliefs.

Central to the controversy surrounding Michael Jackson are two issues: One, his cosmetic surgery (and the reasons for it). Two, his relationship with children, including his own.

I’ll admit – there are things about Jackson’s life and the decisions that have shaped his life that I don’t understand; or, just as importantly, I wouldn’t make myself. What comes to mind are the Berlin hotel incident, the parental obligation to his kids, and his insistence of having unrelated kids spend so much time with him. But, hearing him talk about these same incidents, I have to believe that the man simply sees life from a different perspective than I do. A different perspective, in fact, than most people.

Let’s not kid ourselves people. “Society” is as much a bane as it is a blessing. We have a world filled with rape and murder, greed and adultery, and any number of heinous things. We’ve created a society that’s supposed to benefit most people most of the time – but we all know that no one thing can truly benefit all of the people all of the time. We have differences in opinions regarding the utopian society – democratic, socialistic, communist, dictorial – such that, though we’re all human, we can still disagree on what’s what and we’re willing to bear arms in defiance.

The notion that Michael Jackson’s thinking goes against the grain, really, isn’t a cardinal sin.

Martin Bashir, the man who interviewed Michael Jackson in ABC’s 90 minute special “Life with Michael Jackson”, focused incessantly on the two things I alluded to earlier; but mostly on the issue dealing with Jackson and children. And at one point he (Bashir) said something that I had to agree with – initially. He put himself in the position of Michael Jackson and said, with an allowable degree of certainty, that no person he knows would be comfortable with the idea of him having somebody else’s kids sleeping in his bedroom.

Now let’s be honest people. Perhaps my opinion is skewed because Carribean culture is different than North American culture, but amongst a peoples who routinely make aunts and uncles of those who have no blood relation, I have to think that the line isn’t as clear as Bashir makes it. If trust weren’t a issue (and keep in mind, please, that ideally trust should NOT be an issue) then I would trust my really good, long-time friends (who would also be parents) in addition to my family with matters relating to my children – including sleeping in the same room with them. And for some people, assuming that trust weren’t an issue, even the same bed.

And that’s the crux of it: Trust. Jackson made the statement that it’s not like Jack the Ripper is in the room. All he’s seeking to do is provide an atmosphere of love and caring that this world sorely misses. And I have to agree that the world – indeed, society – isn’t the noble, just and honourable cause that Bashir seemed ready to defend. All you have to do, again, is realize that the human race still hasn’t agreed on what the best version of society is, and within societies people still clamour for certain rights (eg, gay rights), seek to aboloish certain rights (think KKK), or seek to define what’s acceptable and what isn’t in child-rearing (think of the cases involving spanking, as justified by religious beliefs).

The case that Bashir made – the wall on which he was leaning – was a shaky wall indeed.

Michael has done some wierd things, but I believe that the man is honourable, and I believe that he’s being more forward about what he honestly believes in than the vast majority of people in this world.

I also think that he’s astonishingly immature – but what is maturity? If the heart is big enough, does it matter that the brain isn’t so mature?

Really, what’s the answer?

I’m not going to talk about his cosmetic surgery, because I believe that that’s his personal choice and he doesn’t have to justify those choices to anybody but himself. Not sure why he’s lying about it (and I say that because it seems blatantly obvious to me that he’s done more than tweaked his nose a couple of times). But really, there’s nothing worthwhile there; either he’s done it or he hasn’t. Big deal.

In other matters – the ones I touched on – the man is obviously trying, and he’s leading his life by example. And it’s a shame that Trust (always) has to be an issue.

What the HECK is this Whole Home Audio thing?

Glad you asked.

For the past x years I’ve been toiling away on a combination of software and hardware at home that allows me and the wifey to play selections from my vast collection of music to various rooms around the house (and beyond).

If you visit Piper’s Pages, you’ll find a post (login as guest) that begins the record of how this endeavour began.  Yes, it began 4 years ago.

And it’s still going strong.

Browse interface

Browse interface

The project, in today’s form, uses a web interface to browse/search the collection.  The search options are quite powerful (confusingly so?) and can be saved for frequent use, you can create playlists of songs and albums, you can have the system suggest similar music.  There are statistics – including scoring and ranking – and metadata pulled from external sources.  We’ve even got BPM info.

music_zoneThere are a slew of maintenance scripts that power this thing, and no less than three disparate “servers” that go into making it all happen. Currently we’ve got two physical zone – family room and basement – and another four virtual zones for streaming.

So that’s the short intro.  For more you’ll have to visit Piper’s Pages and check out the DP’s Corner database.

My First Post!

Hey all,

This is my first WordPress post, but all of those “in the know” will be aware of Piper’s Pages over at http://www.pipenet.org/people/piperd/.  So while I may be using official blog software now, it’s not to say that I haven’t been blogging for quite… some… time……..

I’m somewhat torn on whether to continue posting to the other site, or perhaps to post here and link here from the other site.  Truthfully I just don’t have the time/inclination to update the backend code that drives Piper’s Pages, so I suppose it makes sense that future posts occur here.  If I permalink from Piper’s Pages, then I’ll lose search functionality on that site but…

I think I’ll just post to both sites, and provide the permalink at the start of Piper’s Pages posts.

Problem solved.  Not that you cared, but one thing you’ll soon learn my friend is that my online sense of entitlement is rather startling.  So that’s that then – let’s blog!