Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed variables to new notation.

Corrected if/else bracket notation to match code style spec.
  • Loading branch information...
commit c422e61bd4d6cab0d5777c96cbbbb00da05acfcc 1 parent e8c9d77
h6w authored March 16, 2012
108  ample/languages/xul/classes/cXULDocument.js
@@ -16,7 +16,6 @@ cXULDocument.prototype.tooltipNode	= null;
16 16
 cXULDocument.prototype.commandDispatcher	= null;
17 17
 
18 18
 // Private properties
19  
-//var hXULDocument_overlays	= {};
20 19
 var hXULDocument_overlayFragments	= {};
21 20
 
22 21
 // Public methods
@@ -26,8 +25,7 @@ cXULDocument.prototype.loadOverlay	= function(sUrl, fObserver) {
26 25
 			"url": 		sUrl,
27 26
 			"async":	true,
28 27
 			"dataType":	"xml",
29  
-			"success":	function(oResponse) 
30  
-			{
  28
+			"success":	function(oResponse) {
31 29
 				//oOverlay	= ample.importNode(oResponse.documentElement, true);
32 30
 				oOverlay = oResponse.documentElement; //We can't import the overlay document 
33 31
 									//because we still need to differentiate
@@ -42,14 +40,12 @@ cXULDocument.prototype.loadOverlay	= function(sUrl, fObserver) {
42 40
 	});
43 41
 };
44 42
 
45  
-cXULDocument.prototype.applyOverlay	= function(oOverlayRoot) 
46  
-{
  43
+cXULDocument.prototype.applyOverlay	= function(oOverlayRoot) {
47 44
 	var oDocument	= this;
48 45
 	fXULDocument_applyOverlays(oDocument.documentElement, oOverlayRoot);
49 46
 };
50 47
 
51  
-function fXULDocument_applyOverlays(oAmpleNode, oOverlayNode) 
52  
-{
  48
+function fXULDocument_applyOverlays(oAmpleNode, oOverlayNode) {
53 49
 	//For each child of the overlay node, if:
54 50
 	//  - it does have an ID and:
55 51
 	//	-- that ID matches an existing node in the ample document, then if
@@ -69,24 +65,19 @@ function fXULDocument_applyOverlays(oAmpleNode, oOverlayNode)
69 65
 	//	   --- otherwise, it gets inserted into the ample node passed in by this function 
70 66
 	//		and the process repeats for all children.	
71 67
 	//Action...
72  
-	for (var iIndex = 0; iIndex < oOverlayNode.childNodes.length; iIndex++) 
73  
-	{
74  
-		var oChild = oOverlayNode.childNodes.item(iIndex);
  68
+	for (var nIndex = 0; nIndex < oOverlayNode.childNodes.length; nIndex++) {
  69
+		var oChild = oOverlayNode.childNodes.item(nIndex);
75 70
 		if (oChild.nodeType == ample.classes.Node.TEXT_NODE && oChild.nodeValue.trim() == '') continue;
76 71
 		if (oChild.nodeType == ample.classes.Node.COMMENT_NODE) continue;
77  
-		if (oChild.nodeType == ample.classes.Node.ELEMENT_NODE) 
78  
-		{
  72
+		if (oChild.nodeType == ample.classes.Node.ELEMENT_NODE) {
79 73
 			var oNewDocEl = null;
80  
-			if (oChild.getAttribute('id')) 
81  
-			{
  74
+			if (oChild.getAttribute('id')) {
82 75
 				//Our overlay node child has an ID.
83 76
 				var sID = oChild.getAttribute('id');
84 77
 				oNewDocEl = ample.getElementById(sID);
85  
-				if (!oNewDocEl) 
86  
-				{
  78
+				if (!oNewDocEl) {
87 79
 					//Our id doesn't match an existing element, ...
88  
-					if (oOverlayNode == oOverlayNode.ownerDocument.documentElement) 
89  
-					{
  80
+					if (oOverlayNode == oOverlayNode.ownerDocument.documentElement) {
90 81
 						//...and it's a child of the overlay root, so store it for later, and 
91 82
 						//skip to the next child.
92 83
 						hXULDocument_overlayFragments[oChild.getAttribute('id')] = oChild;
@@ -100,30 +91,31 @@ function fXULDocument_applyOverlays(oAmpleNode, oOverlayNode)
100 91
 				else {
101 92
 					//Our id does match an existing element
102 93
 					//Check to see if this is a remove instruction...
103  
-					if (oChild.getAttribute('removeelement') && oChild.getAttribute('removeelement') == 'true') {
104  
-	 	 	 	 	//Remove it, and all children, and skip to the next child.
105  
-	 	 	 	 	oNewDocEl.parentNode.removeChild(oNewDocEl);
106  
-	 	 	 	 	continue;
107  
-	 	 	 	 }
108  
-	 	 	 	 //Otherwise, just allow it to merge.
109  
-	 	 	  }
110  
-	 	} 
111  
-		else {
112  
-	 	 	//Our overlay node child doesn't have an ID.
113  
-	 	 	if (oOverlayNode == oOverlayNode.ownerDocument.documentElement) 
114  
-			{
115  
-	 	 		//...and it's a child of the overlay root, so insert it into the root.
116  
-	 	 		oNewDocEl = fXULDocument_importAndAdd(oAmpleNode.ownerDocument.documentElement,oChild);
117  
-	 	 	} else {
118  
-	 	 		//...and it's not a child of root, so add it to the current node.
119  
-	 	 		oNewDocEl = fXULDocument_importAndAdd(oAmpleNode,oChild); //We don't have an id, so insert.
120  
-	 	 	}
121  
-		}
122  
-		fXULDocument_mergeAttributes(oNewDocEl,oChild);
123  
-		fXULDocument_applyOverlays(oNewDocEl,oChild);
124  
-	} else 
125  
-		alert('Non-XUL element in overlay.'+oChild); //We have a non-XUL element, alert.
126  
-}
  94
+					if (oChild.getAttribute('removeelement') && oChild.getAttribute('removeelement') == 'true')	{
  95
+		 	 	 	 	//Remove it, and all children, and skip to the next child.
  96
+		 	 	 	 	oNewDocEl.parentNode.removeChild(oNewDocEl);
  97
+		 	 	 	 	continue;
  98
+		 	 	 	 }
  99
+				 	 //Otherwise, just allow it to merge.
  100
+		 	 	}
  101
+	 		}
  102
+			else { //(!oChild.getAttribute('id')
  103
+		 	 	//Our overlay node child doesn't have an ID.
  104
+		 	 	if (oOverlayNode == oOverlayNode.ownerDocument.documentElement) {
  105
+		 	 		//...and it's a child of the overlay root, so insert it into the root.
  106
+		 	 		oNewDocEl = fXULDocument_importAndAdd(oAmpleNode.ownerDocument.documentElement,oChild);
  107
+		 	 	} 
  108
+				else {
  109
+		 	 		//...and it's not a child of root, so add it to the current node.
  110
+		 	 		oNewDocEl = fXULDocument_importAndAdd(oAmpleNode,oChild); //We don't have an id, so insert.
  111
+		 	 	}
  112
+			}
  113
+			fXULDocument_mergeAttributes(oNewDocEl,oChild);
  114
+			fXULDocument_applyOverlays(oNewDocEl,oChild);
  115
+		} 
  116
+		else 
  117
+			alert('Non-XUL element in overlay.'+oChild); //We have a non-XUL element, alert.
  118
+	}
127 119
 };
128 120
 
129 121
 function fXULDocument_importAndAdd(oParent,oNodeToAdd) {
@@ -135,8 +127,8 @@ function fXULDocument_importAndAdd(oParent,oNodeToAdd) {
135 127
 	}
136 128
 	if (oNodeToAdd.getAttribute('insertafter')) {
137 129
 	    var aInsertAfter = oNodeToAdd.getAttribute('insertafter').split(',');
138  
-	    for (var iIndex = 0; iIndex < aInsertAfter.length; iIndex++) {
139  
-	 	   oInsertAfterEl = ample.query("#"+aInsertAfter[iIndex].trim());
  130
+	    for (var nIndex = 0; nIndex < aInsertAfter.length; nIndex++) {
  131
+	 	   oInsertAfterEl = ample.query("#"+aInsertAfter[nIndex].trim());
140 132
 	 	   if (oInsertAfterEl.size() > 0) {
141 133
 	 	 	  oInsertAfterEl.after(oNewNode);
142 134
 	 	 	  return oNewNode;
@@ -145,8 +137,8 @@ function fXULDocument_importAndAdd(oParent,oNodeToAdd) {
145 137
 	}
146 138
 	if (oNodeToAdd.getAttribute('insertbefore')) {
147 139
 	   var aInsertBefore = oNodeToAdd.getAttribute('insertbefore').split(',');
148  
-	    for (var iIndex = 0; iIndex < aInsertBefore.length; iIndex++) {
149  
-	 	   oInsertBeforeEl = ample.query("#"+aInsertBefore[iIndex].trim());
  140
+	    for (var nIndex = 0; nIndex < aInsertBefore.length; nIndex++) {
  141
+	 	   oInsertBeforeEl = ample.query("#"+aInsertBefore[nIndex].trim());
150 142
 	 	   if (oInsertBeforeEl.size() > 0) {
151 143
 	 	 	  oInsertBeforeEl.before(oNewNode);
152 144
 	 	 	  return oNewNode;
@@ -168,16 +160,16 @@ function fXULDocument_importAndAdd(oParent,oNodeToAdd) {
168 160
 
169 161
 function fXULDocument_mergeAttributes(oAmpleNode,oOverlayNode) {
170 162
 	if (oOverlayNode.attributes) {
171  
-	    for (var iCounter = 0; iCounter < oOverlayNode.attributes.length; iCounter++) {
172  
-	 	   var oAttr = oOverlayNode.attributes.item(iCounter);
  163
+	    for (var nCounter = 0; nCounter < oOverlayNode.attributes.length; nCounter++) {
  164
+	 	   var oAttr = oOverlayNode.attributes.item(nCounter);
173 165
 	 	   if (['insertbefore','insertafter','position'].indexOf(oAttr.name) < 0)
174 166
 	 	 	  oAmpleNode.setAttribute(oAttr.name,oAttr.value);
175 167
 	    }
176 168
 	    return;
177 169
 	}
178 170
 	//else
179  
-	for (var iCounter = 0; iCounter < oOverlayNode.attributes.length; iCounter++) {
180  
-	    var oAttr = oOverlayNode.attributes.item(iCounter);
  171
+	for (var nCounter = 0; nCounter < oOverlayNode.attributes.length; nCounter++) {
  172
+	    var oAttr = oOverlayNode.attributes.item(nCounter);
181 173
 	    if (!(oAttr.value instanceof Function)
182 174
 	 	   && !(oAttr.value instanceof Object)
183 175
 	 	   && ['insertbefore','insertafter','position'].indexOf(oAttr.name) < 0
@@ -188,22 +180,6 @@ function fXULDocument_mergeAttributes(oAmpleNode,oOverlayNode) {
188 180
 }
189 181
 
190 182
 /*
191  
-function fXULDocument_applyOverlaysRecurse(oOverlayEl,oDocEl) {
192  
-	//Action...
193  
-	for (var iIndex = 0; iIndex < oOverlayEl.childNodes.length; iIndex++) {
194  
-	    var oChild = oOverlayEl.childNodes.item(iIndex);
195  
-	    if (oChild.getAttribute('id')) {
196  
-	 	   //We have an id
197  
-	 	   var oNewDocEl = ample.query(oChild.getAttribute('id'),oDocEl);
198  
-	 	   if (oNewDocEl) fXULDocument_applyOverlaysRecurse(oChild,oNewDocEl);  //Our id matches an existing element.
199  
-	 	   else fXULDocument_importAndAdd(oChild,oDocEl); //Our id doesn't insert it at the current location with the id.
200  
-	    }
201  
-	    else fXULDocument_importAndAdd(oChild,oDocEl); //We don't have an id, so insert.
202  
-	}
203  
-}
204  
-*/
205  
-
206  
-/*
207 183
 cXULDocument.prototype.addBroadcastListenerFor	= function(oBroadcaster, oObserver, sAttr) {
208 184
 
209 185
 };

0 notes on commit c422e61

Please sign in to comment.
Something went wrong with that request. Please try again.