Olemis Lang avatar Olemis Lang committed f050f46

TracRpc: Using closures to optimize JS generating RPC TOC.

Comments (0)

Files changed (1)

t5437/t5437-protocol_api-r7194.diff

 new file mode 100644
 --- /dev/null
 +++ b/trunk/tracrpc/htdocs/js/rpc.js
-@@ -0,0 +1,29 @@
+@@ -0,0 +1,30 @@
 +(function($) {
 +    $(document).ready(function () {
 +        // Attempt at making a simple sidebar navigation menu...
-+        $('#content .wikipage').prepend('<div id="rpc-toc" class="wiki-toc"><h4>Page Contents</h4><ul />');
++        $('#content .wikipage').prepend('<div id="rpc-toc" class="wiki-toc"><h4>Page Contents</h4><ul /></div>');
 +        // $('#rpc-toc').css('float', 'right').css('width', '15em');
 +        function toc_entry(_this, item) {
 +            return $('<li><a href="#' + _this.id + '" title="'
 +                     + $(item).text().replace(/^\s+|\s+$/g, '')
 +                     + '">' + _this.id + '</a></li>');
 +          }
++        var ul = $('#rpc-toc ul');
 +        $("#content").find("*[id]").each(function(index, item) {
 +            var elem = undefined;
 +            if (this.tagName == 'H2') {
 +                elem = toc_entry(this, item);
 +                elem.css('padding-left', '1.2em');
 +            }
-+            $('#rpc-toc ul').append(elem);
++            ul.append(elem);
 +        });
 +        $('#rpc-toc').toggle();
 +        // $('.wikipage').css('margin-left', '17em');
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.