getting some weird javascript at the top of my output?

14 views
Skip to first unread message

George Cheyne

unread,
Jul 9, 2015, 4:32:06 PM7/9/15
to prett...@googlegroups.com
hi,

I'm getting started with pretty diff and think I must be doing something stupid.

I'm basically using it in a xslt stylesheet to render some xml that has before and after versions of some text in.

here is my stylesheet:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<style>
#source {
display: none;
}
#target {
display: none;
}
#diffoutput {
height: 98%;
width: 100%
}
</style>
<script src="http://prettydiff.com/prettydiff.js"></script>
<script>
window.onload = function(e) {
var byId = function (id) { return document.getElementById(id); };
var src = byId("target");
var trg = byId("source");
var out = byId("diffoutput");

var args = {
source : trg.innerHTML,
sourcelabel : "Subversion",
diff : src.innerHTML,
difflabel : "Database",
lang : "text"
};
out.srcdoc = prettydiff(args);
};
</script>
</head>
<body>
<pre id="source"><xsl:value-of select="/Entry/Children/Entry/Children/Entry/Source"/></pre>
<pre id="target"><xsl:value-of select="/Entry/Children/Entry/Children/Entry/Target"/></pre>
<iframe id="diffoutput"></iframe>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Basically I pump the output into an iframe but i get a bunch of javascript at the top of the frame (see javascript below).

What am I doing wrong?

By the way, great diff tool, thanks for all the hard work.

Thanks,

George


The javascript:
"function core__auto(a) { var b = [], c = 0, d = 0, join = "", flaga = false, flagb = false, defaultt = clangdefault, output = function core__auto_output(langname) { if (langname === "unknown") { return [ defaultt, setlangmode(defaultt), "unknown" ]; } if (langname === "xhtml") { return [ "xml", "html", "XHTML" ]; } if (langname === "tss") { return [ "javascript", "javascript", "Titanium Stylesheets" ]; } return [ langname, setlangmode(langname), nameproper(langname) ]; }; if (a === null) { return; } if (a === undefined || (/^(\s*#(?!(!\/)))/).test(a) === true || (/\n\s*(\.|@)mixin\(?(\s*)/).test(a) === true) { if ((/\$[a-zA-Z]/).test(a) === true || (/\{\s*(\w|\.|\$|#)+\s*\{/).test(a) === true) { return output("scss"); } if ((/@[a-zA-Z]/).test(a) === true || (/\{\s*(\w|\.|@|#)+\s*\{/).test(a) === true) { return output("less"); } return output("css"); } b = a.replace(/\[[a-zA-Z][\w\-]*\=("|')?[a-zA-Z][\w\-]*("|')?\]/g, "").split(""); c = b.length; if ((/^([\s\w\-]*<)/).test(a) === false && (/(>[\s\w\-]*)$/).test(a) === false) { for (d = 1; d < c; d += 1) { if (flaga === false) { if (b[d] === "*" && b[d - 1] === "/") { b[d - 1] = ""; flaga = true; } else if (flagb === false && b[d] === "f" && d < c - 6 && b[d + 1] === "i" && b[d + 2] === "l" && b[d + 3] === "t" && b[d + 4] === "e" && b[d + 5] === "r" && b[d + 6] === ":") { flagb = true; } } else if (flaga === true && b[d] === "*" && d !== c - 1 && b[d + 1] === "/") { flaga = false; b[d] = ""; b[d + 1] = ""; } else if (flagb === true && b[d] === ";") { flagb = false; b[d] = ""; } if (flaga === true || flagb === true) { b[d] = ""; } } join = b.join(""); if ((/^(\s*(\{|\[))/).test(a) === true && (/((\]|\})\s*)$/).test(a) && a.indexOf(",") !== -1) { return output("json"); } if ((/((\}?(\(\))?\)*;?\s*)|([a-z0-9]("|')?\)*);?(\s*\})*)$/i).test(a) === true && ((/(var\s+[a-z]+[a-zA-Z0-9]*)/).test(a) === true || (/((\=|(\$\())\s*function)|(\s*function\s+(\w*\s+)?\()/).test(a) === true || a.indexOf("{") === -1 || (/^(\s*if\s+\()/).test(a) === true)) { if (a.indexOf("(") > -1 || a.indexOf("=") > -1 || (a.indexOf(";") > -1 && a.indexOf("{") > -1)) { if ((/:\s*((number)|(string))/).test(a) === true && (/((public)|(private))\s+/).test(a) === true) { return output("typescript"); } return output("javascript"); } return output("unknown"); } if (a.indexOf("{") !== -1 && (/^(\s*[\{\$\.#@a-z0-9])|^(\s*\/(\*|\/))|^(\s*\*\s*\{)/i).test(a) === true && (/^(\s*if\s*\()/).test(a) === false && (/\=\s*(\{|\[|\()/).test(join) === false && (((/(\+|-|\=|\?)\=/).test(join) === false || (/\/\/\s*\=+/).test(join) === true) || ((/\=+('|")?\)/).test(a) === true && (/;\s*base64/).test(a) === true)) && (/function(\s+\w+)*\s*\(/).test(join) === false) { if ((/:\s*((number)|(string))/).test(a) === true && (/((public)|(private))\s+/).test(a) === true) { return output("typescript"); } if ((/((public)|(private))\s+(((static)?\s+(v|V)oid)|(class)|(final))/).test(a) === true) { return output("java"); } if ((/<[a-zA-Z]/).test(a) === true && (/<\/[a-zA-Z]/).test(a) === true && ((/\s?\{%/).test(a) === true || (/\{(\{|#)(?!(\{|#|\=))/).test(a) === true)) { return output("twig"); } if ((/^\s*($|@)/).test(a) === false && ((/:\s*(\{|\(|\[)/).test(a) === true || (/^(\s*return;?\s*\{)/).test(a) === true) && (/(\};?\s*)$/).test(a) === true) { return output("javascript"); } if ((/\{\{#/).test(a) === true && (/\{\{\//).test(a) === true && (/<\w/).test(a) === true) { return output("handlebars"); } if ((/\{\s*(\w|\.|@|#)+\s*\{/).test(a) === true) { return output("less"); } if ((/\$(\w|-)/).test(a) === true) { return output("scss"); } if ((/(;|\{|:)\s*@\w/).test(a) === true) { return output("less"); } return output("css"); } if ((/"\s*:\s*\{/).test(a) === true) { return output("tss"); } return output("unknown"); } if ((((/(>[\w\s:]*)?<(\/|!)?[\w\s:-\[]+/).test(a) === true || (/^(\s*<\?xml)/).test(a) === true) && ((/^([\s\w]*<)/).test(a) === true || (/(>[\s\w]*)$/).test(a) === true)) || ((/^(\s*\s*)$/i).test(a) === true)) { if (((/\s*/i).test(a) === true && (/\s*Execution time: 0.014 seconds"
Reply all
Reply to author
Forward
0 new messages