mirror of
https://github.com/kennethreitz/dive-into-python3.git
synced 2026-06-05 23:10:17 +00:00
1 line
1.8 KiB
JavaScript
1 line
1.8 KiB
JavaScript
var HIDESHOW={visible:"hide",hidden:"show"};google.load("jquery","1.3");google.setOnLoadCallback(function(){$(document).ready(function(){$("pre > code").each(function(a){var b=$(this.parentNode);if(b.parents("table").length==0){b.addClass("code")}});$("pre.code, pre.screen").each(function(a){this.id="autopre"+a;$(this).wrapInner('<div class="block"></div>');$(this).prepend('<div class="widgets">[<a class="toggle" href="javascript:toggleCodeBlock(\''+this.id+"')\">"+HIDESHOW.visible+"</a>] [<a href=\"javascript:plainTextOnClick('"+this.id+"')\">open in new window</a>]</div>");$(this).prev("p.download").each(function(b){$(this).next("pre").find("div.widgets").append(" "+$(this).html());this.parentNode.removeChild(this)})});$("pre.code, pre.screen").each(function(){$(this).find("a:not([href])").each(function(d){var c=$(this);var b=c.parents("pre").next("ol").find("li:nth-child("+(d+1)+")");b.add(c).hover(function(){c.addClass("hover");b.addClass("hover")},function(){c.removeClass("hover");b.removeClass("hover")})})});$("table").each(function(){$(this).find("tr:gt(0)").each(function(b){var c=$(this);var a=c.parents("table").next("ol").find("li:nth-child("+(b+1)+")");if(a.length>0){a.add(c).hover(function(){c.addClass("hover");a.addClass("hover")},function(){c.removeClass("hover");a.removeClass("hover")})}})})})});function toggleCodeBlock(c){$("#"+c).find("div.block").toggle();var b=$("#"+c).find("a.toggle");b.text(b.text()==HIDESHOW.visible?HIDESHOW.hidden:HIDESHOW.visible)}function plainTextOnClick(c){var b=$("#"+c).clone();b.find("div.widgets, span").remove();var a=window.open("about:blank","plaintext","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=400,left=35,top=75");a.document.open();a.document.write("<pre>"+b.html());a.document.close()}; |