vForums Support > Programming & Coding :: Database of Codes/Hacks/Mods :: > Code Index

Code Index - Posted By Marc (cr0w) on 8th Mar 08 at 6:06pm
This code adds a code index to a thread of your choice, where you can organize and display codes on your forum.

Preview

Board Header

Code:
 
  1. <div id="code_database"></div>
 



Board Footer

Code:
 
  1. <script type="text/javascript">
  2. <!--
  3. /*
  4. Code Index by Cr0w
  5. Copyright 2006
  6. Do not repost
  7. */
  8.  
  9. //Last Update
  10. var lastup="Wednesday November 15th, 2006 8:45PM"; //Most recent update
  11.  
  12. //Database Info
  13. var dbthread="8"; //The thread where your index will be
  14. var dbforum="abc"; //The board id where your index is in
  15.  
  16. //Sections
  17. var sections=[];
  18. sections[0]=["Category Name","Category ID"];
  19. sections[1]=["Category Name","Category ID"];
  20. sections[2]=["Category Name","Category ID"];
  21.  
  22. //Codes
  23. var codes=[];
  24. codes[0]=["Code Name 1","Thread Number","Category ID"];
  25. codes[1]=["Code Name 2","Thread Number","Category ID"];
  26. codes[2]=["Code Name 3","Thread Number","Category ID"];
  27. codes[3]=["Code Name 4","Thread Number","Category ID"];
  28. codes[4]=["Code Name 5","Thread Number","Category ID"];
  29. codes[5]=["Code Name 6","Thread Number","Category ID"];
  30. codes[6]=["Code Name 7","Thread Number","Category ID"];
  31. codes[7]=["Code Name 8","Thread Number","Category ID"];
  32. codes[8]=["Code Name 9","Thread Number","Category ID"];
  33. codes[9]=["Code Name 10","Thread Number","Category ID"];
  34. codes[10]=["Code Name 11","Thread Number","Category ID"];
  35. codes[11]=["Code Name 12","Thread Number","Category ID"];
  36.  
  37. //Do not edit below
  38.  
  39. function showdb(){
  40. var td=document.getElementsByTagName("td");
  41. for(t=6;t<td.length;t++){
  42. td[t].style.display="none";
  43. }
  44. document.getElementById('code_database').innerHTML='<table cellspacing="1" cellpadding="4" class="border" width="'+vf_width+'" align="center" id="codedb"><tr><td class="title1" colspan="2" align="center">Code Database</td></tr><tr><td class="title2" width="20%" align="center">Navigation</td><td class="title2" width="80%" align="center">Main</td></tr><tr><td class="window1" width="20%" valign="top"><div id="navhere"></div><div id="searchit"></div></td><td class="window1" width="80%" valign="top"><div id="dbmain"></div></td></tr></table>';
  45. var nav=document.getElementById("navhere");
  46. var main=document.getElementById("dbmain");
  47. var search=document.getElementById("searchit");
  48. /* Categories */
  49. nav.innerHTML="";
  50. nav.innerHTML+="<b>Categories</b><br />";
  51. for(l=0;l<sections.length;l++){
  52. var catnum=l+1;
  53. nav.innerHTML+=catnum+". <a href='javascript:void(0)' onclick=\"catchange('"+sections[l][1]+"')\">"+sections[l][0]+"</a><br />";
  54. }
  55. nav.innerHTML+="<br />";
  56. nav.innerHTML+="<b>Other</b><br />";
  57. nav.innerHTML+="1. <a href='javascript:void(0)' onclick='location.reload()'>Recent Codes</a><br />";
  58. nav.innerHTML+="2. <a href='javascript:void(0)' onclick='showfulldb()'>All Codes</a><br />";
  59. nav.innerHTML+="3. <a href='javascript:void(0)' onclick='aboutdb()'>About</a><br /><br />";
  60.  
  61. /* Main DB Page */
  62. main.innerHTML="";
  63. main.innerHTML+="<u><b>Database Info</b></u>";
  64. main.innerHTML+="<br />";
  65. main.innerHTML+="<b>Total Codes:</b> "+codes.length+"<br />";
  66. main.innerHTML+="<b>Last Updated:</b> "+lastup+"<br /><br />";
  67. main.innerHTML+="<b><u>Last 5 Codes</u></b><br /><br />";
  68. var FiveNew="";
  69. var num=1;
  70. for(t=codes.length-1;t>codes.length-6;t--){
  71. FiveNew+=num+". <a href='/board/"+dbforum+"/action/view_topic/topic/"+codes[t][1]+"/'>"+codes[t][0]+"</a><br />";
  72. num=num+1;
  73. }
  74. main.innerHTML+=FiveNew;
  75.  
  76. /* Search DB */
  77. search.innerHTML="";
  78. search.innerHTML+="<b>Search:</b><br />";
  79. search.innerHTML+="<input type='text' id='lookfor' /> ";
  80. search.innerHTML+="<input type='submit' onclick='searchdb()' value='Go' />";
  81. }
  82.  
  83. function searchdb(){
  84. codes.sort();
  85. sections.sort();
  86. var main=document.getElementById("dbmain");
  87. var searchthis=document.getElementById('lookfor');
  88. main.innerHTML="<b><u>Search Results</u></b><br /><br />";
  89. for(i=0;i<codes.length;i++){
  90. if(codes[i][0].match(new RegExp(searchthis.value, 'gi'))){
  91. main.innerHTML+="<li><a href='/board/"+dbforum+"/action/view_topic/topic/"+codes[i][1]+"/'>"+codes[i][0]+"</a></li>";
  92. }
  93. }
  94. }
  95. function catchange(tothis){
  96. codes.sort();
  97. sections.sort();
  98. var main=document.getElementById("dbmain");
  99. main.innerHTML="";
  100. var num=1;
  101. for(q=0;q<codes.length;q++){
  102. if(codes[q][2]==tothis){
  103. main.innerHTML+=num+". <a href='/board/"+dbforum+"/action/view_topic/topic/"+codes[q][1]+"/'>"+codes[q][0]+"</a><br />";
  104. num=num+1;
  105. }
  106. }
  107. }
  108. function aboutdb(){
  109. codes.sort();
  110. sections.sort();
  111. var main=document.getElementById("dbmain");
  112. main.innerHTML="";
  113. main.innerHTML+="<b><u><font size='+1'>";
  114. 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.";
  115. main.innerHTML+="</font></u></b>";
  116. }
  117. function showfulldb(){
  118. codes.sort();
  119. sections.sort();
  120. var main=document.getElementById("dbmain");
  121. main.innerHTML="";
  122. for(t=0;t<codes.length;t++){
  123. var t2=t+1;
  124. main.innerHTML+=t2+". <a href='/board/"+dbforum+"/action/view_topic/topic/"+codes[t][1]+"/'>"+codes[t][0]+"</a><br />";
  125. }
  126. }
  127. if(location.href.match("topic/"+dbthread)){
  128. showdb();
  129. }
  130. //-->
  131. </script>
 

