10.0.5 release

This commit is contained in:
Gaudenz Alder 2018-12-19 17:19:18 +01:00
parent 4743eba8d5
commit 19ca5f87a3
14 changed files with 1379 additions and 1092 deletions

View file

@ -1,3 +1,7 @@
19-DEC-2018: 10.0.5
- Fixes for collaborative editing
19-DEC-2018: 10.0.4
- Fixes for night mode and responsive UI

View file

@ -1 +1 @@
10.0.4
10.0.5

View file

@ -1,7 +1,7 @@
CACHE MANIFEST
# THIS FILE WAS GENERATED. DO NOT MODIFY!
# 12/19/2018 11:31 AM
# 12/19/2018 05:08 PM
app.html
index.html?offline=1

File diff suppressed because it is too large Load diff

View file

@ -2037,9 +2037,9 @@ format:new mxRectangle(0,0,1654,2336)},{key:"a3",title:"A3 (297 mm x 420 mm)",fo
(function(){mxGraphView.prototype.validateBackgroundPage=function(){var a=this.graph;if(null!=a.container&&!a.transparentBackground){if(a.pageVisible){var b=this.getBackgroundPageBounds();if(null==this.backgroundPageShape){for(var c=a.container.firstChild;null!=c&&c.nodeType!=mxConstants.NODETYPE_ELEMENT;)c=c.nextSibling;null!=c&&(this.backgroundPageShape=this.createBackgroundPageShape(b),this.backgroundPageShape.scale=1,this.backgroundPageShape.isShadow=!mxClient.IS_QUIRKS,this.backgroundPageShape.dialect=
mxConstants.DIALECT_STRICTHTML,this.backgroundPageShape.init(a.container),c.style.position="absolute",a.container.insertBefore(this.backgroundPageShape.node,c),this.backgroundPageShape.redraw(),this.backgroundPageShape.node.className="geBackgroundPage",mxEvent.addListener(this.backgroundPageShape.node,"dblclick",mxUtils.bind(this,function(c){a.dblClick(c)})),mxEvent.addGestureListeners(this.backgroundPageShape.node,mxUtils.bind(this,function(c){a.fireMouseEvent(mxEvent.MOUSE_DOWN,new mxMouseEvent(c))}),
mxUtils.bind(this,function(c){null!=a.tooltipHandler&&a.tooltipHandler.isHideOnHover()&&a.tooltipHandler.hide();a.isMouseDown&&!mxEvent.isConsumed(c)&&a.fireMouseEvent(mxEvent.MOUSE_MOVE,new mxMouseEvent(c))}),mxUtils.bind(this,function(c){a.fireMouseEvent(mxEvent.MOUSE_UP,new mxMouseEvent(c))})))}else this.backgroundPageShape.scale=1,this.backgroundPageShape.bounds=b,this.backgroundPageShape.redraw()}else null!=this.backgroundPageShape&&(this.backgroundPageShape.destroy(),this.backgroundPageShape=
null);this.validateBackgroundStyles()}};mxGraphView.prototype.validateBackgroundStyles=function(){var a=this.graph,b=null==a.background||a.background==mxConstants.NONE?a.defaultPageBackgroundColor:a.background,c=null!=b&&this.gridColor!=b.toLowerCase()?this.gridColor:"#ffffff",d="none",g="";if(a.isGridEnabled()){g=10;mxClient.IS_SVG?(d=unescape(encodeURIComponent(this.createSvgGrid(c))),d=window.btoa?btoa(d):Base64.encode(d,!0),d="url(data:image/svg+xml;base64,"+d+")",g=a.gridSize*this.scale*this.gridSteps):
d="url("+this.gridImage+")";var e=c=0;null!=a.view.backgroundPageShape&&(e=this.getBackgroundPageBounds(),c=1+e.x,e=1+e.y);g=-Math.round(g-mxUtils.mod(this.translate.x*this.scale-c,g))+"px "+-Math.round(g-mxUtils.mod(this.translate.y*this.scale-e,g))+"px"}c=a.view.canvas;null!=c.ownerSVGElement&&(c=c.ownerSVGElement);null!=a.view.backgroundPageShape?(a.view.backgroundPageShape.node.style.backgroundPosition=g,a.view.backgroundPageShape.node.style.backgroundImage=d,a.view.backgroundPageShape.node.style.backgroundColor=
b,a.container.className="geDiagramContainer geDiagramBackdrop",c.style.backgroundImage="none",c.style.backgroundColor=""):(a.container.className="geDiagramContainer",c.style.backgroundPosition=g,c.style.backgroundColor=b,c.style.backgroundImage=d)};mxGraphView.prototype.createSvgGrid=function(a){for(var b=this.graph.gridSize*this.scale;b<this.minGridSize;)b*=2;for(var c=this.gridSteps*b,d=[],g=1;g<this.gridSteps;g++){var e=g*b;d.push("M 0 "+e+" L "+c+" "+e+" M "+e+" 0 L "+e+" "+c)}return'<svg width="'+
null);this.validateBackgroundStyles()}};mxGraphView.prototype.validateBackgroundStyles=function(){var a=this.graph,b=null==a.background||a.background==mxConstants.NONE?a.defaultPageBackgroundColor:a.background,c=null!=b&&this.gridColor!=b.toLowerCase()?this.gridColor:"#ffffff",f="none",d="";if(a.isGridEnabled()){d=10;mxClient.IS_SVG?(f=unescape(encodeURIComponent(this.createSvgGrid(c))),f=window.btoa?btoa(f):Base64.encode(f,!0),f="url(data:image/svg+xml;base64,"+f+")",d=a.gridSize*this.scale*this.gridSteps):
f="url("+this.gridImage+")";var e=c=0;null!=a.view.backgroundPageShape&&(e=this.getBackgroundPageBounds(),c=1+e.x,e=1+e.y);d=-Math.round(d-mxUtils.mod(this.translate.x*this.scale-c,d))+"px "+-Math.round(d-mxUtils.mod(this.translate.y*this.scale-e,d))+"px"}c=a.view.canvas;null!=c.ownerSVGElement&&(c=c.ownerSVGElement);null!=a.view.backgroundPageShape?(a.view.backgroundPageShape.node.style.backgroundPosition=d,a.view.backgroundPageShape.node.style.backgroundImage=f,a.view.backgroundPageShape.node.style.backgroundColor=
b,a.container.className="geDiagramContainer geDiagramBackdrop",c.style.backgroundImage="none",c.style.backgroundColor=""):(a.container.className="geDiagramContainer",c.style.backgroundPosition=d,c.style.backgroundColor=b,c.style.backgroundImage=f)};mxGraphView.prototype.createSvgGrid=function(a){for(var b=this.graph.gridSize*this.scale;b<this.minGridSize;)b*=2;for(var c=this.gridSteps*b,d=[],g=1;g<this.gridSteps;g++){var e=g*b;d.push("M 0 "+e+" L "+c+" "+e+" M "+e+" 0 L "+e+" "+c)}return'<svg width="'+
c+'" height="'+c+'" xmlns="'+mxConstants.NS_SVG+'"><defs><pattern id="grid" width="'+c+'" height="'+c+'" patternUnits="userSpaceOnUse"><path d="'+d.join(" ")+'" fill="none" stroke="'+a+'" opacity="0.2" stroke-width="1"/><path d="M '+c+" 0 L 0 0 0 "+c+'" fill="none" stroke="'+a+'" stroke-width="1"/></pattern></defs><rect width="100%" height="100%" fill="url(#grid)"/></svg>'};var a=mxGraph.prototype.panGraph;mxGraph.prototype.panGraph=function(b,d){a.apply(this,arguments);if(null!=this.shiftPreview1){var c=
this.view.canvas;null!=c.ownerSVGElement&&(c=c.ownerSVGElement);var f=this.gridSize*this.view.scale*this.view.gridSteps,f=-Math.round(f-mxUtils.mod(this.view.translate.x*this.view.scale+b,f))+"px "+-Math.round(f-mxUtils.mod(this.view.translate.y*this.view.scale+d,f))+"px";c.style.backgroundPosition=f}};mxGraph.prototype.updatePageBreaks=function(a,b,c){var d=this.view.scale,g=this.view.translate,e=this.pageFormat,n=d*this.pageScale,l=this.view.getBackgroundPageBounds();b=l.width;c=l.height;var r=
new mxRectangle(d*g.x,d*g.y,e.width*n,e.height*n),w=(a=a&&Math.min(r.width,r.height)>this.minPageBreakDist)?Math.ceil(c/r.height)-1:0,v=a?Math.ceil(b/r.width)-1:0,h=l.x+b,x=l.y+c;null==this.horizontalPageBreaks&&0<w&&(this.horizontalPageBreaks=[]);null==this.verticalPageBreaks&&0<v&&(this.verticalPageBreaks=[]);a=mxUtils.bind(this,function(a){if(null!=a){for(var c=a==this.horizontalPageBreaks?w:v,b=0;b<=c;b++){var d=a==this.horizontalPageBreaks?[new mxPoint(Math.round(l.x),Math.round(l.y+(b+1)*r.height)),
@ -2650,14 +2650,14 @@ DrawioFile.prototype.mergeFile=function(a,b,e){try{var d=null!=this.shadowPages?
q=this.ui.getHashValueForPages(this.shadowPages);EditorUi.debug("File.mergeFile",[this],"patch",h,"checksum",q==p,p);p!=q?(this.stats.checksumErrors++,this.checksumError(e,[h])):(this.backupPatch=null,this.inConflictState=this.invalidChecksum=!1,this.setDescriptor(a.getDescriptor()),this.descriptorChanged(),null!=b&&b())}catch(f){this.invalidChecksum=this.inConflictState=!0;null!=window.console&&"1"==urlParams.test&&console.log(f);null!=e&&e(f);try{var u=this.getCurrentUser(),c=null!=u?this.ui.hashValue(u.id):
"unknown";EditorUi.sendReport("Error in mergeFile "+(new Date).toISOString()+":\n\nFile="+this.getId()+" ("+this.getMode()+")\n"+(null!=this.sync?"Client="+this.sync.clientId+"\n":"")+"User="+c+"\nSize="+this.getSize()+"\nSync="+DrawioFile.SYNC+"\n\nStack:\n"+f.stack)}catch(g){}}};
DrawioFile.prototype.checksumError=function(a,b){this.invalidChecksum=this.inConflictState=!0;this.descriptorChanged();null!=this.sync&&this.sync.updateOnlineState();null!=a&&a();try{if(null!=b)for(var e=0;e<b.length;e++)this.ui.anonymizePatch(b[e]);var d=new mxCodec(mxUtils.createXmlDocument()),h=d.document.createElement("mxfile");if(null!=this.shadowPages)for(e=0;e<this.shadowPages.length;e++){var m=this.ui.anonymizeNode(d.encode(new mxGraphModel(this.shadowPages[e].root)));m.setAttribute("id",
this.shadowPages[e].getId());h.appendChild(m)}var p=this.getCurrentUser(),q=null!=p?this.ui.hashValue(p.id):"unknown";null!=this.stats.start&&(this.stats.uptime=Math.round(((new Date).getTime()-(new Date(this.stats.start)).getTime())/1E3));EditorUi.sendReport("Checksum Error "+(new Date).toISOString()+":\n\nFile="+this.getId()+" ("+this.getMode()+")\n"+(null!=this.sync?"Client="+this.sync.clientId+"\n":"")+"User="+q+"\nSize="+this.getSize()+"\nSync="+DrawioFile.SYNC+"\n\nStats:\n"+JSON.stringify(this.stats,
null,2)+"\nData:\n"+mxUtils.getPrettyXml(h)+"\nPatches:\n"+JSON.stringify(b,null,2))}catch(u){console.error(u)}};
this.shadowPages[e].getId());h.appendChild(m)}var p=this.getCurrentUser(),q=null!=p?this.ui.hashValue(p.id):"unknown";null!=this.stats.start&&(this.stats.uptime=Math.round(((new Date).getTime()-(new Date(this.stats.start)).getTime())/1E3));var u=mxUtils.getPrettyXml(h);null!=u&&1E4<u.length&&(u=this.ui.editor.graph.compress(u)+"\n");var c=JSON.stringify(b,null,2);null!=c&&1E4<c.length&&(c=this.ui.editor.graph.compress(c));EditorUi.sendReport("Checksum Error "+(new Date).toISOString()+":\n\nFile="+
this.getId()+" ("+this.getMode()+")\n"+(null!=this.sync?"Client="+this.sync.clientId+"\n":"")+"User="+q+"\nSize="+this.getSize()+"\nSync="+DrawioFile.SYNC+"\n\nStats:\n"+JSON.stringify(this.stats,null,2)+"\n\nData:\n"+u+"\nPatches:\n"+c+"\n\nStack:\n"+Error().stack)}catch(f){console.error(f)}};
DrawioFile.prototype.reloadFile=function(a,b){try{this.ui.spinner.stop();var e=mxUtils.bind(this,function(){this.setModified(!1);var b=this.ui.currentPage,e=this.ui.editor.graph.getViewState(),m=this.ui.editor.graph.getSelectionCells();this.reportEnabled=!1;this.stats.reloads++;this.ui.loadFile(this.getHash(),!0,null,mxUtils.bind(this,function(){this.ui.restoreViewState(b,e,m);null!=this.backupPatch&&this.patch([this.backupPatch]);var d=this.ui.getCurrentFile();null!=d&&(d.stats=this.stats);null!=
a&&a()}))});this.isModified()&&null==this.backupPatch?this.ui.confirm(mxResources.get("allChangesLost"),mxUtils.bind(this,function(){this.handleFileSuccess("manual"==DrawioFile.SYNC)}),e,mxResources.get("cancel"),mxResources.get("discardChanges")):e()}catch(d){null!=b&&b(d)}};
DrawioFile.prototype.copyFile=function(a,b){this.constructor!=DriveFile||this.isRestricted()?this.ui.editor.editAsNew(this.ui.getFileData(!0),this.ui.getCopyFilename(this)):this.makeCopy(mxUtils.bind(this,function(){if(this.ui.spinner.spin(document.body,mxResources.get("saving")))try{this.save(!0,a,b)}catch(e){b(e)}}),b,!0)};DrawioFile.prototype.ignorePatches=function(a){for(var b=!0,e=0;e<a.length&&b;e++)b=b&&0==Object.keys(a[e]).length;return b};
DrawioFile.prototype.patch=function(a,b){if(!this.ignorePatches(a)){var e=this.ui.editor.undoManager,d=e.history.slice(),h=e.indexOfNextAdd,m=this.ui.editor.graph;m.container.style.visibility="hidden";var p=this.changeListenerEnabled;this.changeListenerEnabled=!1;var q=m.foldingEnabled,u=m.mathEnabled,c=m.cellRenderer.redraw;m.cellRenderer.redraw=function(a){a.view.graph.isEditing(a.cell)&&(a.view.graph.scrollCellToVisible(a.cell),a.view.graph.cellEditor.resize());c.apply(this,arguments)};m.model.beginUpdate();
try{for(var f=0;f<a.length;f++)this.ui.pages=this.ui.patchPages(this.ui.pages,a[f],!0,b)}finally{m.model.endUpdate();null!=this.ui.pages&&0<this.ui.pages.length&&0>mxUtils.indexOf(this.ui.pages,this.ui.currentPage)&&this.ui.selectPage(this.ui.pages[0],!0);m.cellRenderer.redraw=c;this.changeListenerEnabled=p;m.container.style.visibility="";e.history=d;e.indexOfNextAdd=h;e.fireEvent(new mxEventObject(mxEvent.CLEAR));if(null==this.ui.currentPage||this.ui.currentPage.needsUpdate)u!=m.mathEnabled?(this.ui.editor.updateGraphComponents(),
m.refresh()):(q!=m.foldingEnabled?m.view.revalidate():m.view.validate(),m.sizeDidChange()),null!=this.ui.format&&m.isSelectionEmpty()&&this.ui.format.refresh();this.ui.updateTabContainer()}}};DrawioFile.prototype.save=function(a,b,e,d,h,m){if(this.isEditable()){if(this.invalidChecksum)throw Error(mxResources.get("checksum"));this.updateFileData();this.clearAutosave()}else throw Error(mxResources.get("readOnly"));};
try{for(var f=0;f<a.length;f++)this.ui.pages=this.ui.patchPages(this.ui.pages,a[f],!0,b,this.isModified())}finally{m.model.endUpdate();null!=this.ui.pages&&0<this.ui.pages.length&&0>mxUtils.indexOf(this.ui.pages,this.ui.currentPage)&&this.ui.selectPage(this.ui.pages[0],!0);m.cellRenderer.redraw=c;this.changeListenerEnabled=p;m.container.style.visibility="";e.history=d;e.indexOfNextAdd=h;e.fireEvent(new mxEventObject(mxEvent.CLEAR));if(null==this.ui.currentPage||this.ui.currentPage.needsUpdate)u!=
m.mathEnabled?(this.ui.editor.updateGraphComponents(),m.refresh()):(q!=m.foldingEnabled?m.view.revalidate():m.view.validate(),m.sizeDidChange()),null!=this.ui.format&&m.isSelectionEmpty()&&this.ui.format.refresh();this.ui.updateTabContainer()}}};DrawioFile.prototype.save=function(a,b,e,d,h,m){if(this.isEditable()){if(this.invalidChecksum)throw Error(mxResources.get("checksum"));this.updateFileData();this.clearAutosave()}else throw Error(mxResources.get("readOnly"));};
DrawioFile.prototype.updateFileData=function(){this.setData(this.ui.getFileData(null,null,null,null,null,null,null,null,this))};DrawioFile.prototype.saveAs=function(a,b,e){};DrawioFile.prototype.saveFile=function(a,b,e,d){};DrawioFile.prototype.getPublicUrl=function(a){a(null)};DrawioFile.prototype.isRestricted=function(){return!1};DrawioFile.prototype.isModified=function(){return this.modified};DrawioFile.prototype.setModified=function(a){this.modified=a};
DrawioFile.prototype.isAutosaveOptional=function(){return!1};DrawioFile.prototype.isAutosave=function(){return!this.inConflictState&&this.ui.editor.autosave};DrawioFile.prototype.isRenamable=function(){return!1};DrawioFile.prototype.rename=function(a,b,e){};DrawioFile.prototype.isMovable=function(){return!1};DrawioFile.prototype.move=function(a,b,e){};DrawioFile.prototype.getHash=function(){return""};DrawioFile.prototype.getId=function(){return""};
DrawioFile.prototype.isEditable=function(){return!this.ui.editor.isChromelessView()||this.ui.editor.editable};DrawioFile.prototype.getUi=function(){return this.ui};DrawioFile.prototype.getTitle=function(){return""};DrawioFile.prototype.setData=function(a){this.data=a};DrawioFile.prototype.getData=function(){return this.data};
@ -2887,8 +2887,8 @@ EditorUi.prototype.createDownloadRequest=function(a,b,d,e,n,l){var c=this.editor
"png"==b&&n&&(l=mxConstants.NONE);return new mxXmlRequest(EXPORT_URL,"format="+b+f+g+"&bg="+(null!=l?l:mxConstants.NONE)+"&base64="+e+"&embedXml="+c+"&xml="+encodeURIComponent(d)+(null!=a?"&filename="+encodeURIComponent(a):""))};EditorUi.prototype.setMode=function(a,b){this.mode=a};EditorUi.prototype.loadDescriptor=function(a,b,d){var c=window.location.hash,f=mxUtils.bind(this,function(d){var f=null!=a.data?a.data:"";null!=d&&0<d.length&&(0<f.length&&(f+="\n"),f+=d);d=new LocalFile(this,"csv"!=a.format&&
0<f.length?f:this.emptyDiagramXml,null!=urlParams.title?decodeURIComponent(urlParams.title):this.defaultFilename,!0);d.getHash=function(){return c};this.fileLoaded(d);"csv"==a.format&&this.importCsv(f,mxUtils.bind(this,function(a){this.editor.undoManager.clear();this.editor.setModified(!1);this.editor.setStatus("")}));if(null!=a.update){var e=null!=a.interval?parseInt(a.interval):6E4,g=null,k=mxUtils.bind(this,function(){var c=this.currentPage;mxUtils.post(a.update,"xml="+encodeURIComponent(mxUtils.getXml(this.editor.getGraphXml())),
mxUtils.bind(this,function(a){c===this.currentPage&&(200<=a.getStatus()&&300>=a.getStatus()?(this.updateDiagram(a.getText()),l()):this.handleError({message:mxResources.get("error")+" "+a.getStatus()}))}),mxUtils.bind(this,function(a){this.handleError(a)}))}),l=mxUtils.bind(this,function(){window.clearTimeout(g);g=window.setTimeout(k,e)});this.editor.addListener("pageSelected",mxUtils.bind(this,function(){l();k()}));l();k()}null!=b&&b()});if(null!=a.url&&0<a.url.length){var e=a.url;/^https?:\/\//.test(e)&&
!this.isCorsEnabledForUrl(e)&&(e=PROXY_URL+"?url="+encodeURIComponent(a.url));this.loadUrl(e,mxUtils.bind(this,function(a){f(a)}),mxUtils.bind(this,function(a){null!=d&&d(a)}))}else f("")};EditorUi.prototype.updateDiagram=function(a){function c(a){var c=new mxCellOverlay(a.image||e.warningImage,a.tooltip,a.align,a.valign,a.offset);c.addListener(mxEvent.CLICK,function(c,b){d.alert(a.tooltip)});return c}var b=null,d=this;if(null!=a&&0<a.length&&(b=mxUtils.parseXml(a),a=null!=b?b.documentElement:null,
null!=a&&"updates"==a.nodeName)){var e=this.editor.graph,l=e.getModel();l.beginUpdate();var r=null;try{for(a=a.firstChild;null!=a;){if("update"==a.nodeName){var h=l.getCell(a.getAttribute("id"));if(null!=h){try{var v=a.getAttribute("value");if(null!=v){var m=mxUtils.parseXml(v).documentElement;if(null!=m)if("1"==m.getAttribute("replace-value"))l.setValue(h,m);else for(var p=m.attributes,t=0;t<p.length;t++)e.setAttributeForCell(h,p[t].nodeName,0<p[t].nodeValue.length?p[t].nodeValue:null)}}catch(A){null!=
!this.isCorsEnabledForUrl(e)&&(e=PROXY_URL+"?url="+encodeURIComponent(e));this.loadUrl(e,mxUtils.bind(this,function(a){f(a)}),mxUtils.bind(this,function(a){null!=d&&d(a)}))}else f("")};EditorUi.prototype.updateDiagram=function(a){function c(a){var c=new mxCellOverlay(a.image||e.warningImage,a.tooltip,a.align,a.valign,a.offset);c.addListener(mxEvent.CLICK,function(c,b){d.alert(a.tooltip)});return c}var b=null,d=this;if(null!=a&&0<a.length&&(b=mxUtils.parseXml(a),a=null!=b?b.documentElement:null,null!=
a&&"updates"==a.nodeName)){var e=this.editor.graph,l=e.getModel();l.beginUpdate();var r=null;try{for(a=a.firstChild;null!=a;){if("update"==a.nodeName){var h=l.getCell(a.getAttribute("id"));if(null!=h){try{var v=a.getAttribute("value");if(null!=v){var m=mxUtils.parseXml(v).documentElement;if(null!=m)if("1"==m.getAttribute("replace-value"))l.setValue(h,m);else for(var p=m.attributes,t=0;t<p.length;t++)e.setAttributeForCell(h,p[t].nodeName,0<p[t].nodeValue.length?p[t].nodeValue:null)}}catch(A){null!=
window.console&&console.log("Error in value for "+h.id+": "+A)}try{var q=a.getAttribute("style");null!=q&&e.model.setStyle(h,q)}catch(A){null!=window.console&&console.log("Error in style for "+h.id+": "+A)}try{var C=a.getAttribute("icon");if(null!=C){var u=0<C.length?JSON.parse(C):null;null!=u&&u.append||e.removeCellOverlays(h);null!=u&&e.addCellOverlay(h,c(u))}}catch(A){null!=window.console&&console.log("Error in icon for "+h.id+": "+A)}try{var D=a.getAttribute("geometry");if(null!=D){var D=JSON.parse(D),
G=e.getCellGeometry(h);if(null!=G){G=G.clone();for(key in D){var J=parseFloat(D[key]);"dx"==key?G.x+=J:"dy"==key?G.y+=J:"dw"==key?G.width+=J:"dh"==key?G.height+=J:G[key]=parseFloat(D[key])}e.model.setGeometry(h,G)}}}catch(A){null!=window.console&&console.log("Error in icon for "+h.id+": "+A)}}}else if("model"==a.nodeName){for(var y=a.firstChild;null!=y&&y.nodeType!=mxConstants.NODETYPE_ELEMENT;)y=y.nextSibling;null!=y&&(new mxCodec(a.firstChild)).decode(y,l)}else if("view"==a.nodeName){if(a.hasAttribute("scale")&&
(e.view.scale=parseFloat(a.getAttribute("scale"))),a.hasAttribute("dx")||a.hasAttribute("dy"))e.view.translate=new mxPoint(parseFloat(a.getAttribute("dx")||0),parseFloat(a.getAttribute("dy")||0))}else"fit"==a.nodeName&&(r=a.hasAttribute("max-scale")?parseFloat(a.getAttribute("max-scale")):1);a=a.nextSibling}}finally{l.endUpdate()}null!=r&&this.chromelessResize&&this.chromelessResize(!0,r)}return b};EditorUi.prototype.getCopyFilename=function(a,b){var c=null!=a&&null!=a.getTitle()?a.getTitle():this.defaultFilename,
@ -2931,13 +2931,13 @@ function(){return document.getElementById("geFooter")});EditorUi.initTheme=funct
Editor.checkmarkImage="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAMAAACeyVWkAAAARVBMVEUAAACZmZkICAgEBASNjY2Dg4MYGBiTk5N5eXl1dXVmZmZQUFBCQkI3NzceHh4MDAykpKSJiYl+fn5sbGxaWlo/Pz8SEhK96uPlAAAAAXRSTlMAQObYZgAAAE5JREFUGNPFzTcSgDAQQ1HJGUfy/Y9K7V1qeOUfzQifCQZai1XHaz11LFysbDbzgDSSWMZiETz3+b8yNUc/MMsktxuC8XQBSncdLwz+8gCCggGXzBcozAAAAABJRU5ErkJggg=="))};EditorUi.initTheme();EditorUi.prototype.hideFooter=function(){var a=document.getElementById("geFooter");null!=a&&(this.footerHeight=0,a.style.display=
"none",this.refresh())};EditorUi.prototype.showFooter=function(a){var c=document.getElementById("geFooter");null!=c&&(this.footerHeight=a,c.style.display="inline",this.refresh())};EditorUi.prototype.showImageDialog=function(a,b,d,e,n){a=new ImageDialog(this,a,b,d,e,n);this.showDialog(a.container,Graph.fileSupport?440:360,Graph.fileSupport?200:90,!0,!0);a.init()};EditorUi.prototype.showBackgroundImageDialog=function(a){a=null!=a?a:mxUtils.bind(this,function(a){a=new ChangePageSetup(this,null,a);a.ignoreColor=
!0;this.editor.graph.model.execute(a)});var c=new BackgroundImageDialog(this,mxUtils.bind(this,function(c){a(c)}));this.showDialog(c.container,360,200,!0,!0);c.init()};EditorUi.prototype.showLibraryDialog=function(a,b,d,e,n){a=new LibraryDialog(this,a,b,d,e,n);this.showDialog(a.container,620,440,!0,!1,mxUtils.bind(this,function(a){a&&null==this.getCurrentFile()&&"1"!=urlParams.embed&&this.showSplash()}));a.init()};EditorUi.prototype.createSidebarFooterContainer=function(){var a=this.createDiv("geSidebarContainer");
a.style.position="absolute";a.style.overflow="hidden";a.style.borderWidth="3px";var b=document.createElement("a");b.className="geTitle";b.style.height="100%";b.style.paddingTop="9px";mxUtils.write(b,mxResources.get("moreShapes")+"...");mxEvent.addListener(b,mxClient.IS_POINTER?"pointerdown":"mousedown",mxUtils.bind(this,function(a){a.preventDefault()}));mxEvent.addListener(b,"click",mxUtils.bind(this,function(a){this.actions.get("shapes").funct();mxEvent.consume(a)}));a.appendChild(b);return a};EditorUi.prototype.handleError=
function(a,b,d){var c=null!=this.spinner&&null!=this.spinner.pause?this.spinner.pause():function(){},e=null!=a&&null!=a.error?a.error:a;if(null!=e||null!=b){a=mxUtils.htmlEntities(mxResources.get("unknownError"));var f=mxResources.get("ok"),g=null;b=null!=b?b:mxResources.get("error");if(null!=e)if(null!=e.retry&&(f=mxResources.get("cancel"),g=function(){c();e.retry()}),404==e.code||404==e.status){a=mxUtils.htmlEntities(mxResources.get("fileNotFoundOrDenied"));var h=window.location.hash;null!=h&&"#G"==
h.substring(0,2)&&(h=h.substring(2),a+=' <a href="https://drive.google.com/open?id='+h+'" target="_blank">'+mxUtils.htmlEntities(mxResources.get("tryOpeningViaThisPage"))+"</a>")}else null!=e.message?a=mxUtils.htmlEntities(e.message):null!=e.response&&null!=e.response.error?a=mxUtils.htmlEntities(e.response.error):"undefined"!==window.App&&(e.code==App.ERROR_TIMEOUT?a=mxUtils.htmlEntities(mxResources.get("timeout")):e.code==App.ERROR_BUSY&&(a=mxUtils.htmlEntities(mxResources.get("busy"))));this.showError(b,
a,f,d,g)}else null!=d&&d()};EditorUi.prototype.showError=function(a,b,d,e,n,l,r,h,v,m,p,t){a=new ErrorDialog(this,a,b,d||mxResources.get("ok"),e,n,l,r,t,h,v);this.showDialog(a.container,m||340,p||150,!0,!1);a.init()};EditorUi.prototype.alert=function(a,b){var c=new ErrorDialog(this,null,a,mxResources.get("ok"),b);this.showDialog(c.container,340,100,!0,!1);c.init()};EditorUi.prototype.confirm=function(a,b,d,e,n){var c=null!=this.spinner&&null!=this.spinner.pause?this.spinner.pause():function(){};this.showDialog((new ConfirmDialog(this,
a,function(){c();null!=b&&b()},function(){c();null!=d&&d()},e,n)).container,340,90,!0,!1)};EditorUi.prototype.setCurrentFile=function(a){this.currentFile=a};EditorUi.prototype.getCurrentFile=function(){return this.currentFile};EditorUi.prototype.isExportToCanvas=function(){return mxClient.IS_CHROMEAPP||!this.editor.graph.mathEnabled&&this.useCanvasForExport};EditorUi.prototype.createSvgDataUri=function(a){return"data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(a)))};EditorUi.prototype.createImageDataUri=
function(a,b,d){var c=a.toDataURL("image/"+d);if(6>=c.length||c==a.cloneNode(!1).toDataURL("image/"+d))throw{message:"Invalid image"};null!=b&&(c=this.writeGraphModelToPng(c,"zTXt","mxGraphModel",atob(this.editor.graph.compress(b))));return c};EditorUi.prototype.saveCanvas=function(a,b,d){var c="jpeg"==d?"jpg":d,e=this.getBaseFilename()+"."+c;a=this.createImageDataUri(a,b,d);this.saveData(e,c,a.substring(a.lastIndexOf(",")+1),"image/"+d,!0)};EditorUi.prototype.isLocalFileSave=function(){return"remote"!=
urlParams.save&&(mxClient.IS_IE||"undefined"!==typeof window.Blob&&"undefined"!==typeof window.URL)&&9!=document.documentMode&&8!=document.documentMode&&7!=document.documentMode&&!mxClient.IS_QUIRKS||this.isOfflineApp()||mxClient.IS_IOS};EditorUi.prototype.showTextDialog=function(a,b){var c=new TextareaDialog(this,a,b,null,null,mxResources.get("close"));c.textarea.style.width="600px";c.textarea.style.height="380px";this.showDialog(c.container,620,460,!0,!0);c.init();document.execCommand("selectall",
a.style.position="absolute";a.style.overflow="hidden";a.style.borderWidth="3px";var b=document.createElement("a");b.className="geTitle";b.style.height="100%";b.style.paddingTop="9px";b.innerHTML='<span style="font-size:18px;margin-right:5px;">+</span>';mxUtils.write(b,mxResources.get("moreShapes")+"...");mxEvent.addListener(b,mxClient.IS_POINTER?"pointerdown":"mousedown",mxUtils.bind(this,function(a){a.preventDefault()}));mxEvent.addListener(b,"click",mxUtils.bind(this,function(a){this.actions.get("shapes").funct();
mxEvent.consume(a)}));a.appendChild(b);return a};EditorUi.prototype.handleError=function(a,b,d){var c=null!=this.spinner&&null!=this.spinner.pause?this.spinner.pause():function(){},e=null!=a&&null!=a.error?a.error:a;if(null!=e||null!=b){a=mxUtils.htmlEntities(mxResources.get("unknownError"));var f=mxResources.get("ok"),g=null;b=null!=b?b:mxResources.get("error");if(null!=e)if(null!=e.retry&&(f=mxResources.get("cancel"),g=function(){c();e.retry()}),404==e.code||404==e.status){a=mxUtils.htmlEntities(mxResources.get("fileNotFoundOrDenied"));
var h=window.location.hash;null!=h&&"#G"==h.substring(0,2)&&(h=h.substring(2),a+=' <a href="https://drive.google.com/open?id='+h+'" target="_blank">'+mxUtils.htmlEntities(mxResources.get("tryOpeningViaThisPage"))+"</a>")}else null!=e.message?a=mxUtils.htmlEntities(e.message):null!=e.response&&null!=e.response.error?a=mxUtils.htmlEntities(e.response.error):"undefined"!==window.App&&(e.code==App.ERROR_TIMEOUT?a=mxUtils.htmlEntities(mxResources.get("timeout")):e.code==App.ERROR_BUSY&&(a=mxUtils.htmlEntities(mxResources.get("busy"))));
this.showError(b,a,f,d,g)}else null!=d&&d()};EditorUi.prototype.showError=function(a,b,d,e,n,l,r,h,v,m,p,t){a=new ErrorDialog(this,a,b,d||mxResources.get("ok"),e,n,l,r,t,h,v);this.showDialog(a.container,m||340,p||150,!0,!1);a.init()};EditorUi.prototype.alert=function(a,b){var c=new ErrorDialog(this,null,a,mxResources.get("ok"),b);this.showDialog(c.container,340,100,!0,!1);c.init()};EditorUi.prototype.confirm=function(a,b,d,e,n){var c=null!=this.spinner&&null!=this.spinner.pause?this.spinner.pause():
function(){};this.showDialog((new ConfirmDialog(this,a,function(){c();null!=b&&b()},function(){c();null!=d&&d()},e,n)).container,340,90,!0,!1)};EditorUi.prototype.setCurrentFile=function(a){this.currentFile=a};EditorUi.prototype.getCurrentFile=function(){return this.currentFile};EditorUi.prototype.isExportToCanvas=function(){return mxClient.IS_CHROMEAPP||!this.editor.graph.mathEnabled&&this.useCanvasForExport};EditorUi.prototype.createSvgDataUri=function(a){return"data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(a)))};
EditorUi.prototype.createImageDataUri=function(a,b,d){var c=a.toDataURL("image/"+d);if(6>=c.length||c==a.cloneNode(!1).toDataURL("image/"+d))throw{message:"Invalid image"};null!=b&&(c=this.writeGraphModelToPng(c,"zTXt","mxGraphModel",atob(this.editor.graph.compress(b))));return c};EditorUi.prototype.saveCanvas=function(a,b,d){var c="jpeg"==d?"jpg":d,e=this.getBaseFilename()+"."+c;a=this.createImageDataUri(a,b,d);this.saveData(e,c,a.substring(a.lastIndexOf(",")+1),"image/"+d,!0)};EditorUi.prototype.isLocalFileSave=
function(){return"remote"!=urlParams.save&&(mxClient.IS_IE||"undefined"!==typeof window.Blob&&"undefined"!==typeof window.URL)&&9!=document.documentMode&&8!=document.documentMode&&7!=document.documentMode&&!mxClient.IS_QUIRKS||this.isOfflineApp()||mxClient.IS_IOS};EditorUi.prototype.showTextDialog=function(a,b){var c=new TextareaDialog(this,a,b,null,null,mxResources.get("close"));c.textarea.style.width="600px";c.textarea.style.height="380px";this.showDialog(c.container,620,460,!0,!0);c.init();document.execCommand("selectall",
!1,null)};EditorUi.prototype.doSaveLocalFile=function(a,b,d,e,n){if(window.Blob&&navigator.msSaveOrOpenBlob)a=e?this.base64ToBlob(a,d):new Blob([a],{type:d}),navigator.msSaveOrOpenBlob(a,b);else if(mxClient.IS_IE)d=window.open("about:blank","_blank"),null==d?mxUtils.popup(a,!0):(d.document.write(a),d.document.close(),d.document.execCommand("SaveAs",!0,b),d.close());else if(mxClient.IS_IOS)this.showTextDialog(b+":",a);else{var c=document.createElement("a"),f=!mxClient.IS_SF&&0>navigator.userAgent.indexOf("PaleMoon/")&&
"undefined"!==typeof c.download;if(mxClient.IS_GC)var g=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./),f=65==(g?parseInt(g[2],10):!1)?!1:f;if(f||this.isOffline()){c.href=URL.createObjectURL(e?this.base64ToBlob(a,d):new Blob([a],{type:d}));f?c.download=b:c.setAttribute("target","_blank");document.body.appendChild(c);try{window.setTimeout(function(){URL.revokeObjectURL(c.href)},0),c.click(),c.parentNode.removeChild(c)}catch(v){}}else this.createEchoRequest(a,b,d,e,n).simulate(document,"_blank")}};
EditorUi.prototype.createEchoRequest=function(a,b,d,e,n,l){a="xml="+encodeURIComponent(a);return new mxXmlRequest(SAVE_URL,a+(null!=d?"&mime="+d:"")+(null!=n?"&format="+n:"")+(null!=l?"&base64="+l:"")+(null!=b?"&filename="+encodeURIComponent(b):"")+(e?"&binary=1":""))};EditorUi.prototype.base64ToBlob=function(a,b){b=b||"";for(var c=atob(a),d=c.length,e=Math.ceil(d/1024),f=Array(e),r=0;r<e;++r){for(var h=1024*r,v=Math.min(h+1024,d),m=Array(v-h),p=0;h<v;++p,++h)m[p]=c[h].charCodeAt(0);f[r]=new Uint8Array(m)}return new Blob(f,
@ -3043,7 +3043,7 @@ function(){return a})})});/(\.v(dx|sdx?))($|\?)/i.test(l.name)||/(\.vs(x|sx?))($
mxSettings.getResizeImages():null,e=function(d,e){if(d||b)mxSettings.setResizeImages(d?e:null),mxSettings.save();c();a(e)};null==d||b?this.showDialog((new ConfirmDialog(this,mxResources.get("resizeLargeImages"),function(a){e(a,!0)},function(a){e(a,!1)},mxResources.get("resize"),mxResources.get("actualSize"),'<img style="margin-top:8px;" src="'+Editor.loResImage+'"/>','<img style="margin-top:8px;" src="'+Editor.hiResImage+'"/>',isLocalStorage||mxClient.IS_CHROMEAPP)).container,340,isLocalStorage||
mxClient.IS_CHROMEAPP?220:200,!0,!0):e(!1,d)};EditorUi.prototype.parseFile=function(a,b,d){d=null!=d?d:a.name;var c=new FormData;c.append("format","xml");c.append("upfile",a,d);var e=new XMLHttpRequest;e.open("POST",OPEN_URL);e.onreadystatechange=function(){b(e)};e.send(c)};EditorUi.prototype.isResampleImage=function(a,b){b=null!=b?b:this.resampleThreshold;return a.length>b};EditorUi.prototype.resizeImage=function(a,b,d,e,h,l){h=null!=h?h:this.maxImageSize;var c=Math.max(1,a.width),f=Math.max(1,a.height);
if(e&&this.isResampleImage(b,l))try{var g=Math.max(c/h,f/h);if(1<g){var k=Math.round(c/g),n=Math.round(f/g),m=document.createElement("canvas");m.width=k;m.height=n;m.getContext("2d").drawImage(a,0,0,k,n);var p=m.toDataURL();if(p.length<b.length){var q=document.createElement("canvas");q.width=k;q.height=n;var u=q.toDataURL();p!==u&&(b=p,c=k,f=n)}}}catch(D){}d(b,c,f)};EditorUi.prototype.crcTable=[];for(var e=0;256>e;e++)for(var d=e,h=0;8>h;h++)d=1==(d&1)?3988292384^d>>>1:d>>>1,EditorUi.prototype.crcTable[e]=
d;EditorUi.prototype.updateCRC=function(a,b,d,e){for(var c=0;c<e;c++)a=EditorUi.prototype.crcTable[(a^b[d+c])&255]^a>>>8;return a};EditorUi.prototype.crc32=function(a){this.crcTable=this.crcTable||this.createCrcTable();for(var c=-1,b=0;b<a.length;b++)c=c>>>8^this.crcTable[(c^a.charCodeAt(b))&255];return(c^-1)>>>0};EditorUi.prototype.writeGraphModelToPng=function(a,b,d,e,h){function c(a,b){var c=k;k+=b;return a.substring(c,k)}function f(a){a=c(a,4);return a.charCodeAt(3)+(a.charCodeAt(2)<<8)+(a.charCodeAt(1)<<
d;EditorUi.prototype.updateCRC=function(a,b,d,e){for(var c=0;c<e;c++)a=EditorUi.prototype.crcTable[(a^b[d+c])&255]^a>>>8;return a};EditorUi.prototype.crc32=function(a){this.crcTable=this.crcTable||this.createCrcTable();for(var c=-1,b=0;b<a.length;b++)c=c>>>8^this.crcTable[(c^a.charCodeAt(b))&255];return(c^-1)>>>0};EditorUi.prototype.writeGraphModelToPng=function(a,b,d,e,h){function c(a,c){var b=k;k+=c;return a.substring(b,k)}function f(a){a=c(a,4);return a.charCodeAt(3)+(a.charCodeAt(2)<<8)+(a.charCodeAt(1)<<
16)+(a.charCodeAt(0)<<24)}function g(a){return String.fromCharCode(a>>24&255,a>>16&255,a>>8&255,a&255)}a=a.substring(a.indexOf(",")+1);a=window.atob?atob(a):Base64.decode(a,!0);var k=0;if(c(a,8)!=String.fromCharCode(137)+"PNG"+String.fromCharCode(13,10,26,10))null!=h&&h();else if(c(a,4),"IHDR"!=c(a,4))null!=h&&h();else{c(a,17);h=a.substring(0,k);do{var n=f(a);if("IDAT"==c(a,4)){h=a.substring(0,k-8);d=d+String.fromCharCode(0)+("zTXt"==b?String.fromCharCode(0):"")+e;e=4294967295;e=this.updateCRC(e,
b,0,4);e=this.updateCRC(e,d,0,d.length);h+=g(d.length)+b+d+g(e^4294967295);h+=a.substring(k-8,a.length);break}h+=a.substring(k-8,k-4+n);c(a,n);c(a,4)}while(n);return"data:image/png;base64,"+(window.btoa?btoa(h):Base64.encode(h,!0))}};EditorUi.prototype.extractGraphModelFromPng=function(a){var b=null;try{var c=a.substring(a.indexOf(",")+1),d=window.atob&&!mxClient.IS_SF?atob(c):Base64.decode(c,!0);EditorUi.parsePng(d,mxUtils.bind(this,function(a,c,e){a=d.substring(a+8,a+8+e);"zTXt"==c?(e=a.indexOf(String.fromCharCode(0)),
"mxGraphModel"==a.substring(0,e)&&(a=this.editor.graph.bytesToString(pako.inflateRaw(a.substring(e+2))).replace(/\+/g," "),null!=a&&0<a.length&&(b=a))):"tEXt"==c&&(a=a.split(String.fromCharCode(0)),1<a.length&&"mxGraphModel"==a[0]&&(b=a[1]));if(null!=b||"IDAT"==c)return!0}))}catch(n){}null!=b&&"%"==b.charAt(0)&&(b=decodeURIComponent(b));null!=b&&"%"==b.charAt(0)&&(b=decodeURIComponent(b));return b};EditorUi.prototype.loadImage=function(a,b,d){var c=new Image;c.onload=function(){b(c)};null!=d&&(c.onerror=
@ -3180,7 +3180,7 @@ EditorUi.prototype.updatePageRoot=function(a){if(null==a.root){var b=this.editor
return a};EditorUi.prototype.selectPage=function(a,b,e){this.editor.graph.isEditing()&&this.editor.graph.stopEditing(!1);b=null!=b?b:!1;this.editor.graph.isMouseDown=!1;this.editor.graph.reset();var d=this.editor.graph.model.createUndoableEdit();d.ignoreEdit=!0;a=new SelectPage(this,a,e);a.execute();d.add(a);d.notify();this.editor.graph.tooltipHandler.hide();b||this.editor.graph.model.fireEvent(new mxEventObject(mxEvent.UNDO,"edit",d))};
EditorUi.prototype.selectNextPage=function(a){var b=this.currentPage;null!=b&&null!=this.pages&&(b=mxUtils.indexOf(this.pages,b),a?this.selectPage(this.pages[mxUtils.mod(b+1,this.pages.length)]):a||this.selectPage(this.pages[mxUtils.mod(b-1,this.pages.length)]))};EditorUi.prototype.insertPage=function(a,b){if(this.editor.graph.isEnabled()){this.editor.graph.isEditing()&&this.editor.graph.stopEditing(!1);a=null!=a?a:this.createPage();b=null!=b?b:this.pages.length;var e=new ChangePage(this,a,a,b);this.editor.graph.model.execute(e)}return a};
EditorUi.prototype.createPage=function(a){var b=new DiagramPage(this.fileNode.ownerDocument.createElement("diagram"));b.setName(null!=a?a:this.createPageName());return b};EditorUi.prototype.createPageName=function(){for(var a={},b=0;b<this.pages.length;b++){var e=this.pages[b].getName();null!=e&&0<e.length&&(a[e]=e)}b=this.pages.length;do e=mxResources.get("pageWithNumber",[++b]);while(null!=a[e]);return e};
EditorUi.prototype.removePage=function(a){var b=this.editor.graph;if(b.isEnabled()){this.editor.graph.isEditing()&&this.editor.graph.stopEditing(!1);b.model.beginUpdate();try{var e=this.currentPage;if(e==a)if(1<this.pages.length){var d=mxUtils.indexOf(this.pages,a);d==this.pages.length-1?d--:d++;e=this.pages[d]}else e=this.insertPage(),b.model.execute(new RenamePage(this,e,mxResources.get("pageWithNumber",[1])));b.model.execute(new ChangePage(this,a,e))}finally{b.model.endUpdate()}}return a};
EditorUi.prototype.removePage=function(a){var b=this.editor.graph;if(b.isEnabled()){this.editor.graph.isEditing()&&this.editor.graph.stopEditing(!1);b.model.beginUpdate();try{var e=this.currentPage;if(e==a&&1<this.pages.length){var d=mxUtils.indexOf(this.pages,a);d==this.pages.length-1?d--:d++;e=this.pages[d]}else 1>=this.pages.length&&(e=this.insertPage(),b.model.execute(new RenamePage(this,e,mxResources.get("pageWithNumber",[1]))));b.model.execute(new ChangePage(this,a,e))}finally{b.model.endUpdate()}}return a};
EditorUi.prototype.duplicatePage=function(a,b){var e=this.editor.graph,d=null;e.isEnabled()&&(e.isEditing()&&e.stopEditing(),d=a.node.cloneNode(!1),d.removeAttribute("id"),d=new DiagramPage(d),d.root=e.cloneCell(e.model.root),d.viewState=e.getViewState(),d.viewState.scale=1,d.viewState.scrollLeft=null,d.viewState.scrollTop=null,d.viewState.currentRoot=null,d.viewState.defaultParent=null,d.setName(b),d=this.insertPage(d,mxUtils.indexOf(this.pages,a)+1));return d};
EditorUi.prototype.renamePage=function(a){if(this.editor.graph.isEnabled()){var b=new FilenameDialog(this,a.getName(),mxResources.get("rename"),mxUtils.bind(this,function(b){null!=b&&0<b.length&&this.editor.graph.model.execute(new RenamePage(this,a,b))}),mxResources.get("rename"));this.showDialog(b.container,300,80,!0,!0);b.init()}return a};EditorUi.prototype.movePage=function(a,b){this.editor.graph.model.execute(new MovePage(this,a,b))};
EditorUi.prototype.createTabContainer=function(){var a=document.createElement("div");a.style.backgroundColor="dark"==uiTheme?"#2a2a2a":"#dcdcdc";a.style.position="absolute";a.style.whiteSpace="nowrap";a.style.overflow="hidden";a.style.height="0px";return a};

File diff suppressed because one or more lines are too long

View file

@ -31,7 +31,7 @@ EditorUi.prototype.viewStateWhitelist = ['background', 'backgroundImage', 'foldi
/**
* Removes all labels, user objects and styles from the given node in-place.
*/
EditorUi.prototype.patchPages = function(pages, diff, markPages, shadow)
EditorUi.prototype.patchPages = function(pages, diff, markPages, shadow, updateEdgeParents)
{
var shadowLookup = {};
var newPages = [];
@ -48,11 +48,6 @@ EditorUi.prototype.patchPages = function(pages, diff, markPages, shadow)
}
}
for (var i = 0; i < pages.length; i++)
{
lookup[pages[i].getId()] = pages[i];
}
if (diff[EditorUi.DIFF_REMOVE] != null)
{
for (var i = 0; i < diff[EditorUi.DIFF_REMOVE].length; i++)
@ -82,30 +77,38 @@ EditorUi.prototype.patchPages = function(pages, diff, markPages, shadow)
}
}
// Restores existing order
var prev = '';
for (var i = 0; i < pages.length; i++)
{
var pageId = pages[i].getId();
// Restores existing order and creates lookup
if (pages != null)
{
var prev = '';
if (moved[prev] == null && !removed[pages[i].getId()] &&
(diff[EditorUi.DIFF_UPDATE] == null ||
diff[EditorUi.DIFF_UPDATE][pageId] == null ||
diff[EditorUi.DIFF_UPDATE][pageId].previous == null))
for (var i = 0; i < pages.length; i++)
{
moved[prev] = pageId;
var pageId = pages[i].getId();
lookup[pageId] = pages[i];
if (moved[prev] == null && !removed[pageId] &&
(diff[EditorUi.DIFF_UPDATE] == null ||
diff[EditorUi.DIFF_UPDATE][pageId] == null ||
diff[EditorUi.DIFF_UPDATE][pageId].previous == null))
{
moved[prev] = pageId;
}
prev = pageId;
}
prev = pageId;
}
}
// FIXME: Workaround for possible duplicate pages
var added = {};
var addPage = mxUtils.bind(this, function(page)
{
var id = (page != null) ? page.getId() : '';
if (page != null)
if (page != null && !added[id])
{
added[id] = true;
newPages.push(page);
var pageDiff = (diff[EditorUi.DIFF_UPDATE] != null) ?
diff[EditorUi.DIFF_UPDATE][id] : null;
@ -126,7 +129,7 @@ EditorUi.prototype.patchPages = function(pages, diff, markPages, shadow)
if (pageDiff.cells != null)
{
this.patchPage(page, pageDiff.cells, shadowLookup[page.getId()]);
this.patchPage(page, pageDiff.cells, shadowLookup[page.getId()], updateEdgeParents);
}
if (markPages && (pageDiff.cells != null ||
@ -300,7 +303,7 @@ EditorUi.prototype.createParentLookup = function(model, diff)
/**
* Removes all labels, user objects and styles from the given node in-place.
*/
EditorUi.prototype.patchPage = function(page, diff, shadowPage)
EditorUi.prototype.patchPage = function(page, diff, shadowPage, updateEdgeParents)
{
var model = (page == this.currentPage) ? this.editor.graph.model : new mxGraphModel(page.root);
var shadowModel = (shadowPage != null) ? new mxGraphModel(shadowPage.root) : null;
@ -309,6 +312,11 @@ EditorUi.prototype.patchPage = function(page, diff, shadowPage)
model.beginUpdate();
try
{
// Disables update of edge parents during update to avoid interference with
// remote updated edge parents
var prev = model.maintainEdgeParent;
model.maintainEdgeParent = false;
// Handles new root cells
var temp = parentLookup[''];
var cellDiff = (temp != null && temp.inserted != null) ? temp.inserted[''] : null;
@ -378,6 +386,15 @@ EditorUi.prototype.patchPage = function(page, diff, shadowPage)
}
}
}
// Only updates edge parents if there are possible changes which is the case
// for patching the local pages in the case where the file was modified
model.maintainEdgeParent = prev;
if (updateEdgeParents)
{
model.updateEdgeParents(model.root);
}
}
finally
{
@ -527,6 +544,18 @@ EditorUi.prototype.patchCell = function(model, cell, diff, shadowCell)
model.setCollapsed(cell, diff.collapsed == 1);
}
if (diff.vertex != null)
{
// Changes vertex state in-place
cell.vertex = diff.vertex == 1;
}
if (diff.edge != null)
{
// Changes edge state in-place
cell.edge = diff.edge == 1;
}
if (diff.connectable != null)
{
// Changes connectable state in-place
@ -991,6 +1020,16 @@ EditorUi.prototype.diffCell = function(oldCell, newCell)
diff['collapsed'] = (newCell.collapsed) ? 1 : 0;
}
if (oldCell.vertex != newCell.vertex)
{
diff['vertex'] = (newCell.vertex) ? 1 : 0;
}
if (oldCell.edge != newCell.edge)
{
diff['edge'] = (newCell.edge) ? 1 : 0;
}
if (oldCell.connectable != newCell.connectable)
{
diff['connectable'] = (newCell.connectable) ? 1 : 0;

View file

@ -337,16 +337,31 @@ DrawioFile.prototype.checksumError = function(error, patches)
this.stats.uptime = Math.round((new Date().getTime() -
new Date(this.stats.start).getTime()) / 1000);
}
var data = mxUtils.getPrettyXml(file);
if (data != null && data.length > 10000)
{
data = this.ui.editor.graph.compress(data) + '\n';
}
var json = JSON.stringify(patches, null, 2);
if (json != null && json.length > 10000)
{
json = this.ui.editor.graph.compress(json);
}
EditorUi.sendReport('Checksum Error ' + new Date().toISOString() + ':\n\n' +
'File=' + this.getId() + ' (' + this.getMode() + ')\n' +
((this.sync != null) ? ('Client=' + this.sync.clientId + '\n') : '') +
'User=' + uid + '\n' +
'Size=' + this.getSize() + '\n' +
'Sync=' + DrawioFile.SYNC + '\n\n' +
'Stats:\n' + JSON.stringify(this.stats, null, 2) + '\n' +
'Data:\n' + mxUtils.getPrettyXml(file) + '\n' +
'Patches:\n' + JSON.stringify(patches, null, 2));
'Stats:\n' + JSON.stringify(this.stats, null, 2) + '\n\n' +
'Data:\n' + data + '\n' +
'Patches:\n' + json + '\n\n' +
'Stack:\n' + new Error().stack);
}
catch (e)
{
@ -507,7 +522,7 @@ DrawioFile.prototype.patch = function(patches, shadow)
for (var i = 0; i < patches.length; i++)
{
this.ui.pages = this.ui.patchPages(this.ui.pages,
patches[i], true, shadow);
patches[i], true, shadow, this.isModified());
}
}
finally

View file

@ -1753,7 +1753,7 @@
if ((/^https?:\/\//.test(realUrl)) && !this.isCorsEnabledForUrl(realUrl))
{
realUrl = PROXY_URL + '?url=' + encodeURIComponent(desc.url);
realUrl = PROXY_URL + '?url=' + encodeURIComponent(realUrl);
}
// LATER: Remove cache-control header
@ -3405,11 +3405,12 @@
div.style.position = 'absolute';
div.style.overflow = 'hidden';
div.style.borderWidth = '3px';
var elt2 = document.createElement('a');
elt2.className = 'geTitle';
elt2.style.height = '100%';
elt2.style.paddingTop = '9px';
elt2.innerHTML = '<span style="font-size:18px;margin-right:5px;">+</span>';
mxUtils.write(elt2, mxResources.get('moreShapes') + '...');

View file

@ -848,30 +848,28 @@ EditorUi.prototype.removePage = function(page)
{
var next = this.currentPage;
if (next == page)
if (next == page && this.pages.length > 1)
{
if (this.pages.length > 1)
var tmp = mxUtils.indexOf(this.pages, page);
if (tmp == this.pages.length - 1)
{
var tmp = mxUtils.indexOf(this.pages, page);
if (tmp == this.pages.length - 1)
{
tmp--;
}
else
{
tmp++;
}
next = this.pages[tmp];
tmp--;
}
else
{
// Removes label with incorrect page number to force
// default page name which is OK for a single page
next = this.insertPage();
graph.model.execute(new RenamePage(this, next, mxResources.get('pageWithNumber', [1])));
tmp++;
}
next = this.pages[tmp];
}
else if (this.pages.length <= 1)
{
// Removes label with incorrect page number to force
// default page name which is OK for a single page
next = this.insertPage();
graph.model.execute(new RenamePage(this, next,
mxResources.get('pageWithNumber', [1])));
}
// Uses model to fire event to trigger autosave

View file

@ -184,7 +184,7 @@ f)+"\n"+t+"}":"{"+z.join(",")+"}";f=t;return l}}"function"!==typeof Date.prototy
e=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,f,g,h={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},k;"function"!==typeof JSON.stringify&&(JSON.stringify=function(a,b,d){var e;g=f="";if("number"===typeof d)for(e=0;e<d;e+=1)g+=" ";else"string"===typeof d&&(g=d);if((k=b)&&"function"!==typeof b&&("object"!==typeof b||"number"!==typeof b.length))throw Error("JSON.stringify");return c("",{"":a})});
"function"!==typeof JSON.parse&&(JSON.parse=function(a,b){function c(a,d){var e,f,g=a[d];if(g&&"object"===typeof g)for(e in g)Object.prototype.hasOwnProperty.call(g,e)&&(f=c(g,e),void 0!==f?g[e]=f:delete g[e]);return b.call(a,d,g)}var e;a=""+a;d.lastIndex=0;d.test(a)&&(a=a.replace(d,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return e=eval("("+a+")"),"function"===typeof b?c({"":e},""):e;throw new SyntaxError("JSON.parse");})})();"undefined"===typeof window.mxBasePath&&(window.mxBasePath="https://www.draw.io/mxgraph/");window.mxLoadStylesheets=window.mxLoadStylesheets||!1;window.mxLoadResources=window.mxLoadResources||!1;window.mxLanguage=window.mxLanguage||"en";window.urlParams=window.urlParams||{};window.MAX_REQUEST_SIZE=window.MAX_REQUEST_SIZE||10485760;window.MAX_AREA=window.MAX_AREA||225E6;window.EXPORT_URL=window.EXPORT_URL||"/export";window.SAVE_URL=window.SAVE_URL||"/save";window.OPEN_URL=window.OPEN_URL||"/open";window.RESOURCES_PATH=window.RESOURCES_PATH||"resources";window.RESOURCE_BASE=window.RESOURCE_BASE||window.RESOURCES_PATH+"/grapheditor";window.STENCIL_PATH=window.STENCIL_PATH||"stencils";window.IMAGE_PATH=window.IMAGE_PATH||"images";
window.STYLE_PATH=window.STYLE_PATH||"styles";window.CSS_PATH=window.CSS_PATH||"styles";window.OPEN_FORM=window.OPEN_FORM||"open.html";window.mxBasePath=window.mxBasePath||"../../../src";window.mxLanguage=window.mxLanguage||urlParams.lang;window.mxLanguages=window.mxLanguages||["de"];var mxClient={VERSION:"10.0.4",IS_IE:0<=navigator.userAgent.indexOf("MSIE"),IS_IE6:0<=navigator.userAgent.indexOf("MSIE 6"),IS_IE11:!!navigator.userAgent.match(/Trident\/7\./),IS_EDGE:!!navigator.userAgent.match(/Edge\//),IS_QUIRKS:0<=navigator.userAgent.indexOf("MSIE")&&(null==document.documentMode||5==document.documentMode),IS_EM:"spellcheck"in document.createElement("textarea")&&8==document.documentMode,VML_PREFIX:"v",OFFICE_PREFIX:"o",IS_NS:0<=navigator.userAgent.indexOf("Mozilla/")&&0>navigator.userAgent.indexOf("MSIE")&&
window.STYLE_PATH=window.STYLE_PATH||"styles";window.CSS_PATH=window.CSS_PATH||"styles";window.OPEN_FORM=window.OPEN_FORM||"open.html";window.mxBasePath=window.mxBasePath||"../../../src";window.mxLanguage=window.mxLanguage||urlParams.lang;window.mxLanguages=window.mxLanguages||["de"];var mxClient={VERSION:"10.0.5",IS_IE:0<=navigator.userAgent.indexOf("MSIE"),IS_IE6:0<=navigator.userAgent.indexOf("MSIE 6"),IS_IE11:!!navigator.userAgent.match(/Trident\/7\./),IS_EDGE:!!navigator.userAgent.match(/Edge\//),IS_QUIRKS:0<=navigator.userAgent.indexOf("MSIE")&&(null==document.documentMode||5==document.documentMode),IS_EM:"spellcheck"in document.createElement("textarea")&&8==document.documentMode,VML_PREFIX:"v",OFFICE_PREFIX:"o",IS_NS:0<=navigator.userAgent.indexOf("Mozilla/")&&0>navigator.userAgent.indexOf("MSIE")&&
0>navigator.userAgent.indexOf("Edge/"),IS_OP:0<=navigator.userAgent.indexOf("Opera/")||0<=navigator.userAgent.indexOf("OPR/"),IS_OT:0<=navigator.userAgent.indexOf("Presto/")&&0>navigator.userAgent.indexOf("Presto/2.4.")&&0>navigator.userAgent.indexOf("Presto/2.3.")&&0>navigator.userAgent.indexOf("Presto/2.2.")&&0>navigator.userAgent.indexOf("Presto/2.1.")&&0>navigator.userAgent.indexOf("Presto/2.0.")&&0>navigator.userAgent.indexOf("Presto/1."),IS_SF:0<=navigator.userAgent.indexOf("AppleWebKit/")&&
0>navigator.userAgent.indexOf("Chrome/")&&0>navigator.userAgent.indexOf("Edge/"),IS_IOS:navigator.userAgent.match(/(iPad|iPhone|iPod)/g)?!0:!1,IS_GC:0<=navigator.userAgent.indexOf("Chrome/")&&0>navigator.userAgent.indexOf("Edge/"),IS_CHROMEAPP:null!=window.chrome&&null!=chrome.app&&null!=chrome.app.runtime,IS_FF:0<=navigator.userAgent.indexOf("Firefox/"),IS_MT:0<=navigator.userAgent.indexOf("Firefox/")&&0>navigator.userAgent.indexOf("Firefox/1.")&&0>navigator.userAgent.indexOf("Firefox/2.")||0<=navigator.userAgent.indexOf("Iceweasel/")&&
0>navigator.userAgent.indexOf("Iceweasel/1.")&&0>navigator.userAgent.indexOf("Iceweasel/2.")||0<=navigator.userAgent.indexOf("SeaMonkey/")&&0>navigator.userAgent.indexOf("SeaMonkey/1.")||0<=navigator.userAgent.indexOf("Iceape/")&&0>navigator.userAgent.indexOf("Iceape/1."),IS_SVG:0<=navigator.userAgent.indexOf("Firefox/")||0<=navigator.userAgent.indexOf("Iceweasel/")||0<=navigator.userAgent.indexOf("Seamonkey/")||0<=navigator.userAgent.indexOf("Iceape/")||0<=navigator.userAgent.indexOf("Galeon/")||

View file

@ -184,7 +184,7 @@ f)+"\n"+t+"}":"{"+z.join(",")+"}";f=t;return l}}"function"!==typeof Date.prototy
e=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,f,g,h={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},k;"function"!==typeof JSON.stringify&&(JSON.stringify=function(a,b,d){var e;g=f="";if("number"===typeof d)for(e=0;e<d;e+=1)g+=" ";else"string"===typeof d&&(g=d);if((k=b)&&"function"!==typeof b&&("object"!==typeof b||"number"!==typeof b.length))throw Error("JSON.stringify");return c("",{"":a})});
"function"!==typeof JSON.parse&&(JSON.parse=function(a,b){function c(a,d){var e,f,g=a[d];if(g&&"object"===typeof g)for(e in g)Object.prototype.hasOwnProperty.call(g,e)&&(f=c(g,e),void 0!==f?g[e]=f:delete g[e]);return b.call(a,d,g)}var e;a=""+a;d.lastIndex=0;d.test(a)&&(a=a.replace(d,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return e=eval("("+a+")"),"function"===typeof b?c({"":e},""):e;throw new SyntaxError("JSON.parse");})})();"undefined"===typeof window.mxBasePath&&(window.mxBasePath="https://www.draw.io/mxgraph/");window.mxLoadStylesheets=window.mxLoadStylesheets||!1;window.mxLoadResources=window.mxLoadResources||!1;window.mxLanguage=window.mxLanguage||"en";window.urlParams=window.urlParams||{};window.MAX_REQUEST_SIZE=window.MAX_REQUEST_SIZE||10485760;window.MAX_AREA=window.MAX_AREA||225E6;window.EXPORT_URL=window.EXPORT_URL||"/export";window.SAVE_URL=window.SAVE_URL||"/save";window.OPEN_URL=window.OPEN_URL||"/open";window.RESOURCES_PATH=window.RESOURCES_PATH||"resources";window.RESOURCE_BASE=window.RESOURCE_BASE||window.RESOURCES_PATH+"/grapheditor";window.STENCIL_PATH=window.STENCIL_PATH||"stencils";window.IMAGE_PATH=window.IMAGE_PATH||"images";
window.STYLE_PATH=window.STYLE_PATH||"styles";window.CSS_PATH=window.CSS_PATH||"styles";window.OPEN_FORM=window.OPEN_FORM||"open.html";window.mxBasePath=window.mxBasePath||"../../../src";window.mxLanguage=window.mxLanguage||urlParams.lang;window.mxLanguages=window.mxLanguages||["de"];var mxClient={VERSION:"10.0.4",IS_IE:0<=navigator.userAgent.indexOf("MSIE"),IS_IE6:0<=navigator.userAgent.indexOf("MSIE 6"),IS_IE11:!!navigator.userAgent.match(/Trident\/7\./),IS_EDGE:!!navigator.userAgent.match(/Edge\//),IS_QUIRKS:0<=navigator.userAgent.indexOf("MSIE")&&(null==document.documentMode||5==document.documentMode),IS_EM:"spellcheck"in document.createElement("textarea")&&8==document.documentMode,VML_PREFIX:"v",OFFICE_PREFIX:"o",IS_NS:0<=navigator.userAgent.indexOf("Mozilla/")&&0>navigator.userAgent.indexOf("MSIE")&&
window.STYLE_PATH=window.STYLE_PATH||"styles";window.CSS_PATH=window.CSS_PATH||"styles";window.OPEN_FORM=window.OPEN_FORM||"open.html";window.mxBasePath=window.mxBasePath||"../../../src";window.mxLanguage=window.mxLanguage||urlParams.lang;window.mxLanguages=window.mxLanguages||["de"];var mxClient={VERSION:"10.0.5",IS_IE:0<=navigator.userAgent.indexOf("MSIE"),IS_IE6:0<=navigator.userAgent.indexOf("MSIE 6"),IS_IE11:!!navigator.userAgent.match(/Trident\/7\./),IS_EDGE:!!navigator.userAgent.match(/Edge\//),IS_QUIRKS:0<=navigator.userAgent.indexOf("MSIE")&&(null==document.documentMode||5==document.documentMode),IS_EM:"spellcheck"in document.createElement("textarea")&&8==document.documentMode,VML_PREFIX:"v",OFFICE_PREFIX:"o",IS_NS:0<=navigator.userAgent.indexOf("Mozilla/")&&0>navigator.userAgent.indexOf("MSIE")&&
0>navigator.userAgent.indexOf("Edge/"),IS_OP:0<=navigator.userAgent.indexOf("Opera/")||0<=navigator.userAgent.indexOf("OPR/"),IS_OT:0<=navigator.userAgent.indexOf("Presto/")&&0>navigator.userAgent.indexOf("Presto/2.4.")&&0>navigator.userAgent.indexOf("Presto/2.3.")&&0>navigator.userAgent.indexOf("Presto/2.2.")&&0>navigator.userAgent.indexOf("Presto/2.1.")&&0>navigator.userAgent.indexOf("Presto/2.0.")&&0>navigator.userAgent.indexOf("Presto/1."),IS_SF:0<=navigator.userAgent.indexOf("AppleWebKit/")&&
0>navigator.userAgent.indexOf("Chrome/")&&0>navigator.userAgent.indexOf("Edge/"),IS_IOS:navigator.userAgent.match(/(iPad|iPhone|iPod)/g)?!0:!1,IS_GC:0<=navigator.userAgent.indexOf("Chrome/")&&0>navigator.userAgent.indexOf("Edge/"),IS_CHROMEAPP:null!=window.chrome&&null!=chrome.app&&null!=chrome.app.runtime,IS_FF:0<=navigator.userAgent.indexOf("Firefox/"),IS_MT:0<=navigator.userAgent.indexOf("Firefox/")&&0>navigator.userAgent.indexOf("Firefox/1.")&&0>navigator.userAgent.indexOf("Firefox/2.")||0<=navigator.userAgent.indexOf("Iceweasel/")&&
0>navigator.userAgent.indexOf("Iceweasel/1.")&&0>navigator.userAgent.indexOf("Iceweasel/2.")||0<=navigator.userAgent.indexOf("SeaMonkey/")&&0>navigator.userAgent.indexOf("SeaMonkey/1.")||0<=navigator.userAgent.indexOf("Iceape/")&&0>navigator.userAgent.indexOf("Iceape/1."),IS_SVG:0<=navigator.userAgent.indexOf("Firefox/")||0<=navigator.userAgent.indexOf("Iceweasel/")||0<=navigator.userAgent.indexOf("Seamonkey/")||0<=navigator.userAgent.indexOf("Iceape/")||0<=navigator.userAgent.indexOf("Galeon/")||

View file

@ -2037,9 +2037,9 @@ format:new mxRectangle(0,0,1654,2336)},{key:"a3",title:"A3 (297 mm x 420 mm)",fo
(function(){mxGraphView.prototype.validateBackgroundPage=function(){var a=this.graph;if(null!=a.container&&!a.transparentBackground){if(a.pageVisible){var b=this.getBackgroundPageBounds();if(null==this.backgroundPageShape){for(var c=a.container.firstChild;null!=c&&c.nodeType!=mxConstants.NODETYPE_ELEMENT;)c=c.nextSibling;null!=c&&(this.backgroundPageShape=this.createBackgroundPageShape(b),this.backgroundPageShape.scale=1,this.backgroundPageShape.isShadow=!mxClient.IS_QUIRKS,this.backgroundPageShape.dialect=
mxConstants.DIALECT_STRICTHTML,this.backgroundPageShape.init(a.container),c.style.position="absolute",a.container.insertBefore(this.backgroundPageShape.node,c),this.backgroundPageShape.redraw(),this.backgroundPageShape.node.className="geBackgroundPage",mxEvent.addListener(this.backgroundPageShape.node,"dblclick",mxUtils.bind(this,function(c){a.dblClick(c)})),mxEvent.addGestureListeners(this.backgroundPageShape.node,mxUtils.bind(this,function(c){a.fireMouseEvent(mxEvent.MOUSE_DOWN,new mxMouseEvent(c))}),
mxUtils.bind(this,function(c){null!=a.tooltipHandler&&a.tooltipHandler.isHideOnHover()&&a.tooltipHandler.hide();a.isMouseDown&&!mxEvent.isConsumed(c)&&a.fireMouseEvent(mxEvent.MOUSE_MOVE,new mxMouseEvent(c))}),mxUtils.bind(this,function(c){a.fireMouseEvent(mxEvent.MOUSE_UP,new mxMouseEvent(c))})))}else this.backgroundPageShape.scale=1,this.backgroundPageShape.bounds=b,this.backgroundPageShape.redraw()}else null!=this.backgroundPageShape&&(this.backgroundPageShape.destroy(),this.backgroundPageShape=
null);this.validateBackgroundStyles()}};mxGraphView.prototype.validateBackgroundStyles=function(){var a=this.graph,b=null==a.background||a.background==mxConstants.NONE?a.defaultPageBackgroundColor:a.background,c=null!=b&&this.gridColor!=b.toLowerCase()?this.gridColor:"#ffffff",d="none",g="";if(a.isGridEnabled()){g=10;mxClient.IS_SVG?(d=unescape(encodeURIComponent(this.createSvgGrid(c))),d=window.btoa?btoa(d):Base64.encode(d,!0),d="url(data:image/svg+xml;base64,"+d+")",g=a.gridSize*this.scale*this.gridSteps):
d="url("+this.gridImage+")";var e=c=0;null!=a.view.backgroundPageShape&&(e=this.getBackgroundPageBounds(),c=1+e.x,e=1+e.y);g=-Math.round(g-mxUtils.mod(this.translate.x*this.scale-c,g))+"px "+-Math.round(g-mxUtils.mod(this.translate.y*this.scale-e,g))+"px"}c=a.view.canvas;null!=c.ownerSVGElement&&(c=c.ownerSVGElement);null!=a.view.backgroundPageShape?(a.view.backgroundPageShape.node.style.backgroundPosition=g,a.view.backgroundPageShape.node.style.backgroundImage=d,a.view.backgroundPageShape.node.style.backgroundColor=
b,a.container.className="geDiagramContainer geDiagramBackdrop",c.style.backgroundImage="none",c.style.backgroundColor=""):(a.container.className="geDiagramContainer",c.style.backgroundPosition=g,c.style.backgroundColor=b,c.style.backgroundImage=d)};mxGraphView.prototype.createSvgGrid=function(a){for(var b=this.graph.gridSize*this.scale;b<this.minGridSize;)b*=2;for(var c=this.gridSteps*b,d=[],g=1;g<this.gridSteps;g++){var e=g*b;d.push("M 0 "+e+" L "+c+" "+e+" M "+e+" 0 L "+e+" "+c)}return'<svg width="'+
null);this.validateBackgroundStyles()}};mxGraphView.prototype.validateBackgroundStyles=function(){var a=this.graph,b=null==a.background||a.background==mxConstants.NONE?a.defaultPageBackgroundColor:a.background,c=null!=b&&this.gridColor!=b.toLowerCase()?this.gridColor:"#ffffff",f="none",d="";if(a.isGridEnabled()){d=10;mxClient.IS_SVG?(f=unescape(encodeURIComponent(this.createSvgGrid(c))),f=window.btoa?btoa(f):Base64.encode(f,!0),f="url(data:image/svg+xml;base64,"+f+")",d=a.gridSize*this.scale*this.gridSteps):
f="url("+this.gridImage+")";var e=c=0;null!=a.view.backgroundPageShape&&(e=this.getBackgroundPageBounds(),c=1+e.x,e=1+e.y);d=-Math.round(d-mxUtils.mod(this.translate.x*this.scale-c,d))+"px "+-Math.round(d-mxUtils.mod(this.translate.y*this.scale-e,d))+"px"}c=a.view.canvas;null!=c.ownerSVGElement&&(c=c.ownerSVGElement);null!=a.view.backgroundPageShape?(a.view.backgroundPageShape.node.style.backgroundPosition=d,a.view.backgroundPageShape.node.style.backgroundImage=f,a.view.backgroundPageShape.node.style.backgroundColor=
b,a.container.className="geDiagramContainer geDiagramBackdrop",c.style.backgroundImage="none",c.style.backgroundColor=""):(a.container.className="geDiagramContainer",c.style.backgroundPosition=d,c.style.backgroundColor=b,c.style.backgroundImage=f)};mxGraphView.prototype.createSvgGrid=function(a){for(var b=this.graph.gridSize*this.scale;b<this.minGridSize;)b*=2;for(var c=this.gridSteps*b,d=[],g=1;g<this.gridSteps;g++){var e=g*b;d.push("M 0 "+e+" L "+c+" "+e+" M "+e+" 0 L "+e+" "+c)}return'<svg width="'+
c+'" height="'+c+'" xmlns="'+mxConstants.NS_SVG+'"><defs><pattern id="grid" width="'+c+'" height="'+c+'" patternUnits="userSpaceOnUse"><path d="'+d.join(" ")+'" fill="none" stroke="'+a+'" opacity="0.2" stroke-width="1"/><path d="M '+c+" 0 L 0 0 0 "+c+'" fill="none" stroke="'+a+'" stroke-width="1"/></pattern></defs><rect width="100%" height="100%" fill="url(#grid)"/></svg>'};var a=mxGraph.prototype.panGraph;mxGraph.prototype.panGraph=function(b,d){a.apply(this,arguments);if(null!=this.shiftPreview1){var c=
this.view.canvas;null!=c.ownerSVGElement&&(c=c.ownerSVGElement);var f=this.gridSize*this.view.scale*this.view.gridSteps,f=-Math.round(f-mxUtils.mod(this.view.translate.x*this.view.scale+b,f))+"px "+-Math.round(f-mxUtils.mod(this.view.translate.y*this.view.scale+d,f))+"px";c.style.backgroundPosition=f}};mxGraph.prototype.updatePageBreaks=function(a,b,c){var d=this.view.scale,g=this.view.translate,e=this.pageFormat,n=d*this.pageScale,l=this.view.getBackgroundPageBounds();b=l.width;c=l.height;var r=
new mxRectangle(d*g.x,d*g.y,e.width*n,e.height*n),w=(a=a&&Math.min(r.width,r.height)>this.minPageBreakDist)?Math.ceil(c/r.height)-1:0,v=a?Math.ceil(b/r.width)-1:0,h=l.x+b,x=l.y+c;null==this.horizontalPageBreaks&&0<w&&(this.horizontalPageBreaks=[]);null==this.verticalPageBreaks&&0<v&&(this.verticalPageBreaks=[]);a=mxUtils.bind(this,function(a){if(null!=a){for(var c=a==this.horizontalPageBreaks?w:v,b=0;b<=c;b++){var d=a==this.horizontalPageBreaks?[new mxPoint(Math.round(l.x),Math.round(l.y+(b+1)*r.height)),
@ -2650,14 +2650,14 @@ DrawioFile.prototype.mergeFile=function(a,b,e){try{var d=null!=this.shadowPages?
q=this.ui.getHashValueForPages(this.shadowPages);EditorUi.debug("File.mergeFile",[this],"patch",h,"checksum",q==p,p);p!=q?(this.stats.checksumErrors++,this.checksumError(e,[h])):(this.backupPatch=null,this.inConflictState=this.invalidChecksum=!1,this.setDescriptor(a.getDescriptor()),this.descriptorChanged(),null!=b&&b())}catch(f){this.invalidChecksum=this.inConflictState=!0;null!=window.console&&"1"==urlParams.test&&console.log(f);null!=e&&e(f);try{var u=this.getCurrentUser(),c=null!=u?this.ui.hashValue(u.id):
"unknown";EditorUi.sendReport("Error in mergeFile "+(new Date).toISOString()+":\n\nFile="+this.getId()+" ("+this.getMode()+")\n"+(null!=this.sync?"Client="+this.sync.clientId+"\n":"")+"User="+c+"\nSize="+this.getSize()+"\nSync="+DrawioFile.SYNC+"\n\nStack:\n"+f.stack)}catch(g){}}};
DrawioFile.prototype.checksumError=function(a,b){this.invalidChecksum=this.inConflictState=!0;this.descriptorChanged();null!=this.sync&&this.sync.updateOnlineState();null!=a&&a();try{if(null!=b)for(var e=0;e<b.length;e++)this.ui.anonymizePatch(b[e]);var d=new mxCodec(mxUtils.createXmlDocument()),h=d.document.createElement("mxfile");if(null!=this.shadowPages)for(e=0;e<this.shadowPages.length;e++){var m=this.ui.anonymizeNode(d.encode(new mxGraphModel(this.shadowPages[e].root)));m.setAttribute("id",
this.shadowPages[e].getId());h.appendChild(m)}var p=this.getCurrentUser(),q=null!=p?this.ui.hashValue(p.id):"unknown";null!=this.stats.start&&(this.stats.uptime=Math.round(((new Date).getTime()-(new Date(this.stats.start)).getTime())/1E3));EditorUi.sendReport("Checksum Error "+(new Date).toISOString()+":\n\nFile="+this.getId()+" ("+this.getMode()+")\n"+(null!=this.sync?"Client="+this.sync.clientId+"\n":"")+"User="+q+"\nSize="+this.getSize()+"\nSync="+DrawioFile.SYNC+"\n\nStats:\n"+JSON.stringify(this.stats,
null,2)+"\nData:\n"+mxUtils.getPrettyXml(h)+"\nPatches:\n"+JSON.stringify(b,null,2))}catch(u){console.error(u)}};
this.shadowPages[e].getId());h.appendChild(m)}var p=this.getCurrentUser(),q=null!=p?this.ui.hashValue(p.id):"unknown";null!=this.stats.start&&(this.stats.uptime=Math.round(((new Date).getTime()-(new Date(this.stats.start)).getTime())/1E3));var u=mxUtils.getPrettyXml(h);null!=u&&1E4<u.length&&(u=this.ui.editor.graph.compress(u)+"\n");var c=JSON.stringify(b,null,2);null!=c&&1E4<c.length&&(c=this.ui.editor.graph.compress(c));EditorUi.sendReport("Checksum Error "+(new Date).toISOString()+":\n\nFile="+
this.getId()+" ("+this.getMode()+")\n"+(null!=this.sync?"Client="+this.sync.clientId+"\n":"")+"User="+q+"\nSize="+this.getSize()+"\nSync="+DrawioFile.SYNC+"\n\nStats:\n"+JSON.stringify(this.stats,null,2)+"\n\nData:\n"+u+"\nPatches:\n"+c+"\n\nStack:\n"+Error().stack)}catch(f){console.error(f)}};
DrawioFile.prototype.reloadFile=function(a,b){try{this.ui.spinner.stop();var e=mxUtils.bind(this,function(){this.setModified(!1);var b=this.ui.currentPage,e=this.ui.editor.graph.getViewState(),m=this.ui.editor.graph.getSelectionCells();this.reportEnabled=!1;this.stats.reloads++;this.ui.loadFile(this.getHash(),!0,null,mxUtils.bind(this,function(){this.ui.restoreViewState(b,e,m);null!=this.backupPatch&&this.patch([this.backupPatch]);var d=this.ui.getCurrentFile();null!=d&&(d.stats=this.stats);null!=
a&&a()}))});this.isModified()&&null==this.backupPatch?this.ui.confirm(mxResources.get("allChangesLost"),mxUtils.bind(this,function(){this.handleFileSuccess("manual"==DrawioFile.SYNC)}),e,mxResources.get("cancel"),mxResources.get("discardChanges")):e()}catch(d){null!=b&&b(d)}};
DrawioFile.prototype.copyFile=function(a,b){this.constructor!=DriveFile||this.isRestricted()?this.ui.editor.editAsNew(this.ui.getFileData(!0),this.ui.getCopyFilename(this)):this.makeCopy(mxUtils.bind(this,function(){if(this.ui.spinner.spin(document.body,mxResources.get("saving")))try{this.save(!0,a,b)}catch(e){b(e)}}),b,!0)};DrawioFile.prototype.ignorePatches=function(a){for(var b=!0,e=0;e<a.length&&b;e++)b=b&&0==Object.keys(a[e]).length;return b};
DrawioFile.prototype.patch=function(a,b){if(!this.ignorePatches(a)){var e=this.ui.editor.undoManager,d=e.history.slice(),h=e.indexOfNextAdd,m=this.ui.editor.graph;m.container.style.visibility="hidden";var p=this.changeListenerEnabled;this.changeListenerEnabled=!1;var q=m.foldingEnabled,u=m.mathEnabled,c=m.cellRenderer.redraw;m.cellRenderer.redraw=function(a){a.view.graph.isEditing(a.cell)&&(a.view.graph.scrollCellToVisible(a.cell),a.view.graph.cellEditor.resize());c.apply(this,arguments)};m.model.beginUpdate();
try{for(var f=0;f<a.length;f++)this.ui.pages=this.ui.patchPages(this.ui.pages,a[f],!0,b)}finally{m.model.endUpdate();null!=this.ui.pages&&0<this.ui.pages.length&&0>mxUtils.indexOf(this.ui.pages,this.ui.currentPage)&&this.ui.selectPage(this.ui.pages[0],!0);m.cellRenderer.redraw=c;this.changeListenerEnabled=p;m.container.style.visibility="";e.history=d;e.indexOfNextAdd=h;e.fireEvent(new mxEventObject(mxEvent.CLEAR));if(null==this.ui.currentPage||this.ui.currentPage.needsUpdate)u!=m.mathEnabled?(this.ui.editor.updateGraphComponents(),
m.refresh()):(q!=m.foldingEnabled?m.view.revalidate():m.view.validate(),m.sizeDidChange()),null!=this.ui.format&&m.isSelectionEmpty()&&this.ui.format.refresh();this.ui.updateTabContainer()}}};DrawioFile.prototype.save=function(a,b,e,d,h,m){if(this.isEditable()){if(this.invalidChecksum)throw Error(mxResources.get("checksum"));this.updateFileData();this.clearAutosave()}else throw Error(mxResources.get("readOnly"));};
try{for(var f=0;f<a.length;f++)this.ui.pages=this.ui.patchPages(this.ui.pages,a[f],!0,b,this.isModified())}finally{m.model.endUpdate();null!=this.ui.pages&&0<this.ui.pages.length&&0>mxUtils.indexOf(this.ui.pages,this.ui.currentPage)&&this.ui.selectPage(this.ui.pages[0],!0);m.cellRenderer.redraw=c;this.changeListenerEnabled=p;m.container.style.visibility="";e.history=d;e.indexOfNextAdd=h;e.fireEvent(new mxEventObject(mxEvent.CLEAR));if(null==this.ui.currentPage||this.ui.currentPage.needsUpdate)u!=
m.mathEnabled?(this.ui.editor.updateGraphComponents(),m.refresh()):(q!=m.foldingEnabled?m.view.revalidate():m.view.validate(),m.sizeDidChange()),null!=this.ui.format&&m.isSelectionEmpty()&&this.ui.format.refresh();this.ui.updateTabContainer()}}};DrawioFile.prototype.save=function(a,b,e,d,h,m){if(this.isEditable()){if(this.invalidChecksum)throw Error(mxResources.get("checksum"));this.updateFileData();this.clearAutosave()}else throw Error(mxResources.get("readOnly"));};
DrawioFile.prototype.updateFileData=function(){this.setData(this.ui.getFileData(null,null,null,null,null,null,null,null,this))};DrawioFile.prototype.saveAs=function(a,b,e){};DrawioFile.prototype.saveFile=function(a,b,e,d){};DrawioFile.prototype.getPublicUrl=function(a){a(null)};DrawioFile.prototype.isRestricted=function(){return!1};DrawioFile.prototype.isModified=function(){return this.modified};DrawioFile.prototype.setModified=function(a){this.modified=a};
DrawioFile.prototype.isAutosaveOptional=function(){return!1};DrawioFile.prototype.isAutosave=function(){return!this.inConflictState&&this.ui.editor.autosave};DrawioFile.prototype.isRenamable=function(){return!1};DrawioFile.prototype.rename=function(a,b,e){};DrawioFile.prototype.isMovable=function(){return!1};DrawioFile.prototype.move=function(a,b,e){};DrawioFile.prototype.getHash=function(){return""};DrawioFile.prototype.getId=function(){return""};
DrawioFile.prototype.isEditable=function(){return!this.ui.editor.isChromelessView()||this.ui.editor.editable};DrawioFile.prototype.getUi=function(){return this.ui};DrawioFile.prototype.getTitle=function(){return""};DrawioFile.prototype.setData=function(a){this.data=a};DrawioFile.prototype.getData=function(){return this.data};
@ -2887,8 +2887,8 @@ EditorUi.prototype.createDownloadRequest=function(a,b,d,e,n,l){var c=this.editor
"png"==b&&n&&(l=mxConstants.NONE);return new mxXmlRequest(EXPORT_URL,"format="+b+f+g+"&bg="+(null!=l?l:mxConstants.NONE)+"&base64="+e+"&embedXml="+c+"&xml="+encodeURIComponent(d)+(null!=a?"&filename="+encodeURIComponent(a):""))};EditorUi.prototype.setMode=function(a,b){this.mode=a};EditorUi.prototype.loadDescriptor=function(a,b,d){var c=window.location.hash,f=mxUtils.bind(this,function(d){var f=null!=a.data?a.data:"";null!=d&&0<d.length&&(0<f.length&&(f+="\n"),f+=d);d=new LocalFile(this,"csv"!=a.format&&
0<f.length?f:this.emptyDiagramXml,null!=urlParams.title?decodeURIComponent(urlParams.title):this.defaultFilename,!0);d.getHash=function(){return c};this.fileLoaded(d);"csv"==a.format&&this.importCsv(f,mxUtils.bind(this,function(a){this.editor.undoManager.clear();this.editor.setModified(!1);this.editor.setStatus("")}));if(null!=a.update){var e=null!=a.interval?parseInt(a.interval):6E4,g=null,k=mxUtils.bind(this,function(){var c=this.currentPage;mxUtils.post(a.update,"xml="+encodeURIComponent(mxUtils.getXml(this.editor.getGraphXml())),
mxUtils.bind(this,function(a){c===this.currentPage&&(200<=a.getStatus()&&300>=a.getStatus()?(this.updateDiagram(a.getText()),l()):this.handleError({message:mxResources.get("error")+" "+a.getStatus()}))}),mxUtils.bind(this,function(a){this.handleError(a)}))}),l=mxUtils.bind(this,function(){window.clearTimeout(g);g=window.setTimeout(k,e)});this.editor.addListener("pageSelected",mxUtils.bind(this,function(){l();k()}));l();k()}null!=b&&b()});if(null!=a.url&&0<a.url.length){var e=a.url;/^https?:\/\//.test(e)&&
!this.isCorsEnabledForUrl(e)&&(e=PROXY_URL+"?url="+encodeURIComponent(a.url));this.loadUrl(e,mxUtils.bind(this,function(a){f(a)}),mxUtils.bind(this,function(a){null!=d&&d(a)}))}else f("")};EditorUi.prototype.updateDiagram=function(a){function c(a){var c=new mxCellOverlay(a.image||e.warningImage,a.tooltip,a.align,a.valign,a.offset);c.addListener(mxEvent.CLICK,function(c,b){d.alert(a.tooltip)});return c}var b=null,d=this;if(null!=a&&0<a.length&&(b=mxUtils.parseXml(a),a=null!=b?b.documentElement:null,
null!=a&&"updates"==a.nodeName)){var e=this.editor.graph,l=e.getModel();l.beginUpdate();var r=null;try{for(a=a.firstChild;null!=a;){if("update"==a.nodeName){var h=l.getCell(a.getAttribute("id"));if(null!=h){try{var v=a.getAttribute("value");if(null!=v){var m=mxUtils.parseXml(v).documentElement;if(null!=m)if("1"==m.getAttribute("replace-value"))l.setValue(h,m);else for(var p=m.attributes,t=0;t<p.length;t++)e.setAttributeForCell(h,p[t].nodeName,0<p[t].nodeValue.length?p[t].nodeValue:null)}}catch(A){null!=
!this.isCorsEnabledForUrl(e)&&(e=PROXY_URL+"?url="+encodeURIComponent(e));this.loadUrl(e,mxUtils.bind(this,function(a){f(a)}),mxUtils.bind(this,function(a){null!=d&&d(a)}))}else f("")};EditorUi.prototype.updateDiagram=function(a){function c(a){var c=new mxCellOverlay(a.image||e.warningImage,a.tooltip,a.align,a.valign,a.offset);c.addListener(mxEvent.CLICK,function(c,b){d.alert(a.tooltip)});return c}var b=null,d=this;if(null!=a&&0<a.length&&(b=mxUtils.parseXml(a),a=null!=b?b.documentElement:null,null!=
a&&"updates"==a.nodeName)){var e=this.editor.graph,l=e.getModel();l.beginUpdate();var r=null;try{for(a=a.firstChild;null!=a;){if("update"==a.nodeName){var h=l.getCell(a.getAttribute("id"));if(null!=h){try{var v=a.getAttribute("value");if(null!=v){var m=mxUtils.parseXml(v).documentElement;if(null!=m)if("1"==m.getAttribute("replace-value"))l.setValue(h,m);else for(var p=m.attributes,t=0;t<p.length;t++)e.setAttributeForCell(h,p[t].nodeName,0<p[t].nodeValue.length?p[t].nodeValue:null)}}catch(A){null!=
window.console&&console.log("Error in value for "+h.id+": "+A)}try{var q=a.getAttribute("style");null!=q&&e.model.setStyle(h,q)}catch(A){null!=window.console&&console.log("Error in style for "+h.id+": "+A)}try{var C=a.getAttribute("icon");if(null!=C){var u=0<C.length?JSON.parse(C):null;null!=u&&u.append||e.removeCellOverlays(h);null!=u&&e.addCellOverlay(h,c(u))}}catch(A){null!=window.console&&console.log("Error in icon for "+h.id+": "+A)}try{var D=a.getAttribute("geometry");if(null!=D){var D=JSON.parse(D),
G=e.getCellGeometry(h);if(null!=G){G=G.clone();for(key in D){var J=parseFloat(D[key]);"dx"==key?G.x+=J:"dy"==key?G.y+=J:"dw"==key?G.width+=J:"dh"==key?G.height+=J:G[key]=parseFloat(D[key])}e.model.setGeometry(h,G)}}}catch(A){null!=window.console&&console.log("Error in icon for "+h.id+": "+A)}}}else if("model"==a.nodeName){for(var y=a.firstChild;null!=y&&y.nodeType!=mxConstants.NODETYPE_ELEMENT;)y=y.nextSibling;null!=y&&(new mxCodec(a.firstChild)).decode(y,l)}else if("view"==a.nodeName){if(a.hasAttribute("scale")&&
(e.view.scale=parseFloat(a.getAttribute("scale"))),a.hasAttribute("dx")||a.hasAttribute("dy"))e.view.translate=new mxPoint(parseFloat(a.getAttribute("dx")||0),parseFloat(a.getAttribute("dy")||0))}else"fit"==a.nodeName&&(r=a.hasAttribute("max-scale")?parseFloat(a.getAttribute("max-scale")):1);a=a.nextSibling}}finally{l.endUpdate()}null!=r&&this.chromelessResize&&this.chromelessResize(!0,r)}return b};EditorUi.prototype.getCopyFilename=function(a,b){var c=null!=a&&null!=a.getTitle()?a.getTitle():this.defaultFilename,
@ -2931,13 +2931,13 @@ function(){return document.getElementById("geFooter")});EditorUi.initTheme=funct
Editor.checkmarkImage="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAMAAACeyVWkAAAARVBMVEUAAACZmZkICAgEBASNjY2Dg4MYGBiTk5N5eXl1dXVmZmZQUFBCQkI3NzceHh4MDAykpKSJiYl+fn5sbGxaWlo/Pz8SEhK96uPlAAAAAXRSTlMAQObYZgAAAE5JREFUGNPFzTcSgDAQQ1HJGUfy/Y9K7V1qeOUfzQifCQZai1XHaz11LFysbDbzgDSSWMZiETz3+b8yNUc/MMsktxuC8XQBSncdLwz+8gCCggGXzBcozAAAAABJRU5ErkJggg=="))};EditorUi.initTheme();EditorUi.prototype.hideFooter=function(){var a=document.getElementById("geFooter");null!=a&&(this.footerHeight=0,a.style.display=
"none",this.refresh())};EditorUi.prototype.showFooter=function(a){var c=document.getElementById("geFooter");null!=c&&(this.footerHeight=a,c.style.display="inline",this.refresh())};EditorUi.prototype.showImageDialog=function(a,b,d,e,n){a=new ImageDialog(this,a,b,d,e,n);this.showDialog(a.container,Graph.fileSupport?440:360,Graph.fileSupport?200:90,!0,!0);a.init()};EditorUi.prototype.showBackgroundImageDialog=function(a){a=null!=a?a:mxUtils.bind(this,function(a){a=new ChangePageSetup(this,null,a);a.ignoreColor=
!0;this.editor.graph.model.execute(a)});var c=new BackgroundImageDialog(this,mxUtils.bind(this,function(c){a(c)}));this.showDialog(c.container,360,200,!0,!0);c.init()};EditorUi.prototype.showLibraryDialog=function(a,b,d,e,n){a=new LibraryDialog(this,a,b,d,e,n);this.showDialog(a.container,620,440,!0,!1,mxUtils.bind(this,function(a){a&&null==this.getCurrentFile()&&"1"!=urlParams.embed&&this.showSplash()}));a.init()};EditorUi.prototype.createSidebarFooterContainer=function(){var a=this.createDiv("geSidebarContainer");
a.style.position="absolute";a.style.overflow="hidden";a.style.borderWidth="3px";var b=document.createElement("a");b.className="geTitle";b.style.height="100%";b.style.paddingTop="9px";mxUtils.write(b,mxResources.get("moreShapes")+"...");mxEvent.addListener(b,mxClient.IS_POINTER?"pointerdown":"mousedown",mxUtils.bind(this,function(a){a.preventDefault()}));mxEvent.addListener(b,"click",mxUtils.bind(this,function(a){this.actions.get("shapes").funct();mxEvent.consume(a)}));a.appendChild(b);return a};EditorUi.prototype.handleError=
function(a,b,d){var c=null!=this.spinner&&null!=this.spinner.pause?this.spinner.pause():function(){},e=null!=a&&null!=a.error?a.error:a;if(null!=e||null!=b){a=mxUtils.htmlEntities(mxResources.get("unknownError"));var f=mxResources.get("ok"),g=null;b=null!=b?b:mxResources.get("error");if(null!=e)if(null!=e.retry&&(f=mxResources.get("cancel"),g=function(){c();e.retry()}),404==e.code||404==e.status){a=mxUtils.htmlEntities(mxResources.get("fileNotFoundOrDenied"));var h=window.location.hash;null!=h&&"#G"==
h.substring(0,2)&&(h=h.substring(2),a+=' <a href="https://drive.google.com/open?id='+h+'" target="_blank">'+mxUtils.htmlEntities(mxResources.get("tryOpeningViaThisPage"))+"</a>")}else null!=e.message?a=mxUtils.htmlEntities(e.message):null!=e.response&&null!=e.response.error?a=mxUtils.htmlEntities(e.response.error):"undefined"!==window.App&&(e.code==App.ERROR_TIMEOUT?a=mxUtils.htmlEntities(mxResources.get("timeout")):e.code==App.ERROR_BUSY&&(a=mxUtils.htmlEntities(mxResources.get("busy"))));this.showError(b,
a,f,d,g)}else null!=d&&d()};EditorUi.prototype.showError=function(a,b,d,e,n,l,r,h,v,m,p,t){a=new ErrorDialog(this,a,b,d||mxResources.get("ok"),e,n,l,r,t,h,v);this.showDialog(a.container,m||340,p||150,!0,!1);a.init()};EditorUi.prototype.alert=function(a,b){var c=new ErrorDialog(this,null,a,mxResources.get("ok"),b);this.showDialog(c.container,340,100,!0,!1);c.init()};EditorUi.prototype.confirm=function(a,b,d,e,n){var c=null!=this.spinner&&null!=this.spinner.pause?this.spinner.pause():function(){};this.showDialog((new ConfirmDialog(this,
a,function(){c();null!=b&&b()},function(){c();null!=d&&d()},e,n)).container,340,90,!0,!1)};EditorUi.prototype.setCurrentFile=function(a){this.currentFile=a};EditorUi.prototype.getCurrentFile=function(){return this.currentFile};EditorUi.prototype.isExportToCanvas=function(){return mxClient.IS_CHROMEAPP||!this.editor.graph.mathEnabled&&this.useCanvasForExport};EditorUi.prototype.createSvgDataUri=function(a){return"data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(a)))};EditorUi.prototype.createImageDataUri=
function(a,b,d){var c=a.toDataURL("image/"+d);if(6>=c.length||c==a.cloneNode(!1).toDataURL("image/"+d))throw{message:"Invalid image"};null!=b&&(c=this.writeGraphModelToPng(c,"zTXt","mxGraphModel",atob(this.editor.graph.compress(b))));return c};EditorUi.prototype.saveCanvas=function(a,b,d){var c="jpeg"==d?"jpg":d,e=this.getBaseFilename()+"."+c;a=this.createImageDataUri(a,b,d);this.saveData(e,c,a.substring(a.lastIndexOf(",")+1),"image/"+d,!0)};EditorUi.prototype.isLocalFileSave=function(){return"remote"!=
urlParams.save&&(mxClient.IS_IE||"undefined"!==typeof window.Blob&&"undefined"!==typeof window.URL)&&9!=document.documentMode&&8!=document.documentMode&&7!=document.documentMode&&!mxClient.IS_QUIRKS||this.isOfflineApp()||mxClient.IS_IOS};EditorUi.prototype.showTextDialog=function(a,b){var c=new TextareaDialog(this,a,b,null,null,mxResources.get("close"));c.textarea.style.width="600px";c.textarea.style.height="380px";this.showDialog(c.container,620,460,!0,!0);c.init();document.execCommand("selectall",
a.style.position="absolute";a.style.overflow="hidden";a.style.borderWidth="3px";var b=document.createElement("a");b.className="geTitle";b.style.height="100%";b.style.paddingTop="9px";b.innerHTML='<span style="font-size:18px;margin-right:5px;">+</span>';mxUtils.write(b,mxResources.get("moreShapes")+"...");mxEvent.addListener(b,mxClient.IS_POINTER?"pointerdown":"mousedown",mxUtils.bind(this,function(a){a.preventDefault()}));mxEvent.addListener(b,"click",mxUtils.bind(this,function(a){this.actions.get("shapes").funct();
mxEvent.consume(a)}));a.appendChild(b);return a};EditorUi.prototype.handleError=function(a,b,d){var c=null!=this.spinner&&null!=this.spinner.pause?this.spinner.pause():function(){},e=null!=a&&null!=a.error?a.error:a;if(null!=e||null!=b){a=mxUtils.htmlEntities(mxResources.get("unknownError"));var f=mxResources.get("ok"),g=null;b=null!=b?b:mxResources.get("error");if(null!=e)if(null!=e.retry&&(f=mxResources.get("cancel"),g=function(){c();e.retry()}),404==e.code||404==e.status){a=mxUtils.htmlEntities(mxResources.get("fileNotFoundOrDenied"));
var h=window.location.hash;null!=h&&"#G"==h.substring(0,2)&&(h=h.substring(2),a+=' <a href="https://drive.google.com/open?id='+h+'" target="_blank">'+mxUtils.htmlEntities(mxResources.get("tryOpeningViaThisPage"))+"</a>")}else null!=e.message?a=mxUtils.htmlEntities(e.message):null!=e.response&&null!=e.response.error?a=mxUtils.htmlEntities(e.response.error):"undefined"!==window.App&&(e.code==App.ERROR_TIMEOUT?a=mxUtils.htmlEntities(mxResources.get("timeout")):e.code==App.ERROR_BUSY&&(a=mxUtils.htmlEntities(mxResources.get("busy"))));
this.showError(b,a,f,d,g)}else null!=d&&d()};EditorUi.prototype.showError=function(a,b,d,e,n,l,r,h,v,m,p,t){a=new ErrorDialog(this,a,b,d||mxResources.get("ok"),e,n,l,r,t,h,v);this.showDialog(a.container,m||340,p||150,!0,!1);a.init()};EditorUi.prototype.alert=function(a,b){var c=new ErrorDialog(this,null,a,mxResources.get("ok"),b);this.showDialog(c.container,340,100,!0,!1);c.init()};EditorUi.prototype.confirm=function(a,b,d,e,n){var c=null!=this.spinner&&null!=this.spinner.pause?this.spinner.pause():
function(){};this.showDialog((new ConfirmDialog(this,a,function(){c();null!=b&&b()},function(){c();null!=d&&d()},e,n)).container,340,90,!0,!1)};EditorUi.prototype.setCurrentFile=function(a){this.currentFile=a};EditorUi.prototype.getCurrentFile=function(){return this.currentFile};EditorUi.prototype.isExportToCanvas=function(){return mxClient.IS_CHROMEAPP||!this.editor.graph.mathEnabled&&this.useCanvasForExport};EditorUi.prototype.createSvgDataUri=function(a){return"data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(a)))};
EditorUi.prototype.createImageDataUri=function(a,b,d){var c=a.toDataURL("image/"+d);if(6>=c.length||c==a.cloneNode(!1).toDataURL("image/"+d))throw{message:"Invalid image"};null!=b&&(c=this.writeGraphModelToPng(c,"zTXt","mxGraphModel",atob(this.editor.graph.compress(b))));return c};EditorUi.prototype.saveCanvas=function(a,b,d){var c="jpeg"==d?"jpg":d,e=this.getBaseFilename()+"."+c;a=this.createImageDataUri(a,b,d);this.saveData(e,c,a.substring(a.lastIndexOf(",")+1),"image/"+d,!0)};EditorUi.prototype.isLocalFileSave=
function(){return"remote"!=urlParams.save&&(mxClient.IS_IE||"undefined"!==typeof window.Blob&&"undefined"!==typeof window.URL)&&9!=document.documentMode&&8!=document.documentMode&&7!=document.documentMode&&!mxClient.IS_QUIRKS||this.isOfflineApp()||mxClient.IS_IOS};EditorUi.prototype.showTextDialog=function(a,b){var c=new TextareaDialog(this,a,b,null,null,mxResources.get("close"));c.textarea.style.width="600px";c.textarea.style.height="380px";this.showDialog(c.container,620,460,!0,!0);c.init();document.execCommand("selectall",
!1,null)};EditorUi.prototype.doSaveLocalFile=function(a,b,d,e,n){if(window.Blob&&navigator.msSaveOrOpenBlob)a=e?this.base64ToBlob(a,d):new Blob([a],{type:d}),navigator.msSaveOrOpenBlob(a,b);else if(mxClient.IS_IE)d=window.open("about:blank","_blank"),null==d?mxUtils.popup(a,!0):(d.document.write(a),d.document.close(),d.document.execCommand("SaveAs",!0,b),d.close());else if(mxClient.IS_IOS)this.showTextDialog(b+":",a);else{var c=document.createElement("a"),f=!mxClient.IS_SF&&0>navigator.userAgent.indexOf("PaleMoon/")&&
"undefined"!==typeof c.download;if(mxClient.IS_GC)var g=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./),f=65==(g?parseInt(g[2],10):!1)?!1:f;if(f||this.isOffline()){c.href=URL.createObjectURL(e?this.base64ToBlob(a,d):new Blob([a],{type:d}));f?c.download=b:c.setAttribute("target","_blank");document.body.appendChild(c);try{window.setTimeout(function(){URL.revokeObjectURL(c.href)},0),c.click(),c.parentNode.removeChild(c)}catch(v){}}else this.createEchoRequest(a,b,d,e,n).simulate(document,"_blank")}};
EditorUi.prototype.createEchoRequest=function(a,b,d,e,n,l){a="xml="+encodeURIComponent(a);return new mxXmlRequest(SAVE_URL,a+(null!=d?"&mime="+d:"")+(null!=n?"&format="+n:"")+(null!=l?"&base64="+l:"")+(null!=b?"&filename="+encodeURIComponent(b):"")+(e?"&binary=1":""))};EditorUi.prototype.base64ToBlob=function(a,b){b=b||"";for(var c=atob(a),d=c.length,e=Math.ceil(d/1024),f=Array(e),r=0;r<e;++r){for(var h=1024*r,v=Math.min(h+1024,d),m=Array(v-h),p=0;h<v;++p,++h)m[p]=c[h].charCodeAt(0);f[r]=new Uint8Array(m)}return new Blob(f,
@ -3043,7 +3043,7 @@ function(){return a})})});/(\.v(dx|sdx?))($|\?)/i.test(l.name)||/(\.vs(x|sx?))($
mxSettings.getResizeImages():null,e=function(d,e){if(d||b)mxSettings.setResizeImages(d?e:null),mxSettings.save();c();a(e)};null==d||b?this.showDialog((new ConfirmDialog(this,mxResources.get("resizeLargeImages"),function(a){e(a,!0)},function(a){e(a,!1)},mxResources.get("resize"),mxResources.get("actualSize"),'<img style="margin-top:8px;" src="'+Editor.loResImage+'"/>','<img style="margin-top:8px;" src="'+Editor.hiResImage+'"/>',isLocalStorage||mxClient.IS_CHROMEAPP)).container,340,isLocalStorage||
mxClient.IS_CHROMEAPP?220:200,!0,!0):e(!1,d)};EditorUi.prototype.parseFile=function(a,b,d){d=null!=d?d:a.name;var c=new FormData;c.append("format","xml");c.append("upfile",a,d);var e=new XMLHttpRequest;e.open("POST",OPEN_URL);e.onreadystatechange=function(){b(e)};e.send(c)};EditorUi.prototype.isResampleImage=function(a,b){b=null!=b?b:this.resampleThreshold;return a.length>b};EditorUi.prototype.resizeImage=function(a,b,d,e,h,l){h=null!=h?h:this.maxImageSize;var c=Math.max(1,a.width),f=Math.max(1,a.height);
if(e&&this.isResampleImage(b,l))try{var g=Math.max(c/h,f/h);if(1<g){var k=Math.round(c/g),n=Math.round(f/g),m=document.createElement("canvas");m.width=k;m.height=n;m.getContext("2d").drawImage(a,0,0,k,n);var p=m.toDataURL();if(p.length<b.length){var q=document.createElement("canvas");q.width=k;q.height=n;var u=q.toDataURL();p!==u&&(b=p,c=k,f=n)}}}catch(D){}d(b,c,f)};EditorUi.prototype.crcTable=[];for(var e=0;256>e;e++)for(var d=e,h=0;8>h;h++)d=1==(d&1)?3988292384^d>>>1:d>>>1,EditorUi.prototype.crcTable[e]=
d;EditorUi.prototype.updateCRC=function(a,b,d,e){for(var c=0;c<e;c++)a=EditorUi.prototype.crcTable[(a^b[d+c])&255]^a>>>8;return a};EditorUi.prototype.crc32=function(a){this.crcTable=this.crcTable||this.createCrcTable();for(var c=-1,b=0;b<a.length;b++)c=c>>>8^this.crcTable[(c^a.charCodeAt(b))&255];return(c^-1)>>>0};EditorUi.prototype.writeGraphModelToPng=function(a,b,d,e,h){function c(a,b){var c=k;k+=b;return a.substring(c,k)}function f(a){a=c(a,4);return a.charCodeAt(3)+(a.charCodeAt(2)<<8)+(a.charCodeAt(1)<<
d;EditorUi.prototype.updateCRC=function(a,b,d,e){for(var c=0;c<e;c++)a=EditorUi.prototype.crcTable[(a^b[d+c])&255]^a>>>8;return a};EditorUi.prototype.crc32=function(a){this.crcTable=this.crcTable||this.createCrcTable();for(var c=-1,b=0;b<a.length;b++)c=c>>>8^this.crcTable[(c^a.charCodeAt(b))&255];return(c^-1)>>>0};EditorUi.prototype.writeGraphModelToPng=function(a,b,d,e,h){function c(a,c){var b=k;k+=c;return a.substring(b,k)}function f(a){a=c(a,4);return a.charCodeAt(3)+(a.charCodeAt(2)<<8)+(a.charCodeAt(1)<<
16)+(a.charCodeAt(0)<<24)}function g(a){return String.fromCharCode(a>>24&255,a>>16&255,a>>8&255,a&255)}a=a.substring(a.indexOf(",")+1);a=window.atob?atob(a):Base64.decode(a,!0);var k=0;if(c(a,8)!=String.fromCharCode(137)+"PNG"+String.fromCharCode(13,10,26,10))null!=h&&h();else if(c(a,4),"IHDR"!=c(a,4))null!=h&&h();else{c(a,17);h=a.substring(0,k);do{var n=f(a);if("IDAT"==c(a,4)){h=a.substring(0,k-8);d=d+String.fromCharCode(0)+("zTXt"==b?String.fromCharCode(0):"")+e;e=4294967295;e=this.updateCRC(e,
b,0,4);e=this.updateCRC(e,d,0,d.length);h+=g(d.length)+b+d+g(e^4294967295);h+=a.substring(k-8,a.length);break}h+=a.substring(k-8,k-4+n);c(a,n);c(a,4)}while(n);return"data:image/png;base64,"+(window.btoa?btoa(h):Base64.encode(h,!0))}};EditorUi.prototype.extractGraphModelFromPng=function(a){var b=null;try{var c=a.substring(a.indexOf(",")+1),d=window.atob&&!mxClient.IS_SF?atob(c):Base64.decode(c,!0);EditorUi.parsePng(d,mxUtils.bind(this,function(a,c,e){a=d.substring(a+8,a+8+e);"zTXt"==c?(e=a.indexOf(String.fromCharCode(0)),
"mxGraphModel"==a.substring(0,e)&&(a=this.editor.graph.bytesToString(pako.inflateRaw(a.substring(e+2))).replace(/\+/g," "),null!=a&&0<a.length&&(b=a))):"tEXt"==c&&(a=a.split(String.fromCharCode(0)),1<a.length&&"mxGraphModel"==a[0]&&(b=a[1]));if(null!=b||"IDAT"==c)return!0}))}catch(n){}null!=b&&"%"==b.charAt(0)&&(b=decodeURIComponent(b));null!=b&&"%"==b.charAt(0)&&(b=decodeURIComponent(b));return b};EditorUi.prototype.loadImage=function(a,b,d){var c=new Image;c.onload=function(){b(c)};null!=d&&(c.onerror=
@ -3180,7 +3180,7 @@ EditorUi.prototype.updatePageRoot=function(a){if(null==a.root){var b=this.editor
return a};EditorUi.prototype.selectPage=function(a,b,e){this.editor.graph.isEditing()&&this.editor.graph.stopEditing(!1);b=null!=b?b:!1;this.editor.graph.isMouseDown=!1;this.editor.graph.reset();var d=this.editor.graph.model.createUndoableEdit();d.ignoreEdit=!0;a=new SelectPage(this,a,e);a.execute();d.add(a);d.notify();this.editor.graph.tooltipHandler.hide();b||this.editor.graph.model.fireEvent(new mxEventObject(mxEvent.UNDO,"edit",d))};
EditorUi.prototype.selectNextPage=function(a){var b=this.currentPage;null!=b&&null!=this.pages&&(b=mxUtils.indexOf(this.pages,b),a?this.selectPage(this.pages[mxUtils.mod(b+1,this.pages.length)]):a||this.selectPage(this.pages[mxUtils.mod(b-1,this.pages.length)]))};EditorUi.prototype.insertPage=function(a,b){if(this.editor.graph.isEnabled()){this.editor.graph.isEditing()&&this.editor.graph.stopEditing(!1);a=null!=a?a:this.createPage();b=null!=b?b:this.pages.length;var e=new ChangePage(this,a,a,b);this.editor.graph.model.execute(e)}return a};
EditorUi.prototype.createPage=function(a){var b=new DiagramPage(this.fileNode.ownerDocument.createElement("diagram"));b.setName(null!=a?a:this.createPageName());return b};EditorUi.prototype.createPageName=function(){for(var a={},b=0;b<this.pages.length;b++){var e=this.pages[b].getName();null!=e&&0<e.length&&(a[e]=e)}b=this.pages.length;do e=mxResources.get("pageWithNumber",[++b]);while(null!=a[e]);return e};
EditorUi.prototype.removePage=function(a){var b=this.editor.graph;if(b.isEnabled()){this.editor.graph.isEditing()&&this.editor.graph.stopEditing(!1);b.model.beginUpdate();try{var e=this.currentPage;if(e==a)if(1<this.pages.length){var d=mxUtils.indexOf(this.pages,a);d==this.pages.length-1?d--:d++;e=this.pages[d]}else e=this.insertPage(),b.model.execute(new RenamePage(this,e,mxResources.get("pageWithNumber",[1])));b.model.execute(new ChangePage(this,a,e))}finally{b.model.endUpdate()}}return a};
EditorUi.prototype.removePage=function(a){var b=this.editor.graph;if(b.isEnabled()){this.editor.graph.isEditing()&&this.editor.graph.stopEditing(!1);b.model.beginUpdate();try{var e=this.currentPage;if(e==a&&1<this.pages.length){var d=mxUtils.indexOf(this.pages,a);d==this.pages.length-1?d--:d++;e=this.pages[d]}else 1>=this.pages.length&&(e=this.insertPage(),b.model.execute(new RenamePage(this,e,mxResources.get("pageWithNumber",[1]))));b.model.execute(new ChangePage(this,a,e))}finally{b.model.endUpdate()}}return a};
EditorUi.prototype.duplicatePage=function(a,b){var e=this.editor.graph,d=null;e.isEnabled()&&(e.isEditing()&&e.stopEditing(),d=a.node.cloneNode(!1),d.removeAttribute("id"),d=new DiagramPage(d),d.root=e.cloneCell(e.model.root),d.viewState=e.getViewState(),d.viewState.scale=1,d.viewState.scrollLeft=null,d.viewState.scrollTop=null,d.viewState.currentRoot=null,d.viewState.defaultParent=null,d.setName(b),d=this.insertPage(d,mxUtils.indexOf(this.pages,a)+1));return d};
EditorUi.prototype.renamePage=function(a){if(this.editor.graph.isEnabled()){var b=new FilenameDialog(this,a.getName(),mxResources.get("rename"),mxUtils.bind(this,function(b){null!=b&&0<b.length&&this.editor.graph.model.execute(new RenamePage(this,a,b))}),mxResources.get("rename"));this.showDialog(b.container,300,80,!0,!0);b.init()}return a};EditorUi.prototype.movePage=function(a,b){this.editor.graph.model.execute(new MovePage(this,a,b))};
EditorUi.prototype.createTabContainer=function(){var a=document.createElement("div");a.style.backgroundColor="dark"==uiTheme?"#2a2a2a":"#dcdcdc";a.style.position="absolute";a.style.whiteSpace="nowrap";a.style.overflow="hidden";a.style.height="0px";return a};

View file

@ -163,6 +163,234 @@ Draw.loadPlugin(function(ui)
}
});
// Adds resource for action
mxResources.parse('placeChildren=Place children...');
// Adds action
ui.actions.addAction('placeChildren', function()
{
var graph = ui.editor.graph;
var cells = graph.getSelectionCells().slice();
if (cells.length > 1)
{
var counter = 0;
var delay = parseInt(prompt('Delay (ms)', defaultDelay));
var max = parseInt(prompt('Cycles', defaultMax));
function schedule()
{
var jitter = 1 + 0.3 * (Math.random() - 0.5);
window.setTimeout(function()
{
// assuming parent is the first cell selected
var parentA = cells[0];
var parentB = cells[1];
var childrenA = parentA.children;
var childrenB = parentB.children;
var numberA = (childrenA != null)? childrenA.length: 0;
var numberB = (childrenB != null)? childrenB.length: 0;
var n = 0;
if (childrenA != null && childrenA.length > 1 || childrenB != null && childrenB.length > 1)
{
graph.getModel().beginUpdate();
try
{
// first, remove a few children from each parent
childrenA = parentA.children;
childrenB = parentB.children;
numberA = (childrenA != null)? childrenA.length: 0;
numberB = (childrenB != null)? childrenB.length: 0;
// 1st parent
n = Math.floor(Math.random() * 4); // how many to delete? at least 1 should remain
n = Math.min(n, Math.max(0, numberA - 2));
console.log(counter + " - removing " + n + " children from parent A");
for (var i = 0; i < n; i++)
{
childrenA = parentA.children;
numberA = (childrenA != null)? childrenA.length: 0;
if (numberA > 0)
{
var k = Math.floor(Math.random() * numberA);
parentA.remove(k);
}
}
// 2nd parent
n = Math.floor(Math.random() * 4); // how many to delete? at least 1 should remain
n = Math.min(n, Math.max(0, numberB - 2));
console.log(counter + " - removing " + n + " children from parent B");
for (var i = 0; i < n; i++)
{
childrenB = parentB.children;
numberB = (childrenB != null)? childrenB.length: 0;
if (numberB > 0)
{
var k = Math.floor(Math.random() * numberB);
parentB.remove(k);
}
}
// second, insert a few children to each parent
childrenA = parentA.children;
childrenB = parentB.children;
numberA = (childrenA != null)? childrenA.length: 0;
numberB = (childrenB != null)? childrenB.length: 0;
// 1st parent
n = Math.floor(Math.random() * 4); // how many to insert?
console.log(counter + " - inserting " + n + " children into parent A");
for (var i = 0; i < n; i++)
{
childrenA = parentA.children;
numberA = (childrenA != null)? childrenA.length: 0;
if (numberA > 0)
{
var k = Math.floor(Math.random() * numberA);
var x = Math.floor(Math.random() * 200);
var y = Math.floor(Math.random() * 50);
var number = Math.floor(Math.random() * 9000 + 1000);
var child = graph.insertVertex(parentA, null, number.toString(), x, y, 120, 30);
parentA.insert(child, k);
}
}
// 2nd parent
n = Math.floor(Math.random() * 4); // how many to insert?
console.log(counter + " - inserting " + n + " children into parent B");
for (var i = 0; i < n; i++)
{
childrenB = parentB.children;
numberB = (childrenB != null)? childrenB.length: 0;
if (numberB > 0)
{
var k = Math.floor(Math.random() * numberB);
var x = Math.floor(Math.random() * 200);
var y = Math.floor(Math.random() * 50);
var number = Math.floor(Math.random() * 9000 + 1000);
var child = graph.insertVertex(parentB, null, number.toString(), x, y, 120, 30);
parentB.insert(child, k);
}
}
// third, shuffle children in each parent
childrenA = parentA.children;
childrenB = parentB.children;
numberA = (childrenA != null)? childrenA.length: 0;
numberB = (childrenB != null)? childrenB.length: 0;
// 1st parent
n = Math.floor(Math.random() * numberA); // how many to shuffle?
console.log(counter + " - moving " + n + " children inside parent A");
for (var i = 0; i < n; i++)
{
childrenA = parentA.children;
numberA = (childrenA != null)? childrenA.length: 0;
if (numberA > 0)
{
var k = Math.floor(Math.random() * numberA); // from index
var l = Math.floor(Math.random() * numberA); // to index
var child = parentA.getChildAt(k);
parentA.insert(child, l);
}
}
// 2nd parent
n = Math.floor(Math.random() * numberB); // how many to shuffle?
console.log(counter + " - moving " + n + " children inside parent B");
for (var i = 0; i < n; i++)
{
childrenB = parentB.children;
numberB = (childrenB != null)? childrenB.length: 0;
if (numberB > 0)
{
var k = Math.floor(Math.random() * numberB); // from index
var l = Math.floor(Math.random() * numberB); // to index
var child = parentB.getChildAt(k);
parentB.insert(child, l);
}
}
// fourth, exchange a few children between both parents
childrenA = parentA.children;
childrenB = parentB.children;
numberA = (childrenA != null)? childrenA.length: 0;
numberB = (childrenB != null)? childrenB.length: 0;
// permute children
var passes = Math.floor(Math.random() * numberA) + 1;
console.log(counter + " - swapping " + passes + " children from parent A to parent B");
for (var i = 0; i < passes; i++)
{
// which child to select from parent A
var k = Math.floor(Math.random() * numberA);
// where to insert it to parent B
var l = Math.floor(Math.random() * (numberB + 1));
graph.model.add(parentB, childrenA[k], l);
numberA -= 1;
numberB += 1;
}
var passes = Math.floor(Math.random() * numberB) + 1;
console.log(counter + " - swapping " + passes + " children from parent B to parent A");
for (var i = 0; i < passes; i++)
{
// which child to select from parent A
var k = Math.floor(Math.random() * numberB);
// where to insert it to parent B
var l = Math.floor(Math.random() * (numberA + 1));
graph.model.add(parentA, childrenB[k], l);
numberA += 1;
numberB -= 1;
}
}
finally
{
graph.getModel().endUpdate();
}
}
if (ui.dialog != null)
{
console.log('swapChildren halted');
}
else
{
ui.saveFile(null, function()
{
if (counter++ < max && ui.dialog == null)
{
console.log('swapChildren', counter);
schedule();
}
else
{
console.log('swapChildren halted');
}
});
}
}, delay * jitter);
}
schedule();
}
else
{
ui.alert(mxResources.get('nothingIsSelected'));
}
});
// Adds resource for action
mxResources.parse('reorderChildren=Reorder children...');
@ -247,6 +475,6 @@ Draw.loadPlugin(function(ui)
{
oldFunct.apply(this, arguments);
ui.menus.addMenuItems(menu, ['-', 'randomLabel', 'reorderChildren', 'swapChildren'], parent);
ui.menus.addMenuItems(menu, ['-', 'randomLabel', 'reorderChildren', 'swapChildren', 'placeChildren'], parent);
};
});