{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\froman\fcharset0 Times New Roman;}{\f1\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\sb100\sa100\f0\fs24 /*\line Blogger Recent Comments\line v1.05\line\line Based on the Farrago Recent Comments Hack v1.03\line boggerhacks.blogspot.com\line (c) 2004 Ebenezer Orthodoxy \line\line Statement: I would GPL the code if the original author would. \line Mods by: Robin Parmar\line Visit: noisetheatre.blogspot.com\line */\line\line // our class\line function RecentComments() \{\line // options to change\line this.displayAmount = 10;\line this.displayTemplate = '<li>[name]:<br/>[title]</li>';\line this.displayPre = '<ul>';\line this.displayPost = '</ul>';\line this.displayLink = true;\line\line // properties\line this.comments = new Array();\line this.title = '';\line this.itemurl = '';\line\line // methods\line this.SetTemplate= rcSetTemplate;\line this.SetAmount = rcSetAmount;\line this.SetLink = rcSetLink;\line this.SetPrePost = rcSetPrePost;\line\line this.SetTitle = rcSetTitle;\line this.SetUrl = rcSetUrl;\line\line this.SortDate = rcSortDate;\line this.AddComment= rcAddComment;\line this.Display = rcDisplay;\line\line // this line uses my date converter method\line this.DateConvert = rcDateConvert;\line\line // comment out the previous line and uncomment the\line // next line to use original date format\line // this.DateConvert = rcDateConvertDefault;\line\line // or write your own and insert it\line\}\line\line // simple property setters: these are used by process\line function rcSetTitle(x) \{\line this.title = document.getElementById(x).innerHTML;\line\}\line function rcSetUrl(x) \{\line this.itemurl = x;\line\}\line\line // these are used by user to customise\line function rcSetTemplate(x) \{\line this.displayTemplate = x;\line\}\line function rcSetAmount(x) \{\line this.displayAmount = x;\line\}\line function rcSetLink(x) \{\line if (x==0) \{\line this.displayLink = false;\line\} else \{\line this.displayLink = true;\line\}\line\}\line function rcSetPrePost(x, y) \{\line this.displayPre = x;\line this.displayPost = y;\line\}\line\line // date format converter\line // insert your own here depending on the format you use for comment dates\line // this one converts from:\line // 01 November, 2005 16:35\line // to:\line // 11/01/2005 16:35:00\line function rcDateConvert(dt) \{\line var s = dt.split(' ');\line var d = s[0];\line var m = s[1];\line var y = s[2];\line var t = s[3];\line\line var MonthHash = new Array();\line MonthHash['January'] = '01';\line MonthHash['February'] = '02'; \line MonthHash['March'] = '03'; \line MonthHash['April'] = '04';\line MonthHash['May'] = '05';\line MonthHash['June'] = '06'; \line MonthHash['July'] = '07';\line MonthHash['August'] = '08';\line MonthHash['September']= '09';\line MonthHash['October'] = '10';\line MonthHash['November'] = '11';\line MonthHash['December'] = '12';\line\line // trim off comma\line m = m.substring(0, m.length-1);\line\line return MonthHash[m] + '/' + d + '/' + y + ' ' + t + ':00';\line\}\line\line // default converter: does nothing\line // use if your comment date format is:\line // mm/dd/yyyy hh:mm:ss\line function rcDateConvertDefault(dt) \{\line return dt;\line\}\line\line // given a date string this returns a sorted representation\line function rcSortDate(strDate) \{\line strDate = this.DateConvert(strDate)\line\line var d = new Date(strDate);\line\line var day = '' + d.getDate();\line if (day.length==1) \{\line day = '0' + day;\line\}\line var month = '' + (d.getMonth()+1);\line if (month.length==1) \{\line month = '0' + month;\line\}\line var hour = '' + d.getHours();\line if (hour.length==1) \{\line hour = '0' + hour;\line\}\line var min = '' + d.getMinutes();\line if (min.length==1) \{\line min = '0' + min;\line\}\line var sec = '' + d.getSeconds();\line if (sec.length==1) \{\line sec = '0' + sec;\line\}\line var sortDate = '' + d.getFullYear() + month + day + hour + min + sec;\line return sortDate;\line\}\line\line // adds to global comments array\line function rcAddComment(title, url, id, a, datestamp) \{\line var author = a;\line var expt = '';\line var st = '';\line\line // grab content of our hidden layer containing all items\line var html = document.getElementById('comm' + id).innerHTML;\line\line // strip out whitespace \line while (html.indexOf("\\n") > -1) \{\line html = html.replace("\\n", "");\line\}\line while (html.indexOf(" />") > -1) \{\line html = html.replace(" />", "/>");\line\}\line while (html.indexOf(" <a/>") > -1) \{\line html = html.replace(" <a/>", "<a/>");\line\}\line\line var htmll = html.toLowerCase();\line var pos1 = htmll.lastIndexOf('<br><a></a>posted by');\line var pos2 = htmll.lastIndexOf('<br><a></a><a></a>');\line var pos3 = htmll.lastIndexOf('<br/><a/><a/>');\line var pos4 = htmll.lastIndexOf('<br/><a></a><a></a>');\line var aoffset = pos1 + 6;\line\line if (pos3 > -1) \{\line pos2 = pos3;\line\}\line if (pos4 > -1) \{\line pos2 = pos4;\line\}\line if (pos2 > -1) \{\line pos1 = pos2;\line aoffset = htmll.lastIndexOf('<a><b> </b></a>');\line if (aoffset == -1) \{\line aoffset = htmll.lastIndexOf('<a><b></b></a>') - 1;\line\}\line\}\line\line if (pos1 > -1) \{\line author = html.substr(aoffset+15, html.length-1);\line expt = html.substr(0, pos1-4);\line\} else \{\line expt = html;\line\}\line expt = expt.replace(/(<([^>]+)>)/ig, "");\line\line if (expt.length > 50) \{\line expt = expt.substr(0, 50);\line if (expt.lastIndexOf(' ') > -1) \{\line expt = expt.substr(0, expt.lastIndexOf(' '));\line\}\line expt += '...';\line\}\line expt = expt.replace('"', "\\"");\line expt = expt.replace("'", "\\'");\line\line author = author.replace("<A ", "<a ");\line if (!this.displayLink) \{\line author = author.replace(/(<([^>]+)>)/ig, "");\line\}\line\line // build a template string of HTML\line st = this.displayTemplate.replace('[name]', author);\line st = st.replace('[title]', '<a title="' + expt + '" href="' + url + '#c' + id + '">' + title + '</a>');\line\line // prefix with date for sorting purposes\line st = this.SortDate(datestamp) + st;\line\line // accumulate on our array\line this.comments.push(st);\line\}\line\line function rcDisplay() \{\line // most recent comments first\line this.comments.sort();\line this.comments.reverse();\line\line if (this.displayPre.length >0) \{\line document.write(this.displayPre);\line\}\line\line for (i=0; i<10 && i < this.comments.length && i < this.displayAmount; i++) \{\line var s = this.comments[i];\line\line // strips off date prefix\line s = s.substr(14, s.length-1); \line document.write(s);\line\}\line\line if (this.displayPost.length >0) \{\line document.write(this.displayPost);\line\}\line\}\par
\pard\f1\fs20\par
}
 