Embed.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  1. (function(stylesheet, stencils)
  2. {
  3. // Callbacks:
  4. // mxClientOnLoad is called after the script is loaded with the stylesheet and the function to create a
  5. // graph (wich takes the container as an argument and returns the graph instance that was created).
  6. // mxClientOnCreate is called when a graph has been created with the graph.
  7. mxStencilRegistry.dynamicLoading = false;
  8. // Adds CSS for tooltips
  9. try
  10. {
  11. var style = document.createElement('style')
  12. style.type = 'text/css'
  13. style.innerHTML = ['div.mxTooltip {',
  14. '-webkit-box-shadow: 3px 3px 12px #C0C0C0;',
  15. '-moz-box-shadow: 3px 3px 12px #C0C0C0;',
  16. 'box-shadow: 3px 3px 12px #C0C0C0;',
  17. 'background: #FFFFCC;',
  18. 'border-style: solid;',
  19. 'border-width: 1px;',
  20. 'border-color: black;',
  21. 'font-family: Arial;',
  22. 'font-size: 8pt;',
  23. 'position: absolute;',
  24. 'cursor: default;',
  25. 'padding: 4px;',
  26. 'color: black;}'].join('\n');
  27. document.getElementsByTagName('head')[0].appendChild(style)
  28. }
  29. catch (e)
  30. {
  31. // ignore
  32. }
  33. var mathJaxLoading = typeof MathJax !== 'undefined' && typeof MathJax.typeset === 'function';
  34. var mathJaxQueue = [];
  35. function renderMath(nodes)
  36. {
  37. try
  38. {
  39. MathJax.typesetClear(nodes);
  40. MathJax.typeset(nodes);
  41. }
  42. catch (e)
  43. {
  44. MathJax.typesetClear(nodes);
  45. if (e.retry != null)
  46. {
  47. e.retry.then(function()
  48. {
  49. MathJax.typesetPromise(nodes);
  50. });
  51. }
  52. else if (window.console != null)
  53. {
  54. console.log('Error in MathJax: ' + e.toString());
  55. }
  56. }
  57. };
  58. function loadMathJax()
  59. {
  60. // Uses existing configuration if MathJax already in page
  61. if (!mathJaxLoading)
  62. {
  63. mathJaxLoading = true;
  64. window.MathJax =
  65. {
  66. options:
  67. {
  68. skipHtmlTags: {'[+]': ['text']}
  69. },
  70. loader:
  71. {
  72. load: [(urlParams['math-output'] == 'html') ?
  73. 'output/chtml' : 'output/svg', 'input/tex',
  74. 'input/asciimath', 'ui/safe']
  75. },
  76. startup:
  77. {
  78. pageReady: function()
  79. {
  80. renderMath(mathJaxQueue);
  81. }
  82. }
  83. };
  84. var script = document.createElement('script');
  85. script.type = 'text/javascript';
  86. script.src = 'https://app.diagrams.net/math/es5/startup.js';
  87. document.getElementsByTagName('head')[0].appendChild(script);
  88. }
  89. };
  90. function addMathJaxGraph(graph)
  91. {
  92. // Initial rendering when MathJax finished loading
  93. if (typeof MathJax !== 'undefined' && typeof MathJax.typeset === 'function')
  94. {
  95. renderMath([graph.container]);
  96. }
  97. else
  98. {
  99. mathJaxQueue.push(graph.container);
  100. }
  101. };
  102. // Handles relative images
  103. mxGraph.prototype.getImageFromBundles = function(key)
  104. {
  105. if (key != null)
  106. {
  107. if (key.substring(0, 7) != 'http://' && key.substring(0, 8) != 'https://' && key.substring(0, 10) != 'data:image')
  108. {
  109. if (key.charAt(0) == '/')
  110. {
  111. key = key.substring(1, key.length);
  112. }
  113. key = 'https://app.diagrams.net/' + key;
  114. }
  115. return key;
  116. }
  117. return null;
  118. };
  119. if (stencils != null)
  120. {
  121. for (var i = 0; i < stencils.length; i++)
  122. {
  123. var xmlDoc = mxUtils.parseXml(stencils[i]);
  124. mxStencilRegistry.parseStencilSet(xmlDoc.documentElement);
  125. }
  126. }
  127. // Panning for touch devices
  128. if (mxClient.IS_TOUCH)
  129. {
  130. mxPanningHandler.prototype.isPanningTrigger = function(me)
  131. {
  132. return true;
  133. };
  134. }
  135. (function()
  136. {
  137. function initGraph(container)
  138. {
  139. try
  140. {
  141. var child = container.firstChild;
  142. while (child != null && child.nodeType != mxConstants.NODETYPE_ELEMENT)
  143. {
  144. child = child.nextSibling;
  145. }
  146. var xml = mxUtils.trim(child.innerHTML);
  147. container.innerText = '';
  148. // Instance needed for decompress helper function
  149. var graph = new Graph(container);
  150. if (xml.substring(0, 4) == '&lt;')
  151. {
  152. xml = xml.replace(/&lt;/g, '<').replace(/&gt;/g, '>').
  153. replace(/&amp;gt;/g, '&gt;').replace(/&amp;lt;/g, '&lt;').
  154. replace(/&amp;quot;/g, '&quot;').replace(/&#xa;/g, '\n');
  155. }
  156. else if (xml.substring(0, 3) == '%3C')
  157. {
  158. xml = decodeURIComponent(xml);
  159. }
  160. else
  161. {
  162. xml = Graph.decompress(xml);
  163. }
  164. var xmlDocument = mxUtils.parseXml(xml);
  165. var configNode = null;
  166. var diagrams = null;
  167. if (xmlDocument.documentElement != null && xmlDocument.documentElement.nodeName == 'mxfile')
  168. {
  169. diagrams = xmlDocument.documentElement.getElementsByTagName('diagram');
  170. configNode = xmlDocument.documentElement;
  171. if (diagrams.length > 0)
  172. {
  173. xml = mxUtils.getTextContent(diagrams[0]);
  174. xml = Graph.decompress(xml);
  175. xmlDocument = mxUtils.parseXml(xml);
  176. }
  177. }
  178. if (xmlDocument.documentElement != null && xmlDocument.documentElement.nodeName == 'mxGraphModel')
  179. {
  180. var decoder = new mxCodec(xmlDocument);
  181. var node = xmlDocument.documentElement;
  182. if (configNode == null)
  183. {
  184. configNode = node;
  185. }
  186. graph.resetViewOnRootChange = false;
  187. graph.setEnabled(false);
  188. if (diagrams != null && diagrams.length > 0)
  189. {
  190. /**
  191. * Adds placeholder for %page% and %pagenumber%
  192. */
  193. var graphGetGlobalVariable = graph.getGlobalVariable;
  194. graph.getGlobalVariable = function(name)
  195. {
  196. if (name == 'page')
  197. {
  198. return diagrams[0].getAttribute('name') || 'Page-1';
  199. }
  200. else if (name == 'pagenumber')
  201. {
  202. return 1;
  203. }
  204. else if (name == 'pagecount')
  205. {
  206. return diagrams.length;
  207. }
  208. return graphGetGlobalVariable.apply(this, arguments);
  209. };
  210. }
  211. graph.foldingEnabled = configNode.getAttribute('nav') == '1';
  212. graph.cellRenderer.forceControlClickHandler = graph.foldingEnabled;
  213. var tooltips = configNode.getAttribute('tooltips');
  214. if (tooltips != '0')
  215. {
  216. graph.setTooltips(true);
  217. }
  218. else
  219. {
  220. graph.setTooltips(false);
  221. }
  222. // Loads the stylesheet
  223. if (stylesheet != null)
  224. {
  225. var xmlDoc = mxUtils.parseXml(stylesheet);
  226. var dec = new mxCodec(xmlDoc);
  227. dec.decode(xmlDoc.documentElement, graph.getStylesheet());
  228. }
  229. var math = configNode.getAttribute('math');
  230. if (math == '1')
  231. {
  232. loadMathJax();
  233. }
  234. // Enables panning with left mouse button
  235. var pan = configNode.getAttribute('pan');
  236. if (pan != '0')
  237. {
  238. graph.panningHandler.useLeftButtonForPanning = true;
  239. graph.panningHandler.ignoreCell = true;
  240. container.style.cursor = 'move';
  241. graph.setPanning(true);
  242. }
  243. else
  244. {
  245. container.style.cursor = 'default';
  246. }
  247. var resize = configNode.getAttribute('resize');
  248. var border = Number(configNode.getAttribute('border') || 0);
  249. graph.border = border;
  250. var fit = configNode.getAttribute('fit');
  251. if ((container.style.width != '100%' && fit != '1' && resize != '0') ||
  252. (container.style.width == '' && container.style.height == ''))
  253. {
  254. graph.resizeContainer = true;
  255. graph.centerZoom = false;
  256. }
  257. else
  258. {
  259. // Updates the container height for autosize width
  260. if (resize != '0' && container.style.width == '100%' && container.style.height == '')
  261. {
  262. graph.resizeContainer = true;
  263. graph.centerZoom = false;
  264. graph.doResizeContainer = function(width, height)
  265. {
  266. // Fixes container size for different box models
  267. if (mxClient.IS_IE)
  268. {
  269. if (document.documentMode >= 9)
  270. {
  271. width += 3;
  272. height += 5;
  273. }
  274. else
  275. {
  276. width += 1;
  277. height += 1;
  278. }
  279. }
  280. else
  281. {
  282. height += 1;
  283. }
  284. if (this.maximumContainerSize != null)
  285. {
  286. width = Math.min(this.maximumContainerSize.width, width);
  287. height = Math.min(this.maximumContainerSize.height, height);
  288. }
  289. this.container.style.height = Math.ceil(height + 18) + 'px';
  290. };
  291. }
  292. else
  293. {
  294. graph.centerZoom = true;
  295. }
  296. }
  297. // Adds handling for hyperlinks, tooltips
  298. var links = configNode.getAttribute('links');
  299. var hl = configNode.getAttribute('highlight');
  300. if (links != '0' || tooltips != '0')
  301. {
  302. var cursor = container.style.cursor;
  303. var tol = graph.getTolerance();
  304. graph.addMouseListener(
  305. {
  306. currentState: null,
  307. currentLink: null,
  308. highlight: (hl != null && hl != '' && hl != mxConstants.NONE) ?
  309. new mxCellHighlight(graph, hl, 2) : null,
  310. startX: 0,
  311. startY: 0,
  312. mouseDown: function(sender, me)
  313. {
  314. this.startX = me.getGraphX();
  315. this.startY = me.getGraphY();
  316. },
  317. mouseMove: function(sender, me)
  318. {
  319. if (graph.isMouseDown)
  320. {
  321. if (this.currentLink != null)
  322. {
  323. var dx = Math.abs(this.startX - me.getGraphX());
  324. var dy = Math.abs(this.startY - me.getGraphY());
  325. if (dx > tol || dy > tol)
  326. {
  327. this.clear();
  328. }
  329. }
  330. }
  331. else
  332. {
  333. if (this.currentState != null && (me.getState() == this.currentState || me.getState() == null) &&
  334. graph.intersects(this.currentState, me.getGraphX(), me.getGraphY()))
  335. {
  336. return;
  337. }
  338. var tmp = graph.view.getState(me.getCell());
  339. if (tmp != this.currentState)
  340. {
  341. if (this.currentState != null)
  342. {
  343. this.clear();
  344. }
  345. this.currentState = tmp;
  346. if (this.currentState != null)
  347. {
  348. this.activate(this.currentState);
  349. }
  350. }
  351. }
  352. },
  353. mouseUp: function(sender, me)
  354. {
  355. var tmp = this.currentLink;
  356. this.clear();
  357. if (tmp != null)
  358. {
  359. if (tmp.charAt(0) == '#')
  360. {
  361. window.location.hash = tmp;
  362. }
  363. else
  364. {
  365. window.open(tmp);
  366. }
  367. }
  368. },
  369. activate: function(state)
  370. {
  371. this.currentLink = graph.getLinkForCell(state.cell);
  372. if (this.currentLink != null)
  373. {
  374. container.style.cursor = 'pointer';
  375. if (this.highlight != null)
  376. {
  377. this.highlight.highlight(state);
  378. }
  379. }
  380. },
  381. clear: function()
  382. {
  383. container.style.cursor = cursor;
  384. this.currentState = null;
  385. this.currentLink = null;
  386. if (this.highlight != null)
  387. {
  388. this.highlight.hide();
  389. }
  390. }
  391. });
  392. }
  393. var x0 = Number(configNode.getAttribute('x0') || 0);
  394. var y0 = Number(configNode.getAttribute('y0') || 0);
  395. graph.view.translate.x = -x0 + border;
  396. graph.view.translate.y = -y0 + border;
  397. function graphAdded(node)
  398. {
  399. var img = node.getAttribute('backgroundImage');
  400. if (img != null)
  401. {
  402. img = JSON.parse(img);
  403. graph.setBackgroundImage(new mxImage(img.src, img.width, img.height));
  404. graph.view.validateBackgroundImage();
  405. }
  406. if (fit != '0')
  407. {
  408. graph.fit(border);
  409. }
  410. if (math == '1')
  411. {
  412. addMathJaxGraph(graph);
  413. }
  414. // Keeps hashtag links on same page
  415. var links = graph.container.getElementsByTagName('a');
  416. if (links != null)
  417. {
  418. for (var i = 0; i < links.length; i++)
  419. {
  420. var href = links[i].getAttribute('href');
  421. if (href != null && href.charAt(0) == '#' &&
  422. links[i].getAttribute('target') == '_blank')
  423. {
  424. links[i].removeAttribute('target');
  425. }
  426. }
  427. }
  428. };
  429. // Load from URL via url attribute
  430. var url = configNode.getAttribute('url');
  431. if (url != null)
  432. {
  433. try
  434. {
  435. // Workaround for unsupported CORS in IE9 XHR
  436. var xhr = (navigator.userAgent != null && navigator.userAgent.indexOf('MSIE 9') > 0) ?
  437. new XDomainRequest() : new XMLHttpRequest();
  438. xhr.open('GET', url);
  439. xhr.onload = mxUtils.bind(this, function()
  440. {
  441. try
  442. {
  443. var data = (xhr.getText != null) ? xhr.getText() : xhr.responseText;
  444. if (data != null)
  445. {
  446. var newDocument = mxUtils.parseXml(data);
  447. // LATER: Add support for .png (with XML) files
  448. // Adds support for HTML
  449. if (newDocument != null && newDocument.documentElement.nodeName == 'html')
  450. {
  451. var divs = newDocument.documentElement.getElementsByTagName('div');
  452. if (divs.length > 0 && divs[0].getAttribute('class') == 'mxgraph')
  453. {
  454. var divs2 = divs[0].getElementsByTagName('div');
  455. if (divs2.length > 0)
  456. {
  457. var data = mxUtils.getTextContent(divs2[0]);
  458. data = Graph.decompress(data);
  459. if (data.length > 0)
  460. {
  461. newDocument = mxUtils.parseXml(data);
  462. }
  463. }
  464. }
  465. }
  466. if (newDocument != null && newDocument.documentElement.nodeName == 'svg')
  467. {
  468. var tmp = newDocument.documentElement.getAttribute('content');
  469. if (tmp != null && tmp.charAt(0) != '<' && tmp.charAt(0) != '%')
  470. {
  471. tmp = unescape((window.atob) ? atob(tmp) : Base64.decode(cont, tmp));
  472. }
  473. if (tmp != null && tmp.charAt(0) == '%')
  474. {
  475. tmp = decodeURIComponent(tmp);
  476. }
  477. if (tmp != null && tmp.length > 0)
  478. {
  479. newDocument = mxUtils.parseXml(tmp);
  480. }
  481. }
  482. if (newDocument.documentElement.nodeName == 'mxfile')
  483. {
  484. var diagrams = newDocument.documentElement.getElementsByTagName('diagram');
  485. if (diagrams.length > 0)
  486. {
  487. var text = mxUtils.trim(mxUtils.getTextContent(diagrams[0]));
  488. if (text.length > 0)
  489. {
  490. var tmp = Graph.decompress(text);
  491. if (tmp != null && tmp.length > 0)
  492. {
  493. newDocument = mxUtils.parseXml(tmp);
  494. }
  495. }
  496. else
  497. {
  498. var temp = mxUtils.getChildNodes(diagrams[0]);
  499. if (temp.length > 0)
  500. {
  501. // Creates new document for unique IDs within mxGraphModel
  502. newDocument = mxUtils.createXmlDocument();
  503. newDocument.appendChild(newDocument.importNode(temp[0], true));
  504. }
  505. }
  506. }
  507. }
  508. decoder = new mxCodec(newDocument);
  509. decoder.decode(newDocument.documentElement, graph.getModel());
  510. graphAdded(newDocument.documentElement);
  511. }
  512. else
  513. {
  514. graph.container.innerText = 'Cannot load ' + url;
  515. }
  516. }
  517. catch (e)
  518. {
  519. graph.container.innerText = 'Cannot load ' + url + ': ' + e.message;
  520. }
  521. });
  522. xhr.onerror = function()
  523. {
  524. graph.container.innerText = 'Cannot load ' + url;
  525. };
  526. xhr.send();
  527. }
  528. catch (e)
  529. {
  530. graph.container.innerText = 'Cannot load ' + url + ': ' + e.message;
  531. }
  532. }
  533. else
  534. {
  535. decoder.decode(node, graph.getModel());
  536. graphAdded(node);
  537. }
  538. if (container.style.width != '100%' && fit != '0' && resize == '1')
  539. {
  540. graph.resizeContainer = true;
  541. graph.centerZoom = false;
  542. }
  543. // Adds zoom, edit etc in top, left corner
  544. var buttons = document.createElement('div');
  545. buttons.style.position = 'absolute';
  546. buttons.style.overflow = 'visible';
  547. buttons.style.cursor = 'pointer';
  548. var bs = graph.getBorderSizes();
  549. var left = 0;
  550. var fontSize = 10;
  551. var bw = 16;
  552. var bh = 16;
  553. if (mxClient.IS_TOUCH)
  554. {
  555. bw = 24;
  556. bh = 24;
  557. var fontSize = 14;
  558. }
  559. function addButton(label, funct)
  560. {
  561. var btn = document.createElement('div');
  562. btn.style.position = 'absolute';
  563. btn.style.border = '1px solid gray';
  564. btn.style.textAlign = 'center';
  565. btn.style.cursor = 'hand';
  566. btn.style.width = bw + 'px';
  567. btn.style.height = bh + 'px';
  568. btn.style.left = left + 'px';
  569. btn.style.top = '0px';
  570. btn.style.backgroundColor = 'white';
  571. mxUtils.setOpacity(btn, 50);
  572. var table = document.createElement('table');
  573. table.style.borderWidth = '0px';
  574. table.style.width = '100%';
  575. table.style.height = '100%';
  576. var tbody = document.createElement('tbody');
  577. var tr = document.createElement('tr');
  578. var td = document.createElement('td');
  579. td.style.verticalAlign = 'middle';
  580. td.style.textAlign = 'center';
  581. td.style.fontSize = fontSize + 'px';
  582. td.style.padding = '0px';
  583. mxUtils.write(td, label);
  584. tr.appendChild(td);
  585. tbody.appendChild(tr);
  586. table.appendChild(tbody);
  587. btn.appendChild(table);
  588. mxEvent.addListener(btn, (mxClient.IS_POINTER) ? 'pointerdown' : 'mousedown', function(evt)
  589. {
  590. mxEvent.consume(evt);
  591. });
  592. mxEvent.addListener(btn, (mxClient.IS_POINTER) ? 'pointerup' : 'mouseup', function(evt)
  593. {
  594. funct();
  595. mxEvent.consume(evt);
  596. });
  597. if (!mxClient.IS_POINTER && mxClient.IS_TOUCH)
  598. {
  599. mxEvent.addListener(btn, 'touchstart', function(evt)
  600. {
  601. mxEvent.consume(evt);
  602. });
  603. mxEvent.addListener(btn, 'touchend', function(evt)
  604. {
  605. funct();
  606. mxEvent.consume(evt);
  607. });
  608. }
  609. left += bw;
  610. buttons.appendChild(btn);
  611. return btn;
  612. };
  613. var zoom = configNode.getAttribute('zoom');
  614. if (zoom != '0')
  615. {
  616. addButton('+', function()
  617. {
  618. graph.zoomIn();
  619. });
  620. addButton('-', function()
  621. {
  622. graph.zoomOut();
  623. });
  624. }
  625. var edit = configNode.getAttribute('edit');
  626. if (edit != null)
  627. {
  628. var button = addButton('', function()
  629. {
  630. // _blank is a special value to open a new editor
  631. // in client mode and send the XML as a message
  632. if (edit == '_blank')
  633. {
  634. if (url != null)
  635. {
  636. window.open('https://app.diagrams.net/#U' + encodeURIComponent(url));
  637. }
  638. else
  639. {
  640. var wnd = null;
  641. var receive = function(evt)
  642. {
  643. if (evt.data == 'ready' && evt.source == wnd)
  644. {
  645. wnd.postMessage(xml, '*');
  646. window.removeEventListener('message', receive);
  647. }
  648. };
  649. window.addEventListener('message', receive);
  650. wnd = window.open('https://app.diagrams.net/?client=1');
  651. }
  652. }
  653. else
  654. {
  655. window.open(edit);
  656. }
  657. });
  658. // Do not use HTML entity to avoid problems with XHTML
  659. button.innerText = '...';
  660. }
  661. function show()
  662. {
  663. buttons.style.top = (container.offsetTop + bs.y) + 'px';
  664. buttons.style.left = (container.offsetLeft + bs.x) + 'px';
  665. buttons.style.visibility = 'visible';
  666. };
  667. if (!mxClient.IS_POINTER && !mxClient.IS_TOUCH)
  668. {
  669. function hide()
  670. {
  671. buttons.style.visibility = 'hidden';
  672. };
  673. mxEvent.addListener(container, 'mouseover', show);
  674. mxEvent.addListener(buttons, 'mouseover', show);
  675. mxEvent.addListener(container, 'mouseout', hide);
  676. mxEvent.addListener(buttons, 'mouseout', hide);
  677. hide();
  678. }
  679. else
  680. {
  681. show();
  682. }
  683. if (buttons.firstChild != null)
  684. {
  685. if (container.nextSibling != null)
  686. {
  687. container.parentNode.insertBefore(buttons, container.nextSibling);
  688. }
  689. else
  690. {
  691. container.parentNode.appendChild(buttons);
  692. }
  693. }
  694. if (typeof(window.mxClientOnCreate) == 'function')
  695. {
  696. window.mxClientOnCreate(graph);
  697. }
  698. }
  699. }
  700. catch (err)
  701. {
  702. if (window.console != null)
  703. {
  704. console.log('Error:', err);
  705. }
  706. }
  707. return graph;
  708. };
  709. if (typeof(mxClientOnLoad) == 'function')
  710. {
  711. mxClientOnLoad(stylesheet, initGraph);
  712. }
  713. else if (mxClient.isBrowserSupported())
  714. {
  715. var tmp = document.getElementsByTagName('*');
  716. var divs = [];
  717. for (var i = 0; i < tmp.length; i++)
  718. {
  719. divs.push(tmp[i]);
  720. }
  721. for (var i = 0; i < divs.length; i++)
  722. {
  723. if (divs[i].className.toString().indexOf('mxgraph') >= 0)
  724. {
  725. initGraph(divs[i]);
  726. }
  727. }
  728. }
  729. })();
  730. // Last line will be replaced by servlet for passing arguments.
  731. })();