NetMaster
Code Helper
"Get caught in my web!"
Posts: 305
NetMaster said 0 great things
|
Post by NetMaster on Mar 5, 2012 13:30:58 GMT -8
ukskc.proboards.com/index.cgiThey want the last post cell to read: Last post by Admin on February 2, 2012, 2:24pm I know how to target the cell and grab the innerHTML but I'm not sure how to break it up and re-arrange it. I would try to write it myself but the site is on a deadline.
|
|
|
Post by Wormopolis on Mar 5, 2012 18:39:30 GMT -8
they dont want the thread title in there anymore?
|
|
NetMaster
Code Helper
"Get caught in my web!"
Posts: 305
NetMaster said 0 great things
|
Post by NetMaster on Mar 5, 2012 20:53:29 GMT -8
Nope that wasn't in the picture they made
|
|
|
Post by Wormopolis on Mar 6, 2012 11:52:58 GMT -8
I always find it funny when sites say they are "on a deadline". what exactly happens if they open 1 day late after the deadline?
if you can get the innerHTML, then use the split command to break it into the 3 lines.
lpstuff=td[x].innerHTML.split(/<br\/?>/i)
lpstuff[0] would have the when lpstuff[1] would have the who lpstuff[2] would have the what
|
|
NetMaster
Code Helper
"Get caught in my web!"
Posts: 305
NetMaster said 0 great things
|
Post by NetMaster on Mar 6, 2012 12:34:24 GMT -8
Aha, thank you Wormo. Let me test it out.
Yep got it. (Was even able to further split the date apart using a comma as the deliminator.)
Small kink.
When I break up the date to leave out the time. If the newest post was made Today. Then there are no comma's and it returns undefined. So how can I fix it. Use an if / else statement to search for innerHTML.match(/Today/) ?
Yep that fixed it. Thanks Wormo.
|
|
|
Post by Wormopolis on Mar 6, 2012 13:22:53 GMT -8
use a match statement to first look for "today", then check for "yesterday", THEN you can split by the comma
|
|
NetMaster
Code Helper
"Get caught in my web!"
Posts: 305
NetMaster said 0 great things
|
Post by NetMaster on Mar 6, 2012 13:48:46 GMT -8
Was wondering about the yesterday thing. Was trying to find a post made yesterday but no forum had one.
Now it is done.
<script type="text/javascript"> //<!-- //Merge Posts/Thread Cells //by NetMaster
var statcells = document.getElementsByTagName('td');
for(i=0;i<statcells.length;i++){ if(statcells[i].className=='windowbg2' && statcells[i].width=='66%'){ if(pb_action=='home'){ var tthreads = statcells[i+1].innerHTML; var tposts = statcells[i+2].innerHTML; statcells[i].width='50%'; statcells[i+2].style.display='none'; statcells[i+1].width='100px'; statcells[i+1].innerHTML='Posts: '+ tposts + '<br/>Threads: ' + tthreads; lpstuff=statcells[i+3].innerHTML.split(/<br\/?>/i); var date = lpstuff[0].split(/\,/i); var who = lpstuff[1]; var day = date[0]; var year = date[1]; if(statcells[i+3].innerHTML.match(/Today/)){ statcells[i+3].innerHTML='Last Post ' + who + '<br/>' + day; } else if(statcells[i+3].innerHTML.match(/Yesterday/)){ statcells[i+3].innerHTML='Last Post ' + who + '<br/>' + day; } else{ statcells[i+3].innerHTML='Last Post ' + who + '<br/>' + day + ', ' + year; } } } } //--> </script>
|
|
|
Post by Wormopolis on Mar 6, 2012 14:10:25 GMT -8
that doesnt give an error on var year = date[1] ?
if date cant be split by "," then date[1] wont exist. I guess maybe it would return an undefined...
|
|
NetMaster
Code Helper
"Get caught in my web!"
Posts: 305
NetMaster said 0 great things
|
Post by NetMaster on Mar 6, 2012 14:34:55 GMT -8
It works (no undefined) ukskc.proboards.com/index.cgiAccording to W3 Schools if the deliminator cannot be found it will return the whole string. But just so I'm not relying on a browser catch: <script type="text/javascript"> //<!-- //Merge Posts/Thread Cells //by NetMaster
var statcells = document.getElementsByTagName('td');
for(i=0;i<statcells.length;i++){ if(statcells[i].className=='windowbg2' && statcells[i].width=='66%'){ if(pb_action=='home'){ var tthreads = statcells[i+1].innerHTML; var tposts = statcells[i+2].innerHTML; statcells[i].width='50%'; statcells[i+2].style.display='none'; statcells[i+1].width='100px'; statcells[i+1].innerHTML='Posts: '+ tposts + '<br/>Threads: ' + tthreads; lpstuff=statcells[i+3].innerHTML.split(/<br\/?>/i); var exdate = lpstuff[0]; var date = lpstuff[0].split(/\,/i); var who = lpstuff[1]; var day = date[0]; var year = date[1]; if(statcells[i+3].innerHTML.match(/Today/)){ statcells[i+3].innerHTML='Last Post ' + who + '<br/>' + exdate; } else if(statcells[i+3].innerHTML.match(/Yesterday/)){ statcells[i+3].innerHTML='Last Post ' + who + '<br/>' + exdate; } else{ statcells[i+3].innerHTML='Last Post ' + who + '<br/>' + day + ', ' + year; } } } } //--> </script>
|
|
|
Post by Wormopolis on Mar 6, 2012 14:44:50 GMT -8
Excellent work!
|
|