BoC Playlist for Friday, December 4, 2009

Jon Bernhardt’s Breakfast of Champions Program
Friday, December 4, 2009
WMBR 88.1 FM
Clicking on an Artist or Song will open a new window displaying all other times that Artist or Song has been played.
Be Sociable, Share!

BoC Playlist for Friday, November 20, 2009

Jon Bernhardt’s Breakfast of Champions Program
Friday, November 20, 2009
WMBR 88.1 FM
Clicking on an Artist or Song will open a new window displaying all other times that Artist or Song has been played.
Be Sociable, Share!

BoC Playlist for Friday, November 13, 2009

Jon Bernhardt’s Breakfast of Champions Program
Friday, November 13, 2009
WMBR 88.1 FM

Listen to recent shows or subscribe to the podcast

Clicking on an Artist or Song will open a new window displaying all other times that Artist or Song has been played.

Be Sociable, Share!

BoC Playlist for Friday, November 6, 2009

Jon Bernhardt’s Breakfast of Champions Program
Friday, November 6, 2009
WMBR 88.1 FM
Fundraising Special
Thanks to you, over $7,200 in donations were pledged during this program!
Clicking on an Artist or Song will open a new window displaying all other times that Artist or Song has been played.
Be Sociable, Share!

25th Anniversary DVD!!!!!1!

[UPDATE: POSTERS ARE GONE!]

This week is Fundraising Week at WMBR. To sweeten the pot for my loyal listeners, I will be offering a very special premium to those who pledge $100 or more. In addition to whatever swell swag you’d normally be eligible to receive, you’ll also get a special DVD collection of live performances from the two 25th Anniversary Concerts I put on back in June. The DVD will include video performances by the Bevis Frond, Condo Fucks (Yo La Tengo), Buffalo Tom, and (hopefully) others. There will also be some audio-only treats, as not all bands were filmed.

But wait! There’s more!! I’ve got 22 copies left of the awesome poster Jef Czekaj designed for the events. The first 22 people who qualify for the DVD will also receive one of these very limited signed (by Jef and myself) numbered (for an edition of 75) hand-silkscreened posters.

But wait!!! There’s still more!!!! Four of the 22 posters were also signed by every musician who performed at the gigs. Four lucky listeners will be randomly chosen from the pool of 22 to receive one of these incredibly rare collector’s items.

It all happens Friday morning, Nov. 6, between 8 and 10 am. WMBR can be heard at 88.1 FM in the greater Boston area, online at http://wmbr.org or via my podcast.

You can pledge online anytime through November 11 here. If you want the DVD & poster, be sure to select “Breakfast of Champions – Fri” from the drop-down list.

25th Anniversay Poster

Be Sociable, Share!

BoC Playlist for Friday, October 30, 2009

Jon Bernhardt’s Breakfast of Champions Program
Friday, October 30, 2009
WMBR 88.1 FM
Clicking on an Artist or Song will open a new window displaying all other times that Artist or Song has been played.
Be Sociable, Share!

BoC Playlist for Friday, October 23, 2009

Jon Bernhardt’s Breakfast of Champions Program
Friday, October 23, 2009
WMBR 88.1 FM
Mind the Bat, Riders!
Clicking on an Artist or Song will open a new window displaying all other times that Artist or Song has been played.
Be Sociable, Share!

BoC Playlist for Friday, October 16, 2009

Jon Bernhardt’s Breakfast of Champions Program
Friday, October 16, 2009
WMBR 88.1 FM
Clicking on an Artist or Song will open a new window displaying all other times that Artist or Song has been played.
Be Sociable, Share!

Wobbly Tech Tip #2: Running a function on just the dragged element of a script.aculo.us sortable

I recently implemented a change to my Track-Blaster software so that DJs can rearrange songs in a playlist by dragging and dropping them from one place to another. To do this, I incorporate the wonderful Scriptaculous javascript library.

I’m not going to give a tutorial of how this effect is achieved. If you want that, there’s a great one here. The reason for this post is to share a solution to a specific problem I was having using these “sortables”.

The problem is this: I drag an element within a sortable. Sometimes I drag it to a different position and sometimes I don’t. I want to run different functions on the dragged element depending on whether it has moved. There are functions included in the library that are useful — Sortable.serialize and Sortable.sequence — but they return a string or array containing the new order of all the elements. I am only interested in the element I’m dragging.

Sortable.create has a callback, OnUpdate, that’s triggered only when an element is moved to a different spot. However, it doesn’t know which element was dragged; the entire list is its parameter. Conversely, there is an option called reverteffect that knows which element was dragged, but it doesn’t know whether it’s gone to a different position or stayed put.

Conveniently, OnUpdate is called before reverteffect. My solution involves using OnUpdate to add a temporary class to the list container. Then, reverteffect is used to test whether that class exists. If it does, the class is removed and a function is called on the moved element. If it doesn’t, a different function can be called on the dragged-but-not-moved element. Here’s a sample page that shows you what I’m talking about. Put your mouse over the up/down arrows and drag that item to somewhere else within the list. Or put it back where you found it. After you’ve dropped it, a message will appear at the bottom identifying the item you just dragged and indicating whether it was moved.

You can examine the source code of this sample page, but here’s some annotations of the important bits. I’m assuming you’re familiar with the fabulous Prototype javascript library. Let’s start at the bottom:


Sortable.create('testlist',{
  constraint: false,tag: 'div', handle: 'moveme',
  reverteffect: moveRevertEffect,
  onUpdate: function(element) {  
    element.addClassName('sortUpdate');
  }
});

This script activates the sortable. The first parameter, “testlist” is the id of the object containing all the things you’ll be dragging. The next parameter is a hash of the various sortable options. The relevant ones to this post are the last two. “reverteffect: moveRevertEffect” replaces the standard Scriptaculous reverteffect with a custom one we’re arbitrarily calling moveRevertEffect. More on this below. “onUpdate: function(element)…” does what I said earlier. onUpdate is only called after you drop an element in a different spot from where it started. If it is called, the class “sortUpdate” (another arbitrary name) is added to the parent container (i.e. testlist).

After an element is dropped, and after onUpdate is called (if it is called), the reverteffect kicks in. Let’s look at that code (from near the top of the sample page):


var moveRevertEffect = 
function(element, top_offset, left_offset) {
  var dur = Math.sqrt(Math.abs(top_offset^2) + 
    Math.abs(left_offset^2))*0.02;
  new Effect.Move(element, { 
    x: -left_offset, y: -top_offset, duration: dur,
    queue: {scope:'_draggable', position:'end'}
  });  
  if (element.up().hasClassName('sortUpdate')) {
    element.up().removeClassName('sortUpdate');
    $('whahappened').innerHTML = element.id + ' has been moved';
  } else {
    $('whahappened').innerHTML = element.id + ' has not moved';
  }
}

This custom script creates the new variable that will replace the standard reverteffect. We want to keep the standard effect but then add to it. So the first part of the custom script (the dur and Effect.Move statements) is simply a copy of the standard version found deep in the bowels of Scriptaculous (in the file dragdrop.js). The if statement is our addition. It checks to see if the parent of the dragged element (i.e. testlist) has the class “sortUpdate”. If it does, that means the element was moved. The class name is removed and we can run whatever function we like using the dragged element as an argument. If the parent doesn’t have the “sortUpdate” class, that means the element was dropped off where it started. The else clause kicks in and we can run some other function using the dragged element as an argument. In the example, I use a (very) simple function that changes the innerHTML property of the div at the bottom, but you can put anything here including ajax calls or whatever.

And that’s it. A rather esoteric problem to be sure, but hopefully someone, somewhere, sometime, will find this useful.

Be Sociable, Share!

BoC Playlist for Friday, October 9, 2009

Jon Bernhardt’s Breakfast of Champions Program
Friday, October 9, 2009
WMBR 88.1 FM

No podcast this week due to the special nature of the Mission of Burma performance, however you can still stream this program for the next two weeks.

Clicking on an Artist or Song will open a new window displaying all other times that Artist or Song has been played.

Be Sociable, Share!