Live Comment Previews

The ‘Live Comment Preview’ hack that I use on The Long Letter has now been implemented here on Eclecticism. If you know what I’m talking about, then we’re good to go. If you don’t know what I’m talking about, then click on the “Comments” link to any post, type something in the comment box, and look just below the comment box. It’s a nifty trick. ;)

I originally picked this up from ScriptyGoddess, with help from Phillip. Geeky tech details on my implementation here follow.

All this is is a nice little JavaScript addition to the page. I don’t believe that this will constitute a security risk, but I’m no expert, so use at your own risk. ;) Obviously, if you do want to use this on your site, you’ll need to have access to your templates.

In the header of the individual entry template, just after the already included JavaScript bits, I added the following code:

<script type="text/javascript">
 var newline = /n/g;
 function ReloadTextDiv() {
  var NewText = document.getElementById("text").value;
  NewText = NewText.replace(newline, "<br />");
  var DivElement = document.getElementById("TextDisplay");
  DivElement.innerHTML = NewText;
  }
</script>

Then, in the body of the template, just after the closing </div> tag following the preview and submit buttons, but before the </form> tag, I added the following:

<br />
<h2>Live Comment Preview:</h2>
<span id="TextDisplay">Note: if you're comfortable with HTML, feel free to use it in your comments. If not, just type away. Single returns will be automatically converted into linebreaks (&lt;br /&gt;), double returns will be converted into paragraph breaks (&lt;p&gt;). This text will disappear as soon as you start typing.</span>

Lastly, in the textarea tag that defines where the comment text is entered in by a visitor, I added a onkeyup="ReloadTextDiv();" declaration. The full textarea tag should look as follows:

<textarea tabindex="4" id="text" name="text" rows="10" style="width: 80%;" onkeyup="ReloadTextDiv();">

What all this does is actually simple enough. As a visitor enters their comment into the comment box, each time they release a key the onkeyup function calls the ReloadTextDiv JavaScript snippet that I added. This function loads any text inside the comment box (identified by its ID of "text"), replaces any carriage returns with <br /> tags so that line breaks appear correctly, then writes the output into the element identified as "TextDisplay" — in this case, between the span tags I added after the submit and preview buttons.

If you find this useful, feel free to use it in your own pages. While I wouldn’t refuse credit, it really does belong to ScriptyGoddess and Phillip. Enjoy!

Turn down the heat!

On the bright side, the weather has been absolutely gorgeous all this weekend. On the downside, I haven’t wanted to leave the apartment — once temperatures hit the mid-80’s to 90’s, I’m quite content to lay in a near-comatose puddle on my bed. ;) However, this being the weekend for the Bite of Seattle food festival, I couldn’t very well stay indoors in the shade all weekend.

The Seattle Center fountain

Prairie had come in to town to visit for the weekend, so Saturday morning we got up around 11, wandered downtown to see Pirates of the Caribbean (which rocked — more on that later, most likely), then walked from the Temple of Avarice to the Seattle Center to wander around the Bite for a while. As I mentioned above, it was gorgeous weather, so Seattle was out in full force. Lots of people, and at times a little overcrowded (does nobody ever pay attention to where they are walking at these things?), but aside from that, not bad at all. I even went out and soaked myself in the fountain — and boy, did that make the sun more bearable for the rest of the afternoon!

The main field at Seattle Center

After grabbing some food and finding a seat in the shade to eat, we each grabbed an ice cream cone, and sat down at one of the music stages to watch The Retros play — if the name hasn’t given it away already, they specialize in 80’s pop, and are a blast to see. We finished our ice cream about the same time they finished their set, and, deciding that we didn’t really want to risk sunburn any more than we already had, we hopped on the monorail and came back to the apartment.

The rest of the weekend was spent mostly here at the apartment, resting and trying to avoid the heat as much as possible. Movies were watched, laundry was done, and not much else. Which, as far as I’m concerned, makes for a perfect weekend.

Alaska Jack

Concurrently with today’s announcement that Alaska Airlines has contracted with Jack Nicholson to act as spokesperson for the airline in all of their television and print advertising in 2004, the airline also revealed an upgrade to the traditional and distinctive Alaska Native image on the tail of their jets:

Alaska Jack

Tribal leaders and Mr. Nicholson’s representatives have so far declined to comment on the announcements.

(Image found in this mindblowing Worth1000 Photoshop contest. Pesudo-‘news’ dragged, kicking and screaming, out of the dingy corners of my brain.)

Hoaxing Bambi

The jury’s still out on this one, but I’d be willing to bet that the Hunting for Bambi ‘business’ (in which men dress up in camo, grab paintball guns, and go running through the woods ‘hunting’ naked women) is nothing more than an elaborate spoof. While most media reports have been long on hype and short on investigation, the Urban Legends Reference Pages are extremely skeptical.

We’re still investigating, but we’d be quite surprised if this scheme was hatched as anything but an attempt to sell videos. (After all, \$19.99 tapes and DVDs, and not \$10,000 hunts, are the product advertised on the site’s opening page.) Our estimation is that the whole “hunt” concept was a phony promotional dog-and-pony show staged for credulous reporters, but now that Hunting for Bambi has attracted plenty of free publicity from the media, they’re attempting to make the concept work for real.

The skyline is back

One minor change to the site design here — I moved my shot of the Seattle skyline that I use over at The Long Letter to this weblog also. Even when that’s the only change, replacing that garish green with the black and white skyline gives a very different feel to the page. I like it. It’s a return to the cool blue/grey combination that I keep returning to.

Bright neon lime green just wasn’t “me”, anyway. ;)

Squirrel Monkeys

Two pieces of news broke in one day yesterday.

Item one: “Microsoft acknowledged a critical vulnerability Wednesday in nearly all versions of its flagship Windows operating system software…[which] could allow hackers to seize control of a victim’s Windows computer over the Internet, stealing data, deleting files or eavesdropping on e-mails.”

Item two: “The Homeland Security Department has chosen Microsoft Corp. as its preferred supplier of desktop computer and server software, according to a statement issued late Tuesday. …perhaps most important to Homeland Security’s mission to get agencies communicating more easily, Microsoft will provide the standard e-mail software for the entire department.”

I loved Jeffrey Zeldman’s summary:

Let’s see what the government might have chosen in its effort to protect American lives from ruthless, technologically sophisticated terrorists:

UNIX, Linux
Inexpensive or free.
Requires some user knowledge.
Practically invulnerable to attack.
Mac OS
Costs money.
Easy to use.
Practically invulnerable to attack.
Windows
Costs money.
Easy to use.
Can be hacked by a squirrel monkey, thus is wide open to attack.
Produced by a company the Department of Justice found guilty of criminally abusing its monopoly power — a finding that is supposed to result in punishment, not in fat contracts bankrolled by taxpayers.

To the bureaucratic mind, the choice was obvious.

Sounds safe and secure to me.