Commit 9942b5cc830a7567c2a515ef7b78fa68946ddac5

Authored by xp.Huang
2 parents 12256b8a 2b2a4a02

Merge branch 'ww' into 'main'

feat: 新增组态分享功能

See merge request yunteng/thingskit-scada!59
@@ -8,3 +8,4 @@ yarn.lock @@ -8,3 +8,4 @@ yarn.lock
8 **/.DS_Store 8 **/.DS_Store
9 **/*.min.js 9 **/*.min.js
10 dist 10 dist
  11 +src/main/webapp/js/grapheditor/compiled/Format.js
No preview for this file type
@@ -57,7 +57,7 @@ public class Xml2Js @@ -57,7 +57,7 @@ public class Xml2Js
57 String name = f.getCanonicalPath() 57 String name = f.getCanonicalPath()
58 .substring(basePath.length() + 1); 58 .substring(basePath.length() + 1);
59 result.add( 59 result.add(
60 - "f['" + name + "'] = '" + processFile(f) + "';\n"); 60 + "f['" + name.replace("\\", "/") + "'] = '" + processFile(f) + "';\n");
61 } 61 }
62 } 62 }
63 } 63 }
@@ -22,26 +22,26 @@ @@ -22,26 +22,26 @@
22 <meta name="mobile-web-app-capable" content="yes"> 22 <meta name="mobile-web-app-capable" content="yes">
23 <meta name="theme-color" content="#d89000"> 23 <meta name="theme-color" content="#d89000">
24 24
25 - <link rel="stylesheet" href="./js/plugin/layui/css/layui.css?v=1670325027797"> 25 + <link rel="stylesheet" href="./js/plugin/layui/css/layui.css?v=1679478216446">
26 26
27 <!-- load configure file --> 27 <!-- load configure file -->
28 - <script src="./js/config/config.js?v=1670325027797"></script> 28 + <script src="./js/config/config.js?v=1679478216446"></script>
29 29
30 <!-- crypto-js --> 30 <!-- crypto-js -->
31 - <script src="./js/plugin/crypto-js/crypto-js.js?v=1670325027797"></script> 31 + <script src="./js/plugin/crypto-js/crypto-js.js?v=1679478216446"></script>
32 32
33 <!-- storage persistent --> 33 <!-- storage persistent -->
34 - <script src="./js/const/persistentStorage.js?v=1670325027797"></script> 34 + <script src="./js/const/persistentStorage.js?v=1679478216446"></script>
35 <!-- Global const --> 35 <!-- Global const -->
36 - <script src="./js/const/const.js?v=1670325027797"></script> 36 + <script src="./js/const/const.js?v=1679478216446"></script>
37 37
38 <!-- Axios --> 38 <!-- Axios -->
39 - <script src="./js/plugin/axios/axios.min.js?v=1670325027797"></script>  
40 - <script src="./js/plugin/axios/DefHttp.js?v=1670325027797"></script>  
41 - <script src="./js/api/index.js?v=1670325027797"></script> 39 + <script src="./js/plugin/axios/axios.min.js?v=1679478216446"></script>
  40 + <script src="./js/plugin/axios/DefHttp.js?v=1679478216446"></script>
  41 + <script src="./js/api/index.js?v=1679478216446"></script>
