Comment Preview for Blogsome!

I’ve implemented Comment Previewing from Blogsome blogs. There is no way to install 3rd party plugins in WordPress MultiUser, so everything has to be done in JavaScript. But really, the plugin is just JavaScript packaged up nice anyway. You need four code fragments, all in your comments.html file. The first one I suggest goes after the line: {if 'open' == $post->comment_status} Because it is a JavaScript that uses { and }, you need to remember the {literal} tags. {literal}<script type="text/javascript"> <!-- function ReloadTextDiv() { var UseInstantPreview = document.getElementById("use_instant_preview").checked; if( UseInstantPreview == true ) { var NewText = document.getElementById("comment").value; splitText = NewText.split(/\n/).join("<br />"); var DivElement = document.getElementById("commentpreview"); DivElement.innerHTML = splitText; } } // --> </script>{/literal} It probably doesn’t matter exactly where it goes, but having it after the {if} clause means it will only be included in the file if comments are open. The second code fragment is: onkeyup="ReloadTextDiv();" And it goes in the <textarea id=comment> tag. In context, mine is: <textarea name="comment" id="comment" cols="60" rows="12" tabindex="4" onkeyup="ReloadTextDiv();"></textarea> The third fragment is the checkbox for enabling or disabling Comment Preview. It can go wherever looks good. <input onclick='ReloadTextDiv();' name="use_instant_preview" type="checkbox" id="use_instant_preview" value="1" checked /> <label for='use_instant_preview'>Use Instant Preview</label> The final fragment tells the browser where the Comment Preview goes: <div><p id="commentpreview"></p></div> And it goes where you want the Comment Preview to actually go. I suggest just after the Submit button, or other instructions. Righto, all of that in there, and it should work. You may need to add an entry to your Site Style Sheet to make the Comment Preview box look the same as your actual comments box. • If you wanted to, you can also have a Preview button that will preview what is in the text area then, rather than having Live Preview. This is good for a couple of reasons: I find that long comments slow down when trying to update every keypress. The big problem is that you cannot have a normal input field inside the form set to do this, it will just try to submit it (or at least, mine did!). So, I’ve replaced my input tags in my form with the following (You may need to insert name='commentform' into the form start tag.): <a class='button' href='javascript:document.commentform.submit();'> Post Reply </a> <a class='button' href='javascript:ForceReloadTextDiv();'> Preview </a> You’ll also need to add the following in just after the ReloadTextDiv function definition: function ForceReloadTextDiv() { var NewText = document.getElementById("comment").value; splitText = NewText.split(/\n/).join(" "); var DivElement = document.getElementById("commentpreview"); DivElement.innerHTML = splitText; }

Quicktags for Comments

Note: The seperate Quicktags toolbar is not supported. Please use the full toolbox script, or hack it any way you like. The remainder of this post remains for posterity only.

This was easier than I thought.  Alex King has done most of the work by having the Quicktags info already in a JavaScript file. I just grabbed my copy of the file (from /wp-admin/quicktags.js) and tweaked it.  To upload to the Blogsome server I had to call it quicktags.jpg, but that is allowed, since you tell the browser explicitly that it is a text/javascript file. So, you can get my quicktags.js file (Right-click and download it!), and upload it to your server, and use the following code in your comments.html. Where you want the toolbar to appear, insert this:

1     <script src="/images/quicktags.jpg" type="text/javascript"></script> 
2     <script type="text/javascript">edToolbar();</script> 

After the <textarea>, insert the following code:

1     <script type="text/javascript"> 
2         <!-- edCanvas = document.getElementById('comment'); //--> 
3     </script>

Note: you may need to chage the argument of getElementById to whatever your textarea id is. I’ve also tweaked the JavaScript file so it includes abbr, acronymand striketags, and doesn’t include the tags that aren’t valid for comments.  And I’ve added a button for inserting < and >, but I’m not totally happy with this.  If anyone wants to edit it so it works better (try it out to see what I mean), then feel free.

I’ve also created another version that uses links instead of buttons (since Camino doesn’t render buttons with style, only as Mac-buttons), but it’s not quite as nice: the labels don’t update. Still, if anyone wants to play around with it, you can get it here. Remember to right-click and download it, it’s not really an image!

Next task: Live Preview.

One Man, One Vote?

The Conservative Philosopher: One Man, One Vote I don’t normally read conservative websites, but I cam across this one as part of some fault-finding I was doing for another Blogsome user.

Suppose you have two people, A and B. A is intelligent, well-informed, and serious. He does his level best to form correct opinions about the issues of the day. He is an independent thinker, and his thinking is based in broad experience of life. B, however, makes no attempt to become informed, or to think for himself. He votes as his union boss tells him to vote. Why should B’s vote have the same weight as A’s?

I think it’s interesting the term “He votes as his union boss tells him to vote.” It shows the clear bias in this piece: that uneducated people are unionists (and implies vice-versa). Would the article read differently if it read: “He votes as the radio shock-jocks tell him to vote.”

It is self-evident that B’s vote should not count as much as A’s.

No, it is not self-evident. It is self evident that you believe that less educated people are lesser human beings. I am all for education: I am a teacher, and believe that education is the key to most of societies ills, but disenfranchising people who are less advantaged than you is not the way to democracy. With ‘lesser people’ not being able to vote, the balance of political power stays firmly in the hands of those who are already advantaged, and will never leave. Why should they vote for someone who wants to educate the poor? It will cost them more than it costs the poor, and it’s all money they wouldn’t otherwise have to pay, since they are sending their children to a private school already. Ideas like this entrench inherited poverty. I used to teach at a less advantaged school, and taught many students from lower Socio-Economic Backgrounds who showed more intelligence than their ‘richer’ counterparts (like those I went to school with, incidentally), and who showed far more moral fibre. Without a reasonable public education system these students would not have had the opportunity to attend university: and most of them are doing far better in their first degree than I did. Now for some straw man:

Comment Policy I (KBJ) have configured the PowerBlogs software so that only those who have (1) registered and (2) been approved (by me) may post comments. Please note that comments do not appear immediately, even by approved users; they must be approved individually. My aim in adopting this policy is to discourage incivility. If you want your comment to appear, it should be civil, coherent, and relevant to the post to which it is attached.

I had a quick read of the site and some comments, and I think the author may only allow comments that (a) support his views on the subject or (b) he already has a rebuttal prepared for, so he can answer straight back.