- Timestamp:
- 2012-01-11T10:05:58+13:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/html-to-expeditee/trunk/src/src/js/html-to-expeditee.js
r24925 r24934 31 31 return elem.clip.width; 32 32 } else { 33 if (elem.style .pixelWidth) {33 if (elem.style && elem.style.pixelWidth) { 34 34 return elem.style.pixelWidth; 35 35 } else { … … 44 44 return elem.clip.height; 45 45 } else { 46 if (elem.style .pixelHeight) {46 if (elem.style && elem.style.pixelHeight) { 47 47 return elem.style.pixelHeight; 48 48 } else { … … 84 84 85 85 86 function htmlToExpeditee(node) 87 { 88 var nodePos = getElementPosition(node); 89 var pxl = nodePos.xl; 90 var pyt = nodePos.yt; 91 var pxr = nodePos.xr; 92 var pyb = nodePos.yb; 86 93 87 function htmlToExpeditee(node,depth) 94 return htmlToExpediteeRec(node, pxl,pyt, pxl,pyt,pxr,pyb, 0); 95 } 96 97 98 function htmlToExpediteeRec(node,baseX,baseY, pxl,pyt,pxr,pyb, depth) 88 99 { 89 100 depth = (depth) ? depth : 0; 90 101 91 102 //var expSyntax = ""; 92 var jsonNode = {};103 var jsonNode = null; 93 104 94 105 if (node.nodeType == 3) { /* text node */ … … 99 110 //expSyntax += "Text item: " + node.nodeValue + "\n"; 100 111 112 jsonNode = {}; 113 101 114 jsonNode.type = "text"; 102 115 jsonNode.text = node.nodeValue; 116 117 jsonNode.x = pxl; 118 jsonNode.y = pyt; 119 103 120 } 104 121 } … … 108 125 /* need to dig out: text size, l/r/justified, font-face, type, colour */ 109 126 110 var elemName = node.Name; 111 if (elemName != "SCRIPT") { 127 var elemName = node.nodeName.toLowerCase(); 112 128 113 129 if (!elemName.match(/script/)) { 130 114 131 var nodePos = getElementPosition(node); 115 132 var xl = nodePos.xl; … … 129 146 */ 130 147 131 var rect = { "xl":xl, "yt":yt, "xr":xr, "yb":yb }; 132 148 jsonNode = {}; 133 149 jsonNode.type = "rect"; 134 150 jsonNode.elem = node.nodeName; 151 152 var rect = { "xl":xl, "yt":yt, "xr":xr, "yb":yb }; 135 153 jsonNode.rect = rect; 136 154 … … 139 157 var cnode = node.firstChild; 140 158 while (cnode != null) { 141 //expSyntax += htmlToExpeditee(cnode,depth+1);142 159 143 var jsonChildNode = htmlToExpeditee(cnode,depth+1); 144 jsonChildNodes.push(jsonChildNode); 160 var jsonChildNode 161 = htmlToExpediteeRec(cnode,baseX,baseY,xl,yt,xr,yb,depth+1); 162 163 if (jsonChildNode != null) { 164 jsonChildNodes.push(jsonChildNode); 165 } 145 166 146 167 cnode = cnode.nextSibling;
Note:
See TracChangeset
for help on using the changeset viewer.