Welcome Guest [Log In] [Register]
We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Code Index
Topic Started: Jan 27 2009, 11:20 PM (320 Views)
Justin186
Member Avatar
IF / ZB coder
 *   *   *  
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>
Edited by Justin186, Jan 29 2009, 01:54 AM.
Offline Profile Quote Post Goto Top
 
Tony
Katorga-12

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.
Offline Profile Quote Post Goto Top
 
Justin186
Member Avatar
IF / ZB coder
 *   *   *  
yer i was planning on doing that and im going to fix some other minor bugs aswell
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Code Snippets · Next Topic »
Add Reply