embed.dev.js 21 KB

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