Index: /gs3-extensions/html-to-expeditee/trunk/src/src/js/html-to-expeditee.js
===================================================================
--- /gs3-extensions/html-to-expeditee/trunk/src/src/js/html-to-expeditee.js (revision 26725)
+++ /gs3-extensions/html-to-expeditee/trunk/src/src/js/html-to-expeditee.js (revision 26726)
@@ -1,4 +1,8 @@
//javascript:
var expSyntaxArray = [];
+
+var font_family;
+var font_size;
+var font_color;
Element.prototype.getElementWidth = function() {
@@ -74,5 +78,5 @@
prop_val = el.style[style_prop];
}
-
+
return prop_val;
@@ -101,5 +105,18 @@
function htmlToExpeditee(node)
{
- var nodePos = getElementPosition(node);
+ var nodePos = getElementPosition(node);
+ var parentStyle = node.getAttribute('style');
+
+ //Use these as default values if font info can't be found for text items.
+ font_family = getStyle(node,'font-family');
+ font_size = getStyle(node,'font-size');
+ font_color = getStyle(node,'color');
+
+ console.log("Retrieving node: " + node);
+
+ console.log("Retrieving font family: " + font_family);
+ console.log("Retrieving font size: " + font_size);
+ console.log("Retrieving font color: " + font_color);
+
var pxl = nodePos.xl;
var pyt = nodePos.yt;
@@ -116,6 +133,8 @@
var jsonNode = null;
-
+
if (node.nodeType == 3) { /* text node */
+
+
var text = node.nodeValue;
@@ -132,12 +151,35 @@
var parent = node.parentNode;
+
if (parent != null) {
- var data = parent.attributes["data"];
-
- if (data != null) {
- jsonNode.data = data.value;
- }
- }
- }
+
+ //obtain font info for text nodes from their parent nodes.
+ var new_font_family = getStyle(parent,"font-family");
+ var new_font_size = getStyle(parent,"font-size");
+ var new_font_color = getStyle(parent,"color");
+
+ if(new_font_family !== undefined && new_font_family !== null)
+ font_family = new_font_family;
+
+ if(new_font_size !== undefined && new_font_size !== null)
+ font_size = new_font_size;
+
+ if(new_font_color !== undefined && new_font_color !== null)
+ font_color = new_font_color;
+
+ var data = parent.attributes["data"];
+
+ if (data != null) {
+ jsonNode.data = data.value;
+ }
+ jsonNode.style = style;
+ }
+ }
+
+ var style = {};
+ style["font-family"] = font_family;
+ style["font-size"] = font_size;
+ style["color"] = font_color;
+
}
else if (node.nodeType == 1) { /* element */
@@ -162,7 +204,16 @@
var yb = nodePos.yb;
- jsonNode = {};
+ jsonNode = {};
jsonNode.type = "rect";
- jsonNode.elem = node.nodeName;
+ jsonNode.elem = node.nodeName;
+
+ if(node.getAttribute("rect") !== undefined){
+
+ /**This is to ensure rectangles aren't drawn around "non-rectangular" items such
+ as text and empty elements such as
**/
+ if(node.getAttribute("rect") === "norect"){
+ jsonNode.type = "norect";
+ }
+ }
var rect = { "xl":xl, "yt":yt, "xr":xr, "yb":yb };
@@ -170,18 +221,14 @@
if (elemName.match("img")) {
- jsonNode.img = node.src;
- }
-
- var style = {};
-
- style["font-family"] = getStyle(node,"font-family");
- style["font-size"] = getStyle(node,"font-size");
+ jsonNode.img = node.src;
+ }
+
+ var style = {};
+
+ //style["font-family"] = getStyle(node,"font-family");
+ //style["font-size"] = getStyle(node,"font-size");
style["background-color"] = getStyle(node,"background-color");
-
- // console.log("background color = " + style["background-color"]);
-
- // console.log("font size = " + style["font-size"]);
-
- jsonNode.style = style;
+
+ jsonNode.style = style;
var attr = node.attributes["attr"];