scriptygoddess

23 Feb, 2003

Live Preview and Smilies

Posted by: kristine In: How to's

Oscar Hills put together a tutorial at the MT Forums about using the Live Preview script from over here together with clickable smilies which show up in the Preview. With all the talk about smilies lately, I thought it was worth linking over here too :)

7 Responses to "Live Preview and Smilies"

1 | Jennifer

February 23rd, 2003 at 9:57 pm

Avatar

Something to be aware of: I actually took the "live preview" off my site because I realized that it so completely choked on the Mac. (and since I'm mostly on a mac at work, I couldn't stand leaving comments when I was there… so I removed it).

Admitedly – I didn't try the script posted on the MT boards – but if/when implementing the script – if you have Mac users, and you don't want them to go insane – you'll want to have them get back to you on how it's working.

2 | Jennifer

February 24th, 2003 at 9:34 am

Avatar

I just was on seadoc.net – and he has the live preview thing running… On a mac right now, and it seems to be okay… so either when I implemented it (way long ago – the original version), I did it wrong, or this new version works better on a mac… :)

3 | Oscar

February 24th, 2003 at 11:38 am

Avatar

It works fine on MacOS X anyway, since that's what I'm on almost all the time (except this very second).

Nothing new in the hack, so I don't know what the old problem was, unless MacOS9 with an old, old browser?

The use of .innerHTML is not always friendly, as you know …

4 | Doc

February 26th, 2003 at 5:35 pm

Avatar

I picked this up of Oscar from above's comments and thought you might want to incorporate it into the Live preiview script

This converts Line breaks into BR/ tags so the breaks display properly. Just add it to the ReloadTextDiv() function.
NewText = NewText.replace(/\n/g,"<br />");

Now If we can just figure out P tag interpretation.

5 | Oscar

February 26th, 2003 at 6:59 pm

Avatar

Actually, I told Adam that that looked good, in his comment over at my place, but I'd spoken too soon. It doesn't work (but it does look good). Anyway, THIS does work:

NewText = NewText.replace( /[\r\n]/g,"<br />");

6 | Doc

February 26th, 2003 at 7:49 pm

Avatar

FYI, That works too, but it double spaces on my Live preview whereas the other single space.
What exactly is the difference as I am not completely familiar with /[\r\n]/g etc.

7 | Oscar

February 26th, 2003 at 10:10 pm

Avatar

Well, it's my mistake anyway Doc. I should have done my homework! Your code works fine on every other browser extant, except, OF COURSE, MSIE 5.2.2 for MacOSX. I should have checked. I still don't understand what the actual problem is, but I would leave the code your way until/unless I find a more universal coding that works (which is what I thought I WAS doing).

As for those scratchings: first, as you know, we are searching the text for the first expression and replacing it with the second. The first expression sits between these //

And "\r" means "carriage return" and "\n" means linefeed.

The "g" flag sits outside the double slashes and specifies that pattern matching should be global (all instances in the string).

The brackets [] are array notation, and they specify that we must match any one of the elements in the array – in this case, either a newline (linefeed) or a carriage return. Now, why so different on different browsers? Go figure – but what fun would it be if everything just worked right!?!?!? :-)

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements