1 // Rewrite chapter urls using the canonical name. e.g ch01.html becomes introduction.html
3 if (document.location.pathname.match(/\/ch\d+\.html$/)) {
4 var url = document.location.href;
5 var canonical = $('link[rel="canonical"]').attr('href');
7 canonical = canonical.replace(/^[^#]+(\/[^\/#]+).*/,'$1');
8 url = url.replace(/\/ch\d+\.html/, canonical);
9 if ("history" in window && "replaceState" in window.history)
10 window.history.replaceState("", document.title, url);
12 document.location.href = url;
17 // Warnings about reading old version of documentation
19 if( $.grep( document.cookie.split(/\s*;\s*/), function(a){return a === 'old_version_warning_removed=true' ? true : false }).length === 0 ){
20 $('#old_version_warning')
22 .find('span.closebar a')
24 $('#old_version_warning').remove();
25 document.cookie="old_version_warning_removed=true";
31 // Sidebar table of contents
34 var click_func = function (e) {
36 if ($('#toc').data('opened')) {
37 $('#toc > *').animate({
38 left: '-=' + $('#toc > ul').width() + 'px'
40 $('#toc').removeData('opened');
42 $('#toc > *').animate({
43 left: '+=' + $('#toc > ul').width() + 'px'
45 $('#toc').data('opened', 1);
49 $('body').click(function () {
50 if( $('#toc').data('opened') ) $('#toc > img').mousedown();
53 var type = document.location.pathname.match(/\/doc\/html\/spec_html\/filter/) ? 'filter' : 'spec';
55 // Get the relevant table of contents
56 $.get(type === 'spec' ? 'index_toc.xml' : 'filter_toc.xml', function (xml) {
58 // Remove the main list from the DOM for performance
59 var $ul = $('#toc > ul').remove();
63 $(xml).find('c').each(function () {
65 var chapter_title = $(this).children('t').text();
66 var chapter_url = $(this).children('u').text();
68 var chapter_li = $('<li/>').append(
72 }).text(chapter_id + '. ' + chapter_title), $('<ul/>').hide()).appendTo($ul);
75 $('#toc img').fadeIn('slow', function () {
76 // Add the main list back to the DOM
77 $ul.removeClass('hidden').css('visibility', 'hidden').appendTo('#toc').css('left', '-' + $ul.width() + 'px').css('visibility', 'visible');
78 $('#toc > img').mousedown(click_func);
79 $('#toc > ul').click(click_func);
80 $('#toc, #toc a').click(function (e) {