| 3 | var page = require('webpage').create(); |
| 4 | |
| 5 | function modifyPage(filename) { |
| 6 | console.log("Modifying " + filename); |
| 7 | |
| 8 | var rawPageString = fs.read(filename); |
| 9 | rawPageString = rawPageString.replace(/<script type="text\/javascript"/g, "<script type='foo/bar'"); |
| 10 | rawPageString = rawPageString.replace(/<script>/g, "<script type='foo/bar'>"); |
| 11 | |
| 12 | page.content = rawPageString; |
| 13 | |
| 14 | page.injectJs("jquery-2.1.4.min.js"); |
| 15 | page.evaluate(function () { |
| 16 | // Remove obsolete attributes |
| 17 | $("img[border]").removeAttr("border"); |
| 18 | $("table[border]").removeAttr("border"); |
| 19 | $("iframe[frameborder]").removeAttr("frameborder"); |
| 20 | $(".memItemLeft[align]").removeAttr("align"); |
| 21 | $(".memItemLeft[valign]").removeAttr("valign"); |
| 22 | $(".memItemRight[valign]").removeAttr("valign"); |
| 23 | $("script[type]").removeAttr("type"); |
| 24 | |
| 25 | // Remove pointless "even" class (replaced with CSS nth-child selector) |
| 26 | $(".even").removeClass("even"); |
| 27 | |
| 28 | // Remove invalid attributes |
| 29 | $("a[doxygen]").removeAttr("doxygen"); |
| 30 | |
| 31 | // Remove hidden elements (that we don't want to show anymore) |
| 32 | $("tr[class^=separator\\:]").remove(); |
| 33 | $(".memSeparator").remove(); |
| 34 | |
| 35 | // Change <a name=""> to <a id=""> |
| 36 | $("a[name]").each(function() { |
| 37 | var elem = $(this); |
| 38 | elem.attr("id", elem.attr("name")); |
| 39 | elem.removeAttr("name"); |
| 40 | }); |
| 41 | |
| 42 | // Reduce complexity of prototype displays |
| 43 | $("div.memproto").each(function(){ |
| 44 | var result = ""; |
| 45 | var found = false; // Purpose of this is to prevent corruption on accidental multiple runs |
| 46 | $(this).find("table.memname > tbody > tr > td").each(function(){ |
| 47 | found = true; |
| 48 | if ($(this).hasClass("paramname")) { |
| 49 | var paramText = $(this).html(); |
| 50 | if (paramText) { |
| 51 | result += $("<span>").addClass("paramname").html(paramText).prop("outerHTML"); |
| 52 | } |
| 53 | } else { |
| 54 | result += $(this).html(); |
| 55 | } |
| 56 | }); |
| 57 | var span = $(this).find("td.mlabels-right"); |
| 58 | if (span.length > 0) { |
| 59 | result += span.html(); |
| 60 | } |
| 61 | if (found) { |
| 62 | $(this).html(result); |