Post by Marc on Nov 15, 2006 19:50:14 GMT -8
Ok, this code will change your code index. It splits the codes into categories, you can search through codes, you can view the most recent codes, etc.
Preview: Here
Now, there are two parts to this code.
Part 1: Board Header
Part 2: Board Footer
Before you use this code, there are a few things to edit.
I'll go through these first:
//Last Update
var lastup="Wednesday November 15th, 2006 8:45PM"; //Most recent update
//Database Info
var dbthread="1163630241"; //The thread where your index will be
var dbforum="test1"; //The board id where your index is in
Edit the first one(var lastup) to the current date & time every time you update your database.
For the second one(var dbthread), create a new thread for your code index, and get the thread number for it.
For the third one(var dbforum), enter the board id where the index thread is in.
Now, for entering the codes and categories.
//Sections
var sections=[];
sections[0]=["Category Name","Category ID"];
sections[1]=["Category Name","Category ID"];
sections[2]=["Category Name","Category ID"];
//Codes
var codes=[];
codes[0]=["Code Name","Thread Number","Category"];
codes[1]=["Code Name","Thread Number","Category"];
codes[2]=["Code Name","Thread Number","Category"];
codes[3]=["Code Name","Thread Number","Category"];
codes[4]=["Code Name","Thread Number","Category"];
codes[5]=["Code Name","Thread Number","Category"];
codes[6]=["Code Name","Thread Number","Category"];
codes[7]=["Code Name","Thread Number","Category"];
codes[8]=["Code Name","Thread Number","Category"];
codes[9]=["Code Name","Thread Number","Category"];
codes[10]=["Code Name","Thread Number","Category"];
codes[11]=["Code Name","Thread Number","Category"];
This part is pretty straightforward as well.
For each new category you want, just repeat the line, increasing the number by 1.
For the "Category ID" part, enter a short 1 word id for your category. For instance, admin editable codes may have a category id of "admin".
For entering codes, you enter the name of the code in the first part, the thread number of the code in the second one, and the id of the category you would like it to be in.
If that confuses you, post in support, and i'll be sure to help you out
Enjoy!
Edit by Ross: Improved the loop to hide the thread information so as not to conflict with any border around forum codes.
Preview: Here
Now, there are two parts to this code.
Part 1: Board Header
<div id="code_database"></div>
Part 2: Board Footer
<script type="text/javascript">
<!--
/*
Code Index by Cr0w
Copyright 2006
Do not repost
*/
//Last Update
var lastup="Wednesday November 15th, 2006 8:45PM"; //Most recent update
//Database Info
var dbthread="1163630241"; //The thread where your index will be
var dbforum="test1"; //The board id where your index is in
//Sections
var sections=[];
sections[0]=["Category Name","Category ID"];
sections[1]=["Category Name","Category ID"];
sections[2]=["Category Name","Category ID"];
//Codes
var codes=[];
codes[0]=["Code Name","Thread Number","Category"];
codes[1]=["Code Name","Thread Number","Category"];
codes[2]=["Code Name","Thread Number","Category"];
codes[3]=["Code Name","Thread Number","Category"];
codes[4]=["Code Name","Thread Number","Category"];
codes[5]=["Code Name","Thread Number","Category"];
codes[6]=["Code Name","Thread Number","Category"];
codes[7]=["Code Name","Thread Number","Category"];
codes[8]=["Code Name","Thread Number","Category"];
codes[9]=["Code Name","Thread Number","Category"];
codes[10]=["Code Name","Thread Number","Category"];
codes[11]=["Code Name","Thread Number","Category"];
//Do not edit below
function showdb(){
var table=document.getElementsByTagName("table");
for(t=0;t<table.length;t++){
if(table[t].width == "92%" && table[t].align == "center" && table[t].cellSpacing == "0" && table[t].cellPadding == "0" && table[t].className != "bordercolor") {
table[t].style.display="none";
break;
}
}
document.getElementById('code_database').innerHTML='<table cellspacing="1" cellpadding="4" class="bordercolor" width="92%" align="center" id="codedb"><tr><td class="titlebg" colspan="2" align="center">Code Database</td></tr><tr><td class="catbg" width="20%" align="center">Navigation</td><td class="catbg" width="80%" align="center">Main</td></tr><tr><td class="windowbg" width="20%" valign="top"><div id="navhere"></div><div id="searchit"></div></td><td class="windowbg" width="80%" valign="top"><div id="dbmain"></div></td></tr></table>';
var nav=document.getElementById("navhere");
var main=document.getElementById("dbmain");
var search=document.getElementById("searchit");
/* Categories */
nav.innerHTML="";
nav.innerHTML+="<b>Categories</b><br />";
for(l=0;l<sections.length;l++){
var catnum=l+1;
nav.innerHTML+=catnum+". <a href='javascript:void(0)' onclick=\"catchange('"+sections[l][1]+"')\">"+sections[l][0]+"</a><br />";
}
nav.innerHTML+="<br />";
nav.innerHTML+="<b>Other</b><br />";
nav.innerHTML+="1. <a href='javascript:void(0)' onclick='location.reload()'>Recent Codes</a><br />";
nav.innerHTML+="2. <a href='javascript:void(0)' onclick='showfulldb()'>All Codes</a><br />";
nav.innerHTML+="3. <a href='javascript:void(0)' onclick='aboutdb()'>About</a><br /><br />";
/* Main DB Page */
main.innerHTML="";
main.innerHTML+="<u><b>Database Info</b></u>";
main.innerHTML+="<br />";
main.innerHTML+="<b>Total Codes:</b> "+codes.length+"<br />";
main.innerHTML+="<b>Last Updated:</b> "+lastup+"<br /><br />";
main.innerHTML+="<b><u>Last 5 Codes</u></b><br /><br />";
var FiveNew="";
var num=1;
for(t=codes.length-1;t>codes.length-6;t--){
FiveNew+=num+". <a href='/index.cgi?board="+dbforum+"&action=display&thread="+codes[t][1]+"'>"+codes[t][0]+"</a><br />";
num=num+1;
}
main.innerHTML+=FiveNew;
/* Search DB */
search.innerHTML="";
search.innerHTML+="<b>Search:</b><br />";
search.innerHTML+="<input type='text' id='lookfor' /> ";
search.innerHTML+="<input type='submit' onclick='searchdb()' value='Go' />";
}
function searchdb(){
codes.sort();
sections.sort();
var main=document.getElementById("dbmain");
var searchthis=document.getElementById('lookfor');
main.innerHTML="<b><u>Search Results</u></b><br /><br />";
for(i=0;i<codes.length;i++){
if(codes[i][0].match(new RegExp(searchthis.value, 'gi'))){
main.innerHTML+="<li><a href='/index.cgi?board="+dbforum+"&action=display&thread="+codes[i][1]+"'>"+codes[i][0]+"</a></li>";
}
}
}
function catchange(tothis){
codes.sort();
sections.sort();
var main=document.getElementById("dbmain");
main.innerHTML="";
var num=1;
for(q=0;q<codes.length;q++){
if(codes[q][2]==tothis){
main.innerHTML+=num+". <a href='/index.cgi?action=display&board="+dbforum+"&thread="+codes[q][1]+"'>"+codes[q][0]+"</a><br />";
num=num+1;
}
}
}
function aboutdb(){
codes.sort();
sections.sort();
var main=document.getElementById("dbmain");
main.innerHTML="";
main.innerHTML+="<b><u><font size='+1'>";
main.innerHTML+="This code database is coded by Cr0w. It is available for use by any forum, as long as it is not reposted without written permission from it's creator.<br /><br />If you encounter any errors with this code, or find anyone who has reposted/ripped this code, please email Cr0w at <a href='mailto:admin@cr0wonline.com'>admin@cr0wonline.com</a>. Thank you.";
main.innerHTML+="</font></u></b>";
}
function showfulldb(){
codes.sort();
sections.sort();
var main=document.getElementById("dbmain");
main.innerHTML="";
for(t=0;t<codes.length;t++){
var t2=t+1;
main.innerHTML+=t2+". <a href='/index.cgi?action=display&board="+dbforum+"&thread="+codes[t][1]+"'>"+codes[t][0]+"</a><br />";
}
}
if(location.href.match("thread="+dbthread)){
showdb();
}
//-->
</script>
Before you use this code, there are a few things to edit.
I'll go through these first:
//Last Update
var lastup="Wednesday November 15th, 2006 8:45PM"; //Most recent update
//Database Info
var dbthread="1163630241"; //The thread where your index will be
var dbforum="test1"; //The board id where your index is in
Edit the first one(var lastup) to the current date & time every time you update your database.
For the second one(var dbthread), create a new thread for your code index, and get the thread number for it.
For the third one(var dbforum), enter the board id where the index thread is in.
Now, for entering the codes and categories.
//Sections
var sections=[];
sections[0]=["Category Name","Category ID"];
sections[1]=["Category Name","Category ID"];
sections[2]=["Category Name","Category ID"];
//Codes
var codes=[];
codes[0]=["Code Name","Thread Number","Category"];
codes[1]=["Code Name","Thread Number","Category"];
codes[2]=["Code Name","Thread Number","Category"];
codes[3]=["Code Name","Thread Number","Category"];
codes[4]=["Code Name","Thread Number","Category"];
codes[5]=["Code Name","Thread Number","Category"];
codes[6]=["Code Name","Thread Number","Category"];
codes[7]=["Code Name","Thread Number","Category"];
codes[8]=["Code Name","Thread Number","Category"];
codes[9]=["Code Name","Thread Number","Category"];
codes[10]=["Code Name","Thread Number","Category"];
codes[11]=["Code Name","Thread Number","Category"];
This part is pretty straightforward as well.
For each new category you want, just repeat the line, increasing the number by 1.
For the "Category ID" part, enter a short 1 word id for your category. For instance, admin editable codes may have a category id of "admin".
For entering codes, you enter the name of the code in the first part, the thread number of the code in the second one, and the id of the category you would like it to be in.
If that confuses you, post in support, and i'll be sure to help you out
Enjoy!
Edit by Ross: Improved the loop to hide the thread information so as not to conflict with any border around forum codes.