Re: Code Index - Posted By Alex Bailey (system) on 8th Mar 08 at 6:56pm
Thanks for this marc been waiting a while {Tongue Out}

Re: Code Index - Posted By Marc (cr0w) on 8th Mar 08 at 7:50pm
 
Thanks for this marc been waiting a while {Tongue Out}


No problem. {Tongue Out}

Re: Code Index - Posted By Nick (nickb) on 9th Mar 08 at 2:11am
{Tongue Out} Preview? lol

Re: Code Index - Posted By Marc (cr0w) on 9th Mar 08 at 2:25am
Added. Ignore the alerts, testing some codes. {Tongue Out}

Re: Code Index - Posted By Nick (nickb) on 9th Mar 08 at 2:26am
I don't see the preview link {Shocked}

Nevermind {Cool}

EDIT:
Thats cool, I like it ^_^

It be put in good use later.

Re: Code Index - Posted By Alex Bailey (system) on 9th Mar 08 at 11:20am
What would be a good update in this would be.

The creator or something so it says who posted the code
also a popup link, instead of it changing the current page

Re: Code Index - Posted By Michael (wrighty) on 9th Mar 08 at 11:49am
If we're suggesting extras, make it possible for the person to decided whether to have it show in a board or in a thread! {Wink}

Re: Code Index - Posted By Alex Bailey (system) on 9th Mar 08 at 12:03pm
what like mine is done now?

Re: Code Index - Posted By Marc (cr0w) on 9th Mar 08 at 4:43pm
@System: For the next version, I will be adding a "creator" feature. {Wink} However, I don't understand what you mean by the second part; "Popup link rather than changing the current page" ? {Unsure}

@Wrighty: Will be added. {Wink}

Re: Code Index - Posted By Alex Bailey (system) on 9th Mar 08 at 4:45pm
When you click a code a new window comes up instead of changing the current page

Re: Code Index - Posted By Marc (cr0w) on 9th Mar 08 at 5:48pm
 
When you click a code a new window comes up instead of changing the current page


Will make it an option. {Wink}