Sunday, March 11, 2007

QOTM - HowTo

Please follow the instructions as mentioned in my QOTD widget post.

Replace the complete script/html content with the one given below.
<script src=" http://build.dojotoolkit.org/0.4.2rc2/dojo.js" type="text/javascript"></script>
<script language="javascript">
var quotesArray;

function loadQuotes(root) {
var content = root.entry.content.$t;
quotesArray = content.split('%');
setInterval("showRandomQuote()", 16000);
}

function showRandomQuote() {
var index = Math.floor(Math.random() * quotesArray.length);
var quote = quotesArray[index];
quote = stripHtml(quote);
document.getElementById("quotesDiv").innerHTML = quote;
dojo.lfx.html.fadeIn('quotesDiv', 2000).play();
setTimeout("dojo.lfx.html.fadeOut('quotesDiv', 2000).play()", 13000);
}

function stripHtml(s) {
return s.replace(/(<([^>]+)>)/ig,' ');
}

</script>
<div id="quotesDiv">
loading quotes...
</div>
<script language="javascript"
src
="http://www2.blogger.com/feeds/DDDDD/posts/full/SSSSSS?alt=json-in-script&amp;callback=loadQuotes ">
</script>
where DDDDDD is your blog id and SSSSSSS is your quotes-data post id.

Please refer my earlier post for all other details. Just now I found a bug in this one. The stripHTML function strips any HTML from the quote text and replaces with a blank space. This is not acceptable.

What I should do is, first replace all the <br> and/or <br/> tags with a blank space and all other tags with empty space. Comments please :)
--
regards/Yogesh

"One can resist the invasion of an army but one cannot resist the invasion of ideas." - Victor Hugo

1 comment:

Alain said...

A Surprising Variation on the Random Quote Generator Theme: Oh! Looks like you’ve been fooling around with your QOTD widget and come up with a new surprising offer. Very cool your new flowing quotes device! I didn’t expect this at all. You seem to be creative in many different ways. I have ideas on how I could take advantage of the new features of your Quote of the moment widget but I’m not ready yet to test this offer on my blog because it’s leading me in a different direction that my last considerations on your QOTD widget have taken me recently. Nevertheless, I suspect that this Quote of the moment widget will probably be very appealing to New Blogger fans when they will discover that such thing exist. You seem to be on your way of creating a specialized department on Random Quote Generator Products on your blog. Good luck with your performance optimization of the Quote of the moment widget.