|
Post by Wormopolis on Nov 22, 2009 0:29:29 GMT -8
Browsers tested: IE and FF placement: board or global footer
puts a button above each post (by quote/modify/delete) that lets you merge a post with the previous post if they are by the same person. includes a variable that lets anyone merge their posts rather then just users with the ability to modify posts.
code:
<script type="text/javascript"> <!-- // OptionMerge multiple posts v 1.0 // by Wormopolis // Do Not Repost - Header must stay intact // put in board footer, or global footer for all boards.
var mergeBtnImage="http://i197.photobucket.com/albums/aa250/WORMOPOLIS/mergeBtn.gif" var showWhoMerged=false; //true or false (admin always sees) var allowSelfMerge=false; //allow anyone to merge their posts var usersWhoCanMergeOwnPosts=/admin|danger|user3|user4/;
if (!location.href.match(/userrecentposts/i) && !location.href.match(/ion=recent/)) {
if (location.href.match(/MERGEIT/)) { for (tbls=document.getElementsByTagName('table'), t=0; t<tbls.length; t++) { tbls[t].style.display="none"; } document.write("<div style='background-color:000000; color: FFFFFF;'><center>Merge Post with Previous Post?<br><br><input type='button' value='Yes' onclick='document.postForm.message.value+=\"\\n[:merge:"+pb_displayname +"]\"; document.postForm.submit();' > <input type='button' value='No' onclick='location.href=document.referrer'></center></div>"); }
modCheck=false;
iCells=document.getElementsByTagName('hr'); for ( i=iCells.length-1; i>0; i--) { if(iCells[i].parentNode.vAlign=='top') { var msgCell = iCells[i].parentNode; var authCell = iCells[i].parentNode.parentNode.parentNode.parentNode.parentNode.previousSibling; var postCell = authCell.parentNode; if (!authCell.getElementsByTagName('a')[2]) { var auth = authCell.innerHTML.split(/<\/A>/i)[2].split("<BR")[0]; } else { var auth = authCell.getElementsByTagName('a')[2].href.split('user=')[1]; } moddy=''; if (msgCell.innerHTML.match(/\[\:merge\:(.*?)\]/)) moddy=RegExp.$1; moddy=(showWhoMerged || pb_username=='admin' ? " Posts merged by: " + moddy + "<br>" : ''); var disc = "<br/><br/><br/>"; var btns=msgCell.parentNode.previousSibling.getElementsByTagName('a'); var modBtn=''; if (btns[0]) btnStuff=btns[0].parentNode; for (m=0; m<btns.length; m++) { var tmp=document.createElement('div'); if (btns[m].href.match(/action=modifypost/)) modBtn=btns[m].href+"&MERGEIT"; var cloneBtn=btns[m].cloneNode(true); tmp.appendChild(cloneBtn); disc+=tmp.innerHTML; } disc+="<br/>"; (iCells[i-1].parentNode.vAlign=='top') ? j=1 : j=2; var prev_msgCell = iCells[i-j].parentNode; var prev_authCell = iCells[i-j].parentNode.parentNode.parentNode.parentNode.parentNode.previousSibling; if (!prev_authCell.getElementsByTagName('a')[2]) { var prev_auth = prev_authCell.innerHTML.split(/<\/A>/i)[2].split("<BR")[0]; } else { var prev_auth = prev_authCell.getElementsByTagName('a')[2].href.split('user=')[1]; } if (prev_auth == auth ) { if (msgCell.innerHTML.match(/\[\:merge\:(.*?)\]/)) { msgCell.innerHTML=msgCell.innerHTML.replace(/\[\:merge\:(.*?)\]/,''); vict=msgCell.firstChild; noob=document.createElement("br"); msgCell.replaceChild(noob,vict); prev_msgCell.innerHTML+=disc + msgCell.innerHTML; postCell.style.display='none'; } else { if (modBtn && (pb_username!=auth || pb_username==auth && (allowSelfMerge || pb_username.match(usersWhoCanMergeOwnPosts)))) { nwBtn=document.createElement('a'); nwBtn.href=modBtn; nwBtnImg=document.createElement('img'); nwBtnImg.src=mergeBtnImage; nwBtnImg.border=0; nwBtn.appendChild(nwBtnImg); if (btnStuff) btnStuff.appendChild(nwBtn); } } } } } } // --> </script>
|
|