inliner.js
[app.webkitpdf] / inliner.js
1
2
3
4 (function(){
5     
6     //var camelize = function(a,b){
7     //    return b.toUpperCase();
8     //}
9     
10     var keys = ['fontFamily','fontSize','fontWeight','fontStyle','color',
11         'textTransform','textDecoration','letterSpacing','wordSpacing',
12         'lineHeight','textAlign','verticalAlign','direction','backgroundColor',
13         'backgroundImage','backgroundRepeat','backgroundposition',
14         'backgroundAttachment','opacity','width','height','top','right','bottom',
15         'left','marginTop','marginRight','marginBottom','marginLeft',
16         'paddingTop','paddingRight','paddingBottom','paddingLeft',
17         'borderTopWidth','borderRightWidth','borderBottomWidth',
18         'borderLeftWidth','borderTopColor','borderRightColor',
19         'borderBottomColor','borderLeftColor','borderTopStyle',
20         'borderRightStyle','borderBottomStyle','borderLeftStyle','position',
21         'display','visibility','zIndex','overflowX','overflowY','whitepace',
22         'clip','float','clear','cursor','list-style-image','list-style-position',
23         'list-style-type','marker-offset'];
24     
25     var fillStyle = function(dom)
26     {
27         if (!dom || dom.nodeType != 1) {
28             return;
29         }
30         console.log(dom.nodeName);
31         
32         var style = window.getComputedStyle(dom, null);
33         if (style.display == 'none') {
34             dom.parentElement.removeChild(dom);
35             return;
36         }
37         
38         
39         
40         for(var i=0;i<style.length;i++){
41             var prop = style[i];
42             //var camel = prop.replace(/\-([a-z])/g, camelize);
43             var val = style.getPropertyValue(prop);
44             //returns[camel] = val;
45             dom.style[prop] = val;
46         }
47         for (var i = dom.childNodes.length -1; i--; i> -1) {
48             fillStyle(dom.childNodes[i]);
49         }
50         
51         
52         //return returns;
53     }
54     var el = document.querySelector('body');
55     fillStyle(el);
56     
57     //var matches = document.getElementsByTagName('style');
58     //for(var i =0;i < matches.length;i++) {
59     //    matches[i].parentElement.removeChild(matches[i]);
60     //}
61     
62      
63     
64 })();