victory1
Full Member
Posts: 102
victory1 said 0 great things
|
Post by victory1 on Feb 5, 2010 11:12:44 GMT -8
I would like a code to hide the <<Last Edit>> tag using Javascript if the edit occurred within 5 minutes of the post.
Basically rather then remove the "Last edited .... " message, I want to put a delay time for a user to edit to prevent the message.
For example. I posted a message, saw a mistake, and fixed the message within say 5 minutes...then no "Last edited ...." message popped up.
|
|
victory1
Full Member
Posts: 102
victory1 said 0 great things
|
Post by victory1 on Feb 5, 2010 12:58:17 GMT -8
Someone pointed me to a code that hides it completely but it does not do I wanted it do, which only to hide it for a brief timeframe. Here is the code.
GF <script type="text/javascript"> <!-- /* remove last edit */ var font=document.getElementsByTagName("font"); if(location.href.match(/on=(displ|search2|(user)?rece)/)){ for(i=0;i<font.length;i++){ if(font[i].innerHTML.match(/Last\sEdit:/i) && font[i].parentNode.align=="left"){ font[i].style.display="none"; } } } // --> </script>
[:merge:Wormopolis]
|
|
|
Post by Wormopolis on Feb 5, 2010 21:51:58 GMT -8
This is going to take a little bit of trial and error. basically it will just involve extracting the 2 timestamps from the top and bottom, converting them to machine timestamps, then comparing them.
keep your eyes peeled.
|
|
victory1
Full Member
Posts: 102
victory1 said 0 great things
|
Post by victory1 on Feb 5, 2010 22:12:57 GMT -8
This is going to take a little bit of trial and error. basically it will just involve extracting the 2 timestamps from the top and bottom, converting them to machine timestamps, then comparing them. keep your eyes peeled. No problem. Thanks
|
|
|
Post by Wormopolis on Feb 8, 2010 1:58:51 GMT -8
Testing #1
and modifying 1 minute later
|
|
|
Post by Wormopolis on Feb 8, 2010 2:22:04 GMT -8
well it works if the post wasnt made today.. I have to figure it our more but Im tired.
modifying several hours later...
|
|
|
Post by Wormopolis on Feb 8, 2010 11:42:33 GMT -8
Give this a shot...
<script type="text/javascript"> <!-- // "last edit" window // by Wormopolis - concept by victory1 // www.wormocodes.com // keep header intact - do not repost
hideIfUnderXMinutes=5;
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; 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(','); 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"; } } } } } }
// --> </script>
|
|
victory1
Full Member
Posts: 102
victory1 said 0 great things
|
Post by victory1 on Feb 8, 2010 13:43:33 GMT -8
It worked!!! You know how many people on Proboards wants that script? A bunch! ;D When I made a Google search for it, there were a lot of inquiries but no follow through! You're the man! Thanks! ;D
|
|
|
Post by Wormopolis on Feb 9, 2010 0:25:07 GMT -8
well I will put it into my submissions area (and eventually the database). so if you see anyone asking about it, send em there.
EDIT days later edit.
|
|