// $('#content a').not($('.tabbedInterface ul.nav a')) // .not($('.expandingSpace a.trigger')) // .not($('.doNotPrint')) // .printPage(); (function($) { var links = {}, linkNum = 0, options = {}; function urlExists(u) { if (links[u]) return true; return false; } function addUrl(u) { if (urlExists(u)) return; links[u] = ++linkNum; } function numForLink(u) { if (!urlExists(u)) addUrl(u); return links[u]; } function fullyQualified(u,s) { s = s || window.location.href; // If u is fully qualified (http://, https://, ftp://, file://, etc) return it if (u.match(/^\w{3,5}:\/\//)) return u; // If u starts with / just prepend the site if (u.substr(0,1) == '/') return window.location.href.substr(0, window.location.href.indexOf('/', 9)) + u; // If u starts with ../ trim and try again if (u.substr(0,3) == '../') { var curr_dir = s; curr_dir = curr_dir.substr(0, curr_dir.lastIndexOf('/')); var parent_dir = curr_dir.substr(0, curr_dir.lastIndexOf('/')); if (parent_dir.substr(-1) != '/') parent_dir += '/'; return fullyQualified(u.substr(3), parent_dir); } // If u starts with ./ it's in the curr directory if (u.substr(0,2) == './') u = u.substr(2); // If we're here, we have something in the current dir return s + u; } $.fn.printPage = function(o) { // setup configuration options = o = $.extend({}, arguments.callee.defaults, o); if (o.skipUrlCheck || $.getURLParam(o.urlParam) == o.urlParamValue) { var footnoteLinks = $(''); $('body').addClass(o.bodyClass); $('body').addClass("noSidebarSecondary"); $('html').attr("style","background: #fff;"); this.not('#'+o.printLinkId).each(function() { var u = fullyQualified($(this).attr('href')); if (! urlExists(u)) $('
  • '+u+'
  • ').appendTo(footnoteLinks); $('['+ numForLink(u) +']').insertAfter($(this)); }); if (linkNum > 0) { // Only add footnotes if we have links to footnote $('

    Links

    ').appendTo("#" + o.appendLinksToId); footnoteLinks.appendTo("#" + o.appendLinksToId); } if (o.postPrintHandler && typeof o.postPrintHandler == 'function') o.postPrintHandler(); } return this; }; function addArg(k,v) { var printPage = $('#' + options.printLinkId); if (! printPage) return; printPage.attr('href', printPage.attr('href')+'&'+encodeURIComponent(k)+'='+encodeURIComponent(v)); } function updateArg(k, v) { k = encodeURIComponent(k); v = encodeURIComponent(v); var printPage = $('#' + options.printLinkId); if (! printPage) return; var href = printPage.attr('href'); var page = href.substr(0, href.indexOf('?')); var attrs = href.substr(href.indexOf('?') + 1).split('&'); var found = false; for (var i =0; i < attrs.length; i++) { var bits = attrs[i].split('='); if (bits[0] == k) { found = true; attrs[i] = [ bits[0], v ].join('='); return; } } if (! found) attrs[attrs.length] = [k,v].join('='); printPage.attr('href', [page, attrs.join('&')].join('?')); } $.fn.printPage.defaults = { bodyClass: 'print', // class to add to body element when in "print" mode urlParam: 'print', // parameter to look for in the querystring as an indication we're in print mode urlParamValue: 1, // value to look for printLinkId: 'PrintLink', // id of the printPage element so that we don't footnote it printDialog: true, // popup the print page dialog skipUrlCheck: false, // skip any url checking and just go into print mode appendLinksToId: 'ContentChannel', // ID of DOM object to append the footnote links to postPrintHandler: function() { } // Callback to run a function after the page has been "printed" }; })(jQuery);