Mercurial > hg > agora-ahsan
view templates/snippet/snippet_details.js @ 120:3cd28df6f85b
Rename <option> attr for pygments style select
From name to data-name, because <option>s don't have names.
For the validator.
author | dellsystem <ilostwaldo@gmail.com> |
---|---|
date | Fri, 14 Sep 2012 21:54:56 -0400 |
parents | 7d753658dc0e |
children | cdfc1d269a75 |
line wrap: on
line source
jQuery(document).ready(function () { curLine = document.location.hash; if(curLine.substring(0,2) == '#l'){ $('div.snippet div.line'+curLine).addClass('marked'); } /** * Diff Ajax Call */ $("form#diffform").submit(function() { $.get("{% url snippet_diff %}", { a: $("input[name=a]:checked").val(), b: $("input[name=b]:checked").val() }, function(data){ $('#diff').html(data).slideDown('fast'); }); return false; }); /** * Changing syntax highlighting colours */ var currentStyle = $('#change-highlighting').attr('data-default'); $('#change-highlighting').change(function () { var newStyle = $(this).find(':selected').attr('data-name'); $('.snippet').removeClass(currentStyle).addClass(newStyle); currentStyle = newStyle; }); /** * Line Highlighting */ $('div.snippet th a').each(function(i){ $(this).click(function(){ var j = $(this).text(); $('div.snippet div.line.marked').removeClass('marked'); $('div.snippet div.line#l'+j).toggleClass('marked'); }); }); //{% if request.session.userprefs.display_all_lexer %} /** * Lexer Guessing */ $('#guess_lexer_btn').click(function(){ $.getJSON('{% url snippet_guess_lexer %}', {'codestring': $('#id_content').val()}, function(data){ if(data.lexer == "unknown"){ $('#guess_lexer_btn').css('color', 'red'); }else{ $('#id_lexer').val(data.lexer); $('#guess_lexer_btn').css('color', 'inherit'); } }); }); //{% endif %} });