|
Post by Wormopolis on Dec 31, 2010 0:17:37 GMT -8
Browser tested: IE, FF, and Chrome placement: global footer Puts little quote buttons next to each topic summary post that will add it as a quote in the current message. will not work from places like recentposts due to the need for post numbers to be recorded. code: <script type="text/javascript"> <!-- // quotes from topic summary v1.2 // by Wormopolis - www.wormocodes.com // keep header intact - do not repost
if (pb_action=='display') { var threadId=(location.href.match(/thread=(\d+)($|&)/) ? RegExp.$1 : 'error'); var postList=''; for (tds=document.getElementsByTagName('td'), p=0; p<tds.length; p++) { if (tds[p].width=='20%' && tds[p].vAlign=='top' && tds[p].align=='left' && tds[p].firstChild && tds[p].firstChild.name) postList+=tds[p].firstChild.name+','; } postList=postList.substr(0,postList.length-1); document.cookie='qts_'+threadId+':'+postList; }
function DateToStamp(datestr) {
var months=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec']; var todayHandler=new Date(); datestr=datestr.replace(/<b>Today<\/b> at/i,months[todayHandler.getMonth()]+' '+todayHandler.getDate()+', '+todayHandler.getFullYear()+', '); todayHandler.setTime(todayHandler.getTime()-(1000*60*60*24)); datestr=datestr.replace(/Yesterday at/i,months[todayHandler.getMonth()]+' '+todayHandler.getDate()+', '+todayHandler.getFullYear()+', ');
datestr=datestr.split(', '); tmpMonth=datestr[0].split(' ')[0]; for (ii=0; ii<months.length; ii++) if (months[ii]==tmpMonth) tmpMonth=ii; tmpDate=datestr[0].split(' ')[1]; tmpYear=datestr[1]; tmpHour=parseInt(datestr[2].split(':')[0]); tmpMin=parseInt(datestr[2].split(':')[1]); // 12am=0 1pm=13 tmpHour+=(datestr[2].match(/pm/i) ? 12 : 0); tmpHour-=(tmpHour%12==0 ? 12 : 0);
finalDate=new Date(); finalDate.setFullYear(tmpYear); finalDate.setMonth(tmpMonth); finalDate.setDate(tmpDate); finalDate.setHours(tmpHour); finalDate.setMinutes(tmpMin); finalDate.setSeconds(0); return parseInt(finalDate.getTime()/1000); }
function showSomething(obj) { obj.style.fontStyle='italic'; obj.style.border='#ffffff 1px solid'; to=window.setTimeout(function() {obj.style.fontStyle=""; obj.style.border=""; },500); }
function recursionQuotes(qcontent) { var qregx1=/(<br><b><a(.*?)wrote:((.|\n)*?)<table (.*?)class=\\?'?quote\\?'?((.|\n)*?)<font (.*?)class=\\?'?quote\\?'?((.|\n)*?)>)((.|\n)*?)(<\/font><\/td><\/tr><\/tbody><\/table><\/td><\/tr><\/tbody><\/table>(?!<\/(font|blockquote)>))/im; var qregx2=/<br><b><a(.*?)wrote:((.|\n)*?)<table (.*?)class=\\?'?quote\\?'?((.|\n)*?)<font (.*?)class=\\?'?quote\\?'?((.|\n)*?)>((.|\n)*?)/im;
var qtmp=qcontent.match(qregx1);
if (qtmp) { if ( qtmp[11].match(qregx2)) { //nested quotes var anothertmp=recursionQuotes(qtmp[11]+qtmp[13]); return recursionQuotes(qtmp[1] + anothertmp + qcontent.replace(qregx1,'')); } else { recauth=(qtmp[2].match(/user=(.*?)\\/) ? RegExp.$1 : ''); recbrd=(qtmp[2].match(/board=(.*?)&/) ? RegExp.$1 : ''); recthrd=(qtmp[2].match(/thread=(.*?)&/) ? RegExp.$1 : ''); recpst=(qtmp[2].match(/post=(.*?)\\/) ? RegExp.$1 : ''); recdate=(qtmp[2].match(/>(.*?)<\/a>/i) ? RegExp.$1 : ''); recdate=DateToStamp(recdate); reccontents=fetchStuff(recauth, recbrd, recthrd, recpst, recdate, qtmp[11]); return recursionQuotes(qcontent.replace(qregx1,reccontents)); } } else { return qcontent; } }
function fetchStuff(auth, brd, thrd, pst, date, contents) { contents=recursionQuotes(contents);
//contents=contents.replace(/<b><a(.*?)wrote:((.|\n)*?)<table (.*?)class=\\?'?quote\\?'?((.|\n)*?)<font (.*?)class=\\?'?quote\\?'?((.|\n)*?)>((.|\n)*?)<\/font><\/td><\/tr><\/tbody><\/table><\/td><\/tr><\/tbody><\/table>(?!<\/(font|blockquote)>)/gim,function(total, qstuff, crap1, crap2, crap3, crap4, crap5, crap6, crap7, crap8, insides) {recauth=(qstuff.match(/user=(.*?)\\/) ? RegExp.$1 : ''); recbrd=(qstuff.match(/board=(.*?)&/) ? RegExp.$1 : ''); recthrd=(qstuff.match(/thread=(.*?)&/) ? RegExp.$1 : ''); recpst=(qstuff.match(/post=(.*?)\\/) ? RegExp.$1 : ''); recdate=(qstuff.match(/>(.*?)<\/a>/i) ? RegExp.$1 : ''); recdate=DateToStamp(recdate); reccontents=fetchStuff(recauth, recbrd, recthrd, recpst, recdate, insides); return reccontents; }); //catch quotes for recursion
contents=contents.replace(/<table(.*?)<embed src=\\?\'?http:\/\/www\.youtube\.com\/v\/(.*?)&((.|\n)*?)<\/table>/gim,'[yt]$2[/yt]'); //catch youtube
contents=contents.replace(/<hr(.*?)>/gim,'[hr]'); //catch HR tags
contents=contents.replace(/<(\/)?marquee>/gim,'[$1move]'); //catch move tags
annoyingrgx=new RegExp("<blockquote><b>code:<\\/b>((.|\\n)*?)<table (.*?)class=\\\\?'?co" + "de\\\\?'?((.|\\n)*?)<font (.*?)class=\\\\?'?code\\\\?'?((.|\\n)*?)>((.|\\n)*?)<\\/fo" + "nt><\\/td><\\/tr><\\/tbody><\\/table>" + "<\\/td><\\/tr><\\/tbody><\\/table><\\/blockquote>","gim"); contents=contents.replace(annoyingrgx,'[co'+'de]$9[/co'+'de]'); //catch code tag
contents=contents.replace(/<div style=\\'filter: glow\(color=(.*?)\,strength=(\d+)\); width: (\d+)px\\'>(.*?)<\/div>/gim,'[glow=$1,$2,$3]$4[/glow]'); //catch glow in IE contents=contents.replace(/<div style=\\'width:(\d+)px; filter:glow\(color=(.*?),strength=(.*?)\)\\'>(.*?)<\/div>/gim,'[glow=$2,$3,$1]$4[/glow]'); //catch glow in Chrome contents=contents.replace(/<div style=\\'width: (\d+)px;\\'>(.*?)<\/div>/gim,'[glow=red,2,$1]$2[/glow]'); //catch glow in FF -cannot derive color or strength, so use defaults
contents=contents.replace(/<div style=\\'(.*?) filter: shadow\(color=(.*?)\,direction=(.*?)\); (.*?) width: (\d+)px; (.*?)\\'>(.*?)<\/div>/gim,function(total,p1,p2,p3,p4,p5,p6,p7){ direct=(p3=='0' ? 'up' : p3=='90' ? 'right' : p3=='180' ? 'down' : 'left'); return ('[shadow='+p2+','+direct+','+p5+']'+p7+'[/shadow]'); }); //catch shadow in IE contents=contents.replace(/<div style=\\'padding:5px;width:(\d+)px;\s?filter:shadow\(color=(.*?),direction=(.*?)\)\\'>(.*?)<\/div>/gim,function(total,p1,p2,p3,p4){direct=(p3=='0' ? 'up' : p3=='90' ? 'right' : p3=='180' ? 'down' : 'left'); return ('[shadow='+p2+','+direct+','+p1+']'+p4+'[/shadow]'); }); //catch shadow in chrome contents=contents.replace(/<div style=\\'padding: 5px; width: (\d+)px;\\'>(.*?)<\/div>/gim,function(total,p1,p2){ return ('[shadow=red,left,'+p1+']'+p2+'[/shadow]'); }); //catch shadow in FF - cannot derive color or direction so use defaults
contents=contents.replace(/<p align=\\?'?(\w+)\\?'?>(.*?)<\/p>/gim,'[$1]$2[/$1]'); //catch alignment
contents=contents.replace(/<font (size|color)=\\?'?(\w+|\d+)\\?'?>(.*?)<\/font>/gim,'[$1=$2]$3[/$1]'); //catch color/size tags
contents=contents.replace(/<font face=\\?'?(\w+|\d+)\\?'?>(.*?)<\/font>/gim,'[font=$1]$2[/font]'); //catch face tags
contents=contents.replace(/<img (title=(.*?))?alt=\\?'?(.*?)\\?'? src=\\'(.*?)images\.proboards\.com(.*?)\\' (.*?)>/gim,'$3'); //catch smilies in IE contents=contents.replace(/<img src=\\'(.*?)images\.proboards\.com(.*?)\\' alt=\\'(.*?)\\' (.*?)>/gim,'$3'); //catch smilies in Chrome and FF
contents=contents.replace(/<img (.*?) src=\\'(.*?)\\' (.*?)>/gim,'[img]$2[/img]'); //catch images
contents=contents.replace(/<a href=(.*?) (.*?)>(.*?)<\/a>/gim,'[url=$1]$3[/url]'); //catch links
contents=contents.replace(/<table border=\\?'?1\\?'?>\n?<tbody>(.*?)<\/tbody><\/table>/gim,'[table]$1[/table]'); //catch tables
contents=contents.replace(/<(\/?)([^>]+)>/gim,'[$1$2]'); //catch all other tags
return ('[quote author='+auth+' board='+brd+' thread='+thrd+' post='+pst+' time='+date+'] '+contents+'[/quote]');
}
(function() { if (pb_action.match(/(modify)?post/)) { var currentThreadPosting=(location.href.match(/thread=(\d+)($|&)/) ? RegExp.$1 : 'error'); if (document.cookie.match(/qts_(\d+):(.*?)(;|$)/)) { var storedThreadId=RegExp.$1; var storedPostList=RegExp.$2; if (currentThreadPosting==storedThreadId) { for (tds=document.getElementsByTagName('td'), ts=0; ts<tds.length; ts++) { if (tds[ts].width=='100%' && tds[ts].className=='titlebg' && tds[ts].innerHTML.match(/Topic Summary/)) { var startRow=tds[ts].parentNode; break; } } if (startRow) { var hrow=startRow.nextSibling; TSpostList=storedPostList.split(','); for (pl=0; pl<TSpostList.length; pl++) { tmpauth=(hrow.getElementsByTagName('a')[0] ? hrow.getElementsByTagName('a')[0].href.split(/user=/)[1] : 'Guest'); tmpdate=hrow.firstChild.firstChild.innerHTML.split(/on /)[1]; //date is in format of Sept 2, 2010, 7:42pm tmpdate=DateToStamp(tmpdate); tmpbrd=location.href.split(/board=/)[1].split(/&/)[0]; tmpthrd=location.href.split(/thread=/)[1].split(/&/)[0]; tmppst=TSpostList[pl]; tmpcontents=hrow.nextSibling.firstChild.firstChild.innerHTML.replace(/'/g,"\\'").replace(/"/g,"\\'").replace(/(\n|\r)/gm,''); tmpcontents=fetchStuff(tmpauth, tmpbrd, tmpthrd, tmppst, tmpdate, tmpcontents); var tmp='<a onclick="hold=\''+tmpcontents+'\'; document.postForm.message.value+=hold; showSomething(this);"><img src="http://s2.images.proboards.com/buttons/quote.gif" border=0></a>'; hrow.firstChild.firstChild.innerHTML='<table width="100%"><tr><td align="left">' + hrow.firstChild.firstChild.innerHTML + '</td><td align="right">'+tmp+'</td></tr></table>'; hrow=hrow.nextSibling.nextSibling; } } } } } })(); // --> </script>
preview: using it on this site currently
|
|
|
Post by Wormopolis on Dec 31, 2010 0:29:56 GMT -8
apparently it doesnt like really long posts...
|
|
|
Post by Wormopolis on Dec 31, 2010 7:58:40 GMT -8
or rather.. something INSIDE itself is tripping things up. I have to investigate further. you can try it out if you want however.
|
|
wildgoosespeeder
Code Helper
Tiers are for strangers!
Posts: 530
wildgoosespeeder said 161 great things
|
Post by wildgoosespeeder on Dec 31, 2010 15:05:38 GMT -8
Well the image tag and smileys could use some work...maybe you or I can work up a solution for the code to tell the difference?
|
|
|
Post by Wormopolis on Dec 31, 2010 15:19:41 GMT -8
the only difference is the src of the picture. Im not about to stor in the code EVERY instance of a smily emote.. I just dont care about them that much.
|
|
|
Post by Wormopolis on May 5, 2011 2:55:51 GMT -8
PB is putting a break into one of those long lines and breaking it. I have to figure out a way around that.
|
|
|
Post by Wormopolis on Oct 22, 2012 15:26:37 GMT -8
version update 1.2: rewrote the recursion algorithms for nested and multiple quotes.
|
|