|
Post by Marty on Jun 22, 2005 9:00:44 GMT -8
This code is cross browser. <script type="text/javascript"> <!-- /* Alphabetize Users Online Made by Marty Please do not repost without my permission */
var td=document.getElementsByTagName("td"); var users=new Array();
for (t=0; t < td.length; t++) { if (td[t].innerHTML.match(/Users Online/i) && td[t].className=="catbg" && td[t+3].innerHTML.match(/\,\s</gi)) { var user=td[t+3].getElementsByTagName("a"); for (u=0; u < user.length; u++) { if (user[u].href.match(/viewprofile&user=/i)) { if (user[u].firstChild.firstChild) { users.push([user[u].getElementsByTagName("font")[0].innerHTML.toLowerCase(),user[u].getElementsByTagName("font")[0].innerHTML,user[u].href,user[u].getElementsByTagName("font")[0].color,user[u].className]); } else { users.push([user[u].innerHTML.toLowerCase(),user[u].innerHTML,user[u].href]); } } } users.sort(); var split=td[t+3].getElementsByTagName("font")[0].innerHTML.split(/<br>/i)[1]; var newUsers=''; for (u=0; u < users.length; u++) { if (users[u].length==5) { newUsers+='<a href="/index.cgi?action=viewprofile&user=' + users[u][2] + '" class="' + users[u][4] + ' onclick="pb_bubble=1"><font color="' + users[u][3] + '">' + users[u][1] + '</font></a>'; } else { newUsers+='<a href="/index.cgi?action=viewprofile&user=' + user[u][2] + '" onclick="pb_bubble=1">' + users[u][1] + '</a>'; } } newUsers=newUsers.replace(/><a/gi,">, <a") td[t+3].innerHTML=td[t+3].innerHTML.replace(split,newUsers); } } //--> </script> This code will alphabetize the users online. It can be annoying to search through all 20 members to see if someone is on, so I made this. Main footer
|
|
|
Post by SonicX on Jun 22, 2005 9:24:28 GMT -8
Nice Code!!
|
|
|
Post by Nomi on Jun 22, 2005 9:28:29 GMT -8
Nice work Marty.
|
|
|
Post by CD on Jun 22, 2005 16:27:32 GMT -8
You scare me Marty. That code scares me.
Oh, and nice code. Makes me feel stupid. >.<
|
|
|
Post by Marty on Jun 22, 2005 22:32:26 GMT -8
It's not really that hard of a code. All you need to do is put all the user names into an array, then use sort().
|
|
|
Post by CrAzY_J on Jun 22, 2005 22:40:19 GMT -8
wooooooooooooooooooo first PB code ive seen with array_push!!
good job Martyyy
|
|
|
Post by Marty on Jun 22, 2005 22:50:18 GMT -8
lol. I learned how to do stuff with arrays a long time ago. I just never used it until now. You can also pop() an array, which gets rid of the last thing in the array. Edit: Oh yeah, you can also shift(), unshift(), and reverse() arrays.
Last Edit: Jun 22, 2005 23:04:24 GMT -8 by Marty
|
|
|
Post by CrAzY_J on Jun 22, 2005 23:05:13 GMT -8
lol. I learned how to do stuff with arrays a long time ago. I just never used it until now. You can also pop() an array, which gets rid of the last thing in the array. yeah i know i just never knew i/anyone could find it usefull for proboards coding Peter used .reverse() , i didnt even think someone could find that usefull for ANY code
|
|
|
Post by Marty on Jun 22, 2005 23:10:18 GMT -8
lol. I learned how to do stuff with arrays a long time ago. I just never used it until now. You can also pop() an array, which gets rid of the last thing in the array. yeah i know i just never knew i/anyone could find it usefull for proboards coding Peter used .reverse() , i didnt even think someone could find that usefull for ANY code That reminds me of a code I was going to make. * runs off to start coding *
|
|
|
Post by CD on Jun 22, 2005 23:36:14 GMT -8
Damn. I fell stupid now. >.<
|
|