This repository has been archived by the owner on Mar 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
mxUtils.js
4520 lines (4011 loc) · 104 KB
/
mxUtils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Copyright (c) 2006-2015, JGraph Ltd
* Copyright (c) 2006-2015, Gaudenz Alder
*/
var mxUtils =
{
/**
* Class: mxUtils
*
* A singleton class that provides cross-browser helper methods.
* This is a global functionality. To access the functions in this
* class, use the global classname appended by the functionname.
* You may have to load chrome://global/content/contentAreaUtils.js
* to disable certain security restrictions in Mozilla for the <open>,
* <save>, <saveAs> and <copy> function.
*
* For example, the following code displays an error message:
*
* (code)
* mxUtils.error('Browser is not supported!', 200, false);
* (end)
*
* Variable: errorResource
*
* Specifies the resource key for the title of the error window. If the
* resource for this key does not exist then the value is used as
* the title. Default is 'error'.
*/
errorResource: (mxClient.language != 'none') ? 'error' : '',
/**
* Variable: closeResource
*
* Specifies the resource key for the label of the close button. If the
* resource for this key does not exist then the value is used as
* the label. Default is 'close'.
*/
closeResource: (mxClient.language != 'none') ? 'close' : '',
/**
* Variable: errorImage
*
* Defines the image used for error dialogs.
*/
errorImage: mxClient.imageBasePath + '/error.gif',
/**
* Function: removeCursors
*
* Removes the cursors from the style of the given DOM node and its
* descendants.
*
* Parameters:
*
* element - DOM node to remove the cursor style from.
*/
removeCursors: function(element)
{
if (element.style != null)
{
element.style.cursor = '';
}
var children = element.childNodes;
if (children != null)
{
var childCount = children.length;
for (var i = 0; i < childCount; i += 1)
{
mxUtils.removeCursors(children[i]);
}
}
},
/**
* Function: getCurrentStyle
*
* Returns the current style of the specified element.
*
* Parameters:
*
* element - DOM node whose current style should be returned.
*/
getCurrentStyle: function()
{
if (mxClient.IS_IE && (document.documentMode == null || document.documentMode < 9))
{
return function(element)
{
return (element != null) ? element.currentStyle : null;
};
}
else
{
return function(element)
{
return (element != null) ?
window.getComputedStyle(element, '') :
null;
};
}
}(),
/**
* Function: parseCssNumber
*
* Parses the given CSS numeric value adding handling for the values thin,
* medium and thick (2, 4 and 6).
*/
parseCssNumber: function(value)
{
if (value == 'thin')
{
value = '2';
}
else if (value == 'medium')
{
value = '4';
}
else if (value == 'thick')
{
value = '6';
}
value = parseFloat(value);
if (isNaN(value))
{
value = 0;
}
return value;
},
/**
* Function: setPrefixedStyle
*
* Adds the given style with the standard name and an optional vendor prefix for the current
* browser.
*
* (code)
* mxUtils.setPrefixedStyle(node.style, 'transformOrigin', '0% 0%');
* (end)
*/
setPrefixedStyle: function()
{
var prefix = null;
if (mxClient.IS_OT)
{
prefix = 'O';
}
else if (mxClient.IS_SF || mxClient.IS_GC)
{
prefix = 'Webkit';
}
else if (mxClient.IS_MT)
{
prefix = 'Moz';
}
else if (mxClient.IS_IE && document.documentMode >= 9 && document.documentMode < 10)
{
prefix = 'ms';
}
return function(style, name, value)
{
style[name] = value;
if (prefix != null && name.length > 0)
{
name = prefix + name.substring(0, 1).toUpperCase() + name.substring(1);
style[name] = value;
}
};
}(),
/**
* Function: hasScrollbars
*
* Returns true if the overflow CSS property of the given node is either
* scroll or auto.
*
* Parameters:
*
* node - DOM node whose style should be checked for scrollbars.
*/
hasScrollbars: function(node)
{
var style = mxUtils.getCurrentStyle(node);
return style != null && (style.overflow == 'scroll' || style.overflow == 'auto');
},
/**
* Function: bind
*
* Returns a wrapper function that locks the execution scope of the given
* function to the specified scope. Inside funct, the "this" keyword
* becomes a reference to that scope.
*/
bind: function(scope, funct)
{
return function()
{
return funct.apply(scope, arguments);
};
},
/**
* Function: eval
*
* Evaluates the given expression using eval and returns the JavaScript
* object that represents the expression result. Supports evaluation of
* expressions that define functions and returns the function object for
* these expressions.
*
* Parameters:
*
* expr - A string that represents a JavaScript expression.
*/
eval: function(expr)
{
var result = null;
if (expr.indexOf('function') >= 0)
{
try
{
eval('var _mxJavaScriptExpression='+expr);
result = _mxJavaScriptExpression;
// TODO: Use delete here?
_mxJavaScriptExpression = null;
}
catch (e)
{
mxLog.warn(e.message + ' while evaluating ' + expr);
}
}
else
{
try
{
result = eval(expr);
}
catch (e)
{
mxLog.warn(e.message + ' while evaluating ' + expr);
}
}
return result;
},
/**
* Function: findNode
*
* Returns the first node where attr equals value.
* This implementation does not use XPath.
*/
findNode: function(node, attr, value)
{
if (node.nodeType == mxConstants.NODETYPE_ELEMENT)
{
var tmp = node.getAttribute(attr);
if (tmp != null && tmp == value)
{
return node;
}
}
node = node.firstChild;
while (node != null)
{
var result = mxUtils.findNode(node, attr, value);
if (result != null)
{
return result;
}
node = node.nextSibling;
}
return null;
},
/**
* Function: getFunctionName
*
* Returns the name for the given function.
*
* Parameters:
*
* f - JavaScript object that represents a function.
*/
getFunctionName: function(f)
{
var str = null;
if (f != null)
{
if (f.name != null)
{
str = f.name;
}
else
{
str = mxUtils.trim(f.toString());
if (/^function\s/.test(str))
{
str = mxUtils.ltrim(str.substring(9));
var idx2 = str.indexOf('(');
if (idx2 > 0)
{
str = str.substring(0, idx2);
}
}
}
}
return str;
},
/**
* Function: indexOf
*
* Returns the index of obj in array or -1 if the array does not contain
* the given object.
*
* Parameters:
*
* array - Array to check for the given obj.
* obj - Object to find in the given array.
*/
indexOf: function(array, obj)
{
if (array != null && obj != null)
{
for (var i = 0; i < array.length; i++)
{
if (array[i] == obj)
{
return i;
}
}
}
return -1;
},
/**
* Function: forEach
*
* Calls the given function for each element of the given array and returns
* the array.
*
* Parameters:
*
* array - Array that contains the elements.
* fn - Function to be called for each object.
*/
forEach: function(array, fn)
{
if (array != null && fn != null)
{
for (var i = 0; i < array.length; i++)
{
fn(array[i]);
}
}
return array;
},
/**
* Function: remove
*
* Removes all occurrences of the given object in the given array or
* object. If there are multiple occurrences of the object, be they
* associative or as an array entry, all occurrences are removed from
* the array or deleted from the object. By removing the object from
* the array, all elements following the removed element are shifted
* by one step towards the beginning of the array.
*
* The length of arrays is not modified inside this function.
*
* Parameters:
*
* obj - Object to find in the given array.
* array - Array to check for the given obj.
*/
remove: function(obj, array)
{
var result = null;
if (typeof(array) == 'object')
{
var index = mxUtils.indexOf(array, obj);
while (index >= 0)
{
array.splice(index, 1);
result = obj;
index = mxUtils.indexOf(array, obj);
}
}
for (var key in array)
{
if (array[key] == obj)
{
delete array[key];
result = obj;
}
}
return result;
},
/**
* Function: isNode
*
* Returns true if the given value is an XML node with the node name
* and if the optional attribute has the specified value.
*
* This implementation assumes that the given value is a DOM node if the
* nodeType property is numeric, that is, if isNaN returns false for
* value.nodeType.
*
* Parameters:
*
* value - Object that should be examined as a node.
* nodeName - String that specifies the node name.
* attributeName - Optional attribute name to check.
* attributeValue - Optional attribute value to check.
*/
isNode: function(value, nodeName, attributeName, attributeValue)
{
if (value != null && !isNaN(value.nodeType) && (nodeName == null ||
value.nodeName.toLowerCase() == nodeName.toLowerCase()))
{
return attributeName == null ||
value.getAttribute(attributeName) == attributeValue;
}
return false;
},
/**
* Function: isAncestorNode
*
* Returns true if the given ancestor is an ancestor of the
* given DOM node in the DOM. This also returns true if the
* child is the ancestor.
*
* Parameters:
*
* ancestor - DOM node that represents the ancestor.
* child - DOM node that represents the child.
*/
isAncestorNode: function(ancestor, child)
{
var parent = child;
while (parent != null)
{
if (parent == ancestor)
{
return true;
}
parent = parent.parentNode;
}
return false;
},
/**
* Function: getChildNodes
*
* Returns an array of child nodes that are of the given node type.
*
* Parameters:
*
* node - Parent DOM node to return the children from.
* nodeType - Optional node type to return. Default is
* <mxConstants.NODETYPE_ELEMENT>.
*/
getChildNodes: function(node, nodeType)
{
nodeType = nodeType || mxConstants.NODETYPE_ELEMENT;
var children = [];
var tmp = node.firstChild;
while (tmp != null)
{
if (tmp.nodeType == nodeType)
{
children.push(tmp);
}
tmp = tmp.nextSibling;
}
return children;
},
/**
* Function: importNode
*
* Cross browser implementation for document.importNode. Uses document.importNode
* in all browsers but IE, where the node is cloned by creating a new node and
* copying all attributes and children into it using importNode, recursively.
*
* Parameters:
*
* doc - Document to import the node into.
* node - Node to be imported.
* allChildren - If all children should be imported.
*/
importNode: function(doc, node, allChildren)
{
if (mxClient.IS_IE && (document.documentMode == null || document.documentMode < 10))
{
return mxUtils.importNodeImplementation(doc, node, allChildren);
}
else
{
return doc.importNode(node, allChildren);
}
},
/**
* Function: importNodeImplementation
*
* Full DOM API implementation for importNode without using importNode API call.
*
* Parameters:
*
* doc - Document to import the node into.
* node - Node to be imported.
* allChildren - If all children should be imported.
*/
importNodeImplementation: function(doc, node, allChildren)
{
switch (node.nodeType)
{
case 1: /* element */
{
var newNode = doc.createElement(node.nodeName);
if (node.attributes && node.attributes.length > 0)
{
for (var i = 0; i < node.attributes.length; i++)
{
newNode.setAttribute(node.attributes[i].nodeName,
node.getAttribute(node.attributes[i].nodeName));
}
}
if (allChildren && node.childNodes && node.childNodes.length > 0)
{
for (var i = 0; i < node.childNodes.length; i++)
{
newNode.appendChild(mxUtils.importNodeImplementation(doc, node.childNodes[i], allChildren));
}
}
return newNode;
break;
}
case 3: /* text */
case 4: /* cdata-section */
case 8: /* comment */
{
return doc.createTextNode((node.nodeValue != null) ? node.nodeValue : node.value);
break;
}
};
},
/**
* Function: createXmlDocument
*
* Returns a new, empty XML document.
*/
createXmlDocument: function()
{
var doc = null;
if (document.implementation && document.implementation.createDocument)
{
doc = document.implementation.createDocument('', '', null);
}
else if ("ActiveXObject" in window)
{
doc = mxUtils.createMsXmlDocument();
}
return doc;
},
/**
* Function: createMsXmlDocument
*
* Returns a new, empty Microsoft.XMLDOM document using ActiveXObject.
*/
createMsXmlDocument: function()
{
var doc = new ActiveXObject('Microsoft.XMLDOM');
doc.async = false;
// Workaround for parsing errors with SVG DTD
doc.validateOnParse = false;
doc.resolveExternals = false;
return doc;
},
/**
* Function: parseXml
*
* Parses the specified XML string into a new XML document and returns the
* new document.
*
* Example:
*
* (code)
* var doc = mxUtils.parseXml(
* '<mxGraphModel><root><MyDiagram id="0"><mxCell/></MyDiagram>'+
* '<MyLayer id="1"><mxCell parent="0" /></MyLayer><MyObject id="2">'+
* '<mxCell style="strokeColor=blue;fillColor=red" parent="1" vertex="1">'+
* '<mxGeometry x="10" y="10" width="80" height="30" as="geometry"/>'+
* '</mxCell></MyObject></root></mxGraphModel>');
* (end)
*
* Parameters:
*
* xml - String that contains the XML data.
*/
parseXml: function()
{
if (window.DOMParser)
{
return function(xml)
{
var parser = new DOMParser();
return parser.parseFromString(xml, 'text/xml');
};
}
else // IE<=9
{
return function(xml)
{
var doc = mxUtils.createMsXmlDocument();
doc.loadXML(xml);
return doc;
};
}
}(),
/**
* Function: clearSelection
*
* Clears the current selection in the page.
*/
clearSelection: function()
{
if (document.selection)
{
return function()
{
document.selection.empty();
};
}
else if (window.getSelection)
{
return function()
{
if (window.getSelection().empty)
{
window.getSelection().empty();
}
else if (window.getSelection().removeAllRanges)
{
window.getSelection().removeAllRanges();
}
};
}
else
{
return function() { };
}
}(),
/**
* Function: removeWhitespace
*
* Removes the sibling text nodes for the given node that only consists
* of tabs, newlines and spaces.
*
* Parameters:
*
* node - DOM node whose siblings should be removed.
* before - Optional boolean that specifies the direction of the traversal.
*/
removeWhitespace: function(node, before)
{
var tmp = (before) ? node.previousSibling : node.nextSibling;
while (tmp != null && tmp.nodeType == mxConstants.NODETYPE_TEXT)
{
var next = (before) ? tmp.previousSibling : tmp.nextSibling;
var text = mxUtils.getTextContent(tmp);
if (mxUtils.trim(text).length == 0)
{
tmp.parentNode.removeChild(tmp);
}
tmp = next;
}
},
/**
* Function: htmlEntities
*
* Replaces characters (less than, greater than, newlines and quotes) with
* their HTML entities in the given string and returns the result.
*
* Parameters:
*
* s - String that contains the characters to be converted.
* newline - If newlines should be replaced. Default is true.
*/
htmlEntities: function(s, newline)
{
s = String(s || '');
s = s.replace(/&/g,'&'); // 38 26
s = s.replace(/"/g,'"'); // 34 22
s = s.replace(/\'/g,'''); // 39 27
s = s.replace(/</g,'<'); // 60 3C
s = s.replace(/>/g,'>'); // 62 3E
if (newline == null || newline)
{
s = s.replace(/\n/g, '
');
}
return s;
},
/**
* Function: isVml
*
* Returns true if the given node is in the VML namespace.
*
* Parameters:
*
* node - DOM node whose tag urn should be checked.
*/
isVml: function(node)
{
return node != null && node.tagUrn == 'urn:schemas-microsoft-com:vml';
},
/**
* Function: getXml
*
* Returns the XML content of the specified node. For Internet Explorer,
* all \r\n\t[\t]* are removed from the XML string and the remaining \r\n
* are replaced by \n. All \n are then replaced with linefeed, or 
 if
* no linefeed is defined.
*
* Parameters:
*
* node - DOM node to return the XML for.
* linefeed - Optional string that linefeeds are converted into. Default is
* 

*/
getXml: function(node, linefeed)
{
var xml = '';
if (mxClient.IS_IE || mxClient.IS_IE11)
{
xml = mxUtils.getPrettyXml(node, '', '', '');
}
else if (window.XMLSerializer != null)
{
var xmlSerializer = new XMLSerializer();
xml = xmlSerializer.serializeToString(node);
}
else if (node.xml != null)
{
xml = node.xml.replace(/\r\n\t[\t]*/g, '').
replace(/>\r\n/g, '>').
replace(/\r\n/g, '\n');
}
// Replaces linefeeds with HTML Entities.
linefeed = linefeed || '
';
xml = xml.replace(/\n/g, linefeed);
return xml;
},
/**
* Function: getPrettyXML
*
* Returns a pretty printed string that represents the XML tree for the
* given node. This method should only be used to print XML for reading,
* use <getXml> instead to obtain a string for processing.
*
* Parameters:
*
* node - DOM node to return the XML for.
* tab - Optional string that specifies the indentation for one level.
* Default is two spaces.
* indent - Optional string that represents the current indentation.
* Default is an empty string.
* newline - Option string that represents a linefeed. Default is '\n'.
*/
getPrettyXml: function(node, tab, indent, newline, ns)
{
var result = [];
if (node != null)
{
tab = (tab != null) ? tab : ' ';
indent = (indent != null) ? indent : '';
newline = (newline != null) ? newline : '\n';
if (node.namespaceURI != null && node.namespaceURI != ns)
{
ns = node.namespaceURI;
if (node.getAttribute('xmlns') == null)
{
node.setAttribute('xmlns', node.namespaceURI);
}
}
if (node.nodeType == mxConstants.NODETYPE_DOCUMENT)
{
result.push(mxUtils.getPrettyXml(node.documentElement, tab, indent, newline, ns));
}
else if (node.nodeType == mxConstants.NODETYPE_DOCUMENT_FRAGMENT)
{
var tmp = node.firstChild;
if (tmp != null)
{
while (tmp != null)
{
result.push(mxUtils.getPrettyXml(tmp, tab, indent, newline, ns));
tmp = tmp.nextSibling;
}
}
}
else if (node.nodeType == mxConstants.NODETYPE_COMMENT)
{
var value = mxUtils.getTextContent(node);
if (value.length > 0)
{
result.push(indent + '<!--' + value + '-->' + newline);
}
}
else if (node.nodeType == mxConstants.NODETYPE_TEXT)
{
var value = mxUtils.trim(mxUtils.getTextContent(node));
if (value.length > 0)
{
result.push(indent + mxUtils.htmlEntities(value, false) + newline);
}
}
else if (node.nodeType == mxConstants.NODETYPE_CDATA)
{
var value = mxUtils.getTextContent(node);
if (value.length > 0)
{
result.push(indent + '<![CDATA[' + value + ']]' + newline);
}
}
else
{
result.push(indent + '<' + node.nodeName);
// Creates the string with the node attributes
// and converts all HTML entities in the values
var attrs = node.attributes;
if (attrs != null)
{
for (var i = 0; i < attrs.length; i++)
{
var val = mxUtils.htmlEntities(attrs[i].value);
result.push(' ' + attrs[i].nodeName + '="' + val + '"');
}
}
// Recursively creates the XML string for each child
// node and appends it here with an indentation
var tmp = node.firstChild;
if (tmp != null)
{
result.push('>' + newline);
while (tmp != null)
{
result.push(mxUtils.getPrettyXml(tmp, tab, indent + tab, newline, ns));
tmp = tmp.nextSibling;
}
result.push(indent + '</'+ node.nodeName + '>' + newline);
}
else
{
result.push(' />' + newline);
}
}
}
return result.join('');
},
/**
* Function: extractTextWithWhitespace
*
* Returns the text content of the specified node.
*
* Parameters:
*
* elems - DOM nodes to return the text for.
*/
extractTextWithWhitespace: function(elems)
{
// Known block elements for handling linefeeds (list is not complete)
var blocks = ['BLOCKQUOTE', 'DIV', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'OL', 'P', 'PRE', 'TABLE', 'UL'];
var ret = [];
function doExtract(elts)
{
// Single break should be ignored
if (elts.length == 1 && (elts[0].nodeName == 'BR' ||
elts[0].innerHTML == '\n'))
{
return;
}
for (var i = 0; i < elts.length; i++)
{
var elem = elts[i];
// DIV with a br or linefeed forces a linefeed
if (elem.nodeName == 'BR' || elem.innerHTML == '\n' ||
((elts.length == 1 || i == 0) && (elem.nodeName == 'DIV' &&
elem.innerHTML.toLowerCase() == '<br>')))
{
ret.push('\n');
}
else
{
if (elem.nodeType === 3 || elem.nodeType === 4)
{
if (elem.nodeValue.length > 0)
{
ret.push(elem.nodeValue);
}
}
else if (elem.nodeType !== 8 && elem.childNodes.length > 0)
{
doExtract(elem.childNodes);
}
if (i < elts.length - 1 && mxUtils.indexOf(blocks, elts[i + 1].nodeName) >= 0)
{
ret.push('\n');
}
}
}
};
doExtract(elems);