X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=inliner.js;h=f079dd86cfe9060762b84925b8623e83da5f4530;hb=674d7c0892acbf9e8ccf30744537f59014ce59d4;hp=32e61128bcda5c9b41423d098bb974e51cf1607d;hpb=c6ee2ba3853ea5b88fd27e9f478302ced666ed57;p=app.webkitpdf diff --git a/inliner.js b/inliner.js index 32e6112..f079dd8 100644 --- a/inliner.js +++ b/inliner.js @@ -1,41 +1,120 @@ +/** + * + * could this work by findind all the visible text, + * then making them hidden.. + * + * -- make a snapshot of the background.. + * + * -- delete the whole page... + * -- show the image as the background. + * -- then overlay all the text given their calculated positions.. + * + * + * + */ - -function(){ +(function(){ + + var camelize = function(a,b){ + return b.toUpperCase(); + } - //var camelize = function(a,b){ - // return b.toUpperCase(); - //} + - var fill = function(dom) + var fillStyle = function(dom, pstyle) { - var style; - var returns = {}; + if (!dom || dom.nodeType != 1) { + //console.log("SKIP: " + dom.nodeName); + return; + } + //console.log(dom.nodeName); + + var style = window.getComputedStyle(dom, null); + if (style.display == 'none' || dom.nodeName == "NOSCRIPT" || dom.nodeName == "SCRIPT" ) { + dom.parentElement.removeChild(dom); + return; + } + var cn = []; + + if (dom.childNodes.length > 100) { + console.log(dom); + throw "too many child nodes?" + dom.childNodes.length ; + } + for (var i = 0;i < dom.childNodes.length;i++) { + cn.push(dom.childNodes[i]); + } + + if (cn.length > 100) { + console.log(dom); + throw "too many child nodes? cn"; + } + for (var i = 0;i < cn.length;i++) { + + //console.log( i + ':'+ cn[i].nodeName); + fillStyle(cn[i], style); + } + + + //var pstyle = false; + //if (dom.nodeName != 'BODY') { + // pstyle = window.getComputedStyle(dom.parentElement, null); + //} + + if (dom.nodeName == 'SPAM') { + pstyle = false; //?? others?? + } + + //if (dom.nodeName == 'LI') { throw 'done'; } + - style = window.getComputedStyle(dom, null); for(var i=0;i