diff static/js/agora.js @ 137:00c71a6192de

Make line numbers work for real This commit has a very long and tragic backstory. For details: http://dellsystem.me/posts/line-numbering/
author dellsystem <ilostwaldo@gmail.com>
date Sat, 29 Sep 2012 18:03:07 -0400
parents 2bca07be6e51
children 4d358e1e3014
line wrap: on
line diff
--- a/static/js/agora.js	Sat Sep 29 14:59:00 2012 -0400
+++ b/static/js/agora.js	Sat Sep 29 18:03:07 2012 -0400
@@ -21,5 +21,18 @@
 
     $(document).ready(function () {
         handleLoginLink();
+
+        // Add in the line numbers (no JS fallback unfortunately)
+        if ($('.snippet').length) {
+            var counter = 1;
+
+            $('.code-lines').children().each(function () {
+                // Set the top offset to be the same as that of the line
+                var div = '<p style="top: ' + this.offsetTop + 'px">' +
+                    '<a href="#l' + counter + '">' + counter + '</a></p>';
+                counter++;
+                $('.line-counters').append(div);
+            });
+        }
     });
 })(jQuery);