|
Code Index
|
|
Topic Started: Jan 27 2009, 11:20 PM (320 Views)
|
|
Justin186
|
Jan 27 2009, 11:20 PM
Post #1
|
- Posts:
- 302
- Group:
- Members
- Member
- #59,790
- Joined:
- July 3, 2005
- I'm Browsing With
- Firefox 3
|
Well i made this because i couldn't be bothered indexing all the codes in the snippets.
this code is mainly for resource boards
So what you do is get the forum id for the forum which contains all the codes.
then create the forums rules and give it the title "Code Index" then, make it so that you can get there by link.
Preview
- Code:
-
<script type='text/javascript'> // IF Code Index by Justin186
var forum = 1;
// Do not edit below var aStarter = ""; var aTopic = ""; document.write("<div id='ajax' style='display:none'></div>"); var loca = location.href.split("?")[0];
if(location.href.match("act=SR&f="+forum+"&pg=")){ var page = location.href.split("&pg=")[1]; page = parseInt(page); locat = page * 15; var url = loca + "?showforum="+forum+"&prune_day=30&sort_by=A-Z&sort_key=title&st="+locat index(url)
}
if(location.href.match("showforum="+forum) || location.href.match("f="+forum)){ var a = document.getElementsByTagName("a") for(b=0;b<a.length;b++){ if(a[b].href.match("act=SR&f="+forum)){ a[b].href += "&pg=0"; } } }
function index(locass){ var aAjax = document.getElementById("ajax"); var aMs = aJx(); aMs.open("GET", locass, true); aMs.onreadystatechange = function(){ if(aMs.readyState == 4){ aAjax.innerHTML = aMs.responseText; var awesome = aAjax.getElementsByTagName("a"); for(xe=0;xe<awesome.length;xe++){ if(awesome[xe].href.indexOf("showtopic=") != -1 && awesome[xe].parentNode.className == "row4"){ aTopic += "<a href='"+awesome[xe].href+"'>"+awesome[xe].innerHTML+"</a> * "; } } for(mt=0;mt<awesome.length;mt++){ if(awesome[mt].href.indexOf("showuser=") != -1 && awesome[mt].parentNode.className == "row2"){ aStarter += "<a href='"+awesome[mt].href+"'>"+awesome[mt].innerHTML+"</a> * " } } var aDiv = document.getElementsByTagName("div"); for(nm=0;nm<aDiv.length;nm++){ if(aDiv[nm].className == "tablepad"){ var topic = aTopic.split(" * "); var start = aStarter.split(" * "); var a = "<div class='titlemedium'><span class='titlemedium' id='pages' align='left'></span><center><b>Code Index</b></center></div><div class='row2'><center><table border='1' cellspacing='1' class='desc' width='100%' style='-moz-border-radius:5px'><tr><th><u>Topic</u></th><th><u>Starter</u></th></tr>"; for(stm=0;stm<topic.length;stm++){ a += "<tr id='awesome"+stm+"' style='-moz-border-radius:5px'><td>" + topic[stm] + "</td></tr>" } a += "</center></table></div>" aDiv[nm].innerHTML = a; for(stl=0;stl<start.length;stl++){ document.getElementById("awesome"+stl).innerHTML += "<td>"+start[stl]+"</td>"; } var cool = aAjax.getElementsByTagName("a") for(xer=0;xer<cool.length;xer++){ if(cool[xer].innerHTML.indexOf("Pages:") != -1){ var rawrr = cool[xer].parentNode.innerHTML.split("(")[2].split(")")[0] var number = parseFloat(rawrr) var ast = "Pages: " for(mzz=0;mzz<number;mzz++){ ast += "<b>[</b> <a href='"+loca + "?act=SR&f=1&pg="+mzz+"'>"+ (mzz + 1) + "</a> <b>]</b> "; } document.getElementById("pages").innerHTML = ast; } } } } } } aMs.send(null); } function aJx(){ var aJr; try { aJr = new XMLHttpRequest(); } catch (e) { try { aJr = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { try { aJr = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { aJr = null; } } } return aJr; } </script>
|
|
|
| |
|
Tony
|
Jan 28 2009, 07:27 AM
Post #2
|
Katorga-12
- Posts:
- 7,026
- Group:
- Global Support Team
- Member
- #32,550
- Joined:
- October 15, 2004
|
It's a nice idea for a code.
How about indexing alphabetically? At the moment it looks to be by topic ID.
A challenge for you: Have the code index by category, alphabetically. This can allow users to set category names that coders pre-pend to the topic titles.
|
|
|
| |
|
Justin186
|
Jan 28 2009, 08:23 AM
Post #3
|
- Posts:
- 302
- Group:
- Members
- Member
- #59,790
- Joined:
- July 3, 2005
- I'm Browsing With
- Firefox 3
|
yer i was planning on doing that and im going to fix some other minor bugs aswell
|
|
|
| |
| 1 user reading this topic (1 Guest and 0 Anonymous)
|