Advertisement
Guest User

dlang phobos

a guest
Oct 1st, 2012
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //================================================================================
  2. //REPLACE THIS:
  3. //================================================================================
  4. function listanchors()
  5. {
  6.     if (typeof inhibitQuickIndex !== 'undefined') return;
  7.     var a = document.getElementById("quickindex");
  8.     if (!a) return;
  9.     var newText = "";
  10.     var hash = new Array;
  11.     var n = 0;
  12.     var values = new Array;
  13.     // List all anchors.
  14.     for (var i = 0; i < document.anchors.length; i++)
  15.     {
  16.         var a = document.anchors[i];
  17.         var text = a.name;
  18.         if (hash[text] > 0) continue;
  19.         hash[text] = 1;
  20.         values[n++] = a.name
  21.     }
  22.  
  23.     values.sort();
  24.  
  25.     for(var i = 0; i < values.length; i++) {
  26.         var a = values[i];
  27.         newText += ' \x3Ca href="\x23' + a +
  28.             '"\x3E\x3Cspan class="d_psymbol"\x3E' + a + '\x3C/span\x3E\x3C/a\x3E';
  29.     }
  30.     if (newText != "") newText = "\x3Cp\x3E\x3Cb\x3EJump to:\x3C/b\x3E" + newText + "\x3C/p\x3E";
  31.     var a = document.getElementById("quickindex");
  32.     a.innerHTML = newText;
  33. }
  34.  
  35. //================================================================================
  36. //WITH THIS:
  37. //================================================================================
  38. function listanchors()
  39. {
  40.     if (typeof inhibitQuickIndex !== 'undefined') return;
  41.     var a = document.getElementById("quickindex");
  42.     if (!a) return;
  43.     var newText = "";
  44.  
  45.     // listanchors modification begin {
  46.  
  47.     function keys(obj)
  48.     {
  49.         var keys = [];
  50.         for(var key in obj)
  51.             if(obj.hasOwnProperty(key))
  52.                 keys.push(key);
  53.         return keys;
  54.     }
  55.  
  56.     var content_div = document.getElementById('content');
  57.     var elems = new Array;
  58.     var regex = /^([^\s]+)\s+\x3Ca name="([^"]+)"[^\x3E]*\x3E\x3C\/a\x3E\x3C[^\x3E]+\x3E([^\x3C]+)\x3C\/[^\x3E]+\x3E(.*?;)$/im;
  59.     var subregex = /(\x3C\w+)\s[^\x3E]*(\x3E)/img;
  60.     var decl_array = new Array;
  61.     var found = false;
  62.  
  63.     if(content_div != null)
  64.         elems = content_div.getElementsByTagName('*');
  65.  
  66.     for(var i in elems)
  67.     {
  68.         if((" " + elems[i].className + " ").indexOf(" d_decl ") > -1)
  69.         {
  70.             var node = elems[i];
  71.             var count = 0;
  72.  
  73.             do
  74.             {
  75.                 if(node.tagName == "DL")
  76.                 {
  77.                     count++;
  78.                     if(count > 1)
  79.                         break;
  80.                 }
  81.  
  82.                 node = node.parentNode;
  83.             }
  84.             while(node != content_div);
  85.  
  86.             if(count == 1)
  87.             {
  88.                 var matches;
  89.  
  90.                 matches = regex.exec(elems[i].innerHTML);
  91.                 if(matches != null && matches.length == 5)
  92.                 {
  93.                     found = true;
  94.  
  95.                     var type;
  96.  
  97.                     matches[4] = matches[4].replace(subregex, "$1$2");
  98.  
  99.                     if(matches[4].length > 0 && matches[4][0] == "(")
  100.                         type = "function";
  101.                     else
  102.                         type = matches[1];
  103.  
  104.                     if(!(type in decl_array))
  105.                         decl_array[type] = new Array;
  106.  
  107.                     decl_array[type].push(matches[1] +
  108.                         " \x3Ca href=\"#" + matches[2] + "\"\x3E" + matches[3] + "\x3C/a\x3E" + matches[4]);
  109.                 }
  110.             }
  111.         }
  112.     }
  113.  
  114.     if(found)
  115.     {
  116.         decl_types = keys(decl_array);
  117.         decl_types.sort(function(a,b){
  118.             var priority = ["function", "class", "struct"].reverse();
  119.             var aa = priority.indexOf(a);
  120.             var bb = priority.indexOf(b);
  121.             if(aa != bb)
  122.                 return bb-aa;
  123.             return a.localeCompare(b);
  124.         });
  125.  
  126.         for(var index in decl_types)
  127.         {
  128.             var type = decl_types[index];
  129.  
  130.             newText += '\x3Cbr\x3E';
  131.             newText += '\x3Cu\x3E' + type + '\x3C/u\x3E\x3Cbr\x3E';
  132.  
  133.             for(var decl in decl_array[type])
  134.                 newText += decl_array[type][decl] + '\x3Cbr\x3E';
  135.         }
  136.     }
  137.     else
  138.     {
  139.         // old code {
  140.  
  141.         var hash = new Array;
  142.         var n = 0;
  143.         var values = new Array;
  144.         // List all anchors.
  145.         for (var i = 0; i < document.anchors.length; i++)
  146.         {
  147.             var a = document.anchors[i];
  148.             var text = a.name;
  149.             if (hash[text] > 0) continue;
  150.             hash[text] = 1;
  151.             values[n++] = a.name
  152.         }
  153.  
  154.         values.sort();
  155.  
  156.         for(var i = 0; i < values.length; i++) {
  157.             var a = values[i];
  158.             newText += ' \x3Ca href="\x23' + a +
  159.                 '"\x3E\x3Cspan class="d_psymbol"\x3E' + a + '\x3C/span\x3E\x3C/a\x3E';
  160.         }
  161.  
  162.         // } // old code
  163.     }
  164.  
  165.     // } // listanchors modification end
  166.  
  167.     if (newText != "") newText = "\x3Cp\x3E\x3Cb\x3EJump to:\x3C/b\x3E" + newText + "\x3C/p\x3E";
  168.     var a = document.getElementById("quickindex");
  169.     a.innerHTML = newText;
  170. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement