|
Post by Wormopolis on Feb 9, 2010 0:31:52 GMT -8
Browser tested: IE and FF placement: board or global footer (closer to the top the better)
this code, though it looks complex, simply hides the "last edit" that appears at the bottom of a post, if the edit occured within a certain number of minutes from the post creation. useful if you make a quick edit after you JUST posted, but dont want the last edit to show there. window minutes are editable.
<script type="text/javascript"> <!-- // "last edit" window v1.4 // by Wormopolis - concept by victory1 // www.wormocodes.com // keep header intact - do not repost
hideIfUnderXMinutes=5; alwaysHideEditFromTheseUsers="admin|otheruser|user3|user4"; //seperate by | alwaysHideOnTheseUsersPosts="admin|otheruser"; //seperate by |
if (true) {
tmpdate=new Date(); tmpydate=new Date(); tmpydate.setTime(tmpdate.getTime()-(1000*60*60*24)); tmpdate=tmpdate.toDateString(); tmpydate=tmpydate.toDateString(); if (tmpdate.match(/(\S+)\s(\S+)\s(\d+)\s(\d+)/)) tmpdate=RegExp.$2+" "+RegExp.$3+", "+RegExp.$4+","; if (tmpdate.match(/ 0(\d)/)) tmpdate=tmpdate.replace(/ 0(\d)/,' '+RegExp.$1); if (tmpydate.match(/(\S+)\s(\S+)\s(\d+)\s(\d+)/)) tmpydate=RegExp.$2+" "+RegExp.$3+", "+RegExp.$4+","; if (tmpydate.match(/ 0(\d)/)) tmpydate=tmpydate.replace(/ 0(\d)/,' '+RegExp.$1);
for (tds=document.getElementsByTagName('td'), p=0; p<tds.length; p++) { if (tds[p].width=='80%' && tds[p].vAlign=='top' && tds[p].className.match(/windowbg/)) { for (i_inside=tds[p].getElementsByTagName('i'), n=0; n<i_inside.length; n++) { if (i_inside[n].innerHTML=="Last Edit:") { f_keep=i_inside[n].parentNode; hold1=f_keep.innerHTML; tmp=new RegExp('user=('+alwaysHideEditFromTheseUsers+')"',''); if (hold1.match(/viewprofile/) && hold1.match(tmp)) f_keep.style.display="none"; if (hold1.match(/<b>Today<\/b> at/i)) hold1=hold1.replace(/<b>Today<\/b> at/i, tmpdate); if (hold1.match(/Yesterday at/i)) hold1=hold1.replace(/Yesterday at/i, tmpydate); e_date=hold1.split(/<\/i> /i)[1].split(/by/)[0].split(','); OPname=tds[p].previousSibling.getElementsByTagName('b');
if (OPname[0] && OPname[0].firstChild && OPname[0].firstChild.nodeName.match(/^a$/i) && OPname[0].firstChild.href.match(/action=viewprofile&user=(.*?)$/i)) { OPname=RegExp.$1; } else { OPname=''; } hold2=tds[p].firstChild.rows[0].cells[1].lastChild.innerHTML; if (hold2.match(/<b>Today<\/b> at/i)) hold2 = hold2.replace(/<b>Today<\/b> at/i, 'on '+tmpdate); if (hold2.match(/Yesterday at/i)) hold2 = hold2.replace(/Yesterday at/i, 'on '+tmpydate); p_date=hold2.split(/on /)[1].split(','); if (e_date[0]==p_date[0] && e_date[1]==p_date[1]) { dt1=new Date(); dt2=new Date(); e_date[2].match(/(\d+):(\d+)(a|p)m/); e_dayp=(RegExp.$3=='p' ? 12 : 0); e_hour=parseInt(RegExp.$1); e_min=parseInt(RegExp.$2); p_date[2].match(/(\d+):(\d+)(a|p)m/); p_dayp=(RegExp.$3=='p' ? 12 : 0); p_hour=parseInt(RegExp.$1); p_min=parseInt(RegExp.$2); e_hour=(e_hour == 12 ? 0 : e_hour)+e_dayp; p_hour=(p_hour == 12 ? 0 : p_hour)+p_dayp; dt1.setHours(e_hour); dt1.setMinutes(e_min); dt2.setHours(p_hour); dt2.setMinutes(p_min); dt1.setSeconds(0); dt2.setSeconds(0); t_span=(dt1-dt2)/(1000*60); if (t_span<hideIfUnderXMinutes) f_keep.style.display="none"; } tmp2=new RegExp('^'+alwaysHideOnTheseUsersPosts+'$',''); if (OPname.match(tmp2)) f_keep.style.display="none"; } } } } }
// --> </script>
|
|
|
Post by Wormopolis on Feb 19, 2010 3:56:32 GMT -8
added a variable to hide edits on certain users posts regardless of time of edit.
|
|
|
Post by Wormopolis on Feb 26, 2010 18:12:25 GMT -8
fixed the last edit to actually work correctly.
|
|
victory1
Full Member
Posts: 102
victory1 said 0 great things
|
Post by victory1 on Feb 27, 2010 14:10:37 GMT -8
I love the new changes. It worked perfectly on my Test Board. I don't know how difficult that might be but I just told my Global Mod about the new changes in the Edit Script and we want to know if the user exclusion can also be change to include other people post. Basically as admin when I modify my own post after 5 minutes it worked. Let's say I want to modify a user post after 5 minutes, can it behave the same way?
|
|
|
Post by Wormopolis on Feb 27, 2010 20:09:53 GMT -8
yeah.. the change you requested on PBS was worded as you wanted it to work if the POST was made by someone in the exclusion list, not if the EDIT was made. so that is how I wrote it.
I replied to your post on PBS.
|
|
victory1
Full Member
Posts: 102
victory1 said 0 great things
|
Post by victory1 on Feb 27, 2010 20:36:58 GMT -8
yeah.. the change you requested on PBS was worded as you wanted it to work if the POST was made by someone in the exclusion list, not if the EDIT was made. so that is how I wrote it. I replied to your post on PBS. Hi, that was not me. I have not requested any changes in PBS. Since I visit this site everyday and saw the new changes which by the way I thought it was cool, the new idea just occurred to my GM after I told him you made changes to the code! Since I don't know anything about coding, I just thought I'd pose his question!
|
|
|
Post by Wormopolis on Feb 28, 2010 0:43:21 GMT -8
oh.. weird. There is another guy on PBS using this code as well then.
I just posted a revised version there. I will post one here as well.
|
|
|
Post by Wormopolis on Nov 7, 2010 17:40:06 GMT -8
version update 1.4: added in variable for last edit to be hidden on particular user's posts regardless of time, revamped code part for hiding certain users edits regardless of post&time.
|
|