42 42
43 <!-- load script --> 43 <!-- load script -->
44 - <script src="./js/config/loadScript.js?v=1670325027797"></script> 44 + <script src="./js/config/loadScript.js?v=1679478216446"></script>
45 45
46 <!-- act editor --> 46 <!-- act editor -->
47 <!-- <script src="https://oss.yuntengcloud.com/iotdocs/thingskit-scada/ace.js"></script> --> 47 <!-- <script src="https://oss.yuntengcloud.com/iotdocs/thingskit-scada/ace.js"></script> -->
@@ -54,7 +54,7 @@ @@ -54,7 +54,7 @@
54 <!-- <script src="https://vjs.zencdn.net/7.10.2/video.min.js"></script> --> 54 <!-- <script src="https://vjs.zencdn.net/7.10.2/video.min.js"></script> -->
55 <!-- <script src="https://oss.yuntengcloud.com/iotdocs/thingskit-scada/video.min.js"></script> --> 55 <!-- <script src="https://oss.yuntengcloud.com/iotdocs/thingskit-scada/video.min.js"></script> -->
56 56
57 - <script src="./js/plugin/layui/layui.js?v=1670325027797"></script> 57 + <script src="./js/plugin/layui/layui.js?v=1679478216446"></script>
58 <!-- <link rel="stylesheet" href="https://cdnjs.loli.net/ajax/libs/layui/2.6.8/css/layui.min.css" 58 <!-- <link rel="stylesheet" href="https://cdnjs.loli.net/ajax/libs/layui/2.6.8/css/layui.min.css"
59 integrity="sha512-iQBJbsNHXUcgEIgWThd2dr8tOdKPvICwqjPEZYY81z3eMya44A5MiAqfWSCh+Ee1YzNYkdrI982Qhwgr8LEYOQ==" 59 integrity="sha512-iQBJbsNHXUcgEIgWThd2dr8tOdKPvICwqjPEZYY81z3eMya44A5MiAqfWSCh+Ee1YzNYkdrI982Qhwgr8LEYOQ=="
60 crossorigin="anonymous" referrerpolicy="no-referrer" /> 60 crossorigin="anonymous" referrerpolicy="no-referrer" />
@@ -63,7 +63,7 @@ @@ -63,7 +63,7 @@
63 crossorigin="anonymous" referrerpolicy="no-referrer"></script> --> 63 crossorigin="anonymous" referrerpolicy="no-referrer"></script> -->
64 64
65 <!-- 引入修改样式 --> 65 <!-- 引入修改样式 -->
66 - <link rel="stylesheet" href="./styles/formatChange.css?v=1670325027797"> 66 + <link rel="stylesheet" href="./styles/formatChange.css?v=1679478216446">
67 67
68 <script type="text/javascript"> 68 <script type="text/javascript">
69 /** 69 /**
@@ -306,7 +306,7 @@ @@ -306,7 +306,7 @@
306 var supportedDomain = (hostName.substring(hostName.length - 8, hostName.length) === '.draw.io') || 306 var supportedDomain = (hostName.substring(hostName.length - 8, hostName.length) === '.draw.io') ||
307 (hostName.substring(hostName.length - 13, hostName.length) === '.diagrams.net'); 307 (hostName.substring(hostName.length - 13, hostName.length) === '.diagrams.net');
308 308
309 - const releaseVersion = '1670325027797' 309 + const releaseVersion = '1679478216446'
310 const appMinSrc = Enable_OSS ? `${OSS_Prefix}app.min.js?v=${releaseVersion}` : `js/app.min.js?v=${releaseVersion}` 310 const appMinSrc = Enable_OSS ? `${OSS_Prefix}app.min.js?v=${releaseVersion}` : `js/app.min.js?v=${releaseVersion}`
311 function loadAppJS() { 311 function loadAppJS() {
312 mxscript(appMinSrc, function () { 312 mxscript(appMinSrc, function () {
@@ -65,8 +65,7 @@ App = function (editor, container, lightbox) { @@ -65,8 +65,7 @@ App = function (editor, container, lightbox) {
65 // Pre-fetches images 65 // Pre-fetches images
66 if (mxClient.IS_SVG) { 66 if (mxClient.IS_SVG) {
67 mxGraph.prototype.warningImage.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAE7SURBVHjaYvz//z8DJQAggBjwGXDuHMP/tWuD/uPTCxBAOA0AaQRK/f/+XeJ/cbHlf1wGAAQQTgPu3QNLgfHSpZo4DQAIIKwGwGyH4e/fFbG6AiQJEEAs2Ew2NFzH8OOHBMO6dT/A/KCg7wxGRh+wuhQggDBcALMdFIAcHBxgDGJjcwVIIUAAYbhAUXEdVos4OO4DXcGBIQ4QQCguQPY7sgtgAYruCpAgQACx4LJdU1OCwctLEcyWlLwPJF+AXQE0EMUBAAEEdwF6yMOiD4RRY0QT7gqQAEAAseDzu6XldYYPH9DD4joQa8L5AAEENgWb7SBcXa0JDQMBrK4AcQACiAlfyOMCEFdAnAYQQEz4FLa0XGf4/v0H0IIPONUABBAjyBmMjIwMS5cK/L927QORbtBkaG29DtYLEGAAH6f7oq3Zc+kAAAAASUVORK5CYII='; 67 mxGraph.prototype.warningImage.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAE7SURBVHjaYvz//z8DJQAggBjwGXDuHMP/tWuD/uPTCxBAOA0AaQRK/f/+XeJ/cbHlf1wGAAQQTgPu3QNLgfHSpZo4DQAIIKwGwGyH4e/fFbG6AiQJEEAs2Ew2NFzH8OOHBMO6dT/A/KCg7wxGRh+wuhQggDBcALMdFIAcHBxgDGJjcwVIIUAAYbhAUXEdVos4OO4DXcGBIQ4QQCguQPY7sgtgAYruCpAgQACx4LJdU1OCwctLEcyWlLwPJF+AXQE0EMUBAAEEdwF6yMOiD4RRY0QT7gqQAEAAseDzu6XldYYPH9DD4joQa8L5AAEENgWb7SBcXa0JDQMBrK4AcQACiAlfyOMCEFdAnAYQQEz4FLa0XGf4/v0H0IIPONUABBAjyBmMjIwMS5cK/L927QORbtBkaG29DtYLEGAAH6f7oq3Zc+kAAAAASUVORK5CYII=';
68 - }  
69 - else { 68 + } else {
70 var img = new Image(); 69 var img = new Image();
71 img.src = mxGraph.prototype.warningImage.src; 70 img.src = mxGraph.prototype.warningImage.src;
72 } 71 }
@@ -82,15 +81,13 @@ App = function (editor, container, lightbox) { @@ -82,15 +81,13 @@ App = function (editor, container, lightbox) {
82 81
83 try { 82 try {
84 wnd = window.open(url); 83 wnd = window.open(url);
85 - }  
86 - catch (e) { 84 + } catch (e) {
87 // ignore 85 // ignore
88 } 86 }
89 87
90 if (wnd == null || wnd === undefined) { 88 if (wnd == null || wnd === undefined) {
91 this.showDialog(new PopupDialog(this, url, pre, fallback).container, 320, 140, true, true); 89 this.showDialog(new PopupDialog(this, url, pre, fallback).container, 320, 140, true, true);
92 - }  
93 - else if (pre != null) { 90 + } else if (pre != null) {
94 pre(); 91 pre();
95 } 92 }
96 }); 93 });
@@ -119,13 +116,11 @@ App = function (editor, container, lightbox) { @@ -119,13 +116,11 @@ App = function (editor, container, lightbox) {
119 for (var i = 0; i < App.DrawPlugins.length; i++) { 116 for (var i = 0; i < App.DrawPlugins.length; i++) {
120 try { 117 try {
121 App.DrawPlugins[i](this); 118 App.DrawPlugins[i](this);
122 - }  
123 - catch (e) { 119 + } catch (e) {
124 if (window.console != null) { 120 if (window.console != null) {
125 console.log('Plugin Error:', e, App.DrawPlugins[i]); 121 console.log('Plugin Error:', e, App.DrawPlugins[i]);
126 } 122 }
127 - }  
128 - finally { 123 + } finally {
129 App.embedModePluginsCount--; 124 App.embedModePluginsCount--;
130 this.initializeEmbedMode(); 125 this.initializeEmbedMode();
131 } 126 }
@@ -135,8 +130,7 @@ App = function (editor, container, lightbox) { @@ -135,8 +130,7 @@ App = function (editor, container, lightbox) {
135 window.Draw.loadPlugin = mxUtils.bind(this, function (callback) { 130 window.Draw.loadPlugin = mxUtils.bind(this, function (callback) {
136 try { 131 try {
137 callback(this); 132 callback(this);
138 - }  
139 - finally { 133 + } finally {
140 App.embedModePluginsCount--; 134 App.embedModePluginsCount--;
141 this.initializeEmbedMode(); 135 this.initializeEmbedMode();
142 } 136 }
@@ -425,8 +419,7 @@ App.getStoredMode = function () { @@ -425,8 +419,7 @@ App.getStoredMode = function () {
425 // Disables loading of client 419 // Disables loading of client
426 window.DriveClient = null; 420 window.DriveClient = null;
427 } 421 }
428 - }  
429 - else { 422 + } else {
430 // Disables loading of client 423 // Disables loading of client
431 window.DriveClient = null; 424 window.DriveClient = null;
432 } 425 }
@@ -444,12 +437,10 @@ App.getStoredMode = function () { @@ -444,12 +437,10 @@ App.getStoredMode = function () {
444 // Must load this after the dropbox SDK since they use the same namespace 437 // Must load this after the dropbox SDK since they use the same namespace
445 mxscript(App.DROPINS_URL, null, 'dropboxjs', App.DROPBOX_APPKEY, true); 438 mxscript(App.DROPINS_URL, null, 'dropboxjs', App.DROPBOX_APPKEY, true);
446 }); 439 });
447 - }  
448 - else if (urlParams['chrome'] == '0') { 440 + } else if (urlParams['chrome'] == '0') {
449 window.DropboxClient = null; 441 window.DropboxClient = null;
450 } 442 }
451 - }  
452 - else { 443 + } else {
453 // Disables loading of client 444 // Disables loading of client
454 window.DropboxClient = null; 445 window.DropboxClient = null;
455 } 446 }
@@ -464,12 +455,10 @@ App.getStoredMode = function () { @@ -464,12 +455,10 @@ App.getStoredMode = function () {
464 window.location.hash.substring(0, 2) == '#W')) { 455 window.location.hash.substring(0, 2) == '#W')) {
465 //Editor.oneDriveInlinePicker can be set with configuration which is done later, so load it all time 456 //Editor.oneDriveInlinePicker can be set with configuration which is done later, so load it all time
466 mxscript(App.ONEDRIVE_URL); 457 mxscript(App.ONEDRIVE_URL);
467 - }  
468 - else if (urlParams['chrome'] == '0') { 458 + } else if (urlParams['chrome'] == '0') {
469 window.OneDriveClient = null; 459 window.OneDriveClient = null;
470 } 460 }
471 - }  
472 - else { 461 + } else {
473 // Disables loading of client 462 // Disables loading of client
474 window.OneDriveClient = null; 463 window.OneDriveClient = null;
475 } 464 }
@@ -485,12 +474,10 @@ App.getStoredMode = function () { @@ -485,12 +474,10 @@ App.getStoredMode = function () {
485 mxscript(App.TRELLO_JQUERY_URL, function () { 474 mxscript(App.TRELLO_JQUERY_URL, function () {
486 mxscript(App.TRELLO_URL); 475 mxscript(App.TRELLO_URL);
487 }); 476 });
488 - }  
489 - else if (urlParams['chrome'] == '0') { 477 + } else if (urlParams['chrome'] == '0') {
490 window.TrelloClient = null; 478 window.TrelloClient = null;
491 } 479 }
492 - }  
493 - else { 480 + } else {
494 // Disables loading of client 481 // Disables loading of client
495 window.TrelloClient = null; 482 window.TrelloClient = null;
496 } 483 }
@@ -530,7 +517,7 @@ App.main = function (callback, createUi) { @@ -530,7 +517,7 @@ App.main = function (callback, createUi) {
530 // 应用启动入口时创建一个axios实例,供全局使用 517 // 应用启动入口时创建一个axios实例,供全局使用
531 defHttp = createAxios({ 518 defHttp = createAxios({
532 timeout: 10 * 1000, 519 timeout: 10 * 1000,
533 - baseURL: '/api', 520 + baseURL: '/api'
534 }) 521 })
535 // Logs uncaught errors 522 // Logs uncaught errors
536 window.onerror = function (message, url, linenumber, colno, err) { 523 window.onerror = function (message, url, linenumber, colno, err) {
@@ -605,13 +592,11 @@ App.main = function (callback, createUi) { @@ -605,13 +592,11 @@ App.main = function (callback, createUi) {
605 alert('Cache cleared'); 592 alert('Cache cleared');
606 } 593 }
607 }); 594 });
608 - }  
609 - else if (Editor.enableServiceWorker) { 595 + } else if (Editor.enableServiceWorker) {
610 // Runs as progressive web app if service workers are supported 596 // Runs as progressive web app if service workers are supported
611 navigator.serviceWorker.register('/service-worker.js'); 597 navigator.serviceWorker.register('/service-worker.js');
612 } 598 }
613 - }  
614 - catch (e) { 599 + } catch (e) {
615 if (window.console != null) { 600 if (window.console != null) {
616 console.error(e); 601 console.error(e);
617 } 602 }
@@ -646,8 +631,7 @@ App.main = function (callback, createUi) { @@ -646,8 +631,7 @@ App.main = function (callback, createUi) {
646 if (temp != null) { 631 if (temp != null) {
647 plugins = temp.plugins; 632 plugins = temp.plugins;
648 } 633 }
649 - }  
650 - catch (e) { 634 + } catch (e) {
651 // ignore 635 // ignore
652 } 636 }
653 } 637 }
@@ -686,8 +670,7 @@ App.main = function (callback, createUi) { @@ -686,8 +670,7 @@ App.main = function (callback, createUi) {
686 670
687 mxscript(plugins[i]); 671 mxscript(plugins[i]);
688 } 672 }
689 - }  
690 - catch (e) { 673 + } catch (e) {
691 // ignore 674 // ignore
692 } 675 }
693 } 676 }
@@ -766,13 +749,11 @@ App.main = function (callback, createUi) { @@ -766,13 +749,11 @@ App.main = function (callback, createUi) {
766 } 749 }
767 750
768 value = config; 751 value = config;
769 - }  
770 - catch (e) { 752 + } catch (e) {
771 window.location.hash = ''; 753 window.location.hash = '';
772 alert(e); 754 alert(e);
773 } 755 }
774 - }  
775 - else { 756 + } else {
776 value = value.merge; 757 value = value.merge;
777 } 758 }
778 } 759 }
@@ -786,8 +767,7 @@ App.main = function (callback, createUi) { @@ -786,8 +767,7 @@ App.main = function (callback, createUi) {
786 } 767 }
787 768
788 window.location.hash = ''; 769 window.location.hash = '';
789 - }  
790 - catch (e) { 770 + } catch (e) {
791 window.location.hash = ''; 771 window.location.hash = '';
792 alert(e); 772 alert(e);
793 } 773 }
@@ -877,8 +857,7 @@ App.main = function (callback, createUi) { @@ -877,8 +857,7 @@ App.main = function (callback, createUi) {
877 if (urlParams['dev'] == '1' || EditorUi.isElectronApp) //TODO check if we can remove these scripts loading from index.html 857 if (urlParams['dev'] == '1' || EditorUi.isElectronApp) //TODO check if we can remove these scripts loading from index.html
878 { 858 {
879 realMain(); 859 realMain();
880 - }  
881 - else { 860 + } else {
882 mxStencilRegistry.allowEval = false; 861 mxStencilRegistry.allowEval = false;
883 let loadScriptList = [ 862 let loadScriptList = [
884 'js/shapes-14-6-5.min.js', 863 'js/shapes-14-6-5.min.js',
@@ -926,8 +905,7 @@ App.main = function (callback, createUi) { @@ -926,8 +905,7 @@ App.main = function (callback, createUi) {
926 if (!isNaN(val) && val > 0) { 905 if (!isNaN(val) && val > 0) {
927 DrawioFile.prototype.autosaveDelay = val; 906 DrawioFile.prototype.autosaveDelay = val;
928 EditorUi.debug('Setting autosaveDelay', val); 907 EditorUi.debug('Setting autosaveDelay', val);
929 - }  
930 - else { 908 + } else {
931 EditorUi.debug('Invalid autosaveDelay', val); 909 EditorUi.debug('Invalid autosaveDelay', val);
932 } 910 }
933 } 911 }
@@ -938,14 +916,12 @@ App.main = function (callback, createUi) { @@ -938,14 +916,12 @@ App.main = function (callback, createUi) {
938 if (!isNaN(val) && val > 0) { 916 if (!isNaN(val) && val > 0) {
939 Graph.prototype.defaultEdgeLength = val; 917 Graph.prototype.defaultEdgeLength = val;
940 EditorUi.debug('Using defaultEdgeLength', val); 918 EditorUi.debug('Using defaultEdgeLength', val);
941 - }  
942 - else { 919 + } else {
943 EditorUi.debug('Invalid defaultEdgeLength', val); 920 EditorUi.debug('Invalid defaultEdgeLength', val);
944 } 921 }
945 } 922 }
946 } 923 }
947 - }  
948 - catch (e) { 924 + } catch (e) {
949 if (window.console != null) { 925 if (window.console != null) {
950 console.error(e); 926 console.error(e);
951 } 927 }
@@ -986,8 +962,7 @@ App.main = function (callback, createUi) { @@ -986,8 +962,7 @@ App.main = function (callback, createUi) {
986 mxSettings.load(); 962 mxSettings.load();
987 doMain(); 963 doMain();
988 } 964 }
989 - }  
990 - catch (e) { 965 + } catch (e) {
991 if (window.console != null) { 966 if (window.console != null) {
992 console.log('Error in configure message: ' + e, evt.data); 967 console.log('Error in configure message: ' + e, evt.data);
993 } 968 }
@@ -998,8 +973,7 @@ App.main = function (callback, createUi) { @@ -998,8 +973,7 @@ App.main = function (callback, createUi) {
998 // Receives XML message from opener and puts it into the graph 973 // Receives XML message from opener and puts it into the graph
999 mxEvent.addListener(window, 'message', configHandler); 974 mxEvent.addListener(window, 'message', configHandler);
1000 op.postMessage(JSON.stringify({ event: 'configure' }), '*'); 975 op.postMessage(JSON.stringify({ event: 'configure' }), '*');
1001 - }  
1002 - else { 976 + } else {
1003 if (Editor.config == null) { 977 if (Editor.config == null) {
1004 // Loads configuration from global scope or local storage 978 // Loads configuration from global scope or local storage
1005 if (window.DRAWIO_CONFIG != null) { 979 if (window.DRAWIO_CONFIG != null) {
@@ -1007,8 +981,7 @@ App.main = function (callback, createUi) { @@ -1007,8 +981,7 @@ App.main = function (callback, createUi) {
1007 EditorUi.debug('Using global configuration', window.DRAWIO_CONFIG); 981 EditorUi.debug('Using global configuration', window.DRAWIO_CONFIG);
1008 Editor.configure(window.DRAWIO_CONFIG); 982 Editor.configure(window.DRAWIO_CONFIG);
1009 mxSettings.load(); 983 mxSettings.load();
1010 - }  
1011 - catch (e) { 984 + } catch (e) {
1012 if (window.console != null) { 985 if (window.console != null) {
1013 console.error(e); 986 console.error(e);
1014 } 987 }
@@ -1028,8 +1001,7 @@ App.main = function (callback, createUi) { @@ -1028,8 +1001,7 @@ App.main = function (callback, createUi) {
1028 Editor.configure(configData); 1001 Editor.configure(configData);
1029 mxSettings.load(); 1002 mxSettings.load();
1030 } 1003 }
1031 - }  
1032 - catch (e) { 1004 + } catch (e) {
1033 if (window.console != null) { 1005 if (window.console != null) {
1034 console.error(e); 1006 console.error(e);
1035 } 1007 }
@@ -1101,8 +1073,7 @@ App.prototype.fullscreenMode = false; @@ -1101,8 +1073,7 @@ App.prototype.fullscreenMode = false;
1101 */ 1073 */
1102 if (urlParams['embed'] != '1') { 1074 if (urlParams['embed'] != '1') {
1103 App.prototype.menubarHeight = 64; 1075 App.prototype.menubarHeight = 64;
1104 -}  
1105 -else { 1076 +} else {
1106 App.prototype.footerHeight = 0; 1077 App.prototype.footerHeight = 0;
1107 } 1078 }
1108 1079
@@ -1148,26 +1119,21 @@ App.loadPlugins = function (plugins, useInclude) { @@ -1148,26 +1119,21 @@ App.loadPlugins = function (plugins, useInclude) {
1148 if (typeof window.drawDevUrl === 'undefined') { 1119 if (typeof window.drawDevUrl === 'undefined') {
1149 if (useInclude) { 1120 if (useInclude) {
1150 mxinclude(url); 1121 mxinclude(url);
1151 - }  
1152 - else { 1122 + } else {
1153 mxscript(url); 1123 mxscript(url);
1154 } 1124 }
1155 - }  
1156 - else { 1125 + } else {
1157 if (useInclude) { 1126 if (useInclude) {
1158 mxinclude(url); 1127 mxinclude(url);
1159 - }  
1160 - else { 1128 + } else {
1161 mxscript(drawDevUrl + url); 1129 mxscript(drawDevUrl + url);
1162 } 1130 }
1163 } 1131 }
1164 } 1132 }
1165 - }  
1166 - else if (window.console != null) { 1133 + } else if (window.console != null) {
1167 console.log('Unknown plugin:', plugins[i]); 1134 console.log('Unknown plugin:', plugins[i]);
1168 } 1135 }
1169 - }  
1170 - catch (e) { 1136 + } catch (e) {
1171 if (window.console != null) { 1137 if (window.console != null) {
1172 console.log('Error loading plugin:', plugins[i], e); 1138 console.log('Error loading plugin:', plugins[i], e);
1173 } 1139 }
@@ -1188,8 +1154,7 @@ App.prototype.initializeEmbedMode = function () { @@ -1188,8 +1154,7 @@ App.prototype.initializeEmbedMode = function () {
1188 1154
1189 if (App.embedModePluginsCount > 0 || this.initEmbedDone) { 1155 if (App.embedModePluginsCount > 0 || this.initEmbedDone) {
1190 return; //Wait for plugins to load, or this is a duplicate call due to timeout 1156 return; //Wait for plugins to load, or this is a duplicate call due to timeout
1191 - }  
1192 - else { 1157 + } else {
1193 this.initEmbedDone = true; 1158 this.initEmbedDone = true;
1194 } 1159 }
1195 1160
@@ -1212,7 +1177,7 @@ App.prototype.initializeViewerMode = function () { @@ -1212,7 +1177,7 @@ App.prototype.initializeViewerMode = function () {
1212 1177
1213 /** 1178 /**
1214 * Translates this point by the given vector. 1179 * Translates this point by the given vector.
1215 - * 原型初始化,所有的原型调用此方法初始化 1180 + * 原型初始化,所有的原型调用此方法初始化
1216 * @param {number} dx X-coordinate of the translation. 1181 * @param {number} dx X-coordinate of the translation.
1217 * @param {number} dy Y-coordinate of the translation. 1182 * @param {number} dy Y-coordinate of the translation.
1218 */ 1183 */
@@ -1280,8 +1245,7 @@ App.prototype.init = function () { @@ -1280,8 +1245,7 @@ App.prototype.init = function () {
1280 1245
1281 // Notifies listeners of new client 1246 // Notifies listeners of new client
1282 this.fireEvent(new mxEventObject('clientLoaded', 'client', this.oneDrive)); 1247 this.fireEvent(new mxEventObject('clientLoaded', 'client', this.oneDrive));
1283 - }  
1284 - else if (window.DrawOneDriveClientCallback == null) { 1248 + } else if (window.DrawOneDriveClientCallback == null) {
1285 window.DrawOneDriveClientCallback = initOneDriveClient; 1249 window.DrawOneDriveClientCallback = initOneDriveClient;
1286 } 1250 }
1287 }); 1251 });
@@ -1309,14 +1273,12 @@ App.prototype.init = function () { @@ -1309,14 +1273,12 @@ App.prototype.init = function () {
1309 1273
1310 // Notifies listeners of new client 1274 // Notifies listeners of new client
1311 this.fireEvent(new mxEventObject('clientLoaded', 'client', this.trello)); 1275 this.fireEvent(new mxEventObject('clientLoaded', 'client', this.trello));
1312 - }  
1313 - catch (e) { 1276 + } catch (e) {
1314 if (window.console != null) { 1277 if (window.console != null) {
1315 console.error(e); 1278 console.error(e);
1316 } 1279 }
1317 } 1280 }
1318 - }  
1319 - else if (window.DrawTrelloClientCallback == null) { 1281 + } else if (window.DrawTrelloClientCallback == null) {
1320 window.DrawTrelloClientCallback = initTrelloClient; 1282 window.DrawTrelloClientCallback = initTrelloClient;
1321 } 1283 }
1322 }); 1284 });
@@ -1353,12 +1315,10 @@ App.prototype.init = function () { @@ -1353,12 +1315,10 @@ App.prototype.init = function () {
1353 * Clears any callbacks. 1315 * Clears any callbacks.
1354 */ 1316 */
1355 window.DrawGapiClientCallback = null; 1317 window.DrawGapiClientCallback = null;
1356 - }  
1357 - else { 1318 + } else {
1358 doInit(); 1319 doInit();
1359 } 1320 }
1360 - }  
1361 - else if (window.DrawGapiClientCallback == null) { 1321 + } else if (window.DrawGapiClientCallback == null) {
1362 window.DrawGapiClientCallback = initDriveClient; 1322 window.DrawGapiClientCallback = initDriveClient;
1363 } 1323 }
1364 }); 1324 });
@@ -1390,14 +1350,12 @@ App.prototype.init = function () { @@ -1390,14 +1350,12 @@ App.prototype.init = function () {
1390 1350
1391 // Notifies listeners of new client 1351 // Notifies listeners of new client
1392 this.fireEvent(new mxEventObject('clientLoaded', 'client', this.dropbox)); 1352 this.fireEvent(new mxEventObject('clientLoaded', 'client', this.dropbox));
1393 - }  
1394 - catch (e) { 1353 + } catch (e) {
1395 if (window.console != null) { 1354 if (window.console != null) {
1396 console.error(e); 1355 console.error(e);
1397 } 1356 }
1398 } 1357 }
1399 - }  
1400 - else if (window.DrawDropboxClientCallback == null) { 1358 + } else if (window.DrawDropboxClientCallback == null) {
1401 window.DrawDropboxClientCallback = initDropboxClient; 1359 window.DrawDropboxClientCallback = initDropboxClient;
1402 } 1360 }
1403 }); 1361 });
@@ -1420,8 +1378,7 @@ App.prototype.init = function () { @@ -1420,8 +1378,7 @@ App.prototype.init = function () {
1420 // Sets the initial mode 1378 // Sets the initial mode
1421 if (urlParams['local'] == '1') { 1379 if (urlParams['local'] == '1') {
1422 this.setMode(App.MODE_DEVICE); 1380 this.setMode(App.MODE_DEVICE);
1423 - }  
1424 - else { 1381 + } else {
1425 this.mode = App.mode; 1382 this.mode = App.mode;
1426 } 1383 }
1427 1384
@@ -1445,8 +1402,7 @@ App.prototype.init = function () { @@ -1445,8 +1402,7 @@ App.prototype.init = function () {
1445 if (urlParams['extAuth'] != '1' && (mode == App.MODE_DEVICE || mode == App.MODE_BROWSER)) { 1402 if (urlParams['extAuth'] != '1' && (mode == App.MODE_DEVICE || mode == App.MODE_BROWSER)) {
1446 //关闭桌面弹出广告 1403 //关闭桌面弹出广告
1447 //this.showDownloadDesktopBanner(); 1404 //this.showDownloadDesktopBanner();
1448 - }  
1449 - else if (urlParams['embed'] != '1' && this.getServiceName() == 'draw.io') { 1405 + } else if (urlParams['embed'] != '1' && this.getServiceName() == 'draw.io') {
1450 // just app.diagrams.net users 1406 // just app.diagrams.net users
1451 // this.showNameConfBanner(); 1407 // this.showNameConfBanner();
1452 } 1408 }
@@ -1485,8 +1441,7 @@ App.prototype.init = function () { @@ -1485,8 +1441,7 @@ App.prototype.init = function () {
1485 window.clearTimeout(timeoutThread); 1441 window.clearTimeout(timeoutThread);
1486 })); 1442 }));
1487 } 1443 }
1488 - }  
1489 - else if (this.menubar != null) { 1444 + } else if (this.menubar != null) {
1490 this.menubar.container.style.paddingTop = '0px'; 1445 this.menubar.container.style.paddingTop = '0px';
1491 } 1446 }
1492 1447
@@ -1823,8 +1778,7 @@ App.prototype.checkLicense = function () { @@ -1823,8 +1778,7 @@ App.prototype.checkLicense = function () {
1823 } 1778 }
1824 } 1779 }
1825 } 1780 }
1826 - }  
1827 - catch (e) { 1781 + } catch (e) {
1828 // ignore 1782 // ignore
1829 } 1783 }
1830 })); 1784 }));
@@ -1848,8 +1802,7 @@ App.prototype.getEditBlankXml = function () { @@ -1848,8 +1802,7 @@ App.prototype.getEditBlankXml = function () {
1848 1802
1849 if (file != null && this.editor.isChromelessView() && this.editor.graph.isLightboxView()) { 1803 if (file != null && this.editor.isChromelessView() && this.editor.graph.isLightboxView()) {
1850 return file.getData(); 1804 return file.getData();
1851 - }  
1852 - else { 1805 + } else {
1853 return this.getFileData(true); 1806 return this.getFileData(true);
1854 } 1807 }
1855 }; 1808 };
@@ -1872,8 +1825,7 @@ App.prototype.addRecent = function (entry) { @@ -1872,8 +1825,7 @@ App.prototype.addRecent = function (entry) {
1872 1825
1873 if (recent == null) { 1826 if (recent == null) {
1874 recent = []; 1827 recent = [];
1875 - }  
1876 - else { 1828 + } else {
1877 for (var i = 0; i < recent.length; i++) { 1829 for (var i = 0; i < recent.length; i++) {
1878 if (recent[i].id == entry.id) { 1830 if (recent[i].id == entry.id) {
1879 recent.splice(i, 1); 1831 recent.splice(i, 1);
@@ -1900,8 +1852,7 @@ App.prototype.getRecent = function () { @@ -1900,8 +1852,7 @@ App.prototype.getRecent = function () {
1900 if (recent != null) { 1852 if (recent != null) {
1901 return JSON.parse(recent); 1853 return JSON.parse(recent);
1902 } 1854 }
1903 - }  
1904 - catch (e) { 1855 + } catch (e) {
1905 // ignore 1856 // ignore
1906 } 1857 }
1907 1858
@@ -1916,8 +1867,7 @@ App.prototype.resetRecent = function (entry) { @@ -1916,8 +1867,7 @@ App.prototype.resetRecent = function (entry) {
1916 if (isLocalStorage && localStorage != null) { 1867 if (isLocalStorage && localStorage != null) {
1917 try { 1868 try {
1918 localStorage.removeItem('.recent'); 1869 localStorage.removeItem('.recent');
1919 - }  
1920 - catch (e) { 1870 + } catch (e) {
1921 // ignore 1871 // ignore
1922 } 1872 }
1923 } 1873 }
@@ -1929,8 +1879,7 @@ App.prototype.resetRecent = function (entry) { @@ -1929,8 +1879,7 @@ App.prototype.resetRecent = function (entry) {
1929 App.prototype.onBeforeUnload = function () { 1879 App.prototype.onBeforeUnload = function () {
1930 if (urlParams['embed'] == '1' && this.editor.modified) { 1880 if (urlParams['embed'] == '1' && this.editor.modified) {
1931 return mxResources.get('allChangesLost'); 1881 return mxResources.get('allChangesLost');
1932 - }  
1933 - else { 1882 + } else {
1934 var file = this.getCurrentFile(); 1883 var file = this.getCurrentFile();
1935 1884
1936 if (file != null) { 1885 if (file != null) {
@@ -1939,11 +1888,9 @@ App.prototype.onBeforeUnload = function () { @@ -1939,11 +1888,9 @@ App.prototype.onBeforeUnload = function () {
1939 urlParams['nowarn'] != '1' && !this.isDiagramEmpty() && urlParams['url'] == null && 1888 urlParams['nowarn'] != '1' && !this.isDiagramEmpty() && urlParams['url'] == null &&
1940 !this.editor.isChromelessView() && file.fileHandle == null) { 1889 !this.editor.isChromelessView() && file.fileHandle == null) {
1941 return mxResources.get('ensureDataSaved'); 1890 return mxResources.get('ensureDataSaved');
1942 - }  
1943 - else if (file.isModified()) { 1891 + } else if (file.isModified()) {
1944 return mxResources.get('allChangesLost'); 1892 return mxResources.get('allChangesLost');
1945 - }  
1946 - else { 1893 + } else {
1947 file.close(true); 1894 file.close(true);
1948 } 1895 }
1949 } 1896 }
@@ -2023,8 +1970,7 @@ App.prototype.getThumbnail = function (width, fn) { @@ -2023,8 +1970,7 @@ App.prototype.getThumbnail = function (width, fn) {
2023 1970
2024 if (this.currentPage == page) { 1971 if (this.currentPage == page) {
2025 graph.setBackgroundImage(bgImg); 1972 graph.setBackgroundImage(bgImg);
2026 - }  
2027 - else if (page.viewState != null && page.viewState != null) { 1973 + } else if (page.viewState != null && page.viewState != null) {
2028 bgImg = page.viewState.backgroundImage; 1974 bgImg = page.viewState.backgroundImage;
2029 graph.setBackgroundImage(bgImg); 1975 graph.setBackgroundImage(bgImg);
2030 } 1976 }
@@ -2032,8 +1978,7 @@ App.prototype.getThumbnail = function (width, fn) { @@ -2032,8 +1978,7 @@ App.prototype.getThumbnail = function (width, fn) {
2032 graph.getGlobalVariable = function (name) { 1978 graph.getGlobalVariable = function (name) {
2033 if (name == 'page') { 1979 if (name == 'page') {
2034 return page.getName(); 1980 return page.getName();
2035 - }  
2036 - else if (name == 'pagenumber') { 1981 + } else if (name == 'pagenumber') {
2037 return 1; 1982 return 1;
2038 } 1983 }
2039 1984
@@ -2053,8 +1998,7 @@ App.prototype.getThumbnail = function (width, fn) { @@ -2053,8 +1998,7 @@ App.prototype.getThumbnail = function (width, fn) {
2053 if (graph != this.editor.graph && graph.container.parentNode != null) { 1998 if (graph != this.editor.graph && graph.container.parentNode != null) {
2054 graph.container.parentNode.removeChild(graph.container); 1999 graph.container.parentNode.removeChild(graph.container);
2055 } 2000 }
2056 - }  
2057 - catch (e) { 2001 + } catch (e) {
2058 canvas = null; 2002 canvas = null;
2059 } 2003 }
2060 2004
@@ -2066,8 +2010,7 @@ App.prototype.getThumbnail = function (width, fn) { @@ -2066,8 +2010,7 @@ App.prototype.getThumbnail = function (width, fn) {
2066 null, 'diagram', null); 2010 null, 'diagram', null);
2067 2011
2068 result = true; 2012 result = true;
2069 - }  
2070 - else if (this.canvasSupported && this.getCurrentFile() != null) { 2013 + } else if (this.canvasSupported && this.getCurrentFile() != null) {
2071 var canvas = document.createElement('canvas'); 2014 var canvas = document.createElement('canvas');
2072 var bounds = graph.getGraphBounds(); 2015 var bounds = graph.getGraphBounds();
2073 var t = graph.view.translate; 2016 var t = graph.view.translate;
@@ -2157,8 +2100,7 @@ App.prototype.getThumbnail = function (width, fn) { @@ -2157,8 +2100,7 @@ App.prototype.getThumbnail = function (width, fn) {
2157 if (graph != this.editor.graph && graph.container.parentNode != null) { 2100 if (graph != this.editor.graph && graph.container.parentNode != null) {
2158 graph.container.parentNode.removeChild(graph.container); 2101 graph.container.parentNode.removeChild(graph.container);
2159 } 2102 }
2160 - }  
2161 - catch (e) { 2103 + } catch (e) {
2162 canvas = null; 2104 canvas = null;
2163 } 2105 }
2164 2106
@@ -2167,8 +2109,7 @@ App.prototype.getThumbnail = function (width, fn) { @@ -2167,8 +2109,7 @@ App.prototype.getThumbnail = function (width, fn) {
2167 2109
2168 result = true; 2110 result = true;
2169 } 2111 }
2170 - }  
2171 - catch (e) { 2112 + } catch (e) {
2172 result = false; 2113 result = false;
2173 2114
2174 // Removes temporary graph from DOM 2115 // Removes temporary graph from DOM
@@ -2229,16 +2170,13 @@ App.prototype.createBackground = function () { @@ -2229,16 +2170,13 @@ App.prototype.createBackground = function () {
2229 if (mode == App.MODE_GOOGLE) { 2170 if (mode == App.MODE_GOOGLE) {
2230 this.appIcon.setAttribute('title', mxResources.get('openIt', [mxResources.get('googleDrive')])); 2171 this.appIcon.setAttribute('title', mxResources.get('openIt', [mxResources.get('googleDrive')]));
2231 this.appIcon.style.cursor = 'pointer'; 2172 this.appIcon.style.cursor = 'pointer';
2232 - }  
2233 - else if (mode == App.MODE_DROPBOX) { 2173 + } else if (mode == App.MODE_DROPBOX) {
2234 this.appIcon.setAttribute('title', mxResources.get('openIt', [mxResources.get('dropbox')])); 2174 this.appIcon.setAttribute('title', mxResources.get('openIt', [mxResources.get('dropbox')]));
2235 this.appIcon.style.cursor = 'pointer'; 2175 this.appIcon.style.cursor = 'pointer';
2236 - }  
2237 - else if (mode == App.MODE_ONEDRIVE) { 2176 + } else if (mode == App.MODE_ONEDRIVE) {
2238 this.appIcon.setAttribute('title', mxResources.get('openIt', [mxResources.get('oneDrive')])); 2177 this.appIcon.setAttribute('title', mxResources.get('openIt', [mxResources.get('oneDrive')]));
2239 this.appIcon.style.cursor = 'pointer'; 2178 this.appIcon.style.cursor = 'pointer';
2240 - }  
2241 - else { 2179 + } else {
2242 this.appIcon.removeAttribute('title'); 2180 this.appIcon.removeAttribute('title');
2243 this.appIcon.style.cursor = (mode == App.MODE_DEVICE) ? 'pointer' : 'default'; 2181 this.appIcon.style.cursor = (mode == App.MODE_DEVICE) ? 'pointer' : 'default';
2244 } 2182 }
@@ -2248,14 +2186,12 @@ App.prototype.createBackground = function () { @@ -2248,14 +2186,12 @@ App.prototype.createBackground = function () {
2248 try { 2186 try {
2249 if (isLocalStorage) { 2187 if (isLocalStorage) {
2250 localStorage.setItem('.mode', mode); 2188 localStorage.setItem('.mode', mode);
2251 - }  
2252 - else if (typeof (Storage) != 'undefined') { 2189 + } else if (typeof (Storage) != 'undefined') {
2253 var expiry = new Date(); 2190 var expiry = new Date();
2254 expiry.setYear(expiry.getFullYear() + 1); 2191 expiry.setYear(expiry.getFullYear() + 1);
2255 document.cookie = 'MODE=' + mode + '; expires=' + expiry.toUTCString(); 2192 document.cookie = 'MODE=' + mode + '; expires=' + expiry.toUTCString();
2256 } 2193 }
2257 - }  
2258 - catch (e) { 2194 + } catch (e) {
2259 // ignore possible access denied 2195 // ignore possible access denied
2260 } 2196 }
2261 } 2197 }
@@ -2270,8 +2206,7 @@ App.prototype.createBackground = function () { @@ -2270,8 +2206,7 @@ App.prototype.createBackground = function () {
2270 App.prototype.appIconClicked = function (evt) { 2206 App.prototype.appIconClicked = function (evt) {
2271 if (mxEvent.isAltDown(evt)) { 2207 if (mxEvent.isAltDown(evt)) {
2272 this.showSplash(true); 2208 this.showSplash(true);
2273 - }  
2274 - else { 2209 + } else {
2275 var file = this.getCurrentFile(); 2210 var file = this.getCurrentFile();
2276 var mode = (file != null) ? file.getMode() : null; 2211 var mode = (file != null) ? file.getMode() : null;
2277 2212
@@ -2280,15 +2215,12 @@ App.prototype.appIconClicked = function (evt) { @@ -2280,15 +2215,12 @@ App.prototype.appIconClicked = function (evt) {
2280 file.desc.parents.length > 0 && !mxEvent.isShiftDown(evt)) { 2215 file.desc.parents.length > 0 && !mxEvent.isShiftDown(evt)) {
2281 // Opens containing folder 2216 // Opens containing folder
2282 this.openLink('https://drive.google.com/drive/folders/' + file.desc.parents[0].id); 2217 this.openLink('https://drive.google.com/drive/folders/' + file.desc.parents[0].id);
2283 - }  
2284 - else if (file != null && file.getId() != null) { 2218 + } else if (file != null && file.getId() != null) {
2285 this.openLink('https://drive.google.com/open?id=' + file.getId()); 2219 this.openLink('https://drive.google.com/open?id=' + file.getId());
2286 - }  
2287 - else { 2220 + } else {
2288 this.openLink('https://drive.google.com/?authuser=0'); 2221 this.openLink('https://drive.google.com/?authuser=0');
2289 } 2222 }
2290 - }  
2291 - else if (mode == App.MODE_ONEDRIVE) { 2223 + } else if (mode == App.MODE_ONEDRIVE) {
2292 if (file != null && file.meta != null && file.meta.webUrl != null) { 2224 if (file != null && file.meta != null && file.meta.webUrl != null) {
2293 var url = file.meta.webUrl; 2225 var url = file.meta.webUrl;
2294 var name = encodeURIComponent(file.meta.name); 2226 var name = encodeURIComponent(file.meta.name);
@@ -2298,12 +2230,10 @@ App.prototype.appIconClicked = function (evt) { @@ -2298,12 +2230,10 @@ App.prototype.appIconClicked = function (evt) {
2298 } 2230 }
2299 2231
2300 this.openLink(url); 2232 this.openLink(url);
2301 - }  
2302 - else { 2233 + } else {
2303 this.openLink('https://onedrive.live.com/'); 2234 this.openLink('https://onedrive.live.com/');
2304 } 2235 }
2305 - }  
2306 - else if (mode == App.MODE_DROPBOX) { 2236 + } else if (mode == App.MODE_DROPBOX) {
2307 if (file != null && file.stat != null && file.stat.path_display != null) { 2237 if (file != null && file.stat != null && file.stat.path_display != null) {
2308 var url = 'https://www.dropbox.com/home/Apps/drawio' + file.stat.path_display; 2238 var url = 'https://www.dropbox.com/home/Apps/drawio' + file.stat.path_display;
2309 2239
@@ -2312,31 +2242,24 @@ App.prototype.appIconClicked = function (evt) { @@ -2312,31 +2242,24 @@ App.prototype.appIconClicked = function (evt) {
2312 } 2242 }
2313 2243
2314 this.openLink(url); 2244 this.openLink(url);
2315 - }  
2316 - else { 2245 + } else {
2317 this.openLink('https://www.dropbox.com/'); 2246 this.openLink('https://www.dropbox.com/');
2318 } 2247 }
2319 - }  
2320 - else if (mode == App.MODE_TRELLO) { 2248 + } else if (mode == App.MODE_TRELLO) {
2321 this.openLink('https://trello.com/'); 2249 this.openLink('https://trello.com/');
2322 - }  
2323 - else if (mode == App.MODE_GITHUB) { 2250 + } else if (mode == App.MODE_GITHUB) {
2324 if (file != null && file.constructor == GitHubFile) { 2251 if (file != null && file.constructor == GitHubFile) {
2325 this.openLink(file.meta.html_url); 2252 this.openLink(file.meta.html_url);
2326 - }  
2327 - else { 2253 + } else {
2328 this.openLink('https://github.com/'); 2254 this.openLink('https://github.com/');
2329 } 2255 }
2330 - }  
2331 - else if (mode == App.MODE_GITLAB) { 2256 + } else if (mode == App.MODE_GITLAB) {
2332 if (file != null && file.constructor == GitLabFile) { 2257 if (file != null && file.constructor == GitLabFile) {
2333 this.openLink(file.meta.html_url); 2258 this.openLink(file.meta.html_url);
2334 - }  
2335 - else { 2259 + } else {
2336 this.openLink(DRAWIO_GITLAB_URL); 2260 this.openLink(DRAWIO_GITLAB_URL);
2337 } 2261 }
2338 - }  
2339 - else if (mode == App.MODE_DEVICE) { 2262 + } else if (mode == App.MODE_DEVICE) {
2340 this.openLink('https://get.draw.io/'); 2263 this.openLink('https://get.draw.io/');
2341 } 2264 }
2342 } 2265 }
@@ -2352,8 +2275,7 @@ App.prototype.appIconClicked = function (evt) { @@ -2352,8 +2275,7 @@ App.prototype.appIconClicked = function (evt) {
2352 App.prototype.clearMode = function () { 2275 App.prototype.clearMode = function () {
2353 if (isLocalStorage) { 2276 if (isLocalStorage) {
2354 localStorage.removeItem('.mode'); 2277 localStorage.removeItem('.mode');
2355 - }  
2356 - else if (typeof (Storage) != 'undefined') { 2278 + } else if (typeof (Storage) != 'undefined') {
2357 var expiry = new Date(); 2279 var expiry = new Date();
2358 expiry.setYear(expiry.getFullYear() - 1); 2280 expiry.setYear(expiry.getFullYear() - 1);
2359 document.cookie = 'MODE=; expires=' + expiry.toUTCString(); 2281 document.cookie = 'MODE=; expires=' + expiry.toUTCString();
@@ -2408,8 +2330,7 @@ App.prototype.open = function () { @@ -2408,8 +2330,7 @@ App.prototype.open = function () {
2408 value.substring(0, 8) != 'https://') { 2330 value.substring(0, 8) != 'https://') {
2409 var doc = mxUtils.parseXml(window.opener[value]); 2331 var doc = mxUtils.parseXml(window.opener[value]);
2410 this.editor.setGraphXml(doc.documentElement); 2332 this.editor.setGraphXml(doc.documentElement);
2411 - }  
2412 - else if (window.opener.openFile != null) { 2333 + } else if (window.opener.openFile != null) {
2413 window.opener.openFile.setConsumer(mxUtils.bind(this, function (xml, filename, temp) { 2334 window.opener.openFile.setConsumer(mxUtils.bind(this, function (xml, filename, temp) {
2414 this.spinner.stop(); 2335 this.spinner.stop();
2415 2336
@@ -2419,8 +2340,7 @@ App.prototype.open = function () { @@ -2419,8 +2340,7 @@ App.prototype.open = function () {
2419 2340
2420 if (title != null) { 2341 if (title != null) {
2421 filename = decodeURIComponent(title); 2342 filename = decodeURIComponent(title);
2422 - }  
2423 - else { 2343 + } else {
2424 filename = this.defaultFilename; 2344 filename = this.defaultFilename;
2425 } 2345 }
2426 } 2346 }
@@ -2438,8 +2358,7 @@ App.prototype.open = function () { @@ -2438,8 +2358,7 @@ App.prototype.open = function () {
2438 })); 2358 }));
2439 } 2359 }
2440 } 2360 }
2441 - }  
2442 - catch (e) { 2361 + } catch (e) {
2443 // ignore 2362 // ignore
2444 } 2363 }
2445 }; 2364 };
@@ -2462,8 +2381,7 @@ App.prototype.load = function () { @@ -2462,8 +2381,7 @@ App.prototype.load = function () {
2462 if (this.spinner.spin(document.body, mxResources.get('starting'))) { 2381 if (this.spinner.spin(document.body, mxResources.get('starting'))) {
2463 try { 2382 try {
2464 this.stateArg = (urlParams['state'] != null && this.drive != null) ? JSON.parse(decodeURIComponent(urlParams['state'])) : null; 2383 this.stateArg = (urlParams['state'] != null && this.drive != null) ? JSON.parse(decodeURIComponent(urlParams['state'])) : null;
2465 - }  
2466 - catch (e) { 2384 + } catch (e) {
2467 // ignores invalid state args 2385 // ignores invalid state args
2468 } 2386 }
2469 2387
@@ -2479,8 +2397,7 @@ App.prototype.load = function () { @@ -2479,8 +2397,7 @@ App.prototype.load = function () {
2479 if (urlParams['fileId'] != null) { 2397 if (urlParams['fileId'] != null) {
2480 window.location.hash = 'G' + urlParams['fileId']; 2398 window.location.hash = 'G' + urlParams['fileId'];
2481 window.location.search = this.getSearch(['fileId']); 2399 window.location.search = this.getSearch(['fileId']);
2482 - }  
2483 - else { 2400 + } else {
2484 // Asynchronous or disabled loading of client 2401 // Asynchronous or disabled loading of client
2485 if (this.drive == null) { 2402 if (this.drive == null) {
2486 if (this.mode == App.MODE_GOOGLE) { 2403 if (this.mode == App.MODE_GOOGLE) {
@@ -2488,20 +2405,19 @@ App.prototype.load = function () { @@ -2488,20 +2405,19 @@ App.prototype.load = function () {
2488 } 2405 }
2489 2406
2490 this.start(); 2407 this.start();
2491 - }  
2492 - else { 2408 + } else {
2493 this.loadGapi(mxUtils.bind(this, function () { 2409 this.loadGapi(mxUtils.bind(this, function () {
2494 this.start(); 2410 this.start();
2495 })); 2411 }));
2496 } 2412 }
2497 } 2413 }
2498 } 2414 }
2499 - }  
2500 - else { 2415 + } else {
2501 this.restoreLibraries(); 2416 this.restoreLibraries();
2502 2417
2503 if (urlParams['gapi'] == '1') { 2418 if (urlParams['gapi'] == '1') {
2504 - this.loadGapi(function () { }); 2419 + this.loadGapi(function () {
  2420 + });
2505 } 2421 }
2506 } 2422 }
2507 }; 2423 };
@@ -2648,8 +2564,7 @@ App.prototype.start = function () { @@ -2648,8 +2564,7 @@ App.prototype.start = function () {
2648 (!this.editor.chromeless || this.editor.editable)) { 2564 (!this.editor.chromeless || this.editor.editable)) {
2649 this.showNameChangeBanner(); 2565 this.showNameChangeBanner();
2650 } 2566 }
2651 - }  
2652 - catch (e) { 2567 + } catch (e) {
2653 // ignore 2568 // ignore
2654 } 2569 }
2655 2570
@@ -2662,8 +2577,7 @@ App.prototype.start = function () { @@ -2662,8 +2577,7 @@ App.prototype.start = function () {
2662 if (file == null || file.getHash() != id) { 2577 if (file == null || file.getHash() != id) {
2663 this.loadFile(id, true); 2578 this.loadFile(id, true);
2664 } 2579 }
2665 - }  
2666 - catch (e) { 2580 + } catch (e) {
2667 // Workaround for possible scrollWidth of null in Dialog ctor 2581 // Workaround for possible scrollWidth of null in Dialog ctor
2668 if (document.body != null) { 2582 if (document.body != null) {
2669 this.handleError(e, mxResources.get('errorLoadingFile'), mxUtils.bind(this, function () { 2583 this.handleError(e, mxResources.get('errorLoadingFile'), mxUtils.bind(this, function () {
@@ -2682,8 +2596,7 @@ App.prototype.start = function () { @@ -2682,8 +2596,7 @@ App.prototype.start = function () {
2682 null, mxUtils.bind(this, function (e) { 2596 null, mxUtils.bind(this, function (e) {
2683 this.handleError(e, mxResources.get('errorLoadingFile')); 2597 this.handleError(e, mxResources.get('errorLoadingFile'));
2684 })); 2598 }));
2685 - }  
2686 - catch (e) { 2599 + } catch (e) {
2687 this.handleError(e, mxResources.get('errorLoadingFile')); 2600 this.handleError(e, mxResources.get('errorLoadingFile'));
2688 } 2601 }
2689 } 2602 }
@@ -2708,8 +2621,7 @@ App.prototype.start = function () { @@ -2708,8 +2621,7 @@ App.prototype.start = function () {
2708 2621
2709 if (title != null) { 2622 if (title != null) {
2710 title = decodeURIComponent(title); 2623 title = decodeURIComponent(title);
2711 - }  
2712 - else { 2624 + } else {
2713 title = this.defaultFilename; 2625 title = this.defaultFilename;
2714 } 2626 }
2715 2627
@@ -2732,14 +2644,12 @@ App.prototype.start = function () { @@ -2732,14 +2644,12 @@ App.prototype.start = function () {
2732 2644
2733 if (value != null) { 2645 if (value != null) {
2734 doLoadFile(parent[decodeURIComponent(value)]); 2646 doLoadFile(parent[decodeURIComponent(value)]);
2735 - }  
2736 - else { 2647 + } else {
2737 value = urlParams['data']; 2648 value = urlParams['data'];
2738 2649
2739 if (value != null) { 2650 if (value != null) {
2740 doLoadFile(decodeURIComponent(value)); 2651 doLoadFile(decodeURIComponent(value));
2741 - }  
2742 - else { 2652 + } else {
2743 this.installMessageHandler(mxUtils.bind(this, function (xml, evt) { 2653 this.installMessageHandler(mxUtils.bind(this, function (xml, evt) {
2744 // Ignores messages from other windows 2654 // Ignores messages from other windows
2745 if (evt.source == parent) { 2655 if (evt.source == parent) {
@@ -2756,8 +2666,7 @@ App.prototype.start = function () { @@ -2756,8 +2666,7 @@ App.prototype.start = function () {
2756 var prev = Editor.useLocalStorage; 2666 var prev = Editor.useLocalStorage;
2757 this.createFile(this.defaultFilename, null, null, null, null, null, null, true); 2667 this.createFile(this.defaultFilename, null, null, null, null, null, null, true);
2758 Editor.useLocalStorage = prev; 2668 Editor.useLocalStorage = prev;
2759 - }  
2760 - else { 2669 + } else {
2761 var waiting = false; 2670 var waiting = false;
2762 2671
2763 // Checks if we're waiting for some asynchronous file to be loaded 2672 // Checks if we're waiting for some asynchronous file to be loaded
@@ -2765,24 +2674,21 @@ App.prototype.start = function () { @@ -2765,24 +2674,21 @@ App.prototype.start = function () {
2765 // were opened from another domain then this will fail. 2674 // were opened from another domain then this will fail.
2766 try { 2675 try {
2767 waiting = window.opener != null && window.opener.openFile != null; 2676 waiting = window.opener != null && window.opener.openFile != null;
2768 - }  
2769 - catch (e) { 2677 + } catch (e) {
2770 // ignore 2678 // ignore
2771 } 2679 }
2772 2680
2773 if (waiting) { 2681 if (waiting) {
2774 // Spinner is stopped in App.open 2682 // Spinner is stopped in App.open
2775 this.spinner.spin(document.body, mxResources.get('loading')) 2683 this.spinner.spin(document.body, mxResources.get('loading'))
2776 - }  
2777 - else { 2684 + } else {
2778 var id = this.getDiagramId(); 2685 var id = this.getDiagramId();
2779 2686
2780 if (EditorUi.enableDrafts && urlParams['mode'] == null && 2687 if (EditorUi.enableDrafts && urlParams['mode'] == null &&
2781 this.getServiceName() == 'draw.io' && (id == null || id.length == 0) && 2688 this.getServiceName() == 'draw.io' && (id == null || id.length == 0) &&
2782 !this.editor.isChromelessView()) { 2689 !this.editor.isChromelessView()) {
2783 this.checkDrafts(); 2690 this.checkDrafts();
2784 - }  
2785 - else if (id != null && id.length > 0) { 2691 + } else if (id != null && id.length > 0) {
2786 this.loadFile(id, null, null, mxUtils.bind(this, function () { 2692 this.loadFile(id, null, null, mxUtils.bind(this, function () {
2787 var temp = decodeURIComponent(urlParams['viewbox'] || ''); 2693 var temp = decodeURIComponent(urlParams['viewbox'] || '');
2788 2694
@@ -2790,18 +2696,15 @@ App.prototype.start = function () { @@ -2790,18 +2696,15 @@ App.prototype.start = function () {
2790 try { 2696 try {
2791 var bounds = JSON.parse(temp); 2697 var bounds = JSON.parse(temp);
2792 this.editor.graph.fitWindow(bounds, bounds.border); 2698 this.editor.graph.fitWindow(bounds, bounds.border);
2793 - }  
2794 - catch (e) { 2699 + } catch (e) {
2795 // Ignore invalid viewport 2700 // Ignore invalid viewport
2796 console.error(e); 2701 console.error(e);
2797 } 2702 }
2798 } 2703 }
2799 })); 2704 }));
2800 - }  
2801 - else if (urlParams['splash'] != '0' || urlParams['mode'] != null) { 2705 + } else if (urlParams['splash'] != '0' || urlParams['mode'] != null) {
2802 this.loadFile(); 2706 this.loadFile();
2803 - }  
2804 - else if (!EditorUi.isElectronApp) { 2707 + } else if (!EditorUi.isElectronApp) {
2805 this.createFile(this.defaultFilename, this.getFileData(), null, null, null, null, null, true); 2708 this.createFile(this.defaultFilename, this.getFileData(), null, null, null, null, null, true);
2806 } 2709 }
2807 } 2710 }
@@ -2817,7 +2720,8 @@ App.prototype.start = function () { @@ -2817,7 +2720,8 @@ App.prototype.start = function () {
2817 // Removes URL parameter and reloads the page 2720 // Removes URL parameter and reloads the page
2818 if (this.spinner.spin(document.body, mxResources.get('reconnecting'))) { 2721 if (this.spinner.spin(document.body, mxResources.get('reconnecting'))) {
2819 window.location.search = this.getSearch(['create', 'title']); 2722 window.location.search = this.getSearch(['create', 'title']);
2820 - }; 2723 + }
  2724 + ;
2821 }); 2725 });
2822 2726
2823 var showCreateDialog = mxUtils.bind(this, function (xml) { 2727 var showCreateDialog = mxUtils.bind(this, function (xml) {
@@ -2833,8 +2737,7 @@ App.prototype.start = function () { @@ -2833,8 +2737,7 @@ App.prototype.start = function () {
2833 2737
2834 if (title != null) { 2738 if (title != null) {
2835 title = decodeURIComponent(title); 2739 title = decodeURIComponent(title);
2836 - }  
2837 - else { 2740 + } else {
2838 title = this.defaultFilename; 2741 title = this.defaultFilename;
2839 } 2742 }
2840 2743
@@ -2853,8 +2756,7 @@ App.prototype.start = function () { @@ -2853,8 +2756,7 @@ App.prototype.start = function () {
2853 this.createFile((filename.length > 0) ? filename : this.defaultFilename, 2756 this.createFile((filename.length > 0) ? filename : this.defaultFilename,
2854 this.getFileData(), null, null, null, true, null, true); 2757 this.getFileData(), null, null, null, true, null, true);
2855 Editor.useLocalStorage = prev; 2758 Editor.useLocalStorage = prev;
2856 - }  
2857 - else { 2759 + } else {
2858 this.pickFolder(mode, mxUtils.bind(this, function (folderId) { 2760 this.pickFolder(mode, mxUtils.bind(this, function (folderId) {
2859 this.createFile(filename, this.getFileData(true), 2761 this.createFile(filename, this.getFileData(true),
2860 null, mode, null, true, folderId); 2762 null, mode, null, true, folderId);
@@ -2881,24 +2783,20 @@ App.prototype.start = function () { @@ -2881,24 +2783,20 @@ App.prototype.start = function () {
2881 try { 2783 try {
2882 if (window.opener != null && window.opener[value] != null) { 2784 if (window.opener != null && window.opener[value] != null) {
2883 showCreateDialog(window.opener[value]); 2785 showCreateDialog(window.opener[value]);
2884 - }  
2885 - else { 2786 + } else {
2886 this.handleError(null, mxResources.get('errorLoadingFile')); 2787 this.handleError(null, mxResources.get('errorLoadingFile'));
2887 } 2788 }
2888 - }  
2889 - catch (e) { 2789 + } catch (e) {
2890 this.handleError(e, mxResources.get('errorLoadingFile')); 2790 this.handleError(e, mxResources.get('errorLoadingFile'));
2891 } 2791 }
2892 - }  
2893 - else { 2792 + } else {
2894 this.loadTemplate(value, function (text) { 2793 this.loadTemplate(value, function (text) {
2895 showCreateDialog(text); 2794 showCreateDialog(text);
2896 }, mxUtils.bind(this, function () { 2795 }, mxUtils.bind(this, function () {
2897 this.handleError(null, mxResources.get('errorLoadingFile'), reconnect); 2796 this.handleError(null, mxResources.get('errorLoadingFile'), reconnect);
2898 })); 2797 }));
2899 } 2798 }
2900 - }  
2901 - else { 2799 + } else {
2902 // Passes the fileId from the state parameter to the hash tag and reloads 2800 // Passes the fileId from the state parameter to the hash tag and reloads
2903 // the page without the state parameter 2801 // the page without the state parameter
2904 if ((window.location.hash == null || window.location.hash.length <= 1) && 2802 if ((window.location.hash == null || window.location.hash.length <= 1) &&
@@ -2912,8 +2810,7 @@ App.prototype.start = function () { @@ -2912,8 +2810,7 @@ App.prototype.start = function () {
2912 2810
2913 window.location.hash = 'G' + this.stateArg.ids[0]; 2811 window.location.hash = 'G' + this.stateArg.ids[0];
2914 } 2812 }
2915 - }  
2916 - else if ((window.location.hash == null || window.location.hash.length <= 1) && 2813 + } else if ((window.location.hash == null || window.location.hash.length <= 1) &&
2917 this.drive != null && this.stateArg != null && this.stateArg.action == 'create') { 2814 this.drive != null && this.stateArg != null && this.stateArg.action == 'create') {
2918 if (window.history && window.history.replaceState) { 2815 if (window.history && window.history.replaceState) {
2919 // Removes state URL parameter without reloading the page 2816 // Removes state URL parameter without reloading the page
@@ -2927,12 +2824,10 @@ App.prototype.start = function () { @@ -2927,12 +2824,10 @@ App.prototype.start = function () {
2927 this.createFile((urlParams['title'] != null) ? 2824 this.createFile((urlParams['title'] != null) ?
2928 decodeURIComponent(urlParams['title']) : 2825 decodeURIComponent(urlParams['title']) :
2929 this.defaultFilename); 2826 this.defaultFilename);
2930 - }  
2931 - else { 2827 + } else {
2932 this.actions.get('new').funct(); 2828 this.actions.get('new').funct();
2933 } 2829 }
2934 - }  
2935 - else { 2830 + } else {
2936 // Removes open URL parameter. Hash is also updated in Init to load client. 2831 // Removes open URL parameter. Hash is also updated in Init to load client.
2937 if (urlParams['open'] != null && window.history && window.history.replaceState) { 2832 if (urlParams['open'] != null && window.history && window.history.replaceState) {
2938 2833
@@ -2945,8 +2840,7 @@ App.prototype.start = function () { @@ -2945,8 +2840,7 @@ App.prototype.start = function () {
2945 } 2840 }
2946 } 2841 }
2947 } 2842 }
2948 - }  
2949 - catch (e) { 2843 + } catch (e) {
2950 this.handleError(e); 2844 this.handleError(e);
2951 } 2845 }
2952 }; 2846 };
@@ -2994,16 +2888,14 @@ App.prototype.filterDrafts = function (filePath, guid, callback) { @@ -2994,16 +2888,14 @@ App.prototype.filterDrafts = function (filePath, guid, callback) {
2994 drafts.push(obj); 2888 drafts.push(obj);
2995 } 2889 }
2996 } 2890 }
2997 - }  
2998 - catch (e) { 2891 + } catch (e) {
2999 // ignore 2892 // ignore
3000 } 2893 }
3001 } 2894 }
3002 2895
3003 result(); 2896 result();
3004 }, result)); 2897 }, result));
3005 - }  
3006 - catch (e) { 2898 + } catch (e) {
3007 result(); 2899 result();
3008 } 2900 }
3009 }; 2901 };
@@ -3025,8 +2917,7 @@ App.prototype.checkDrafts = function () { @@ -3025,8 +2917,7 @@ App.prototype.checkDrafts = function () {
3025 this.loadDraft(drafts[0].data, mxUtils.bind(this, function () { 2917 this.loadDraft(drafts[0].data, mxUtils.bind(this, function () {
3026 this.removeDatabaseItem(drafts[0].key); 2918 this.removeDatabaseItem(drafts[0].key);
3027 })); 2919 }));
3028 - }  
3029 - else if (drafts.length > 1) { 2920 + } else if (drafts.length > 1) {
3030 var ts = new Date(drafts[0].modified); 2921 var ts = new Date(drafts[0].modified);
3031 2922
3032 var dlg = new DraftDialog(this, (drafts.length > 1) ? mxResources.get('selectDraft') : 2923 var dlg = new DraftDialog(this, (drafts.length > 1) ? mxResources.get('selectDraft') :
@@ -3053,23 +2944,19 @@ App.prototype.checkDrafts = function () { @@ -3053,23 +2944,19 @@ App.prototype.checkDrafts = function () {
3053 this.showDialog(dlg.container, 640, 480, true, false, mxUtils.bind(this, function (cancel) { 2944 this.showDialog(dlg.container, 640, 480, true, false, mxUtils.bind(this, function (cancel) {
3054 if (urlParams['splash'] != '0') { 2945 if (urlParams['splash'] != '0') {
3055 this.loadFile(); 2946 this.loadFile();
3056 - }  
3057 - else { 2947 + } else {
3058 this.createFile(this.defaultFilename, this.getFileData(), null, null, null, null, null, true); 2948 this.createFile(this.defaultFilename, this.getFileData(), null, null, null, null, null, true);
3059 } 2949 }
3060 })); 2950 }));
3061 dlg.init(); 2951 dlg.init();
3062 - }  
3063 - else if (urlParams['splash'] != '0') { 2952 + } else if (urlParams['splash'] != '0') {
3064 this.loadFile(); 2953 this.loadFile();
3065 - }  
3066 - else { 2954 + } else {
3067 this.createFile(this.defaultFilename, this.getFileData(), null, null, null, null, null, true); 2955 this.createFile(this.defaultFilename, this.getFileData(), null, null, null, null, null, true);
3068 } 2956 }
3069 })); 2957 }));
3070 }), 0); 2958 }), 0);
3071 - }  
3072 - catch (e) { 2959 + } catch (e) {
3073 // ignore 2960 // ignore
3074 } 2961 }
3075 }; 2962 };
@@ -3108,8 +2995,7 @@ App.prototype.showSplash = function (force) { @@ -3108,8 +2995,7 @@ App.prototype.showSplash = function (force) {
3108 mxResources.get('errorLoadingFile'), mxUtils.bind(this, function () { 2995 mxResources.get('errorLoadingFile'), mxUtils.bind(this, function () {
3109 this.showSplash(); 2996 this.showSplash();
3110 })); 2997 }));
3111 - }  
3112 - else if (!mxClient.IS_CHROMEAPP && (this.mode == null || force)) { 2998 + } else if (!mxClient.IS_CHROMEAPP && (this.mode == null || force)) {
3113 var rowLimit = (serviceCount == 4) ? 2 : 3; 2999 var rowLimit = (serviceCount == 4) ? 2 : 3;
3114 3000
3115 var dlg = new StorageDialog(this, mxUtils.bind(this, function () { 3001 var dlg = new StorageDialog(this, mxUtils.bind(this, function () {
@@ -3119,8 +3005,7 @@ App.prototype.showSplash = function (force) { @@ -3119,8 +3005,7 @@ App.prototype.showSplash = function (force) {
3119 3005
3120 this.showDialog(dlg.container, (rowLimit < 3) ? 200 : 300, 3006 this.showDialog(dlg.container, (rowLimit < 3) ? 200 : 300,
3121 ((serviceCount > 3) ? 320 : 210), true, false); 3007 ((serviceCount > 3) ? 320 : 210), true, false);
3122 - }  
3123 - else if (urlParams['create'] == null) { 3008 + } else if (urlParams['create'] == null) {
3124 showSecondDialog(); 3009 showSecondDialog();
3125 } 3010 }
3126 }; 3011 };
@@ -3209,12 +3094,10 @@ App.prototype.loadFileSystemEntry = function (fileHandle, success, error) { @@ -3209,12 +3094,10 @@ App.prototype.loadFileSystemEntry = function (fileHandle, success, error) {
3209 } 3094 }
3210 3095
3211 success(new LocalFile(this, data, file.name, null, fileHandle, file)); 3096 success(new LocalFile(this, data, file.name, null, fileHandle, file));
3212 - }  
3213 - else { 3097 + } else {
3214 this.openFileHandle(e.target.result, file.name, file, false, fileHandle); 3098 this.openFileHandle(e.target.result, file.name, file, false, fileHandle);
3215 } 3099 }
3216 - }  
3217 - catch (e) { 3100 + } catch (e) {
3218 error(e); 3101 error(e);
3219 } 3102 }
3220 }); 3103 });
@@ -3225,13 +3108,11 @@ App.prototype.loadFileSystemEntry = function (fileHandle, success, error) { @@ -3225,13 +3108,11 @@ App.prototype.loadFileSystemEntry = function (fileHandle, success, error) {
3225 file.type === 'application/pdf') && 3108 file.type === 'application/pdf') &&
3226 file.type.substring(0, 9) !== 'image/svg') { 3109 file.type.substring(0, 9) !== 'image/svg') {
3227 reader.readAsDataURL(file); 3110 reader.readAsDataURL(file);
3228 - }  
3229 - else { 3111 + } else {
3230 reader.readAsText(file); 3112 reader.readAsText(file);
3231 } 3113 }
3232 }), error); 3114 }), error);
3233 - }  
3234 - catch (e) { 3115 + } catch (e) {
3235 error(e); 3116 error(e);
3236 } 3117 }
3237 }; 3118 };
@@ -3261,12 +3142,10 @@ App.prototype.createFileSystemOptions = function (name) { @@ -3261,12 +3142,10 @@ App.prototype.createFileSystemOptions = function (name) {
3261 3142
3262 if (this.editor.diagramFileTypes[i].extension == temp) { 3143 if (this.editor.diagramFileTypes[i].extension == temp) {
3263 ext.splice(0, 0, obj); 3144 ext.splice(0, 0, obj);
3264 - }  
3265 - else { 3145 + } else {
3266 if (this.editor.diagramFileTypes[i].extension == temp) { 3146 if (this.editor.diagramFileTypes[i].extension == temp) {
3267 ext.splice(0, 0, obj); 3147 ext.splice(0, 0, obj);
3268 - }  
3269 - else { 3148 + } else {
3270 ext.push(obj); 3149 ext.push(obj);
3271 } 3150 }
3272 } 3151 }
@@ -3310,18 +3189,15 @@ App.prototype.pickFile = function (mode) { @@ -3310,18 +3189,15 @@ App.prototype.pickFile = function (mode) {
3310 if (mode == App.MODE_GOOGLE) { 3189 if (mode == App.MODE_GOOGLE) {
3311 if (this.drive != null && typeof (google) != 'undefined' && typeof (google.picker) != 'undefined') { 3190 if (this.drive != null && typeof (google) != 'undefined' && typeof (google.picker) != 'undefined') {
3312 this.drive.pickFile(); 3191 this.drive.pickFile();
3313 - }  
3314 - else { 3192 + } else {
3315 this.openLink('https://drive.google.com'); 3193 this.openLink('https://drive.google.com');
3316 } 3194 }
3317 - }  
3318 - else { 3195 + } else {
3319 var peer = this.getPeerForMode(mode); 3196 var peer = this.getPeerForMode(mode);
3320 3197
3321 if (peer != null) { 3198 if (peer != null) {
3322 peer.pickFile(); 3199 peer.pickFile();
3323 - }  
3324 - else if (mode == App.MODE_DEVICE && EditorUi.nativeFileSupport) { 3200 + } else if (mode == App.MODE_DEVICE && EditorUi.nativeFileSupport) {
3325 window.showOpenFilePicker().then(mxUtils.bind(this, function (fileHandles) { 3201 window.showOpenFilePicker().then(mxUtils.bind(this, function (fileHandles) {
3326 if (fileHandles != null && fileHandles.length > 0 && 3202 if (fileHandles != null && fileHandles.length > 0 &&
3327 this.spinner.spin(document.body, mxResources.get('loading'))) { 3203 this.spinner.spin(document.body, mxResources.get('loading'))) {
@@ -3332,8 +3208,7 @@ App.prototype.pickFile = function (mode) { @@ -3332,8 +3208,7 @@ App.prototype.pickFile = function (mode) {
3332 this.handleError(e); 3208 this.handleError(e);
3333 } 3209 }
3334 })); 3210 }));
3335 - }  
3336 - else if (mode == App.MODE_DEVICE && Graph.fileSupport) { 3211 + } else if (mode == App.MODE_DEVICE && Graph.fileSupport) {
3337 if (this.openFileInputElt == null) { 3212 if (this.openFileInputElt == null) {
3338 var input = document.createElement('input'); 3213 var input = document.createElement('input');
3339 input.setAttribute('type', 'file'); 3214 input.setAttribute('type', 'file');
@@ -3356,8 +3231,7 @@ App.prototype.pickFile = function (mode) { @@ -3356,8 +3231,7 @@ App.prototype.pickFile = function (mode) {
3356 } 3231 }
3357 3232
3358 this.openFileInputElt.click(); 3233 this.openFileInputElt.click();
3359 - }  
3360 - else { 3234 + } else {
3361 this.hideDialog(); 3235 this.hideDialog();
3362 window.openNew = this.getCurrentFile() != null && !this.isDiagramEmpty(); 3236 window.openNew = this.getCurrentFile() != null && !this.isDiagramEmpty();
3363 window.baseUrl = this.getUrl(); 3237 window.baseUrl = this.getUrl();
@@ -3398,8 +3272,7 @@ App.prototype.pickFile = function (mode) { @@ -3398,8 +3272,7 @@ App.prototype.pickFile = function (mode) {
3398 3272
3399 if (currentFile == null || !currentFile.isModified()) { 3273 if (currentFile == null || !currentFile.isModified()) {
3400 doOpenFile(); 3274 doOpenFile();
3401 - }  
3402 - else { 3275 + } else {
3403 this.confirm(mxResources.get('allChangesLost'), null, doOpenFile, 3276 this.confirm(mxResources.get('allChangesLost'), null, doOpenFile,
3404 mxResources.get('cancel'), mxResources.get('discardChanges')); 3277 mxResources.get('cancel'), mxResources.get('discardChanges'));
3405 } 3278 }
@@ -3419,8 +3292,7 @@ App.prototype.pickFile = function (mode) { @@ -3419,8 +3292,7 @@ App.prototype.pickFile = function (mode) {
3419 }); 3292 });
3420 } 3293 }
3421 } 3294 }
3422 - }  
3423 - catch (e) { 3295 + } catch (e) {
3424 this.handleError(e); 3296 this.handleError(e);
3425 } 3297 }
3426 }; 3298 };
@@ -3448,20 +3320,17 @@ App.prototype.pickLibrary = function (mode) { @@ -3448,20 +3320,17 @@ App.prototype.pickLibrary = function (mode) {
3448 if (optionalFile != null) { 3320 if (optionalFile != null) {
3449 try { 3321 try {
3450 this.loadLibrary(optionalFile); 3322 this.loadLibrary(optionalFile);
3451 - }  
3452 - catch (e) { 3323 + } catch (e) {
3453 this.handleError(e, mxResources.get('errorLoadingFile')); 3324 this.handleError(e, mxResources.get('errorLoadingFile'));
3454 } 3325 }
3455 - }  
3456 - else { 3326 + } else {
3457 if (this.spinner.spin(document.body, mxResources.get('loading'))) { 3327 if (this.spinner.spin(document.body, mxResources.get('loading'))) {
3458 peer.getLibrary(id, mxUtils.bind(this, function (file) { 3328 peer.getLibrary(id, mxUtils.bind(this, function (file) {
3459 this.spinner.stop(); 3329 this.spinner.stop();
3460 3330
3461 try { 3331 try {
3462 this.loadLibrary(file); 3332 this.loadLibrary(file);
3463 - }  
3464 - catch (e) { 3333 + } catch (e) {
3465 this.handleError(e, mxResources.get('errorLoadingFile')); 3334 this.handleError(e, mxResources.get('errorLoadingFile'));
3466 } 3335 }
3467 }), mxUtils.bind(this, function (resp) { 3336 }), mxUtils.bind(this, function (resp) {
@@ -3471,8 +3340,7 @@ App.prototype.pickLibrary = function (mode) { @@ -3471,8 +3340,7 @@ App.prototype.pickLibrary = function (mode) {
3471 } 3340 }
3472 })); 3341 }));
3473 } 3342 }
3474 - }  
3475 - else if (mode == App.MODE_DEVICE && Graph.fileSupport) { 3343 + } else if (mode == App.MODE_DEVICE && Graph.fileSupport) {
3476 if (this.libFileInputElt == null) { 3344 if (this.libFileInputElt == null) {
3477 var input = document.createElement('input'); 3345 var input = document.createElement('input');
3478 input.setAttribute('type', 'file'); 3346 input.setAttribute('type', 'file');
@@ -3486,8 +3354,7 @@ App.prototype.pickLibrary = function (mode) { @@ -3486,8 +3354,7 @@ App.prototype.pickLibrary = function (mode) {
3486 reader.onload = mxUtils.bind(this, function (e) { 3354 reader.onload = mxUtils.bind(this, function (e) {
3487 try { 3355 try {
3488 this.loadLibrary(new LocalLibrary(this, e.target.result, file.name)); 3356 this.loadLibrary(new LocalLibrary(this, e.target.result, file.name));
3489 - }  
3490 - catch (e) { 3357 + } catch (e) {
3491 this.handleError(e, mxResources.get('errorLoadingFile')); 3358 this.handleError(e, mxResources.get('errorLoadingFile'));
3492 } 3359 }
3493 }); 3360 });
@@ -3509,8 +3376,7 @@ App.prototype.pickLibrary = function (mode) { @@ -3509,8 +3376,7 @@ App.prototype.pickLibrary = function (mode) {
3509 } 3376 }
3510 3377
3511 this.libFileInputElt.click(); 3378 this.libFileInputElt.click();
3512 - }  
3513 - else { 3379 + } else {
3514 window.openNew = false; 3380 window.openNew = false;
3515 window.openKey = 'open'; 3381 window.openKey = 'open';
3516 3382
@@ -3538,8 +3404,7 @@ App.prototype.pickLibrary = function (mode) { @@ -3538,8 +3404,7 @@ App.prototype.pickLibrary = function (mode) {
3538 try { 3404 try {
3539 this.loadLibrary((mode == App.MODE_BROWSER) ? new StorageLibrary(this, xml, filename) : 3405 this.loadLibrary((mode == App.MODE_BROWSER) ? new StorageLibrary(this, xml, filename) :
3540 new LocalLibrary(this, xml, filename)); 3406 new LocalLibrary(this, xml, filename));
3541 - }  
3542 - catch (e) { 3407 + } catch (e) {
3543 this.handleError(e, mxResources.get('errorLoadingFile')); 3408 this.handleError(e, mxResources.get('errorLoadingFile'));
3544 } 3409 }
3545 })); 3410 }));
@@ -3589,43 +3454,37 @@ App.prototype.saveLibrary = function (name, images, file, mode, noSpin, noReload @@ -3589,43 +3454,37 @@ App.prototype.saveLibrary = function (name, images, file, mode, noSpin, noReload
3589 this.hideDialog(true); 3454 this.hideDialog(true);
3590 this.libraryLoaded(newFile, images); 3455 this.libraryLoaded(newFile, images);
3591 }), error, this.drive.libraryMimeType); 3456 }), error, this.drive.libraryMimeType);
3592 - }  
3593 - else if (mode == App.MODE_GITHUB && this.gitHub != null && this.spinner.spin(document.body, mxResources.get('inserting'))) { 3457 + } else if (mode == App.MODE_GITHUB && this.gitHub != null && this.spinner.spin(document.body, mxResources.get('inserting'))) {
3594 this.gitHub.insertLibrary(name, xml, mxUtils.bind(this, function (newFile) { 3458 this.gitHub.insertLibrary(name, xml, mxUtils.bind(this, function (newFile) {
3595 this.spinner.stop(); 3459 this.spinner.stop();
3596 this.hideDialog(true); 3460 this.hideDialog(true);
3597 this.libraryLoaded(newFile, images); 3461 this.libraryLoaded(newFile, images);
3598 }), error, folderId); 3462 }), error, folderId);
3599 - }  
3600 - else if (mode == App.MODE_GITLAB && this.gitLab != null && this.spinner.spin(document.body, mxResources.get('inserting'))) { 3463 + } else if (mode == App.MODE_GITLAB && this.gitLab != null && this.spinner.spin(document.body, mxResources.get('inserting'))) {
3601 this.gitLab.insertLibrary(name, xml, mxUtils.bind(this, function (newFile) { 3464 this.gitLab.insertLibrary(name, xml, mxUtils.bind(this, function (newFile) {
3602 this.spinner.stop(); 3465 this.spinner.stop();
3603 this.hideDialog(true); 3466 this.hideDialog(true);
3604 this.libraryLoaded(newFile, images); 3467 this.libraryLoaded(newFile, images);
3605 }), error, folderId); 3468 }), error, folderId);
3606 - }  
3607 - else if (mode == App.MODE_TRELLO && this.trello != null && this.spinner.spin(document.body, mxResources.get('inserting'))) { 3469 + } else if (mode == App.MODE_TRELLO && this.trello != null && this.spinner.spin(document.body, mxResources.get('inserting'))) {
3608 this.trello.insertLibrary(name, xml, mxUtils.bind(this, function (newFile) { 3470 this.trello.insertLibrary(name, xml, mxUtils.bind(this, function (newFile) {
3609 this.spinner.stop(); 3471 this.spinner.stop();
3610 this.hideDialog(true); 3472 this.hideDialog(true);
3611 this.libraryLoaded(newFile, images); 3473 this.libraryLoaded(newFile, images);
3612 }), error, folderId); 3474 }), error, folderId);
3613 - }  
3614 - else if (mode == App.MODE_DROPBOX && this.dropbox != null && this.spinner.spin(document.body, mxResources.get('inserting'))) { 3475 + } else if (mode == App.MODE_DROPBOX && this.dropbox != null && this.spinner.spin(document.body, mxResources.get('inserting'))) {
3615 this.dropbox.insertLibrary(name, xml, mxUtils.bind(this, function (newFile) { 3476 this.dropbox.insertLibrary(name, xml, mxUtils.bind(this, function (newFile) {
3616 this.spinner.stop(); 3477 this.spinner.stop();
3617 this.hideDialog(true); 3478 this.hideDialog(true);
3618 this.libraryLoaded(newFile, images); 3479 this.libraryLoaded(newFile, images);
3619 }), error, folderId); 3480 }), error, folderId);
3620 - }  
3621 - else if (mode == App.MODE_ONEDRIVE && this.oneDrive != null && this.spinner.spin(document.body, mxResources.get('inserting'))) { 3481 + } else if (mode == App.MODE_ONEDRIVE && this.oneDrive != null && this.spinner.spin(document.body, mxResources.get('inserting'))) {
3622 this.oneDrive.insertLibrary(name, xml, mxUtils.bind(this, function (newFile) { 3482 this.oneDrive.insertLibrary(name, xml, mxUtils.bind(this, function (newFile) {
3623 this.spinner.stop(); 3483 this.spinner.stop();
3624 this.hideDialog(true); 3484 this.hideDialog(true);
3625 this.libraryLoaded(newFile, images); 3485 this.libraryLoaded(newFile, images);
3626 }), error, folderId); 3486 }), error, folderId);
3627 - }  
3628 - else if (mode == App.MODE_BROWSER) { 3487 + } else if (mode == App.MODE_BROWSER) {
3629 var fn = mxUtils.bind(this, function () { 3488 var fn = mxUtils.bind(this, function () {
3630 var file = new StorageLibrary(this, xml, name); 3489 var file = new StorageLibrary(this, xml, name);
3631 3490
@@ -3638,17 +3497,14 @@ App.prototype.saveLibrary = function (name, images, file, mode, noSpin, noReload @@ -3638,17 +3497,14 @@ App.prototype.saveLibrary = function (name, images, file, mode, noSpin, noReload
3638 3497
3639 if (localStorage.getItem(name) == null) { 3498 if (localStorage.getItem(name) == null) {
3640 fn(); 3499 fn();
3641 - }  
3642 - else { 3500 + } else {
3643 this.confirm(mxResources.get('replaceIt', [name]), fn); 3501 this.confirm(mxResources.get('replaceIt', [name]), fn);
3644 } 3502 }
3645 - }  
3646 - else { 3503 + } else {
3647 this.handleError({ message: mxResources.get('serviceUnavailableOrBlocked') }); 3504 this.handleError({ message: mxResources.get('serviceUnavailableOrBlocked') });
3648 } 3505 }
3649 })); 3506 }));
3650 - }  
3651 - else if (noSpin || this.spinner.spin(document.body, mxResources.get('saving'))) { 3507 + } else if (noSpin || this.spinner.spin(document.body, mxResources.get('saving'))) {
3652 file.setData(xml); 3508 file.setData(xml);
3653 3509
3654 var doSave = mxUtils.bind(this, function () { 3510 var doSave = mxUtils.bind(this, function () {
@@ -3683,13 +3539,11 @@ App.prototype.saveLibrary = function (name, images, file, mode, noSpin, noReload @@ -3683,13 +3539,11 @@ App.prototype.saveLibrary = function (name, images, file, mode, noSpin, noReload
3683 3539
3684 doSave(); 3540 doSave();
3685 }), error) 3541 }), error)
3686 - }  
3687 - else { 3542 + } else {
3688 doSave(); 3543 doSave();
3689 } 3544 }
3690 } 3545 }
3691 - }  
3692 - catch (e) { 3546 + } catch (e) {
3693 this.handleError(e); 3547 this.handleError(e);
3694 } 3548 }
3695 }; 3549 };
@@ -3712,8 +3566,7 @@ App.prototype.saveFile = function (forceDialog, success) { @@ -3712,8 +3566,7 @@ App.prototype.saveFile = function (forceDialog, success) {
3712 // is to show no saved status for device files 3566 // is to show no saved status for device files
3713 if (file.getMode() != App.MODE_DEVICE) { 3567 if (file.getMode() != App.MODE_DEVICE) {
3714 this.editor.setStatus(mxUtils.htmlEntities(mxResources.get('allChangesSaved'))); 3568 this.editor.setStatus(mxUtils.htmlEntities(mxResources.get('allChangesSaved')));
3715 - }  
3716 - else { 3569 + } else {
3717 this.editor.setStatus(''); 3570 this.editor.setStatus('');
3718 } 3571 }
3719 } 3572 }
@@ -3725,8 +3578,7 @@ App.prototype.saveFile = function (forceDialog, success) { @@ -3725,8 +3578,7 @@ App.prototype.saveFile = function (forceDialog, success) {
3725 3578
3726 if (!forceDialog && file.getTitle() != null && file.invalidFileHandle == null && this.mode != null) { 3579 if (!forceDialog && file.getTitle() != null && file.invalidFileHandle == null && this.mode != null) {
3727 this.save(file.getTitle(), done); 3580 this.save(file.getTitle(), done);
3728 - }  
3729 - else if (file != null && file.constructor == LocalFile && file.fileHandle != null) { 3581 + } else if (file != null && file.constructor == LocalFile && file.fileHandle != null) {
3730 this.showSaveFilePicker(mxUtils.bind(this, function (fileHandle, desc) { 3582 this.showSaveFilePicker(mxUtils.bind(this, function (fileHandle, desc) {
3731 file.invalidFileHandle = null; 3583 file.invalidFileHandle = null;
3732 file.fileHandle = fileHandle; 3584 file.fileHandle = fileHandle;
@@ -3734,8 +3586,7 @@ App.prototype.saveFile = function (forceDialog, success) { @@ -3734,8 +3586,7 @@ App.prototype.saveFile = function (forceDialog, success) {
3734 file.desc = desc; 3586 file.desc = desc;
3735 this.save(desc.name, done); 3587 this.save(desc.name, done);
3736 }), null, this.createFileSystemOptions(file.getTitle())); 3588 }), null, this.createFileSystemOptions(file.getTitle()));
3737 - }  
3738 - else { 3589 + } else {
3739 var filename = (file.getTitle() != null) ? file.getTitle() : this.defaultFilename; 3590 var filename = (file.getTitle() != null) ? file.getTitle() : this.defaultFilename;
3740 var allowTab = !mxClient.IS_IOS || !navigator.standalone; 3591 var allowTab = !mxClient.IS_IOS || !navigator.standalone;
3741 var prev = this.mode; 3592 var prev = this.mode;
@@ -3760,13 +3611,11 @@ App.prototype.saveFile = function (forceDialog, success) { @@ -3760,13 +3611,11 @@ App.prototype.saveFile = function (forceDialog, success) {
3760 3611
3761 if (mxClient.IS_GC || mxClient.IS_FF || document.documentMode >= 5) { 3612 if (mxClient.IS_GC || mxClient.IS_FF || document.documentMode >= 5) {
3762 input.select(); 3613 input.select();
3763 - }  
3764 - else { 3614 + } else {
3765 document.execCommand('selectAll', false, null); 3615 document.execCommand('selectAll', false, null);
3766 } 3616 }
3767 }), mxResources.get('yes'), mxResources.get('no')); 3617 }), mxResources.get('yes'), mxResources.get('no'));
3768 - }  
3769 - else { 3618 + } else {
3770 this.hideDialog(); 3619 this.hideDialog();
3771 3620
3772 if (prev == null && mode == App.MODE_DEVICE) { 3621 if (prev == null && mode == App.MODE_DEVICE) {
@@ -3784,17 +3633,14 @@ App.prototype.saveFile = function (forceDialog, success) { @@ -3784,17 +3633,14 @@ App.prototype.saveFile = function (forceDialog, success) {
3784 this.handleError(e); 3633 this.handleError(e);
3785 } 3634 }
3786 }), this.createFileSystemOptions(name)); 3635 }), this.createFileSystemOptions(name));
3787 - }  
3788 - else { 3636 + } else {
3789 this.setMode(App.MODE_DEVICE); 3637 this.setMode(App.MODE_DEVICE);
3790 this.save(name, done); 3638 this.save(name, done);
3791 } 3639 }
3792 - }  
3793 - else if (mode == 'download') { 3640 + } else if (mode == 'download') {
3794 var tmp = new LocalFile(this, null, name); 3641 var tmp = new LocalFile(this, null, name);
3795 tmp.save(); 3642 tmp.save();
3796 - }  
3797 - else if (mode == '_blank') { 3643 + } else if (mode == '_blank') {
3798 window.openFile = new OpenFile(function () { 3644 window.openFile = new OpenFile(function () {
3799 window.openFile = null; 3645 window.openFile = null;
3800 }); 3646 });
@@ -3802,16 +3648,14 @@ App.prototype.saveFile = function (forceDialog, success) { @@ -3802,16 +3648,14 @@ App.prototype.saveFile = function (forceDialog, success) {
3802 // Do not use a filename to use undefined mode 3648 // Do not use a filename to use undefined mode
3803 window.openFile.setData(this.getFileData(true)); 3649 window.openFile.setData(this.getFileData(true));
3804 this.openLink(this.getUrl(window.location.pathname), null, true); 3650 this.openLink(this.getUrl(window.location.pathname), null, true);
3805 - }  
3806 - else if (prev != mode) { 3651 + } else if (prev != mode) {
3807 this.pickFolder(mode, mxUtils.bind(this, function (folderId) { 3652 this.pickFolder(mode, mxUtils.bind(this, function (folderId) {
3808 this.createFile(name, this.getFileData(/(\.xml)$/i.test(name) || 3653 this.createFile(name, this.getFileData(/(\.xml)$/i.test(name) ||
3809 name.indexOf('.') < 0 || /(\.drawio)$/i.test(name), 3654 name.indexOf('.') < 0 || /(\.drawio)$/i.test(name),
3810 /(\.svg)$/i.test(name), /(\.html)$/i.test(name)), 3655 /(\.svg)$/i.test(name), /(\.html)$/i.test(name)),
3811 null, mode, done, this.mode == null, folderId); 3656 null, mode, done, this.mode == null, folderId);
3812 })); 3657 }));
3813 - }  
3814 - else if (mode != null) { 3658 + } else if (mode != null) {
3815 this.save(name, done); 3659 this.save(name, done);
3816 } 3660 }
3817 } 3661 }
@@ -3857,8 +3701,7 @@ App.prototype.loadTemplate = function (url, onload, onerror, templateFilename, a @@ -3857,8 +3701,7 @@ App.prototype.loadTemplate = function (url, onload, onerror, templateFilename, a
3857 if (!isVisioFilename) { 3701 if (!isVisioFilename) {
3858 if (asLibrary) { 3702 if (asLibrary) {
3859 filterFn = this.isRemoteVisioData(data) ? 'raw.vss' : 'raw.vssx'; 3703 filterFn = this.isRemoteVisioData(data) ? 'raw.vss' : 'raw.vssx';
3860 - }  
3861 - else { 3704 + } else {
3862 filterFn = this.isRemoteVisioData(data) ? 'raw.vsd' : 'raw.vsdx'; 3705 filterFn = this.isRemoteVisioData(data) ? 'raw.vsd' : 'raw.vsdx';
3863 } 3706 }
3864 } 3707 }
@@ -3866,8 +3709,7 @@ App.prototype.loadTemplate = function (url, onload, onerror, templateFilename, a @@ -3866,8 +3709,7 @@ App.prototype.loadTemplate = function (url, onload, onerror, templateFilename, a
3866 this.importVisio(this.base64ToBlob(responseData.substring(responseData.indexOf(',') + 1)), function (xml) { 3709 this.importVisio(this.base64ToBlob(responseData.substring(responseData.indexOf(',') + 1)), function (xml) {
3867 onload(xml); 3710 onload(xml);
3868 }, onerror, filterFn); 3711 }, onerror, filterFn);
3869 - }  
3870 - else if (new XMLHttpRequest().upload && this.isRemoteFileFormat(data, filterFn)) { 3712 + } else if (new XMLHttpRequest().upload && this.isRemoteFileFormat(data, filterFn)) {
3871 if (this.isExternalDataComms()) { 3713 if (this.isExternalDataComms()) {
3872 // Asynchronous parsing via server 3714 // Asynchronous parsing via server
3873 this.parseFileData(data, mxUtils.bind(this, function (xhr) { 3715 this.parseFileData(data, mxUtils.bind(this, function (xhr) {
@@ -3876,27 +3718,23 @@ App.prototype.loadTemplate = function (url, onload, onerror, templateFilename, a @@ -3876,27 +3718,23 @@ App.prototype.loadTemplate = function (url, onload, onerror, templateFilename, a
3876 onload(xhr.responseText); 3718 onload(xhr.responseText);
3877 } 3719 }
3878 }), url); 3720 }), url);
3879 - }  
3880 - else { 3721 + } else {
3881 this.showError(mxResources.get('error'), mxResources.get('notInOffline'), null, onerror); 3722 this.showError(mxResources.get('error'), mxResources.get('notInOffline'), null, onerror);
3882 } 3723 }
3883 - }  
3884 - else if (this.isLucidChartData(data)) { 3724 + } else if (this.isLucidChartData(data)) {
3885 this.convertLucidChart(data, mxUtils.bind(this, function (xml) { 3725 this.convertLucidChart(data, mxUtils.bind(this, function (xml) {
3886 onload(xml); 3726 onload(xml);
3887 }), mxUtils.bind(this, function (e) { 3727 }), mxUtils.bind(this, function (e) {
3888 onerror(e); 3728 onerror(e);
3889 })); 3729 }));
3890 - }  
3891 - else { 3730 + } else {
3892 if (/(\.png)($|\?)/i.test(filterFn) || Editor.isPngData(data)) { 3731 if (/(\.png)($|\?)/i.test(filterFn) || Editor.isPngData(data)) {
3893 data = Editor.extractGraphModelFromPng(responseData); 3732 data = Editor.extractGraphModelFromPng(responseData);
3894 } 3733 }
3895 3734
3896 onload(data); 3735 onload(data);
3897 } 3736 }
3898 - }  
3899 - catch (e) { 3737 + } catch (e) {
3900 onerror(e); 3738 onerror(e);
3901 } 3739 }
3902 }), onerror, /(\.png)($|\?)/i.test(filterFn) || /(\.v(dx|sdx?))($|\?)/i.test(filterFn) || 3740 }), onerror, /(\.png)($|\?)/i.test(filterFn) || /(\.v(dx|sdx?))($|\?)/i.test(filterFn) ||
@@ -3912,23 +3750,17 @@ App.prototype.loadTemplate = function (url, onload, onerror, templateFilename, a @@ -3912,23 +3750,17 @@ App.prototype.loadTemplate = function (url, onload, onerror, templateFilename, a
3912 App.prototype.getPeerForMode = function (mode) { 3750 App.prototype.getPeerForMode = function (mode) {
3913 if (mode == App.MODE_GOOGLE) { 3751 if (mode == App.MODE_GOOGLE) {
3914 return this.drive; 3752 return this.drive;
3915 - }  
3916 - else if (mode == App.MODE_GITHUB) { 3753 + } else if (mode == App.MODE_GITHUB) {
3917 return this.gitHub; 3754 return this.gitHub;
3918 - }  
3919 - else if (mode == App.MODE_GITLAB) { 3755 + } else if (mode == App.MODE_GITLAB) {
3920 return this.gitLab; 3756 return this.gitLab;
3921 - }  
3922 - else if (mode == App.MODE_DROPBOX) { 3757 + } else if (mode == App.MODE_DROPBOX) {
3923 return this.dropbox; 3758 return this.dropbox;
3924 - }  
3925 - else if (mode == App.MODE_ONEDRIVE) { 3759 + } else if (mode == App.MODE_ONEDRIVE) {
3926 return this.oneDrive; 3760 return this.oneDrive;
3927 - }  
3928 - else if (mode == App.MODE_TRELLO) { 3761 + } else if (mode == App.MODE_TRELLO) {
3929 return this.trello; 3762 return this.trello;
3930 - }  
3931 - else { 3763 + } else {
3932 return null; 3764 return null;
3933 } 3765 }
3934 }; 3766 };
@@ -3954,8 +3786,7 @@ App.prototype.createFile = function (title, data, libs, mode, done, replace, fol @@ -3954,8 +3786,7 @@ App.prototype.createFile = function (title, data, libs, mode, done, replace, fol
3954 3786
3955 if (resp == null && this.getCurrentFile() == null && this.dialog == null) { 3787 if (resp == null && this.getCurrentFile() == null && this.dialog == null) {
3956 this.showSplash(); 3788 this.showSplash();
3957 - }  
3958 - else if (resp != null) { 3789 + } else if (resp != null) {
3959 this.handleError(resp); 3790 this.handleError(resp);
3960 } 3791 }
3961 }); 3792 });
@@ -3970,44 +3801,37 @@ App.prototype.createFile = function (title, data, libs, mode, done, replace, fol @@ -3970,44 +3801,37 @@ App.prototype.createFile = function (title, data, libs, mode, done, replace, fol
3970 complete(); 3801 complete();
3971 this.fileCreated(file, libs, replace, done, clibs); 3802 this.fileCreated(file, libs, replace, done, clibs);
3972 }), error); 3803 }), error);
3973 - }  
3974 - else if (mode == App.MODE_GITHUB && this.gitHub != null) { 3804 + } else if (mode == App.MODE_GITHUB && this.gitHub != null) {
3975 this.gitHub.insertFile(title, data, mxUtils.bind(this, function (file) { 3805 this.gitHub.insertFile(title, data, mxUtils.bind(this, function (file) {
3976 complete(); 3806 complete();
3977 this.fileCreated(file, libs, replace, done, clibs); 3807 this.fileCreated(file, libs, replace, done, clibs);
3978 }), error, false, folderId); 3808 }), error, false, folderId);
3979 - }  
3980 - else if (mode == App.MODE_GITLAB && this.gitLab != null) { 3809 + } else if (mode == App.MODE_GITLAB && this.gitLab != null) {
3981 this.gitLab.insertFile(title, data, mxUtils.bind(this, function (file) { 3810 this.gitLab.insertFile(title, data, mxUtils.bind(this, function (file) {
3982 complete(); 3811 complete();
3983 this.fileCreated(file, libs, replace, done, clibs); 3812 this.fileCreated(file, libs, replace, done, clibs);
3984 }), error, false, folderId); 3813 }), error, false, folderId);
3985 - }  
3986 - else if (mode == App.MODE_TRELLO && this.trello != null) { 3814 + } else if (mode == App.MODE_TRELLO && this.trello != null) {
3987 this.trello.insertFile(title, data, mxUtils.bind(this, function (file) { 3815 this.trello.insertFile(title, data, mxUtils.bind(this, function (file) {
3988 complete(); 3816 complete();
3989 this.fileCreated(file, libs, replace, done, clibs); 3817 this.fileCreated(file, libs, replace, done, clibs);
3990 }), error, false, folderId); 3818 }), error, false, folderId);
3991 - }  
3992 - else if (mode == App.MODE_DROPBOX && this.dropbox != null) { 3819 + } else if (mode == App.MODE_DROPBOX && this.dropbox != null) {
3993 this.dropbox.insertFile(title, data, mxUtils.bind(this, function (file) { 3820 this.dropbox.insertFile(title, data, mxUtils.bind(this, function (file) {
3994 complete(); 3821 complete();
3995 this.fileCreated(file, libs, replace, done, clibs); 3822 this.fileCreated(file, libs, replace, done, clibs);
3996 }), error); 3823 }), error);
3997 - }  
3998 - else if (mode == App.MODE_ONEDRIVE && this.oneDrive != null) { 3824 + } else if (mode == App.MODE_ONEDRIVE && this.oneDrive != null) {
3999 this.oneDrive.insertFile(title, data, mxUtils.bind(this, function (file) { 3825 this.oneDrive.insertFile(title, data, mxUtils.bind(this, function (file) {
4000 complete(); 3826 complete();
4001 this.fileCreated(file, libs, replace, done, clibs); 3827 this.fileCreated(file, libs, replace, done, clibs);
4002 }), error, false, folderId); 3828 }), error, false, folderId);
4003 - }  
4004 - else if (mode == App.MODE_BROWSER) { 3829 + } else if (mode == App.MODE_BROWSER) {
4005 StorageFile.insertFile(this, title, data, mxUtils.bind(this, function (file) { 3830 StorageFile.insertFile(this, title, data, mxUtils.bind(this, function (file) {
4006 complete(); 3831 complete();
4007 this.fileCreated(file, libs, replace, done, clibs); 3832 this.fileCreated(file, libs, replace, done, clibs);
4008 }), error); 3833 }), error);
4009 - }  
4010 - else if (!tempFile && mode == App.MODE_DEVICE && EditorUi.nativeFileSupport) { 3834 + } else if (!tempFile && mode == App.MODE_DEVICE && EditorUi.nativeFileSupport) {
4011 complete(); 3835 complete();
4012 3836
4013 this.showSaveFilePicker(mxUtils.bind(this, function (fileHandle, desc) { 3837 this.showSaveFilePicker(mxUtils.bind(this, function (fileHandle, desc) {
@@ -4021,13 +3845,11 @@ App.prototype.createFile = function (title, data, libs, mode, done, replace, fol @@ -4021,13 +3845,11 @@ App.prototype.createFile = function (title, data, libs, mode, done, replace, fol
4021 error(e); 3845 error(e);
4022 } 3846 }
4023 }), this.createFileSystemOptions(title)); 3847 }), this.createFileSystemOptions(title));
4024 - }  
4025 - else { 3848 + } else {
4026 complete(); 3849 complete();
4027 this.fileCreated(new LocalFile(this, data, title, mode == null), libs, replace, done, clibs); 3850 this.fileCreated(new LocalFile(this, data, title, mode == null), libs, replace, done, clibs);
4028 } 3851 }
4029 - }  
4030 - catch (e) { 3852 + } catch (e) {
4031 complete(); 3853 complete();
4032 this.handleError(e); 3854 this.handleError(e);
4033 } 3855 }
@@ -4121,8 +3943,7 @@ App.prototype.fileCreated = function (file, libs, replace, done, clibs) { @@ -4121,8 +3943,7 @@ App.prototype.fileCreated = function (file, libs, replace, done, clibs) {
4121 var fn2 = mxUtils.bind(this, function () { 3943 var fn2 = mxUtils.bind(this, function () {
4122 if (replace || currentFile == null || !currentFile.isModified()) { 3944 if (replace || currentFile == null || !currentFile.isModified()) {
4123 fn3(); 3945 fn3();
4124 - }  
4125 - else { 3946 + } else {
4126 this.confirm(mxResources.get('allChangesLost'), null, fn3, 3947 this.confirm(mxResources.get('allChangesLost'), null, fn3,
4127 mxResources.get('cancel'), mxResources.get('discardChanges')); 3948 mxResources.get('cancel'), mxResources.get('discardChanges'));
4128 } 3949 }
@@ -4148,8 +3969,7 @@ App.prototype.fileCreated = function (file, libs, replace, done, clibs) { @@ -4148,8 +3969,7 @@ App.prototype.fileCreated = function (file, libs, replace, done, clibs) {
4148 } 3969 }
4149 3970
4150 window.openWindow(url, null, fn2); 3971 window.openWindow(url, null, fn2);
4151 - }  
4152 - else { 3972 + } else {
4153 fn2(); 3973 fn2();
4154 } 3974 }
4155 }); 3975 });
@@ -4157,8 +3977,7 @@ App.prototype.fileCreated = function (file, libs, replace, done, clibs) { @@ -4157,8 +3977,7 @@ App.prototype.fileCreated = function (file, libs, replace, done, clibs) {
4157 // Updates data in memory for local files 3977 // Updates data in memory for local files
4158 if (file.constructor == LocalFile) { 3978 if (file.constructor == LocalFile) {
4159 fn(); 3979 fn();
4160 - }  
4161 - else { 3980 + } else {
4162 file.saveFile(file.getTitle(), false, mxUtils.bind(this, function () { 3981 file.saveFile(file.getTitle(), false, mxUtils.bind(this, function () {
4163 fn(); 3982 fn();
4164 }), mxUtils.bind(this, function (resp) { 3983 }), mxUtils.bind(this, function (resp) {
@@ -4185,6 +4004,11 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { @@ -4185,6 +4004,11 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) {
4185 } 4004 }
4186 4005
4187 function getToken() { 4006 function getToken() {
  4007 +
  4008 + /**
  4009 + * @description
  4010 + * @type {{userId: string, dev?: string, share?: string, configuration: string, publicId?: string }}
  4011 + */
4188 const urlParams = (function () { 4012 const urlParams = (function () {
4189 var result = new Object(); 4013 var result = new Object();
4190 var params = window.location.search.slice(1).split('&'); 4014 var params = window.location.search.slice(1).split('&');
@@ -4199,8 +4023,11 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { @@ -4199,8 +4023,11 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) {
4199 4023
4200 return result; 4024 return result;
4201 })(); 4025 })();
4202 - 4026 + console.log(urlParams)
4203 if (urlParams.userId) { 4027 if (urlParams.userId) {
  4028 + /**
  4029 + * @description 小程序第三方登录获取token
  4030 + */
4204 axios.get(`/api/yt/third/login/id/${urlParams.userId}`) 4031 axios.get(`/api/yt/third/login/id/${urlParams.userId}`)
4205 .then(res => { 4032 .then(res => {
4206 const { token, refreshToken } = res.data || {} 4033 const { token, refreshToken } = res.data || {}
@@ -4209,78 +4036,155 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { @@ -4209,78 +4036,155 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) {
4209 getSaveContent() 4036 getSaveContent()
4210 }) 4037 })
4211 } else { 4038 } else {
4212 - getSaveContent() 4039 + /**
  4040 + * @description 分享页面获取token
  4041 + */
  4042 + if (urlParams.share && urlParams.publicId) {
  4043 + axios.post('/api/auth/login/public', { publicId: urlParams.publicId })
  4044 + .then(res => {
  4045 + const { token, refreshToken } = res.data || {}
  4046 + GLOBAL_TOKEN.token = token
  4047 + GLOBAL_TOKEN.refreshToken = refreshToken
  4048 + getSaveContent()
  4049 + })
  4050 + } else {
  4051 + getSaveContent()
  4052 + }
4213 } 4053 }
4214 } 4054 }
4215 4055
4216 getToken() 4056 getToken()
4217 4057
4218 var updateButtonContainer = this.updateButtonContainer 4058 var updateButtonContainer = this.updateButtonContainer
4219 - // var lockUnlock = this.actions.actions.lockUnlock.funct  
4220 - // var selectAll = this.actions.actions.selectAll.funct  
4221 function getUserPermission() { 4059 function getUserPermission() {
4222 defHttp.get('/yt/role/me/permissions') 4060 defHttp.get('/yt/role/me/permissions')
4223 .then(res => { 4061 .then(res => {
4224 USER_PERMISSION.permission = res 4062 USER_PERMISSION.permission = res
4225 updateButtonContainer() 4063 updateButtonContainer()
4226 - // var flag = hasSavePermission()  
4227 - // if (!flag) {  
4228 - // selectAll()  
4229 - // lockUnlock()  
4230 - // }  
4231 }) 4064 })
4232 } 4065 }
  4066 +
  4067 + function afterSaveContent(response) {
  4068 + getUserPermission()
  4069 + const { platform } = response || {}
  4070 + const pageSizeControl = PageSetupDialog.getFormats
  4071 + PageSetupDialog.getFormats = function () {
  4072 + if (platform === 'phone') {
  4073 + return [
  4074 + { key: 'iPhone 8', title: 'iPhone 8', format: new mxRectangle(0, 0, 375, 667) },
  4075 + { key: 'iPhone 8 Plus', title: 'iPhone 8 Plus', format: new mxRectangle(0, 0, 415, 737) },
  4076 + { key: 'iPhone X/XS', title: 'iPhone X/XS', format: new mxRectangle(0, 0, 376, 813) },
  4077 + {
  4078 + key: 'iPhone XR/XS Max',
  4079 + title: 'iPhone XR/XS Max',
  4080 + format: new mxRectangle(0, 0, 415, 897)
  4081 + },
  4082 + { key: 'iPad 4', title: 'iPad 4', format: new mxRectangle(0, 0, 709, 1025) },
  4083 + { key: 'Galaxy S9', title: 'Galaxy S9', format: new mxRectangle(0, 0, 361, 741) },
  4084 + { key: 'Galaxy S10E', title: 'Galaxy S10E', format: new mxRectangle(0, 0, 361, 741) },
  4085 + { key: 'Galaxy S10E', title: 'Galaxy S10E', format: new mxRectangle(0, 0, 361, 741) },
  4086 + { key: 'Galaxy S10/S10+', title: 'Galaxy S10/S10+', format: new mxRectangle(0, 0, 413, 870) },
  4087 + { key: 'Pixel 2', title: 'Pixel 2', format: new mxRectangle(0, 0, 413, 732) },
  4088 + { key: 'Pixel 3', title: 'Pixel 3', format: new mxRectangle(0, 0, 413, 825) },
  4089 + { key: 'Pixel 3', title: 'Pixel 3', format: new mxRectangle(0, 0, 413, 825) },
  4090 + { key: 'Pixel XL', title: 'Pixel XL', format: new mxRectangle(0, 0, 413, 848) },
  4091 + { key: 'custom', title: mxResources.get('custom'), format: null }
  4092 + ]
  4093 + }
  4094 + return pageSizeControl.apply(this, arguments)
  4095 + }
  4096 + Editor.configurationName = response.configurationName + ".drawio";
  4097 + if (response.configurationContentList.length > 0) {
  4098 + response.configurationContentList.forEach((item) => {
  4099 + Editor.configurationContentId = item.id;
  4100 + if (item.content) {
  4101 + Editor.defaultContent = item.content;
  4102 + } else {
  4103 + //默认空白内容
  4104 + Editor.defaultContent = EditorUi.prototype.emptyDiagramXml;
  4105 + }
  4106 + })
  4107 + }
  4108 + if (id == null || id.length == 0) {
  4109 + fn();
  4110 + } else if (currentFile != null && !sameWindow) {
  4111 + this.showDialog(new PopupDialog(this, this.getUrl() + '#' + id,
  4112 + null, fn).container, 320, 140, true, true);
  4113 + } else {
  4114 + fn();
  4115 + }
  4116 +
  4117 + }
  4118 +
4233 var pageFormat = this.editor.graph.pageFormat 4119 var pageFormat = this.editor.graph.pageFormat
4234 4120
4235 - // 调用API,获取保存的内容  
4236 - function getSaveContent() {  
4237 - defHttp.get('/yt/configuration/center/get_configuration_info/' + Editor.configurationId) 4121 + function createAccessTokenFormLayer() {
  4122 + var field = 'accessCredentials'
  4123 + var formSubmitFilter = 'formData'
  4124 + var index = layer.open({
  4125 + type: 1,
  4126 + title: '访问令牌',
  4127 + area: ['350px', '200px'],
  4128 + closeBtn: 0,
  4129 + content: `
  4130 + <section style="padding: 20px;display: flex;justify-content: center;align-items: center;flex-direction: column;">
  4131 + <form class="layui-form" action="">
  4132 + <div class="layui-form-item">
  4133 + <label class="layui-form-label" style="width: 60px;padding: 9px 0;">访问令牌</label>
  4134 + <div class="layui-input-block" style="margin-left: 70px;">
  4135 + <input required lay-verify="required" type="text" name="${field}" lay-verify="title" autocomplete="off" placeholder="请输入访问令牌" class="layui-input">
  4136 + </div>
  4137 + </div>
  4138 + <button lay-submit lay-filter="${formSubmitFilter}" type="button" class="layui-btn layui-btn-normal" style="width: 100%; margin-top: 10px;">进入</button>
  4139 + </form>
  4140 + </section>
  4141 + `,
  4142 + });
  4143 + var form = layui.form
  4144 + form.on(`submit(${formSubmitFilter})`, function (data) {
  4145 + var value = data.field.accessCredentials
  4146 + getShareContentData(value, index)
  4147 + })
  4148 + }
  4149 +
  4150 + function getShareContentData(accessCredentials, index) {
  4151 + var id = urlParams.configurationId
  4152 + var share = urlParams.share
  4153 + defHttp.get(`/yt/share/${share}/share_data/${id}${accessCredentials ? `?accessCredentials=${accessCredentials}` : ''}`)
  4154 + .then(function (res) {
  4155 + var layer = layui.layer
  4156 + index && layer.close(index)
  4157 + afterSaveContent(res.data)
  4158 + })
  4159 + .catch(function (error) {
  4160 + var msg = error.response ? (error.response.data || {}).msg || '' : error.message
  4161 + var layer = layui.layer
  4162 + layer.msg(msg, { icon: 5, offset: 't' });
  4163 + })
  4164 + }
  4165 +
  4166 + function checkSharePageNeedAccessToken() {
  4167 + var id = urlParams.configurationId
  4168 + var share = urlParams.share
  4169 + defHttp.get(`/yt/share/check/${share}/${id}`)
4238 .then(function (response) { 4170 .then(function (response) {
4239 - getUserPermission()  
4240 - const { platform } = response || {}  
4241 - const pageSizeControl = PageSetupDialog.getFormats  
4242 - PageSetupDialog.getFormats = function () {  
4243 - if (platform === 'phone') {  
4244 - return [  
4245 - { key: 'iPhone 8', title: 'iPhone 8', format: new mxRectangle(0, 0, 375, 667) },  
4246 - { key: 'iPhone 8 Plus', title: 'iPhone 8 Plus', format: new mxRectangle(0, 0, 415, 737) },  
4247 - { key: 'iPhone X/XS', title: 'iPhone X/XS', format: new mxRectangle(0, 0, 376, 813) },  
4248 - { key: 'iPhone XR/XS Max', title: 'iPhone XR/XS Max', format: new mxRectangle(0, 0, 415, 897) },  
4249 - { key: 'iPad 4', title: 'iPad 4', format: new mxRectangle(0, 0, 709, 1025) },  
4250 - { key: 'Galaxy S9', title: 'Galaxy S9', format: new mxRectangle(0, 0, 361, 741) },  
4251 - { key: 'Galaxy S10E', title: 'Galaxy S10E', format: new mxRectangle(0, 0, 361, 741) },  
4252 - { key: 'Galaxy S10E', title: 'Galaxy S10E', format: new mxRectangle(0, 0, 361, 741) },  
4253 - { key: 'Galaxy S10/S10+', title: 'Galaxy S10/S10+', format: new mxRectangle(0, 0, 413, 870) },  
4254 - { key: 'Pixel 2', title: 'Pixel 2', format: new mxRectangle(0, 0, 413, 732) },  
4255 - { key: 'Pixel 3', title: 'Pixel 3', format: new mxRectangle(0, 0, 413, 825) },  
4256 - { key: 'Pixel 3', title: 'Pixel 3', format: new mxRectangle(0, 0, 413, 825) },  
4257 - { key: 'Pixel XL', title: 'Pixel XL', format: new mxRectangle(0, 0, 413, 848) },  
4258 - { key: 'custom', title: mxResources.get('custom'), format: null }  
4259 - ]  
4260 - }  
4261 - return pageSizeControl.apply(this, arguments)  
4262 - }  
4263 - Editor.configurationName = response.configurationName + ".drawio";  
4264 - if (response.configurationContentList.length > 0) {  
4265 - response.configurationContentList.forEach((item) => {  
4266 - Editor.configurationContentId = item.id;  
4267 - if (item.content) {  
4268 - Editor.defaultContent = item.content;  
4269 - } else {  
4270 - //默认空白内容  
4271 - Editor.defaultContent = EditorUi.prototype.emptyDiagramXml;  
4272 - }  
4273 - })  
4274 - }  
4275 - if (id == null || id.length == 0) {  
4276 - fn();  
4277 - } else if (currentFile != null && !sameWindow) {  
4278 - this.showDialog(new PopupDialog(this, this.getUrl() + '#' + id,  
4279 - null, fn).container, 320, 140, true, true); 4171 + if (response.data) {
  4172 + createAccessTokenFormLayer()
4280 } else { 4173 } else {
4281 - fn(); 4174 + getShareContentData()
4282 } 4175 }
  4176 + })
  4177 + }
4283 4178
  4179 + // 调用API,获取保存的内容
  4180 + function getSaveContent() {
  4181 + if (urlParams.share) {
  4182 + checkSharePageNeedAccessToken()
  4183 + return
  4184 + }
  4185 + defHttp.get('/yt/configuration/center/get_configuration_info/' + Editor.configurationId)
  4186 + .then(function (response) {
  4187 + afterSaveContent(response)
4284 }) 4188 })
4285 .catch(function (error) { 4189 .catch(function (error) {
4286 }); 4190 });
@@ -4710,23 +4614,17 @@ App.prototype.getLibraryStorageHint = function (file) { @@ -4710,23 +4614,17 @@ App.prototype.getLibraryStorageHint = function (file) {
4710 4614
4711 if (file.constructor == DriveLibrary) { 4615 if (file.constructor == DriveLibrary) {
4712 tip += ' (' + mxResources.get('googleDrive') + ')'; 4616 tip += ' (' + mxResources.get('googleDrive') + ')';
4713 - }  
4714 - else if (file.constructor == GitHubLibrary) { 4617 + } else if (file.constructor == GitHubLibrary) {
4715 tip += ' (' + mxResources.get('github') + ')'; 4618 tip += ' (' + mxResources.get('github') + ')';
4716 - }  
4717 - else if (file.constructor == TrelloLibrary) { 4619 + } else if (file.constructor == TrelloLibrary) {
4718 tip += ' (' + mxResources.get('trello') + ')'; 4620 tip += ' (' + mxResources.get('trello') + ')';
4719 - }  
4720 - else if (file.constructor == DropboxLibrary) { 4621 + } else if (file.constructor == DropboxLibrary) {
4721 tip += ' (' + mxResources.get('dropbox') + ')'; 4622 tip += ' (' + mxResources.get('dropbox') + ')';
4722 - }  
4723 - else if (file.constructor == OneDriveLibrary) { 4623 + } else if (file.constructor == OneDriveLibrary) {
4724 tip += ' (' + mxResources.get('oneDrive') + ')'; 4624 tip += ' (' + mxResources.get('oneDrive') + ')';
4725 - }  
4726 - else if (file.constructor == StorageLibrary) { 4625 + } else if (file.constructor == StorageLibrary) {
4727 tip += ' (' + mxResources.get('browser') + ')'; 4626 tip += ' (' + mxResources.get('browser') + ')';
4728 - }  
4729 - else if (file.constructor == LocalLibrary) { 4627 + } else if (file.constructor == LocalLibrary) {
4730 tip += ' (' + mxResources.get('device') + ')'; 4628 tip += ' (' + mxResources.get('device') + ')';
4731 } 4629 }
4732 4630
@@ -4831,19 +4729,16 @@ App.prototype.loadLibraries = function (libs, done) { @@ -4831,19 +4729,16 @@ App.prototype.loadLibraries = function (libs, done) {
4831 4729
4832 if (xml != null) { 4730 if (xml != null) {
4833 onload(new StorageLibrary(this, xml, name)); 4731 onload(new StorageLibrary(this, xml, name));
4834 - }  
4835 - else { 4732 + } else {
4836 onerror(); 4733 onerror();
4837 } 4734 }
4838 }), onerror); 4735 }), onerror);
4839 - }  
4840 - catch (e) { 4736 + } catch (e) {
4841 onerror(); 4737 onerror();
4842 } 4738 }
4843 }), 0); 4739 }), 0);
4844 } 4740 }
4845 - }  
4846 - else if (service == 'U') { 4741 + } else if (service == 'U') {
4847 var url = decodeURIComponent(id.substring(1)); 4742 var url = decodeURIComponent(id.substring(1));
4848 4743
4849 if (!this.isOffline()) { 4744 if (!this.isOffline()) {
@@ -4851,16 +4746,14 @@ App.prototype.loadLibraries = function (libs, done) { @@ -4851,16 +4746,14 @@ App.prototype.loadLibraries = function (libs, done) {
4851 if (text != null && text.length > 0) { 4746 if (text != null && text.length > 0) {
4852 // LATER: Convert mxfile to mxlibrary using code from libraryLoaded 4747 // LATER: Convert mxfile to mxlibrary using code from libraryLoaded
4853 onload(new UrlLibrary(this, text, url)); 4748 onload(new UrlLibrary(this, text, url));
4854 - }  
4855 - else { 4749 + } else {
4856 onerror(); 4750 onerror();
4857 } 4751 }
4858 }), function () { 4752 }), function () {
4859 onerror(); 4753 onerror();
4860 }, null, true); 4754 }, null, true);
4861 } 4755 }
4862 - }  
4863 - else if (service == 'R') { 4756 + } else if (service == 'R') {
4864 var libDesc = decodeURIComponent(id.substring(1)); 4757 var libDesc = decodeURIComponent(id.substring(1));
4865 4758
4866 try { 4759 try {
@@ -4874,52 +4767,43 @@ App.prototype.loadLibraries = function (libs, done) { @@ -4874,52 +4767,43 @@ App.prototype.loadLibraries = function (libs, done) {
4874 this.remoteInvoke('getFileContent', [libObj.downloadUrl], null, mxUtils.bind(this, function (libContent) { 4767 this.remoteInvoke('getFileContent', [libObj.downloadUrl], null, mxUtils.bind(this, function (libContent) {
4875 try { 4768 try {
4876 onload(new RemoteLibrary(this, libContent, libObj)); 4769 onload(new RemoteLibrary(this, libContent, libObj));
4877 - }  
4878 - catch (e) { 4770 + } catch (e) {
4879 onerror(); 4771 onerror();
4880 } 4772 }
4881 }), function () { 4773 }), function () {
4882 onerror(); 4774 onerror();
4883 }); 4775 });
4884 - }  
4885 - catch (e) { 4776 + } catch (e) {
4886 onerror(); 4777 onerror();
4887 } 4778 }
4888 - }  
4889 - else if (service == 'S' && this.loadDesktopLib != null) { 4779 + } else if (service == 'S' && this.loadDesktopLib != null) {
4890 try { 4780 try {
4891 this.loadDesktopLib(decodeURIComponent(id.substring(1)), function (desktopLib) { 4781 this.loadDesktopLib(decodeURIComponent(id.substring(1)), function (desktopLib) {
4892 onload(desktopLib); 4782 onload(desktopLib);
4893 }, onerror); 4783 }, onerror);
4894 - }  
4895 - catch (e) { 4784 + } catch (e) {
4896 onerror(); 4785 onerror();
4897 } 4786 }
4898 - }  
4899 - else { 4787 + } else {
4900 var peer = null; 4788 var peer = null;
4901 4789
4902 if (service == 'G') { 4790 if (service == 'G') {
4903 if (this.drive != null && this.drive.user != null) { 4791 if (this.drive != null && this.drive.user != null) {
4904 peer = this.drive; 4792 peer = this.drive;
4905 } 4793 }
4906 - }  
4907 - else if (service == 'H') { 4794 + } else if (service == 'H') {
4908 if (this.gitHub != null && this.gitHub.getUser() != null) { 4795 if (this.gitHub != null && this.gitHub.getUser() != null) {
4909 peer = this.gitHub; 4796 peer = this.gitHub;
4910 } 4797 }
4911 - }  
4912 - else if (service == 'T') { 4798 + } else if (service == 'T') {
4913 if (this.trello != null && this.trello.isAuthorized()) { 4799 if (this.trello != null && this.trello.isAuthorized()) {
4914 peer = this.trello; 4800 peer = this.trello;
4915 } 4801 }
4916 - }  
4917 - else if (service == 'D') { 4802 + } else if (service == 'D') {
4918 if (this.dropbox != null && this.dropbox.getUser() != null) { 4803 if (this.dropbox != null && this.dropbox.getUser() != null) {
4919 peer = this.dropbox; 4804 peer = this.dropbox;
4920 } 4805 }
4921 - }  
4922 - else if (service == 'W') { 4806 + } else if (service == 'W') {
4923 if (this.oneDrive != null && this.oneDrive.getUser() != null) { 4807 if (this.oneDrive != null && this.oneDrive.getUser() != null) {
4924 peer = this.oneDrive; 4808 peer = this.oneDrive;
4925 } 4809 }
@@ -4929,15 +4813,13 @@ App.prototype.loadLibraries = function (libs, done) { @@ -4929,15 +4813,13 @@ App.prototype.loadLibraries = function (libs, done) {
4929 peer.getLibrary(decodeURIComponent(id.substring(1)), mxUtils.bind(this, function (file) { 4813 peer.getLibrary(decodeURIComponent(id.substring(1)), mxUtils.bind(this, function (file) {
4930 try { 4814 try {
4931 onload(file); 4815 onload(file);
4932 - }  
4933 - catch (e) { 4816 + } catch (e) {
4934 onerror(); 4817 onerror();
4935 } 4818 }
4936 }), function (resp) { 4819 }), function (resp) {
4937 onerror(); 4820 onerror();
4938 }); 4821 });
4939 - }  
4940 - else { 4822 + } else {
4941 onerror(true); 4823 onerror(true);
4942 } 4824 }
4943 } 4825 }
@@ -4946,8 +4828,7 @@ App.prototype.loadLibraries = function (libs, done) { @@ -4946,8 +4828,7 @@ App.prototype.loadLibraries = function (libs, done) {
4946 } 4828 }
4947 4829
4948 checkDone(); 4830 checkDone();
4949 - }  
4950 - else { 4831 + } else {
4951 checkDone(); 4832 checkDone();
4952 } 4833 }
4953 } 4834 }
@@ -4968,8 +4849,7 @@ App.prototype.updateButtonContainer = function () { @@ -4968,8 +4849,7 @@ App.prototype.updateButtonContainer = function () {
4968 this.buttonContainer.style.paddingRight = '12px'; 4849 this.buttonContainer.style.paddingRight = '12px';
4969 this.buttonContainer.style.paddingTop = '6px'; 4850 this.buttonContainer.style.paddingTop = '6px';
4970 this.buttonContainer.style.right = urlParams['noLangIcon'] == '1' ? '0' : '25px'; 4851 this.buttonContainer.style.right = urlParams['noLangIcon'] == '1' ? '0' : '25px';
4971 - }  
4972 - else if (uiTheme != 'min') { 4852 + } else if (uiTheme != 'min') {
4973 this.buttonContainer.style.paddingRight = '38px'; 4853 this.buttonContainer.style.paddingRight = '38px';
4974 this.buttonContainer.style.paddingTop = '6px'; 4854 this.buttonContainer.style.paddingTop = '6px';
4975 } 4855 }
@@ -4989,14 +4869,11 @@ App.prototype.updateButtonContainer = function () { @@ -4989,14 +4869,11 @@ App.prototype.updateButtonContainer = function () {
4989 if (uiTheme == 'atlas') { 4869 if (uiTheme == 'atlas') {
4990 this.commentButton.style.marginRight = '10px'; 4870 this.commentButton.style.marginRight = '10px';
4991 this.commentButton.style.marginTop = '-3px'; 4871 this.commentButton.style.marginTop = '-3px';
4992 - }  
4993 - else if (uiTheme == 'min') { 4872 + } else if (uiTheme == 'min') {
4994 this.commentButton.style.marginTop = '1px'; 4873 this.commentButton.style.marginTop = '1px';
4995 - }  
4996 - else if (urlParams['atlas'] == '1') { 4874 + } else if (urlParams['atlas'] == '1') {
4997 this.commentButton.style.marginTop = '-2px'; 4875 this.commentButton.style.marginTop = '-2px';
4998 - }  
4999 - else { 4876 + } else {
5000 this.commentButton.style.marginTop = '-5px'; 4877 this.commentButton.style.marginTop = '-5px';
5001 } 4878 }
5002 4879
@@ -5010,8 +4887,7 @@ App.prototype.updateButtonContainer = function () { @@ -5010,8 +4887,7 @@ App.prototype.updateButtonContainer = function () {
5010 this.commentButton.style.filter = 'invert(100%)'; 4887 this.commentButton.style.filter = 'invert(100%)';
5011 } 4888 }
5012 } 4889 }
5013 - }  
5014 - else if (this.commentButton != null) { 4890 + } else if (this.commentButton != null) {
5015 this.commentButton.parentNode.removeChild(this.commentButton); 4891 this.commentButton.parentNode.removeChild(this.commentButton);
5016 this.commentButton = null; 4892 this.commentButton = null;
5017 } 4893 }
@@ -5140,8 +5016,7 @@ App.prototype.updateButtonContainer = function () { @@ -5140,8 +5016,7 @@ App.prototype.updateButtonContainer = function () {
5140 this.rightContainer.appendChild(this.saveButton); 5016 this.rightContainer.appendChild(this.saveButton);
5141 5017
5142 } 5018 }
5143 - }  
5144 - else if (this.shareButton != null) { 5019 + } else if (this.shareButton != null) {
5145 this.shareButton.parentNode.removeChild(this.shareButton); 5020 this.shareButton.parentNode.removeChild(this.shareButton);
5146 this.shareButton = null; 5021 this.shareButton = null;
5147 this.saveButton.parentNode.removeChild(this.saveButton); 5022 this.saveButton.parentNode.removeChild(this.saveButton);
@@ -5160,8 +5035,7 @@ App.prototype.updateButtonContainer = function () { @@ -5160,8 +5035,7 @@ App.prototype.updateButtonContainer = function () {
5160 // TODO thingskit close notify bell 5035 // TODO thingskit close notify bell
5161 // this.fetchAndShowNotification('online', this.mode); 5036 // this.fetchAndShowNotification('online', this.mode);
5162 } 5037 }
5163 - }  
5164 - else if (urlParams['notif'] != null) //Notif for embed mode 5038 + } else if (urlParams['notif'] != null) //Notif for embed mode
5165 { 5039 {
5166 // TODO thingskit close notify bell 5040 // TODO thingskit close notify bell
5167 // this.fetchAndShowNotification(urlParams['notif']); 5041 // this.fetchAndShowNotification(urlParams['notif']);
@@ -5204,8 +5078,8 @@ App.prototype.fetchAndShowNotification = function (target, subtarget) { @@ -5204,8 +5078,8 @@ App.prototype.fetchAndShowNotification = function (target, subtarget) {
5204 if (localStorage != null) { 5078 if (localStorage != null) {
5205 cachedNotif = JSON.parse(localStorage.getItem(cachedNotifKey)); 5079 cachedNotif = JSON.parse(localStorage.getItem(cachedNotifKey));
5206 } 5080 }
5207 - }  
5208 - catch (e) { } //Ignore 5081 + } catch (e) {
  5082 + } //Ignore
5209 5083
5210 if (cachedNotif == null || cachedNotif.ts + 24 * 60 * 60 * 1000 < Date.now()) //Cache for one day 5084 if (cachedNotif == null || cachedNotif.ts + 24 * 60 * 60 * 1000 < Date.now()) //Cache for one day
5211 { 5085 {
@@ -5228,8 +5102,7 @@ App.prototype.fetchAndShowNotification = function (target, subtarget) { @@ -5228,8 +5102,7 @@ App.prototype.fetchAndShowNotification = function (target, subtarget) {
5228 processNotif(notifs); 5102 processNotif(notifs);
5229 } 5103 }
5230 })); 5104 }));
5231 - }  
5232 - else { 5105 + } else {
5233 processNotif(cachedNotif.notifs); 5106 processNotif(cachedNotif.notifs);
5234 } 5107 }
5235 }; 5108 };
@@ -5291,8 +5164,7 @@ App.prototype.showNotification = function (notifs, lsReadFlag) { @@ -5291,8 +5164,7 @@ App.prototype.showNotification = function (notifs, lsReadFlag) {
5291 if (uiTheme == 'min') { 5164 if (uiTheme == 'min') {
5292 this.notificationBtn.style.width = '30px'; 5165 this.notificationBtn.style.width = '30px';
5293 this.notificationBtn.style.top = '4px'; 5166 this.notificationBtn.style.top = '4px';
5294 - }  
5295 - else if (urlParams['atlas'] == '1') { 5167 + } else if (urlParams['atlas'] == '1') {
5296 this.notificationBtn.style.top = '2px'; 5168 this.notificationBtn.style.top = '2px';
5297 } 5169 }
5298 5170
@@ -5353,15 +5225,13 @@ App.prototype.showNotification = function (notifs, lsReadFlag) { @@ -5353,15 +5225,13 @@ App.prototype.showNotification = function (notifs, lsReadFlag) {
5353 this.notificationWin.style.top = (r.top + this.notificationBtn.clientHeight) + 'px'; 5225 this.notificationWin.style.top = (r.top + this.notificationBtn.clientHeight) + 'px';
5354 this.notificationWin.style.left = (r.right - this.notificationWin.clientWidth) + 'px'; 5226 this.notificationWin.style.left = (r.right - this.notificationWin.clientWidth) + 'px';
5355 shouldAnimate(0); //Stop animation once notifications are open 5227 shouldAnimate(0); //Stop animation once notifications are open
5356 - }  
5357 - else { 5228 + } else {
5358 markAllAsRead(); 5229 markAllAsRead();
5359 } 5230 }
5360 })); 5231 }));
5361 5232
5362 mxEvent.addListener(winClose, 'click', markAllAsRead); 5233 mxEvent.addListener(winClose, 'click', markAllAsRead);
5363 - }  
5364 - else { 5234 + } else {
5365 this.notificationBtn.style.display = ''; //In case it was hidden 5235 this.notificationBtn.style.display = ''; //In case it was hidden
5366 } 5236 }
5367 5237
@@ -5370,8 +5240,7 @@ App.prototype.showNotification = function (notifs, lsReadFlag) { @@ -5370,8 +5240,7 @@ App.prototype.showNotification = function (notifs, lsReadFlag) {
5370 5240
5371 if (notifListEl == null) { 5241 if (notifListEl == null) {
5372 return; //This shouldn't happen and no meaning of continuing 5242 return; //This shouldn't happen and no meaning of continuing
5373 - }  
5374 - else { 5243 + } else {
5375 notifListEl.innerHTML = '<div class="line"></div>'; 5244 notifListEl.innerHTML = '<div class="line"></div>';
5376 5245
5377 for (var i = 0; i < notifs.length; i++) { 5246 for (var i = 0; i < notifs.length; i++) {
@@ -5442,14 +5311,12 @@ App.prototype.save = function (name, done) { @@ -5442,14 +5311,12 @@ App.prototype.save = function (name, done) {
5442 try { 5311 try {
5443 if (name == file.getTitle()) { 5312 if (name == file.getTitle()) {
5444 file.save(true, success, error); 5313 file.save(true, success, error);
5445 - }  
5446 - else { 5314 + } else {
5447 file.saveAs(name, success, error) 5315 file.saveAs(name, success, error)
5448 } 5316 }
5449 5317
5450 console.log('file', file) 5318 console.log('file', file)
5451 - }  
5452 - catch (err) { 5319 + } catch (err) {
5453 error(err); 5320 error(err);
5454 } 5321 }
5455 } 5322 }
@@ -5479,8 +5346,7 @@ App.prototype.pickFolder = function (mode, fn, enabled, direct, force) { @@ -5479,8 +5346,7 @@ App.prototype.pickFolder = function (mode, fn, enabled, direct, force) {
5479 fn(folderId); 5346 fn(folderId);
5480 } 5347 }
5481 }), force); 5348 }), force);
5482 - }  
5483 - else if (enabled && mode == App.MODE_ONEDRIVE && this.oneDrive != null) { 5349 + } else if (enabled && mode == App.MODE_ONEDRIVE && this.oneDrive != null) {
5484 this.oneDrive.pickFolder(mxUtils.bind(this, function (files) { 5350 this.oneDrive.pickFolder(mxUtils.bind(this, function (files) {
5485 var folderId = null; 5351 var folderId = null;
5486 resume(); 5352 resume();
@@ -5490,26 +5356,22 @@ App.prototype.pickFolder = function (mode, fn, enabled, direct, force) { @@ -5490,26 +5356,22 @@ App.prototype.pickFolder = function (mode, fn, enabled, direct, force) {
5490 fn(folderId); 5356 fn(folderId);
5491 } 5357 }
5492 }), direct); 5358 }), direct);
5493 - }  
5494 - else if (enabled && mode == App.MODE_GITHUB && this.gitHub != null) { 5359 + } else if (enabled && mode == App.MODE_GITHUB && this.gitHub != null) {
5495 this.gitHub.pickFolder(mxUtils.bind(this, function (folderPath) { 5360 this.gitHub.pickFolder(mxUtils.bind(this, function (folderPath) {
5496 resume(); 5361 resume();
5497 fn(folderPath); 5362 fn(folderPath);
5498 })); 5363 }));
5499 - }  
5500 - else if (enabled && mode == App.MODE_GITLAB && this.gitLab != null) { 5364 + } else if (enabled && mode == App.MODE_GITLAB && this.gitLab != null) {
5501 this.gitLab.pickFolder(mxUtils.bind(this, function (folderPath) { 5365 this.gitLab.pickFolder(mxUtils.bind(this, function (folderPath) {
5502 resume(); 5366 resume();
5503 fn(folderPath); 5367 fn(folderPath);
5504 })); 5368 }));
5505 - }  
5506 - else if (enabled && mode == App.MODE_TRELLO && this.trello != null) { 5369 + } else if (enabled && mode == App.MODE_TRELLO && this.trello != null) {
5507 this.trello.pickFolder(mxUtils.bind(this, function (cardId) { 5370 this.trello.pickFolder(mxUtils.bind(this, function (cardId) {
5508 resume(); 5371 resume();
5509 fn(cardId); 5372 fn(cardId);
5510 })); 5373 }));
5511 - }  
5512 - else { 5374 + } else {
5513 EditorUi.prototype.pickFolder.apply(this, arguments); 5375 EditorUi.prototype.pickFolder.apply(this, arguments);
5514 } 5376 }
5515 }; 5377 };
@@ -5529,8 +5391,7 @@ App.prototype.exportFile = function (data, filename, mimeType, base64Encoded, mo @@ -5529,8 +5391,7 @@ App.prototype.exportFile = function (data, filename, mimeType, base64Encoded, mo
5529 this.handleError(resp); 5391 this.handleError(resp);
5530 })); 5392 }));
5531 } 5393 }
5532 - }  
5533 - else if (mode == App.MODE_GOOGLE) { 5394 + } else if (mode == App.MODE_GOOGLE) {
5534 if (this.drive != null && this.spinner.spin(document.body, mxResources.get('saving'))) { 5395 if (this.drive != null && this.spinner.spin(document.body, mxResources.get('saving'))) {
5535 this.drive.insertFile(filename, data, folderId, mxUtils.bind(this, function (resp) { 5396 this.drive.insertFile(filename, data, folderId, mxUtils.bind(this, function (resp) {
5536 // TODO: Add callback with url param for clickable status message 5397 // TODO: Add callback with url param for clickable status message
@@ -5563,8 +5424,7 @@ App.prototype.exportFile = function (data, filename, mimeType, base64Encoded, mo @@ -5563,8 +5424,7 @@ App.prototype.exportFile = function (data, filename, mimeType, base64Encoded, mo
5563 this.handleError(resp); 5424 this.handleError(resp);
5564 }), mimeType, base64Encoded); 5425 }), mimeType, base64Encoded);
5565 } 5426 }
5566 - }  
5567 - else if (mode == App.MODE_ONEDRIVE) { 5427 + } else if (mode == App.MODE_ONEDRIVE) {
5568 if (this.oneDrive != null && this.spinner.spin(document.body, mxResources.get('saving'))) { 5428 if (this.oneDrive != null && this.spinner.spin(document.body, mxResources.get('saving'))) {
5569 // KNOWN: OneDrive does not show .svg extension 5429 // KNOWN: OneDrive does not show .svg extension
5570 this.oneDrive.insertFile(filename, (base64Encoded) ? this.base64ToBlob(data, mimeType) : 5430 this.oneDrive.insertFile(filename, (base64Encoded) ? this.base64ToBlob(data, mimeType) :
@@ -5575,8 +5435,7 @@ App.prototype.exportFile = function (data, filename, mimeType, base64Encoded, mo @@ -5575,8 +5435,7 @@ App.prototype.exportFile = function (data, filename, mimeType, base64Encoded, mo
5575 this.handleError(resp); 5435 this.handleError(resp);
5576 }), false, folderId); 5436 }), false, folderId);
5577 } 5437 }
5578 - }  
5579 - else if (mode == App.MODE_GITHUB) { 5438 + } else if (mode == App.MODE_GITHUB) {
5580 if (this.gitHub != null && this.spinner.spin(document.body, mxResources.get('saving'))) { 5439 if (this.gitHub != null && this.spinner.spin(document.body, mxResources.get('saving'))) {
5581 // Must insert file as library to force the file to be written 5440 // Must insert file as library to force the file to be written
5582 this.gitHub.insertFile(filename, data, mxUtils.bind(this, function () { 5441 this.gitHub.insertFile(filename, data, mxUtils.bind(this, function () {
@@ -5586,8 +5445,7 @@ App.prototype.exportFile = function (data, filename, mimeType, base64Encoded, mo @@ -5586,8 +5445,7 @@ App.prototype.exportFile = function (data, filename, mimeType, base64Encoded, mo
5586 this.handleError(resp); 5445 this.handleError(resp);
5587 }), true, folderId, base64Encoded); 5446 }), true, folderId, base64Encoded);
5588 } 5447 }
5589 - }  
5590 - else if (mode == App.MODE_GITLAB) { 5448 + } else if (mode == App.MODE_GITLAB) {
5591 if (this.gitHub != null && this.spinner.spin(document.body, mxResources.get('saving'))) { 5449 if (this.gitHub != null && this.spinner.spin(document.body, mxResources.get('saving'))) {
5592 // Must insert file as library to force the file to be written 5450 // Must insert file as library to force the file to be written
5593 this.gitLab.insertFile(filename, data, mxUtils.bind(this, function () { 5451 this.gitLab.insertFile(filename, data, mxUtils.bind(this, function () {
@@ -5597,8 +5455,7 @@ App.prototype.exportFile = function (data, filename, mimeType, base64Encoded, mo @@ -5597,8 +5455,7 @@ App.prototype.exportFile = function (data, filename, mimeType, base64Encoded, mo
5597 this.handleError(resp); 5455 this.handleError(resp);
5598 }), true, folderId, base64Encoded); 5456 }), true, folderId, base64Encoded);
5599 } 5457 }
5600 - }  
5601 - else if (mode == App.MODE_TRELLO) { 5458 + } else if (mode == App.MODE_TRELLO) {
5602 if (this.trello != null && this.spinner.spin(document.body, mxResources.get('saving'))) { 5459 if (this.trello != null && this.spinner.spin(document.body, mxResources.get('saving'))) {
5603 this.trello.insertFile(filename, (base64Encoded) ? this.base64ToBlob(data, mimeType) : 5460 this.trello.insertFile(filename, (base64Encoded) ? this.base64ToBlob(data, mimeType) :
5604 data, mxUtils.bind(this, function () { 5461 data, mxUtils.bind(this, function () {
@@ -5608,16 +5465,14 @@ App.prototype.exportFile = function (data, filename, mimeType, base64Encoded, mo @@ -5608,16 +5465,14 @@ App.prototype.exportFile = function (data, filename, mimeType, base64Encoded, mo
5608 this.handleError(resp); 5465 this.handleError(resp);
5609 }), false, folderId); 5466 }), false, folderId);
5610 } 5467 }
5611 - }  
5612 - else if (mode == App.MODE_BROWSER) { 5468 + } else if (mode == App.MODE_BROWSER) {
5613 var fn = mxUtils.bind(this, function () { 5469 var fn = mxUtils.bind(this, function () {
5614 localStorage.setItem(filename, data); 5470 localStorage.setItem(filename, data);
5615 }); 5471 });
5616 5472
5617 if (localStorage.getItem(filename) == null) { 5473 if (localStorage.getItem(filename) == null) {
5618 fn(); 5474 fn();
5619 - }  
5620 - else { 5475 + } else {
5621 this.confirm(mxResources.get('replaceIt', [filename]), fn); 5476 this.confirm(mxResources.get('replaceIt', [filename]), fn);
5622 } 5477 }
5623 } 5478 }
@@ -5657,8 +5512,7 @@ App.prototype.descriptorChanged = function () { @@ -5657,8 +5512,7 @@ App.prototype.descriptorChanged = function () {
5657 5512
5658 if (newHash.length > 0) { 5513 if (newHash.length > 0) {
5659 window.location.hash = newHash; 5514 window.location.hash = newHash;
5660 - }  
5661 - else if (window.location.hash.length > 0) { 5515 + } else if (window.location.hash.length > 0) {
5662 window.location.hash = ''; 5516 window.location.hash = '';
5663 } 5517 }
5664 } 5518 }
@@ -5691,8 +5545,7 @@ App.prototype.showAuthDialog = function (peer, showRememberOption, fn, closeFn) @@ -5691,8 +5545,7 @@ App.prototype.showAuthDialog = function (peer, showRememberOption, fn, closeFn)
5691 resume(); 5545 resume();
5692 })); 5546 }));
5693 } 5547 }
5694 - }  
5695 - catch (e) { 5548 + } catch (e) {
5696 this.editor.setStatus(mxUtils.htmlEntities(e.message)); 5549 this.editor.setStatus(mxUtils.htmlEntities(e.message));
5697 } 5550 }
5698 })).container, 300, (showRememberOption) ? 180 : 140, true, true, mxUtils.bind(this, function (cancel) { 5551 })).container, 300, (showRememberOption) ? 180 : 140, true, true, mxUtils.bind(this, function (cancel) {
@@ -5748,24 +5601,21 @@ App.prototype.convertFile = function (url, filename, mimeType, extension, succes @@ -5748,24 +5601,21 @@ App.prototype.convertFile = function (url, filename, mimeType, extension, succes
5748 if (gitHubUrl) { 5601 if (gitHubUrl) {
5749 var file = JSON.parse(req.responseText); 5602 var file = JSON.parse(req.responseText);
5750 blob = this.base64ToBlob(file.content, 'application/octet-stream'); 5603 blob = this.base64ToBlob(file.content, 'application/octet-stream');
5751 - }  
5752 - else { 5604 + } else {
5753 blob = new Blob([req.response], { type: 'application/octet-stream' }); 5605 blob = new Blob([req.response], { type: 'application/octet-stream' });
5754 } 5606 }
5755 5607
5756 this.importVisio(blob, mxUtils.bind(this, function (xml) { 5608 this.importVisio(blob, mxUtils.bind(this, function (xml) {
5757 success(new LocalFile(this, xml, name, true)); 5609 success(new LocalFile(this, xml, name, true));
5758 }), error, filename) 5610 }), error, filename)
5759 - }  
5760 - else if (error != null) { 5611 + } else if (error != null) {
5761 error({ message: mxResources.get('errorLoadingFile') }); 5612 error({ message: mxResources.get('errorLoadingFile') });
5762 } 5613 }
5763 }); 5614 });
5764 5615
5765 req.onerror = error; 5616 req.onerror = error;
5766 req.send(); 5617 req.send();
5767 - }  
5768 - else { 5618 + } else {
5769 var handleData = mxUtils.bind(this, function (data) { 5619 var handleData = mxUtils.bind(this, function (data) {
5770 try { 5620 try {
5771 if (/\.pdf$/i.test(filename)) { 5621 if (/\.pdf$/i.test(filename)) {
@@ -5774,34 +5624,28 @@ App.prototype.convertFile = function (url, filename, mimeType, extension, succes @@ -5774,34 +5624,28 @@ App.prototype.convertFile = function (url, filename, mimeType, extension, succes
5774 if (temp != null && temp.length > 0) { 5624 if (temp != null && temp.length > 0) {
5775 success(new LocalFile(this, temp, name, true)); 5625 success(new LocalFile(this, temp, name, true));
5776 } 5626 }
5777 - }  
5778 - else if (/\.png$/i.test(filename)) { 5627 + } else if (/\.png$/i.test(filename)) {
5779 var temp = this.extractGraphModelFromPng(data); 5628 var temp = this.extractGraphModelFromPng(data);
5780 5629
5781 if (temp != null) { 5630 if (temp != null) {
5782 success(new LocalFile(this, temp, name, true)); 5631 success(new LocalFile(this, temp, name, true));
5783 - }  
5784 - else { 5632 + } else {
5785 success(new LocalFile(this, data, filename, true)); 5633 success(new LocalFile(this, data, filename, true));
5786 } 5634 }
5787 - }  
5788 - else if (Graph.fileSupport && new XMLHttpRequest().upload && this.isRemoteFileFormat(data, url)) { 5635 + } else if (Graph.fileSupport && new XMLHttpRequest().upload && this.isRemoteFileFormat(data, url)) {
5789 this.parseFileData(data, mxUtils.bind(this, function (xhr) { 5636 this.parseFileData(data, mxUtils.bind(this, function (xhr) {
5790 if (xhr.readyState == 4) { 5637 if (xhr.readyState == 4) {
5791 if (xhr.status >= 200 && xhr.status <= 299) { 5638 if (xhr.status >= 200 && xhr.status <= 299) {
5792 success(new LocalFile(this, xhr.responseText, name, true)); 5639 success(new LocalFile(this, xhr.responseText, name, true));
5793 - }  
5794 - else if (error != null) { 5640 + } else if (error != null) {
5795 error({ message: mxResources.get('errorLoadingFile') }); 5641 error({ message: mxResources.get('errorLoadingFile') });
5796 } 5642 }
5797 } 5643 }
5798 }), filename); 5644 }), filename);
5799 - }  
5800 - else { 5645 + } else {
5801 success(new LocalFile(this, data, name, true)); 5646 success(new LocalFile(this, data, name, true));
5802 } 5647 }
5803 - }  
5804 - catch (e) { 5648 + } catch (e) {
5805 if (error != null) { 5649 if (error != null) {
5806 error(e); 5650 error(e);
5807 } 5651 }
@@ -5824,11 +5668,9 @@ App.prototype.convertFile = function (url, filename, mimeType, extension, succes @@ -5824,11 +5668,9 @@ App.prototype.convertFile = function (url, filename, mimeType, extension, succes
5824 if (file.encoding === 'base64') { 5668 if (file.encoding === 'base64') {
5825 if (/\.png$/i.test(filename)) { 5669 if (/\.png$/i.test(filename)) {
5826 data = 'data:image/png;base64,' + data; 5670 data = 'data:image/png;base64,' + data;
5827 - }  
5828 - else if (/\.pdf$/i.test(filename)) { 5671 + } else if (/\.pdf$/i.test(filename)) {
5829 data = 'data:application/pdf;base64,' + data; 5672 data = 'data:application/pdf;base64,' + data;
5830 - }  
5831 - else { 5673 + } else {
5832 // Workaround for character encoding issues in IE10/11 5674 // Workaround for character encoding issues in IE10/11
5833 data = (window.atob && !mxClient.IS_IE && !mxClient.IS_IE11) ? atob(data) : Base64.decode(data); 5675 data = (window.atob && !mxClient.IS_IE && !mxClient.IS_IE11) ? atob(data) : Base64.decode(data);
5834 } 5676 }
@@ -5836,8 +5678,7 @@ App.prototype.convertFile = function (url, filename, mimeType, extension, succes @@ -5836,8 +5678,7 @@ App.prototype.convertFile = function (url, filename, mimeType, extension, succes
5836 5678
5837 handleData(data); 5679 handleData(data);
5838 } 5680 }
5839 - }  
5840 - else if (error != null) { 5681 + } else if (error != null) {
5841 error({ code: App.ERROR_UNKNOWN }); 5682 error({ code: App.ERROR_UNKNOWN });
5842 } 5683 }
5843 }), function () { 5684 }), function () {
@@ -5849,11 +5690,9 @@ App.prototype.convertFile = function (url, filename, mimeType, extension, succes @@ -5849,11 +5690,9 @@ App.prototype.convertFile = function (url, filename, mimeType, extension, succes
5849 error({ code: App.ERROR_TIMEOUT, retry: fn }); 5690 error({ code: App.ERROR_TIMEOUT, retry: fn });
5850 } 5691 }
5851 }, headers); 5692 }, headers);
5852 - }  
5853 - else if (executeRequest != null) { 5693 + } else if (executeRequest != null) {
5854 executeRequest(url, handleData, error, binary); 5694 executeRequest(url, handleData, error, binary);
5855 - }  
5856 - else { 5695 + } else {
5857 this.editor.loadUrl(url, handleData, error, binary, null, null, null, headers); 5696 this.editor.loadUrl(url, handleData, error, binary, null, null, null, headers);
5858 } 5697 }
5859 } 5698 }
@@ -5908,24 +5747,19 @@ App.prototype.updateHeader = function () { @@ -5908,24 +5747,19 @@ App.prototype.updateHeader = function () {
5908 if (mode == App.MODE_GOOGLE) { 5747 if (mode == App.MODE_GOOGLE) {
5909 this.appIcon.style.backgroundImage = 'url(' + IMAGE_PATH + '/google-drive-logo-white.svg)'; 5748 this.appIcon.style.backgroundImage = 'url(' + IMAGE_PATH + '/google-drive-logo-white.svg)';
5910 this.appIcon.style.backgroundSize = '70% 70%'; 5749 this.appIcon.style.backgroundSize = '70% 70%';
5911 - }  
5912 - else if (mode == App.MODE_DROPBOX) { 5750 + } else if (mode == App.MODE_DROPBOX) {
5913 this.appIcon.style.backgroundImage = 'url(' + IMAGE_PATH + '/dropbox-logo-white.svg)'; 5751 this.appIcon.style.backgroundImage = 'url(' + IMAGE_PATH + '/dropbox-logo-white.svg)';
5914 this.appIcon.style.backgroundSize = '70% 70%'; 5752 this.appIcon.style.backgroundSize = '70% 70%';
5915 - }  
5916 - else if (mode == App.MODE_ONEDRIVE) { 5753 + } else if (mode == App.MODE_ONEDRIVE) {
5917 this.appIcon.style.backgroundImage = 'url(' + IMAGE_PATH + '/onedrive-logo-white.svg)'; 5754 this.appIcon.style.backgroundImage = 'url(' + IMAGE_PATH + '/onedrive-logo-white.svg)';
5918 this.appIcon.style.backgroundSize = '70% 70%'; 5755 this.appIcon.style.backgroundSize = '70% 70%';
5919 - }  
5920 - else if (mode == App.MODE_GITHUB) { 5756 + } else if (mode == App.MODE_GITHUB) {
5921 this.appIcon.style.backgroundImage = 'url(' + IMAGE_PATH + '/github-logo-white.svg)'; 5757 this.appIcon.style.backgroundImage = 'url(' + IMAGE_PATH + '/github-logo-white.svg)';
5922 this.appIcon.style.backgroundSize = '70% 70%'; 5758 this.appIcon.style.backgroundSize = '70% 70%';
5923 - }  
5924 - else if (mode == App.MODE_GITLAB) { 5759 + } else if (mode == App.MODE_GITLAB) {
5925 this.appIcon.style.backgroundImage = 'url(' + IMAGE_PATH + '/gitlab-logo-white.svg)'; 5760 this.appIcon.style.backgroundImage = 'url(' + IMAGE_PATH + '/gitlab-logo-white.svg)';
5926 this.appIcon.style.backgroundSize = '100% 100%'; 5761 this.appIcon.style.backgroundSize = '100% 100%';
5927 - }  
5928 - else if (mode == App.MODE_TRELLO) { 5762 + } else if (mode == App.MODE_TRELLO) {
5929 this.appIcon.style.backgroundImage = 'url(' + IMAGE_PATH + '/trello-logo-white-orange.svg)'; 5763 this.appIcon.style.backgroundImage = 'url(' + IMAGE_PATH + '/trello-logo-white-orange.svg)';
5930 this.appIcon.style.backgroundSize = '70% 70%'; 5764 this.appIcon.style.backgroundSize = '70% 70%';
5931 } 5765 }
@@ -6037,8 +5871,7 @@ App.prototype.updateHeader = function () { @@ -6037,8 +5871,7 @@ App.prototype.updateHeader = function () {
6037 var toggleFormatPanel = mxUtils.bind(this, function () { 5871 var toggleFormatPanel = mxUtils.bind(this, function () {
6038 if (this.formatWidth > 0) { 5872 if (this.formatWidth > 0) {
6039 this.toggleFormatElement.style.backgroundImage = 'url(\'' + this.formatShowImage + '\')'; 5873 this.toggleFormatElement.style.backgroundImage = 'url(\'' + this.formatShowImage + '\')';
6040 - }  
6041 - else { 5874 + } else {
6042 this.toggleFormatElement.style.backgroundImage = 'url(\'' + this.formatHideImage + '\')'; 5875 this.toggleFormatElement.style.backgroundImage = 'url(\'' + this.formatHideImage + '\')';
6043 } 5876 }
6044 }); 5877 });
@@ -6180,8 +6013,7 @@ App.prototype.toggleCompactMode = function (visible) { @@ -6180,8 +6013,7 @@ App.prototype.toggleCompactMode = function (visible) {
6180 this.menubarHeight = App.prototype.menubarHeight; 6013 this.menubarHeight = App.prototype.menubarHeight;
6181 this.refresh(); 6014 this.refresh();
6182 this.toggleElement.style.backgroundImage = 'url(\'' + this.chevronUpImage + '\')'; 6015 this.toggleElement.style.backgroundImage = 'url(\'' + this.chevronUpImage + '\')';
6183 - }  
6184 - else { 6016 + } else {
6185 this.menubar.container.style.position = 'relative'; 6017 this.menubar.container.style.position = 'relative';
6186 this.menubar.container.style.paddingLeft = '4px'; 6018 this.menubar.container.style.paddingLeft = '4px';
6187 this.menubar.container.style.paddingTop = '0px'; 6019 this.menubar.container.style.paddingTop = '0px';
@@ -6216,8 +6048,7 @@ App.prototype.updateUserElement = function () { @@ -6216,8 +6048,7 @@ App.prototype.updateUserElement = function () {
6216 this.userElement.parentNode.removeChild(this.userElement); 6048 this.userElement.parentNode.removeChild(this.userElement);
6217 this.userElement = null; 6049 this.userElement = null;
6218 } 6050 }
6219 - }  
6220 - else { 6051 + } else {
6221 if (this.userElement == null) { 6052 if (this.userElement == null) {
6222 this.userElement = document.createElement('a'); 6053 this.userElement = document.createElement('a');
6223 this.userElement.className = 'geItem'; 6054 this.userElement.className = 'geItem';
@@ -6259,8 +6090,7 @@ App.prototype.updateUserElement = function () { @@ -6259,8 +6090,7 @@ App.prototype.updateUserElement = function () {
6259 6090
6260 if (this.userPanel.parentNode != null) { 6091 if (this.userPanel.parentNode != null) {
6261 this.userPanel.parentNode.removeChild(this.userPanel); 6092 this.userPanel.parentNode.removeChild(this.userPanel);
6262 - }  
6263 - else { 6093 + } else {
6264 var connected = false; 6094 var connected = false;
6265 this.userPanel.innerHTML = ''; 6095 this.userPanel.innerHTML = '';
6266 6096
@@ -6300,8 +6130,7 @@ App.prototype.updateUserElement = function () { @@ -6300,8 +6130,7 @@ App.prototype.updateUserElement = function () {
6300 this.spinner.stop(); 6130 this.spinner.stop();
6301 callback(); 6131 callback();
6302 }), 2000); 6132 }), 2000);
6303 - }  
6304 - else { 6133 + } else {
6305 callback(); 6134 callback();
6306 } 6135 }
6307 }); 6136 });
@@ -6531,13 +6360,11 @@ App.prototype.updateUserElement = function () { @@ -6531,13 +6360,11 @@ App.prototype.updateUserElement = function () {
6531 6360
6532 if (!file.isModified()) { 6361 if (!file.isModified()) {
6533 doLogout(); 6362 doLogout();
6534 - }  
6535 - else { 6363 + } else {
6536 this.confirm(mxResources.get('allChangesLost'), null, doLogout, 6364 this.confirm(mxResources.get('allChangesLost'), null, doLogout,
6537 mxResources.get('cancel'), mxResources.get('discardChanges')); 6365 mxResources.get('cancel'), mxResources.get('discardChanges'));
6538 } 6366 }
6539 - }  
6540 - else { 6367 + } else {
6541 this.dropbox.logout(); 6368 this.dropbox.logout();
6542 } 6369 }
6543 }), mxResources.get('dropbox')); 6370 }), mxResources.get('dropbox'));
@@ -6555,13 +6382,11 @@ App.prototype.updateUserElement = function () { @@ -6555,13 +6382,11 @@ App.prototype.updateUserElement = function () {
6555 6382
6556 if (!file.isModified()) { 6383 if (!file.isModified()) {
6557 doLogout(); 6384 doLogout();
6558 - }  
6559 - else { 6385 + } else {
6560 this.confirm(mxResources.get('allChangesLost'), null, doLogout, 6386 this.confirm(mxResources.get('allChangesLost'), null, doLogout,
6561 mxResources.get('cancel'), mxResources.get('discardChanges')); 6387 mxResources.get('cancel'), mxResources.get('discardChanges'));
6562 } 6388 }
6563 - }  
6564 - else { 6389 + } else {
6565 this.oneDrive.logout(); 6390 this.oneDrive.logout();
6566 } 6391 }
6567 }), mxResources.get('oneDrive')); 6392 }), mxResources.get('oneDrive'));
@@ -6579,13 +6404,11 @@ App.prototype.updateUserElement = function () { @@ -6579,13 +6404,11 @@ App.prototype.updateUserElement = function () {
6579 6404
6580 if (!file.isModified()) { 6405 if (!file.isModified()) {
6581 doLogout(); 6406 doLogout();
6582 - }  
6583 - else { 6407 + } else {
6584 this.confirm(mxResources.get('allChangesLost'), null, doLogout, 6408 this.confirm(mxResources.get('allChangesLost'), null, doLogout,
6585 mxResources.get('cancel'), mxResources.get('discardChanges')); 6409 mxResources.get('cancel'), mxResources.get('discardChanges'));
6586 } 6410 }
6587 - }  
6588 - else { 6411 + } else {
6589 this.gitHub.logout(); 6412 this.gitHub.logout();
6590 } 6413 }
6591 }), mxResources.get('github')); 6414 }), mxResources.get('github'));
@@ -6603,13 +6426,11 @@ App.prototype.updateUserElement = function () { @@ -6603,13 +6426,11 @@ App.prototype.updateUserElement = function () {
6603 6426
6604 if (!file.isModified()) { 6427 if (!file.isModified()) {
6605 doLogout(); 6428 doLogout();
6606 - }  
6607 - else { 6429 + } else {
6608 this.confirm(mxResources.get('allChangesLost'), null, doLogout, 6430 this.confirm(mxResources.get('allChangesLost'), null, doLogout,
6609 mxResources.get('cancel'), mxResources.get('discardChanges')); 6431 mxResources.get('cancel'), mxResources.get('discardChanges'));
6610 } 6432 }
6611 - }  
6612 - else { 6433 + } else {
6613 this.gitLab.logout(); 6434 this.gitLab.logout();
6614 } 6435 }
6615 }), mxResources.get('gitlab')); 6436 }), mxResources.get('gitlab'));
@@ -6628,13 +6449,11 @@ App.prototype.updateUserElement = function () { @@ -6628,13 +6449,11 @@ App.prototype.updateUserElement = function () {
6628 6449
6629 if (!file.isModified()) { 6450 if (!file.isModified()) {
6630 doLogout(); 6451 doLogout();
6631 - }  
6632 - else { 6452 + } else {
6633 this.confirm(mxResources.get('allChangesLost'), null, doLogout, 6453 this.confirm(mxResources.get('allChangesLost'), null, doLogout,
6634 mxResources.get('cancel'), mxResources.get('discardChanges')); 6454 mxResources.get('cancel'), mxResources.get('discardChanges'));
6635 } 6455 }
6636 - }  
6637 - else { 6456 + } else {
6638 this.trello.logout(); 6457 this.trello.logout();
6639 } 6458 }
6640 }), mxResources.get('trello')); 6459 }), mxResources.get('trello'));
@@ -6672,8 +6491,7 @@ App.prototype.updateUserElement = function () { @@ -6672,8 +6491,7 @@ App.prototype.updateUserElement = function () {
6672 div.appendChild(btn); 6491 div.appendChild(btn);
6673 this.userPanel.appendChild(div); 6492 this.userPanel.appendChild(div);
6674 } 6493 }
6675 - }  
6676 - else { 6494 + } else {
6677 var btn = mxUtils.button(mxResources.get('close'), mxUtils.bind(this, function () { 6495 var btn = mxUtils.button(mxResources.get('close'), mxUtils.bind(this, function () {
6678 if (!mxEvent.isConsumed(evt) && this.userPanel != null && this.userPanel.parentNode != null) { 6496 if (!mxEvent.isConsumed(evt) && this.userPanel != null && this.userPanel.parentNode != null) {
6679 this.userPanel.parentNode.removeChild(this.userPanel); 6497 this.userPanel.parentNode.removeChild(this.userPanel);
@@ -6701,17 +6519,13 @@ App.prototype.updateUserElement = function () { @@ -6701,17 +6519,13 @@ App.prototype.updateUserElement = function () {
6701 6519
6702 if (this.drive != null && this.drive.getUser() != null) { 6520 if (this.drive != null && this.drive.getUser() != null) {
6703 user = this.drive.getUser(); 6521 user = this.drive.getUser();
6704 - }  
6705 - else if (this.oneDrive != null && this.oneDrive.getUser() != null) { 6522 + } else if (this.oneDrive != null && this.oneDrive.getUser() != null) {
6706 user = this.oneDrive.getUser(); 6523 user = this.oneDrive.getUser();
6707 - }  
6708 - else if (this.dropbox != null && this.dropbox.getUser() != null) { 6524 + } else if (this.dropbox != null && this.dropbox.getUser() != null) {
6709 user = this.dropbox.getUser(); 6525 user = this.dropbox.getUser();
6710 - }  
6711 - else if (this.gitHub != null && this.gitHub.getUser() != null) { 6526 + } else if (this.gitHub != null && this.gitHub.getUser() != null) {
6712 user = this.gitHub.getUser(); 6527 user = this.gitHub.getUser();
6713 - }  
6714 - else if (this.gitLab != null && this.gitLab.getUser() != null) { 6528 + } else if (this.gitLab != null && this.gitLab.getUser() != null) {
6715 user = this.gitLab.getUser(); 6529 user = this.gitLab.getUser();
6716 } 6530 }
6717 //TODO Trello no user issue 6531 //TODO Trello no user issue
@@ -6723,8 +6537,7 @@ App.prototype.updateUserElement = function () { @@ -6723,8 +6537,7 @@ App.prototype.updateUserElement = function () {
6723 mxUtils.write(this.userElement, user.displayName); 6537 mxUtils.write(this.userElement, user.displayName);
6724 this.userElement.style.display = 'block'; 6538 this.userElement.style.display = 'block';
6725 } 6539 }
6726 - }  
6727 - else { 6540 + } else {
6728 this.userElement.style.display = 'none'; 6541 this.userElement.style.display = 'none';
6729 } 6542 }
6730 } 6543 }
@@ -6736,14 +6549,11 @@ App.prototype.getCurrentUser = function () { @@ -6736,14 +6549,11 @@ App.prototype.getCurrentUser = function () {
6736 6549
6737 if (this.drive != null && this.drive.getUser() != null) { 6550 if (this.drive != null && this.drive.getUser() != null) {
6738 user = this.drive.getUser(); 6551 user = this.drive.getUser();
6739 - }  
6740 - else if (this.oneDrive != null && this.oneDrive.getUser() != null) { 6552 + } else if (this.oneDrive != null && this.oneDrive.getUser() != null) {
6741 user = this.oneDrive.getUser(); 6553 user = this.oneDrive.getUser();
6742 - }  
6743 - else if (this.dropbox != null && this.dropbox.getUser() != null) { 6554 + } else if (this.dropbox != null && this.dropbox.getUser() != null) {
6744 user = this.dropbox.getUser(); 6555 user = this.dropbox.getUser();
6745 - }  
6746 - else if (this.gitHub != null && this.gitHub.getUser() != null) { 6556 + } else if (this.gitHub != null && this.gitHub.getUser() != null) {
6747 user = this.gitHub.getUser(); 6557 user = this.gitHub.getUser();
6748 } 6558 }
6749 //TODO Trello no user issue 6559 //TODO Trello no user issue
@@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
26 * 26 *
27 */ 27 */
28 // Sidebar.prototype.defaultEntries = 'component;fan;engine;valve;controller;light;button;conduit;instrument;sewage;air;filters;pumps;factoryFacilities;flowMeter;foodProcessing;heater;industrial;plant;power;processCooling;processHeating;sink;'; 28 // Sidebar.prototype.defaultEntries = 'component;fan;engine;valve;controller;light;button;conduit;instrument;sewage;air;filters;pumps;factoryFacilities;flowMeter;foodProcessing;heater;industrial;plant;power;processCooling;processHeating;sink;';
29 - Sidebar.prototype.defaultEntries = 'component;fan;engine;valve;control;light;button;conduit;instrument;sewage;factoryFacilities;flowMeter;industrial;sink;'; 29 + Sidebar.prototype.defaultEntries = 'basicComponent;fan;engine;valve;control;light;button;conduit;instrument;sewage;factoryFacilities;flowMeter;industrial;sink;';
30 30
31 /** 31 /**
32 * Library definitions 32 * Library definitions
@@ -373,7 +373,7 @@ @@ -373,7 +373,7 @@
373 Sidebar.prototype.configuration = [ 373 Sidebar.prototype.configuration = [
374 { id: 'general', libs: ['general', 'misc', 'advanced'] }, 374 { id: 'general', libs: ['general', 'misc', 'advanced'] },
375 //加入自定义图形ID 375 //加入自定义图形ID
376 - { id: 'fan' }, { id: 'engine' }, { id: 'valve' }, { id: 'component' }, { id: 'control' }, { id: 'sewage' }, { id: 'conduit' }, { id: 'light' }, { id: 'instrument' }, { id: 'button' }, 376 + { id: 'fan' }, { id: 'engine' }, { id: 'valve' }, { id: 'basicComponent' }, { id: 'control' }, { id: 'sewage' }, { id: 'conduit' }, { id: 'light' }, { id: 'instrument' }, { id: 'button' },
377 { id: 'air' }, { id: 'filters' }, { id: 'pumps' }, { id: 'factoryFacilities' }, { id: 'flowMeter' }, { id: 'foodProcessing' }, { id: 'heater' }, { id: 'industrial' }, { id: 'plant' }, { id: 'power' }, { id: 'processCooling' }, { id: 'processHeating' }, { id: 'sink' }, 377 { id: 'air' }, { id: 'filters' }, { id: 'pumps' }, { id: 'factoryFacilities' }, { id: 'flowMeter' }, { id: 'foodProcessing' }, { id: 'heater' }, { id: 'industrial' }, { id: 'plant' }, { id: 'power' }, { id: 'processCooling' }, { id: 'processHeating' }, { id: 'sink' },
378 378
379 379
@@ -744,7 +744,7 @@ @@ -744,7 +744,7 @@
744 { title: "风机", id: 'fan', image: IMAGE_PATH + '/thingskit/风机.png' }, 744 { title: "风机", id: 'fan', image: IMAGE_PATH + '/thingskit/风机.png' },
745 { title: "发动机", id: 'engine', image: IMAGE_PATH + '/thingskit/发动机.png' }, 745 { title: "发动机", id: 'engine', image: IMAGE_PATH + '/thingskit/发动机.png' },
746 { title: "阀门", id: 'valve', image: IMAGE_PATH + '/thingskit/阀门.png' }, 746 { title: "阀门", id: 'valve', image: IMAGE_PATH + '/thingskit/阀门.png' },
747 - { title: "基础组件", id: 'component', image: IMAGE_PATH + '/thingskit/基础元件.png' }, 747 + { title: "基础组件", id: 'basicComponent', image: IMAGE_PATH + '/thingskit/基础元件.png' },
748 { title: "污水处理", id: 'sewage', image: IMAGE_PATH + '/thingskit/污水处理.png' }, 748 { title: "污水处理", id: 'sewage', image: IMAGE_PATH + '/thingskit/污水处理.png' },
749 { title: "管道", id: 'conduit', image: IMAGE_PATH + '/thingskit/管道.png' }, 749 { title: "管道", id: 'conduit', image: IMAGE_PATH + '/thingskit/管道.png' },
750 { title: "灯", id: 'light', image: IMAGE_PATH + '/thingskit/灯.png' }, 750 { title: "灯", id: 'light', image: IMAGE_PATH + '/thingskit/灯.png' },
1 (function () { 1 (function () {
2 // Adds Atlassian shapes 2 // Adds Atlassian shapes
3 Sidebar.prototype.addBasicComponentsPalette = function () { 3 Sidebar.prototype.addBasicComponentsPalette = function () {
4 - this.setCurrentSearchEntryLibrary('component');  
5 - const dt = 'basic' 4 + this.setCurrentSearchEntryLibrary('basicComponent');
  5 + const dt = 'basicComponent'
6 const gn = `mxgraph.${dt}` 6 const gn = `mxgraph.${dt}`
7 const currentDate = getCurrentDate(); 7 const currentDate = getCurrentDate();
8 const basicAttr = this.enumCellBasicAttribute 8 const basicAttr = this.enumCellBasicAttribute
@@ -46,20 +46,20 @@ @@ -46,20 +46,20 @@
46 }) 46 })
47 return this.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, '实时时间'); 47 return this.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, '实时时间');
48 })), 48 })),
49 - this.addEntry(this.getTagsForStencil('mxgraph.basic', '变量图片', 'basic').join(' '), mxUtils.bind(this, function () { 49 + this.addEntry(this.getTagsForStencil(gn, '变量图片', 'basic').join(' '), mxUtils.bind(this, function () {
50 const cell = new mxCell('', new mxGeometry(0, 0, 194, 95), 'image;image=images/thingskit/img-placeholder.png;imageAspect=0;'); 50 const cell = new mxCell('', new mxGeometry(0, 0, 194, 95), 'image;image=images/thingskit/img-placeholder.png;imageAspect=0;');
51 cell.setVertex(true) 51 cell.setVertex(true)
52 this.setCellAttributes(cell, { [basicAttr.COMPONENT_TYPE]: componentType.VAR_IMAGE }) 52 this.setCellAttributes(cell, { [basicAttr.COMPONENT_TYPE]: componentType.VAR_IMAGE })
53 return this.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, '变量图片'); 53 return this.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, '变量图片');
54 })), 54 })),
55 - this.addEntry(this.getTagsForStencil('mxgraph.basic', '视频', 'basic').join(' '), mxUtils.bind(this, function () { 55 + this.addEntry(this.getTagsForStencil(gn, '视频', 'basic').join(' '), mxUtils.bind(this, function () {
56 const template = createVideoTemplate(300, 150) 56 const template = createVideoTemplate(300, 150)
57 const cell = new mxCell(template, new mxGeometry(0, 0, 300, 150), 'text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;overflow=hidden;'); 57 const cell = new mxCell(template, new mxGeometry(0, 0, 300, 150), 'text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;overflow=hidden;');
58 cell.setVertex(true) 58 cell.setVertex(true)
59 this.setCellAttributes(cell, { [basicAttr.COMPONENT_TYPE]: componentType.VIDEO }) 59 this.setCellAttributes(cell, { [basicAttr.COMPONENT_TYPE]: componentType.VIDEO })
60 return this.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, '视频'); 60 return this.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, '视频');
61 })), 61 })),
62 - this.addEntry(this.getTagsForStencil('mxgraph.basic', '图片', 'basic').join(' '), mxUtils.bind(this, function () { 62 + this.addEntry(this.getTagsForStencil(gn, '图片', 'basic').join(' '), mxUtils.bind(this, function () {
63 const cell = new mxCell(`<img class="basic-component__image" src="${Proxy_Prefix}/images/thingskit/img-placeholder.png" />`, new mxGeometry(0, 0, 190, 190), 'text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;overflow=hidden;'); 63 const cell = new mxCell(`<img class="basic-component__image" src="${Proxy_Prefix}/images/thingskit/img-placeholder.png" />`, new mxGeometry(0, 0, 190, 190), 'text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;overflow=hidden;');
64 cell.setVertex(true) 64 cell.setVertex(true)
65 this.setCellAttributes(cell, { [basicAttr.COMPONENT_TYPE]: componentType.IMAGE }) 65 this.setCellAttributes(cell, { [basicAttr.COMPONENT_TYPE]: componentType.IMAGE })
@@ -67,7 +67,7 @@ @@ -67,7 +67,7 @@
67 })), 67 })),
68 ]; 68 ];
69 69
70 - this.addPaletteFunctions('component', '基础元件', true, fns); 70 + this.addPaletteFunctions(dt, '基础元件', true, fns);
71 this.setCurrentSearchEntryLibrary(); 71 this.setCurrentSearchEntryLibrary();
72 }; 72 };
73 73