perf: 去掉刷新提示及前端报错
This commit is contained in:
parent
63534d3eb5
commit
cc24ff22e9
@ -118,7 +118,6 @@ export default {
|
||||
let route = this.readOnly ? 'viewer' : 'index';
|
||||
let theme = this.themeIsDark ? 'dark' : 'light'
|
||||
this.url = $A.originUrl('js/drawio/' + route + '.html?lang=' + language + '&theme=' + theme + '&dev=1');
|
||||
console.log('this.url',this.url);
|
||||
},
|
||||
mounted() {
|
||||
window.addEventListener('message', this.handleMessage)
|
||||
|
File diff suppressed because one or more lines are too long
@ -4,13 +4,13 @@
|
||||
"description": "diagrams.net is a completely free diagram editor",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/images/android-chrome-196x196.png",
|
||||
"src": "../images/android-chrome-196x196.png",
|
||||
"sizes": "196x196",
|
||||
"type": "image/png",
|
||||
"purpose": "any maskable"
|
||||
},
|
||||
{
|
||||
"src": "/images/android-chrome-512x512.png",
|
||||
"src": "../images/android-chrome-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
}
|
||||
@ -19,4 +19,4 @@
|
||||
"background_color": "#DF6C0C",
|
||||
"display": "fullscreen",
|
||||
"start_url": "/index.html"
|
||||
}
|
||||
}
|
||||
|
@ -930,10 +930,10 @@ App.main = function(callback, createUi)
|
||||
mxscript(App.DROPBOX_URL, function()
|
||||
{
|
||||
// Must load this after the dropbox SDK since they use the same namespace
|
||||
mxscript(App.DROPINS_URL, function()
|
||||
{
|
||||
DrawDropboxClientCallback();
|
||||
}, 'dropboxjs', App.DROPBOX_APPKEY);
|
||||
// mxscript(App.DROPINS_URL, function()
|
||||
// {
|
||||
// DrawDropboxClientCallback();
|
||||
// }, 'dropboxjs', App.DROPBOX_APPKEY);
|
||||
});
|
||||
}
|
||||
// Disables client
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2018, JGraph Ltd
|
||||
* Copyright (c) 2006-2018, Gaudenz Alder
|
||||
*
|
||||
*
|
||||
* Realtime collaboration for any file.
|
||||
*/
|
||||
DrawioFileSync = function(file)
|
||||
@ -23,9 +23,9 @@ DrawioFileSync = function(file)
|
||||
this.fileChangedNotify();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mxEvent.addListener(window, 'online', this.onlineListener);
|
||||
|
||||
|
||||
// Listens to visible state changes
|
||||
this.visibleListener = mxUtils.bind(this, function()
|
||||
{
|
||||
@ -41,9 +41,9 @@ DrawioFileSync = function(file)
|
||||
this.start();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mxEvent.addListener(document, 'visibilitychange', this.visibleListener);
|
||||
|
||||
|
||||
// Listens to visible state changes
|
||||
this.activityListener = mxUtils.bind(this, function(evt)
|
||||
{
|
||||
@ -54,11 +54,11 @@ DrawioFileSync = function(file)
|
||||
mxEvent.addListener(document, (mxClient.IS_POINTER) ? 'pointermove' : 'mousemove', this.activityListener);
|
||||
mxEvent.addListener(document, 'keypress', this.activityListener);
|
||||
mxEvent.addListener(window, 'focus', this.activityListener);
|
||||
|
||||
|
||||
if (!mxClient.IS_POINTER && mxClient.IS_TOUCH)
|
||||
{
|
||||
mxEvent.addListener(document, 'touchstart', this.activityListener);
|
||||
mxEvent.addListener(document, 'touchmove', this.activityListener);
|
||||
mxEvent.addListener(document, 'touchmove', this.activityListener);
|
||||
}
|
||||
|
||||
// Listens to errors in the pusher API
|
||||
@ -76,14 +76,14 @@ DrawioFileSync = function(file)
|
||||
{
|
||||
this.updateOnlineState();
|
||||
this.updateStatus();
|
||||
|
||||
|
||||
if (this.isConnected())
|
||||
{
|
||||
if (!this.announced)
|
||||
{
|
||||
var user = this.file.getCurrentUser();
|
||||
var join = {a: 'join'};
|
||||
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
join.name = encodeURIComponent(user.displayName);
|
||||
@ -103,7 +103,7 @@ DrawioFileSync = function(file)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Listens to messages
|
||||
this.changeListener = mxUtils.bind(this, function(data)
|
||||
{
|
||||
@ -116,7 +116,7 @@ DrawioFileSync = function(file)
|
||||
try
|
||||
{
|
||||
var msg = this.stringToObject(data);
|
||||
|
||||
|
||||
if (msg != null)
|
||||
{
|
||||
EditorUi.debug('Sync.message', [this], msg, data.length, 'bytes');
|
||||
@ -142,14 +142,14 @@ DrawioFileSync = function(file)
|
||||
{
|
||||
this.fileChangedNotify();
|
||||
}
|
||||
|
||||
|
||||
// NOTE: Probably UTF16 in username for join/leave message causing this
|
||||
// var len = (data != null) ? data.length : 'null';
|
||||
//
|
||||
//
|
||||
// EditorUi.logError('Protocol Error ' + e.message,
|
||||
// null, 'data_' + len + '_file_' + this.file.getHash() +
|
||||
// '_client_' + this.clientId);
|
||||
//
|
||||
//
|
||||
// if (window.console != null)
|
||||
// {
|
||||
// console.log(e);
|
||||
@ -239,17 +239,17 @@ DrawioFileSync.prototype.start = function()
|
||||
{
|
||||
this.channelId = this.file.getChannelId();
|
||||
}
|
||||
|
||||
|
||||
if (this.key == null)
|
||||
{
|
||||
this.key = this.file.getChannelKey();
|
||||
}
|
||||
|
||||
|
||||
if (this.pusher == null && this.channelId != null &&
|
||||
document.visibilityState != 'hidden')
|
||||
document.visibilityState != 'hidden')
|
||||
{
|
||||
this.pusher = this.ui.getPusher();
|
||||
|
||||
|
||||
if (this.pusher != null)
|
||||
{
|
||||
try
|
||||
@ -264,7 +264,7 @@ DrawioFileSync.prototype.start = function()
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
this.pusher.connect();
|
||||
@ -315,7 +315,7 @@ DrawioFileSync.prototype.updateOnlineState = function()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var addClickHandler = mxUtils.bind(this, function(elt)
|
||||
{
|
||||
mxEvent.addListener(elt, 'click', mxUtils.bind(this, function(evt)
|
||||
@ -325,7 +325,7 @@ DrawioFileSync.prototype.updateOnlineState = function()
|
||||
this.resetUpdateStatusThread();
|
||||
this.updateOnlineState();
|
||||
this.updateStatus();
|
||||
|
||||
|
||||
if (!this.file.inConflictState && this.enabled)
|
||||
{
|
||||
this.fileChangedNotify();
|
||||
@ -345,7 +345,7 @@ DrawioFileSync.prototype.updateOnlineState = function()
|
||||
elt.style.backgroundSize = '24px 24px';
|
||||
elt.style.height = '24px';
|
||||
elt.style.width = '24px';
|
||||
|
||||
|
||||
addClickHandler(elt);
|
||||
this.ui.buttonContainer.appendChild(elt);
|
||||
this.collaboratorsElement = elt;
|
||||
@ -373,29 +373,29 @@ DrawioFileSync.prototype.updateOnlineState = function()
|
||||
elt.style.width = '16px';
|
||||
elt.style.height = '16px';
|
||||
mxUtils.setOpacity(elt, 60);
|
||||
|
||||
|
||||
if (uiTheme == 'dark')
|
||||
{
|
||||
elt.style.filter = 'invert(100%)';
|
||||
}
|
||||
|
||||
|
||||
// Prevents focus
|
||||
mxEvent.addListener(elt, (mxClient.IS_POINTER) ? 'pointerdown' : 'mousedown',
|
||||
mxUtils.bind(this, function(evt)
|
||||
{
|
||||
evt.preventDefault();
|
||||
}));
|
||||
|
||||
|
||||
addClickHandler(elt);
|
||||
this.ui.toolbarContainer.appendChild(elt);
|
||||
this.collaboratorsElement = elt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (this.collaboratorsElement != null)
|
||||
{
|
||||
var status = '';
|
||||
|
||||
|
||||
if (!this.enabled)
|
||||
{
|
||||
status = mxResources.get('disconnected');
|
||||
@ -412,7 +412,7 @@ DrawioFileSync.prototype.updateOnlineState = function()
|
||||
{
|
||||
status = mxResources.get('online');
|
||||
}
|
||||
|
||||
|
||||
this.collaboratorsElement.setAttribute('title', status);
|
||||
this.collaboratorsElement.style.backgroundImage = 'url(' + ((!this.enabled) ? Editor.syncDisabledImage :
|
||||
((!this.ui.isOffline(true) && this.isConnected() && !this.file.invalidChecksum) ?
|
||||
@ -432,7 +432,7 @@ DrawioFileSync.prototype.updateStatus = function()
|
||||
{
|
||||
this.stop();
|
||||
}
|
||||
|
||||
|
||||
if (!this.file.isModified() && !this.file.inConflictState &&
|
||||
this.file.autosaveThread == null && !this.file.savingFile &&
|
||||
!this.file.redirectDialogShowing)
|
||||
@ -441,31 +441,31 @@ DrawioFileSync.prototype.updateStatus = function()
|
||||
{
|
||||
// LATER: Write out modified date for more than 2 weeks ago
|
||||
var str = this.ui.timeSince(new Date(this.lastModified));
|
||||
|
||||
|
||||
if (str == null)
|
||||
{
|
||||
str = mxResources.get('lessThanAMinute');
|
||||
}
|
||||
|
||||
|
||||
var history = this.file.isRevisionHistorySupported();
|
||||
|
||||
// Consumed and displays last message
|
||||
var msg = this.lastMessage;
|
||||
this.lastMessage = null;
|
||||
|
||||
|
||||
if (msg != null && msg.length > 40)
|
||||
{
|
||||
msg = msg.substring(0, 40) + '...';
|
||||
}
|
||||
|
||||
var label = mxResources.get('lastChange', [str]);
|
||||
|
||||
|
||||
this.ui.editor.setStatus('<div title="'+ mxUtils.htmlEntities(label) + '">' + mxUtils.htmlEntities(label) + '</div>' +
|
||||
(this.file.isEditable() ? '' : '<div class="geStatusAlert">' + mxUtils.htmlEntities(mxResources.get('readOnly')) + '</div>') +
|
||||
(this.isConnected() ? '' : '<div class="geStatusAlert">' + mxUtils.htmlEntities(mxResources.get('disconnected')) + '</div>') +
|
||||
((msg != null) ? ' <span title="' + mxUtils.htmlEntities(msg) + '">(' + mxUtils.htmlEntities(msg) + ')</span>' : ''));
|
||||
var links = this.ui.statusContainer.getElementsByTagName('div');
|
||||
|
||||
|
||||
if (links.length > 0 && history)
|
||||
{
|
||||
links[0].style.display = 'inline-block';
|
||||
@ -474,7 +474,7 @@ DrawioFileSync.prototype.updateStatus = function()
|
||||
{
|
||||
links[0].style.cursor = 'pointer';
|
||||
links[0].style.textDecoration = 'underline';
|
||||
|
||||
|
||||
mxEvent.addListener(links[0], 'click', mxUtils.bind(this, function()
|
||||
{
|
||||
this.ui.actions.get('revisionHistory').funct();
|
||||
@ -484,25 +484,25 @@ DrawioFileSync.prototype.updateStatus = function()
|
||||
|
||||
// Fades in/out last message
|
||||
var spans = this.ui.statusContainer.getElementsByTagName('span');
|
||||
|
||||
|
||||
if (spans.length > 0)
|
||||
{
|
||||
var temp = spans[0];
|
||||
temp.style.opacity = '0';
|
||||
mxUtils.setPrefixedStyle(temp.style, 'transition', 'all 0.2s ease');
|
||||
|
||||
|
||||
window.setTimeout(mxUtils.bind(this, function()
|
||||
{
|
||||
mxUtils.setOpacity(temp, 100);
|
||||
mxUtils.setPrefixedStyle(temp.style, 'transition', 'all 1s ease');
|
||||
|
||||
|
||||
window.setTimeout(mxUtils.bind(this, function()
|
||||
{
|
||||
mxUtils.setOpacity(temp, 0);
|
||||
}), this.updateStatusInterval / 2);
|
||||
}), 0);
|
||||
}
|
||||
|
||||
|
||||
this.resetUpdateStatusThread();
|
||||
}
|
||||
else
|
||||
@ -521,7 +521,7 @@ DrawioFileSync.prototype.resetUpdateStatusThread = function()
|
||||
{
|
||||
window.clearInterval(this.updateStatusThread);
|
||||
}
|
||||
|
||||
|
||||
if (this.channel != null)
|
||||
{
|
||||
this.updateStatusThread = window.setInterval(mxUtils.bind(this, function()
|
||||
@ -540,7 +540,7 @@ DrawioFileSync.prototype.installListeners = function()
|
||||
{
|
||||
this.pusher.connection.bind('state_change', this.connectionListener);
|
||||
}
|
||||
|
||||
|
||||
if (this.channel != null)
|
||||
{
|
||||
this.channel.bind('changed', this.changeListener);
|
||||
@ -565,7 +565,7 @@ DrawioFileSync.prototype.handleMessageData = function(data)
|
||||
{
|
||||
this.file.stats.joined++;
|
||||
}
|
||||
|
||||
|
||||
if (data.name != null)
|
||||
{
|
||||
this.lastMessage = mxResources.get((data.a == 'join') ?
|
||||
@ -577,7 +577,7 @@ DrawioFileSync.prototype.handleMessageData = function(data)
|
||||
else if (data.m != null)
|
||||
{
|
||||
var mod = new Date(data.m);
|
||||
|
||||
|
||||
// Ignores obsolete messages
|
||||
if (this.lastMessageModified == null || this.lastMessageModified < mod)
|
||||
{
|
||||
@ -605,7 +605,7 @@ DrawioFileSync.prototype.optimisticSync = function(retryCount)
|
||||
if (this.reloadThread == null)
|
||||
{
|
||||
retryCount = (retryCount != null) ? retryCount : 0;
|
||||
|
||||
|
||||
if (retryCount < this.maxOptimisticReloadRetries)
|
||||
{
|
||||
this.reloadThread = window.setTimeout(mxUtils.bind(this, function()
|
||||
@ -613,12 +613,12 @@ DrawioFileSync.prototype.optimisticSync = function(retryCount)
|
||||
this.file.getLatestVersion(mxUtils.bind(this, function(latestFile)
|
||||
{
|
||||
this.reloadThread = null;
|
||||
|
||||
|
||||
if (latestFile != null)
|
||||
{
|
||||
var etag = latestFile.getCurrentRevisionId();
|
||||
var current = this.file.getCurrentRevisionId();
|
||||
|
||||
|
||||
// Retries if the file has not changed
|
||||
if (current == etag)
|
||||
{
|
||||
@ -639,7 +639,7 @@ DrawioFileSync.prototype.optimisticSync = function(retryCount)
|
||||
}));
|
||||
}), (retryCount + 1) * this.file.optimisticSyncDelay);
|
||||
}
|
||||
|
||||
|
||||
if (urlParams['test'] == '1')
|
||||
{
|
||||
EditorUi.debug('Sync.optimisticSync', [this], 'retryCount', retryCount);
|
||||
@ -722,9 +722,9 @@ DrawioFileSync.prototype.fileChanged = function(success, error, abort, lazy)
|
||||
}
|
||||
}
|
||||
}), (lazy) ? this.cacheReadyDelay : 0);
|
||||
|
||||
|
||||
this.notifyThread = thread;
|
||||
|
||||
|
||||
return thread;
|
||||
};
|
||||
|
||||
@ -770,7 +770,7 @@ DrawioFileSync.prototype.p2pCatchup = function(data, from, to, id, desc, success
|
||||
{
|
||||
var etag = this.file.getDescriptorRevisionId(desc);
|
||||
var current = this.file.getCurrentRevisionId();
|
||||
|
||||
|
||||
if (!this.isValidState())
|
||||
{
|
||||
if (error != null)
|
||||
@ -781,23 +781,23 @@ DrawioFileSync.prototype.p2pCatchup = function(data, from, to, id, desc, success
|
||||
else
|
||||
{
|
||||
var secret = this.file.getDescriptorSecret(desc);
|
||||
|
||||
|
||||
if (abort == null || !abort())
|
||||
{
|
||||
this.file.stats.bytesReceived += data.length;
|
||||
this.file.stats.bytesReceived += data.length;
|
||||
var checksum = null;
|
||||
var temp = [];
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var result = [data];
|
||||
|
||||
|
||||
if (result != null && result.length > 0)
|
||||
{
|
||||
for (var i = 0; i < result.length; i++)
|
||||
{
|
||||
var value = this.stringToObject(result[i]);
|
||||
|
||||
|
||||
if (value.v > DrawioFileSync.PROTOCOL)
|
||||
{
|
||||
failed = true;
|
||||
@ -822,13 +822,13 @@ DrawioFileSync.prototype.p2pCatchup = function(data, from, to, id, desc, success
|
||||
catch (e)
|
||||
{
|
||||
temp = [];
|
||||
|
||||
|
||||
if (window.console != null && urlParams['test'] == '1')
|
||||
{
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
if (temp.length > 0)
|
||||
@ -863,11 +863,11 @@ DrawioFileSync.prototype.catchup = function(desc, success, error, abort)
|
||||
{
|
||||
var etag = this.file.getDescriptorRevisionId(desc);
|
||||
var current = this.file.getCurrentRevisionId();
|
||||
|
||||
|
||||
if (current == etag)
|
||||
{
|
||||
this.file.patchDescriptor(this.file.getDescriptor(), desc);
|
||||
|
||||
|
||||
if (success != null)
|
||||
{
|
||||
success();
|
||||
@ -883,7 +883,7 @@ DrawioFileSync.prototype.catchup = function(desc, success, error, abort)
|
||||
else
|
||||
{
|
||||
var secret = this.file.getDescriptorSecret(desc);
|
||||
|
||||
|
||||
if (secret == null || urlParams['lockdown'] == '1')
|
||||
{
|
||||
this.reload(success, error, abort);
|
||||
@ -894,7 +894,7 @@ DrawioFileSync.prototype.catchup = function(desc, success, error, abort)
|
||||
// etag is visible to client so retry once after cache miss
|
||||
var cacheReadyRetryCount = 0;
|
||||
var failed = false;
|
||||
|
||||
|
||||
var doCatchup = mxUtils.bind(this, function()
|
||||
{
|
||||
if (abort == null || !abort())
|
||||
@ -917,21 +917,21 @@ DrawioFileSync.prototype.catchup = function(desc, success, error, abort)
|
||||
else
|
||||
{
|
||||
var acceptResponse = true;
|
||||
|
||||
|
||||
var timeoutThread = window.setTimeout(mxUtils.bind(this, function()
|
||||
{
|
||||
acceptResponse = false;
|
||||
this.reload(success, error, abort);
|
||||
}), this.ui.timeout);
|
||||
|
||||
|
||||
mxUtils.get(EditorUi.cacheUrl + '?id=' + encodeURIComponent(this.channelId) +
|
||||
'&from=' + encodeURIComponent(current) + '&to=' + encodeURIComponent(etag) +
|
||||
((secret != null) ? '&secret=' + encodeURIComponent(secret) : ''),
|
||||
mxUtils.bind(this, function(req)
|
||||
{
|
||||
this.file.stats.bytesReceived += req.getText().length;
|
||||
this.file.stats.bytesReceived += req.getText().length;
|
||||
window.clearTimeout(timeoutThread);
|
||||
|
||||
|
||||
if (acceptResponse && (abort == null || !abort()))
|
||||
{
|
||||
// Ignores patch if shadow has changed
|
||||
@ -953,20 +953,20 @@ DrawioFileSync.prototype.catchup = function(desc, success, error, abort)
|
||||
{
|
||||
var checksum = null;
|
||||
var temp = [];
|
||||
|
||||
|
||||
if (req.getStatus() >= 200 && req.getStatus() <= 299 &&
|
||||
req.getText().length > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = JSON.parse(req.getText());
|
||||
|
||||
|
||||
if (result != null && result.length > 0)
|
||||
{
|
||||
for (var i = 0; i < result.length; i++)
|
||||
{
|
||||
var value = this.stringToObject(result[i]);
|
||||
|
||||
|
||||
if (value.v > DrawioFileSync.PROTOCOL)
|
||||
{
|
||||
failed = true;
|
||||
@ -991,14 +991,14 @@ DrawioFileSync.prototype.catchup = function(desc, success, error, abort)
|
||||
catch (e)
|
||||
{
|
||||
temp = [];
|
||||
|
||||
|
||||
if (window.console != null && urlParams['test'] == '1')
|
||||
{
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
if (temp.length > 0)
|
||||
@ -1034,7 +1034,7 @@ DrawioFileSync.prototype.catchup = function(desc, success, error, abort)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
window.setTimeout(doCatchup, this.cacheReadyDelay);
|
||||
}
|
||||
}
|
||||
@ -1051,7 +1051,7 @@ DrawioFileSync.prototype.reload = function(success, error, abort, shadow)
|
||||
this.lastModified = this.file.getLastModifiedDate();
|
||||
this.updateStatus();
|
||||
this.start();
|
||||
|
||||
|
||||
if (success != null)
|
||||
{
|
||||
success();
|
||||
@ -1092,9 +1092,9 @@ DrawioFileSync.prototype.merge = function(patches, checksum, desc, success, erro
|
||||
{
|
||||
this.file.shadowPages = this.ui.patchPages(this.file.shadowPages, patches[i]);
|
||||
}
|
||||
|
||||
|
||||
var current = (checksum != null) ? this.ui.getHashValueForPages(this.file.shadowPages) : null;
|
||||
|
||||
|
||||
if (urlParams['test'] == '1')
|
||||
{
|
||||
EditorUi.debug('Sync.merge', [this],
|
||||
@ -1105,13 +1105,13 @@ DrawioFileSync.prototype.merge = function(patches, checksum, desc, success, erro
|
||||
'patches', patches,
|
||||
'checksum', checksum == current, checksum);
|
||||
}
|
||||
|
||||
|
||||
// Compares the checksum
|
||||
if (checksum != null && checksum != current)
|
||||
{
|
||||
var from = this.ui.hashValue(this.file.getCurrentRevisionId());
|
||||
var to = this.ui.hashValue(etag);
|
||||
|
||||
|
||||
this.file.checksumError(error, patches, 'From: ' + from + '\nTo: ' + to +
|
||||
'\nChecksum: ' + checksum + '\nCurrent: ' + current, etag, 'merge');
|
||||
|
||||
@ -1119,7 +1119,7 @@ DrawioFileSync.prototype.merge = function(patches, checksum, desc, success, erro
|
||||
// shadowPages has been modified in-place above
|
||||
// LATER: Check if fallback to reload is possible
|
||||
// this.reload(success, error, abort, this.ui.pages);
|
||||
|
||||
|
||||
// Abnormal termination
|
||||
return;
|
||||
}
|
||||
@ -1129,7 +1129,7 @@ DrawioFileSync.prototype.merge = function(patches, checksum, desc, success, erro
|
||||
this.file.patch(patches,
|
||||
(DrawioFile.LAST_WRITE_WINS) ?
|
||||
this.file.backupPatch : null);
|
||||
|
||||
|
||||
// Logs successull patch
|
||||
// try
|
||||
// {
|
||||
@ -1152,7 +1152,7 @@ DrawioFileSync.prototype.merge = function(patches, checksum, desc, success, erro
|
||||
this.file.inConflictState = false;
|
||||
this.file.patchDescriptor(this.file.getDescriptor(), desc);
|
||||
this.file.backupPatch = null;
|
||||
|
||||
|
||||
if (success != null)
|
||||
{
|
||||
success();
|
||||
@ -1163,19 +1163,19 @@ DrawioFileSync.prototype.merge = function(patches, checksum, desc, success, erro
|
||||
this.file.inConflictState = true;
|
||||
this.file.invalidChecksum = true;
|
||||
this.file.descriptorChanged();
|
||||
|
||||
|
||||
if (error != null)
|
||||
{
|
||||
error(e);
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
if (this.file.errorReportsEnabled)
|
||||
{
|
||||
var from = this.ui.hashValue(this.file.getCurrentRevisionId());
|
||||
var to = this.ui.hashValue(etag);
|
||||
|
||||
|
||||
this.file.sendErrorReport('Error in merge',
|
||||
'From: ' + from + '\nTo: ' + to +
|
||||
'\nChecksum: ' + checksum +
|
||||
@ -1186,7 +1186,7 @@ DrawioFileSync.prototype.merge = function(patches, checksum, desc, success, erro
|
||||
{
|
||||
var user = this.file.getCurrentUser();
|
||||
var uid = (user != null) ? user.id : 'unknown';
|
||||
|
||||
|
||||
EditorUi.logError('Error in merge', null,
|
||||
this.file.getMode() + '.' +
|
||||
this.file.getId(), uid, e);
|
||||
@ -1205,7 +1205,7 @@ DrawioFileSync.prototype.merge = function(patches, checksum, desc, success, erro
|
||||
DrawioFileSync.prototype.descriptorChanged = function(etag)
|
||||
{
|
||||
this.lastModified = this.file.getLastModifiedDate();
|
||||
|
||||
|
||||
if (this.channelId != null)
|
||||
{
|
||||
var msg = this.objectToString(this.createMessage({a: 'desc',
|
||||
@ -1219,7 +1219,7 @@ DrawioFileSync.prototype.descriptorChanged = function(etag)
|
||||
this.file.stats.bytesSent += data.length;
|
||||
this.file.stats.msgSent++;
|
||||
}
|
||||
|
||||
|
||||
this.updateStatus();
|
||||
};
|
||||
|
||||
@ -1229,12 +1229,12 @@ DrawioFileSync.prototype.descriptorChanged = function(etag)
|
||||
DrawioFileSync.prototype.objectToString = function(obj)
|
||||
{
|
||||
var data = Graph.compress(JSON.stringify(obj));
|
||||
|
||||
|
||||
if (this.key != null && typeof CryptoJS !== 'undefined')
|
||||
{
|
||||
data = CryptoJS.AES.encrypt(data, this.key).toString();
|
||||
}
|
||||
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
@ -1247,7 +1247,7 @@ DrawioFileSync.prototype.stringToObject = function(data)
|
||||
{
|
||||
data = CryptoJS.AES.decrypt(data, this.key).toString(CryptoJS.enc.Utf8);
|
||||
}
|
||||
|
||||
|
||||
return JSON.parse(Graph.decompress(data));
|
||||
};
|
||||
|
||||
@ -1257,18 +1257,18 @@ DrawioFileSync.prototype.stringToObject = function(data)
|
||||
DrawioFileSync.prototype.createToken = function(secret, success, error)
|
||||
{
|
||||
var acceptResponse = true;
|
||||
|
||||
|
||||
var timeoutThread = window.setTimeout(mxUtils.bind(this, function()
|
||||
{
|
||||
acceptResponse = false;
|
||||
error({code: App.ERROR_TIMEOUT, message: mxResources.get('timeout')});
|
||||
}), this.ui.timeout);
|
||||
|
||||
|
||||
mxUtils.get(EditorUi.cacheUrl + '?id=' + encodeURIComponent(this.channelId) +
|
||||
'&secret=' + encodeURIComponent(secret), mxUtils.bind(this, function(req)
|
||||
{
|
||||
window.clearTimeout(timeoutThread);
|
||||
|
||||
|
||||
if (acceptResponse)
|
||||
{
|
||||
if (req.getStatus() >= 200 && req.getStatus() <= 299)
|
||||
@ -1305,17 +1305,17 @@ DrawioFileSync.prototype.sendFileChanges = function(pages, lastDesc)
|
||||
var secret = this.file.getDescriptorSecret(this.file.getDescriptor());
|
||||
var etag = this.file.getDescriptorRevisionId(lastDesc);
|
||||
var current = this.file.getCurrentRevisionId();
|
||||
|
||||
|
||||
var shadow = (this.file.shadowPages != null) ?
|
||||
this.file.shadowPages : this.ui.getPagesForNode(
|
||||
mxUtils.parseXml(this.file.shadowData).documentElement)
|
||||
var lastSecret = this.file.getDescriptorSecret(lastDesc);
|
||||
var checksum = this.ui.getHashValueForPages(pages);
|
||||
var diff = this.ui.diffPages(shadow, pages);
|
||||
|
||||
|
||||
// Data is stored in cache and message is sent to all listeners
|
||||
var data = this.objectToString(this.createMessage({patch: diff, checksum: checksum}));
|
||||
|
||||
|
||||
this.file.p2pCollab.sendMessage('diff', {
|
||||
id: this.channelId,
|
||||
from: etag, to: current,
|
||||
@ -1334,7 +1334,7 @@ DrawioFileSync.prototype.fileSaved = function(pages, lastDesc, success, error, t
|
||||
this.lastModified = this.file.getLastModifiedDate();
|
||||
this.resetUpdateStatusThread();
|
||||
this.catchupRetryCount = 0;
|
||||
|
||||
|
||||
if (!this.ui.isOffline(true) && !this.file.inConflictState && !this.file.redirectDialogShowing)
|
||||
{
|
||||
this.start();
|
||||
@ -1346,23 +1346,23 @@ DrawioFileSync.prototype.fileSaved = function(pages, lastDesc, success, error, t
|
||||
var secret = this.file.getDescriptorSecret(this.file.getDescriptor());
|
||||
var etag = this.file.getDescriptorRevisionId(lastDesc);
|
||||
var current = this.file.getCurrentRevisionId();
|
||||
|
||||
|
||||
if (secret == null || urlParams['lockdown'] == '1')
|
||||
{
|
||||
this.file.stats.msgSent++;
|
||||
|
||||
|
||||
// Notify only
|
||||
mxUtils.post(EditorUi.cacheUrl, this.getIdParameters() +
|
||||
'&msg=' + encodeURIComponent(msg), function()
|
||||
{
|
||||
// Ignore response
|
||||
});
|
||||
|
||||
|
||||
if (success != null)
|
||||
{
|
||||
success();
|
||||
}
|
||||
|
||||
|
||||
if (urlParams['test'] == '1')
|
||||
{
|
||||
EditorUi.debug('Sync.fileSaved', [this], 'from', etag, 'to', current,
|
||||
@ -1377,20 +1377,20 @@ DrawioFileSync.prototype.fileSaved = function(pages, lastDesc, success, error, t
|
||||
var lastSecret = this.file.getDescriptorSecret(lastDesc);
|
||||
var checksum = this.ui.getHashValueForPages(pages);
|
||||
var diff = this.ui.diffPages(shadow, pages);
|
||||
|
||||
|
||||
// Data is stored in cache and message is sent to all listeners
|
||||
var data = this.objectToString(this.createMessage({patch: diff, checksum: checksum}));
|
||||
this.file.stats.bytesSent += data.length;
|
||||
this.file.stats.msgSent++;
|
||||
|
||||
|
||||
var acceptResponse = true;
|
||||
|
||||
|
||||
var timeoutThread = window.setTimeout(mxUtils.bind(this, function()
|
||||
{
|
||||
acceptResponse = false;
|
||||
error({code: App.ERROR_TIMEOUT, message: mxResources.get('timeout')});
|
||||
}), this.ui.timeout);
|
||||
|
||||
|
||||
mxUtils.post(EditorUi.cacheUrl, this.getIdParameters() +
|
||||
'&from=' + encodeURIComponent(etag) + '&to=' + encodeURIComponent(current) +
|
||||
'&msg=' + encodeURIComponent(msg) + ((secret != null) ? '&secret=' + encodeURIComponent(secret) : '') +
|
||||
@ -1400,7 +1400,7 @@ DrawioFileSync.prototype.fileSaved = function(pages, lastDesc, success, error, t
|
||||
mxUtils.bind(this, function(req)
|
||||
{
|
||||
window.clearTimeout(timeoutThread);
|
||||
|
||||
|
||||
if (acceptResponse)
|
||||
{
|
||||
if (req.getStatus() >= 200 && req.getStatus() <= 299)
|
||||
@ -1416,7 +1416,7 @@ DrawioFileSync.prototype.fileSaved = function(pages, lastDesc, success, error, t
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
if (urlParams['test'] == '1')
|
||||
{
|
||||
EditorUi.debug('Sync.fileSaved', [this],
|
||||
@ -1424,13 +1424,13 @@ DrawioFileSync.prototype.fileSaved = function(pages, lastDesc, success, error, t
|
||||
data.length, 'bytes', 'diff', diff, 'checksum', checksum);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Logs successull diff
|
||||
// try
|
||||
// {
|
||||
// var user = this.file.getCurrentUser();
|
||||
// var uid = (user != null) ? user.id : 'unknown';
|
||||
//
|
||||
//
|
||||
// EditorUi.logEvent({category: 'DIFF-SYNC-FILE-' + this.file.getHash(),
|
||||
// action: uid + '-diff-' + data.length + '-sent-' +
|
||||
// this.file.stats.bytesSent + '-msgs-' +
|
||||
@ -1442,7 +1442,7 @@ DrawioFileSync.prototype.fileSaved = function(pages, lastDesc, success, error, t
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Ignores cache response as clients
|
||||
// load file if cache entry failed
|
||||
this.file.shadowPages = pages;
|
||||
@ -1454,13 +1454,13 @@ DrawioFileSync.prototype.fileSaved = function(pages, lastDesc, success, error, t
|
||||
DrawioFileSync.prototype.getIdParameters = function()
|
||||
{
|
||||
var result = 'id=' + this.channelId;
|
||||
|
||||
|
||||
if (this.pusher != null && this.pusher.connection != null &&
|
||||
this.pusher.connection.socket_id != null)
|
||||
{
|
||||
result += '&sid=' + this.pusher.connection.socket_id;
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
@ -1478,11 +1478,11 @@ DrawioFileSync.prototype.createMessage = function(data)
|
||||
DrawioFileSync.prototype.fileConflict = function(desc, success, error)
|
||||
{
|
||||
this.catchupRetryCount++;
|
||||
|
||||
|
||||
if (this.catchupRetryCount < this.maxCatchupRetries)
|
||||
{
|
||||
this.file.stats.conflicts++;
|
||||
|
||||
|
||||
if (desc != null)
|
||||
{
|
||||
this.catchup(desc, success, error);
|
||||
@ -1496,7 +1496,7 @@ DrawioFileSync.prototype.fileConflict = function(desc, success, error)
|
||||
{
|
||||
this.file.stats.timeouts++;
|
||||
this.catchupRetryCount = 0;
|
||||
|
||||
|
||||
if (error != null)
|
||||
{
|
||||
error({code: App.ERROR_TIMEOUT, message: mxResources.get('timeout')});
|
||||
@ -1512,26 +1512,26 @@ DrawioFileSync.prototype.stop = function()
|
||||
if (this.pusher != null)
|
||||
{
|
||||
EditorUi.debug('Sync.stop', [this]);
|
||||
|
||||
|
||||
if (this.pusher.connection != null)
|
||||
{
|
||||
this.pusher.connection.unbind('state_change', this.connectionListener);
|
||||
this.pusher.connection.unbind('error', this.pusherErrorListener);
|
||||
}
|
||||
|
||||
if (this.channel != null)
|
||||
|
||||
if (this.channel != null)
|
||||
{
|
||||
this.channel.unbind('changed', this.changeListener);
|
||||
|
||||
|
||||
// See https://github.com/pusher/pusher-js/issues/75
|
||||
// this.pusher.unsubscribe(this.channelId);
|
||||
this.channel = null;
|
||||
}
|
||||
|
||||
|
||||
this.pusher.disconnect();
|
||||
this.pusher = null;
|
||||
}
|
||||
|
||||
|
||||
this.updateOnlineState();
|
||||
this.updateStatus();
|
||||
};
|
||||
@ -1545,19 +1545,19 @@ DrawioFileSync.prototype.destroy = function()
|
||||
{
|
||||
var user = this.file.getCurrentUser();
|
||||
var leave = {a: 'leave'};
|
||||
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
leave.name = encodeURIComponent(user.displayName);
|
||||
leave.uid = user.id;
|
||||
}
|
||||
|
||||
|
||||
mxUtils.post(EditorUi.cacheUrl, this.getIdParameters() +
|
||||
'&msg=' + encodeURIComponent(this.objectToString(
|
||||
this.createMessage(leave))));
|
||||
this.file.stats.msgSent++;
|
||||
}
|
||||
|
||||
|
||||
this.stop();
|
||||
|
||||
if (this.updateStatusThread != null)
|
||||
@ -1565,7 +1565,7 @@ DrawioFileSync.prototype.destroy = function()
|
||||
window.clearInterval(this.updateStatusThread);
|
||||
this.updateStatusThread = null;
|
||||
}
|
||||
|
||||
|
||||
if (this.onlineListener != null)
|
||||
{
|
||||
mxEvent.removeListener(window, 'online', this.onlineListener);
|
||||
@ -1583,16 +1583,16 @@ DrawioFileSync.prototype.destroy = function()
|
||||
mxEvent.removeListener(document, (mxClient.IS_POINTER) ? 'pointermove' : 'mousemove', this.activityListener);
|
||||
mxEvent.removeListener(document, 'keypress', this.activityListener);
|
||||
mxEvent.removeListener(window, 'focus', this.activityListener);
|
||||
|
||||
|
||||
if (!mxClient.IS_POINTER && mxClient.IS_TOUCH)
|
||||
{
|
||||
mxEvent.removeListener(document, 'touchstart', this.activityListener);
|
||||
mxEvent.removeListener(document, 'touchmove', this.activityListener);
|
||||
mxEvent.removeListener(document, 'touchmove', this.activityListener);
|
||||
}
|
||||
|
||||
|
||||
this.activityListener = null;
|
||||
}
|
||||
|
||||
|
||||
if (this.collaboratorsElement != null)
|
||||
{
|
||||
this.collaboratorsElement.parentNode.removeChild(this.collaboratorsElement);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3404,10 +3404,10 @@ EditorUi.prototype.addBeforeUnloadListener = function()
|
||||
// This must be disabled during save and image export
|
||||
window.onbeforeunload = mxUtils.bind(this, function()
|
||||
{
|
||||
if (!this.editor.isChromelessView())
|
||||
{
|
||||
return this.onBeforeUnload();
|
||||
}
|
||||
// if (!this.editor.isChromelessView())
|
||||
// {
|
||||
// return this.onBeforeUnload();
|
||||
// }
|
||||
});
|
||||
};
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user