|
|
|
@ -268,13 +268,13 @@ editorType;this._isExcel=c_oEditorId.Spreadsheet===editorType;this._isPresentati
|
|
|
|
|
docid;this.sockjs_url=AscCommon.getBaseUrl()+"../../../../doc/"+docid+"/c"};DocsCoApi.prototype.auth=function(isViewer,opt_openCmd,opt_isIdle){this._isViewer=isViewer;if(this._locks){this.ownedLockBlocks=[];for(var block in this._locks)if(this._locks.hasOwnProperty(block)){var lock=this._locks[block];if(lock["state"]===2)this.ownedLockBlocks.push(lock["blockValue"])}this._locks={}}this._send({"type":"auth","docid":this._docid,"documentCallbackUrl":this._documentCallbackUrl,"token":this._token,"user":{"id":this._user.asc_getId(),
|
|
|
|
|
"username":this._user.asc_getUserName(),"firstname":this._user.asc_getFirstName(),"lastname":this._user.asc_getLastName(),"indexUser":this._indexUser},"editorType":this.editorType,"lastOtherSaveTime":this.lastOtherSaveTime,"block":this.ownedLockBlocks,"sessionId":this._id,"sessionTimeConnect":this._sessionTimeConnect,"sessionTimeIdle":opt_isIdle>=0?opt_isIdle:0,"documentFormatSave":this._documentFormatSave,"view":this._isViewer,"isCloseCoAuthoring":this.isCloseCoAuthoring,"openCmd":opt_openCmd,"lang":this.lang,
|
|
|
|
|
"mode":this.mode,"permissions":this.permissions,"encrypted":this.encrypted,"jwtOpen":this.jwtOpen,"jwtSession":this.jwtSession})};DocsCoApi.prototype._initSocksJs=function(){var t=this;var sockjs;sockjs=this.sockjs={};var send=function(data){setTimeout(function(){sockjs.onmessage({data:JSON.stringify(data)})})};var license={type:"license",license:{type:3,mode:0,rights:1,buildVersion:"5.2.6",buildNumber:2}};var channel;require(["/common/outer/worker-channel.js","/common/common-util.js"],function(Channel,
|
|
|
|
|
Util){var msgEv=Util.mkEvent();var p=window.parent;if(editor.isReporterMode){p=window.opener;window.parent=p}else window.APP=p&&p.APP;window.addEventListener("message",function(msg){if(msg.source!==p)return;msgEv.fire(msg)});var postMsg=function(data){p.postMessage(data,"*")};Channel.create(msgEv,postMsg,function(chan){channel=chan;send(license);chan.on("CMD",function(obj){send(obj)})})});sockjs.onopen=function(){t._state=ConnectionState.WaitAuth;t.onFirstConnect()};sockjs.onopen();sockjs.close=function(){console.error("Close realtime")};
|
|
|
|
|
sockjs.send=function(data){try{var obj=JSON.parse(data)}catch(e){console.error(e);return}if(channel)channel.event("CMD",obj)};sockjs.onmessage=function(e){t._onServerMessage(e.data)};return sockjs};DocsCoApi.prototype._onServerOpen=function(){if(this.reconnectTimeout){clearTimeout(this.reconnectTimeout);this.reconnectTimeout=null;this.attemptCount=0}this._state=ConnectionState.WaitAuth;this.onFirstConnect()};DocsCoApi.prototype._onServerMessage=function(data){var dataObject=JSON.parse(data);switch(dataObject["type"]){case "auth":this._onAuth(dataObject);
|
|
|
|
|
break;case "message":this._onMessages(dataObject,false);break;case "cursor":this._onCursor(dataObject);break;case "meta":this._onMeta(dataObject);break;case "getLock":this._onGetLock(dataObject);break;case "releaseLock":this._onReleaseLock(dataObject);break;case "connectState":this._onConnectionStateChanged(dataObject);break;case "saveChanges":this._onSaveChanges(dataObject);break;case "authChanges":this._onAuthChanges(dataObject);break;case "saveLock":this._onSaveLock(dataObject);break;case "unSaveLock":this._onUnSaveLock(dataObject);
|
|
|
|
|
break;case "savePartChanges":this._onSavePartChanges(dataObject);break;case "drop":this._onDrop(dataObject);break;case "waitAuth":break;case "error":this._onDrop(dataObject);break;case "documentOpen":this._documentOpen(dataObject);break;case "warning":this._onWarning(dataObject);break;case "license":this._onLicense(dataObject);break;case "session":this._onSession(dataObject);break;case "refreshToken":this._onRefreshToken(dataObject["messages"]);break;case "expiredToken":this._onExpiredToken(dataObject);
|
|
|
|
|
break;case "forceSaveStart":this._onForceSaveStart(dataObject["messages"]);break;case "forceSave":this._onForceSave(dataObject["messages"]);break}};DocsCoApi.prototype._onServerClose=function(evt){if(ConnectionState.SaveChanges===this._state){this._isReSaveAfterAuth=true;if(null!==this.saveCallbackErrorTimeOutId){clearTimeout(this.saveCallbackErrorTimeOutId);this.saveCallbackErrorTimeOutId=null}}this._state=ConnectionState.Reconnect;var bIsDisconnectAtAll=c_oCloseCode.serverShutdown<=evt.code&&evt.code<=
|
|
|
|
|
c_oCloseCode.drop||this.attemptCount>=this.maxAttemptCount;var code=null;if(bIsDisconnectAtAll){this._state=ConnectionState.ClosedAll;code=evt.code}if(this.onDisconnect)this.onDisconnect(evt.reason,code);if(!bIsDisconnectAtAll)this._tryReconnect()};DocsCoApi.prototype._reconnect=function(){delete this.sockjs;this._initSocksJs()};DocsCoApi.prototype._tryReconnect=function(){var t=this;if(this.reconnectTimeout){clearTimeout(this.reconnectTimeout);t.reconnectTimeout=null}++this.attemptCount;this.reconnectTimeout=
|
|
|
|
|
setTimeout(function(){t._reconnect()},this.reconnectInterval)};window["AscCommon"]=window["AscCommon"]||{};window["AscCommon"].CDocsCoApi=CDocsCoApi})(window);"use strict";
|
|
|
|
|
Util){var msgEv=Util.mkEvent();var p=window.parent;if(editor&&editor.isReporterMode){p=window.opener;window.parent=p}else window.APP=p&&p.APP;window.addEventListener("message",function(msg){if(msg.source!==p)return;msgEv.fire(msg)});var postMsg=function(data){p.postMessage(data,"*")};Channel.create(msgEv,postMsg,function(chan){channel=chan;send(license);chan.on("CMD",function(obj){send(obj)})})});sockjs.onopen=function(){t._state=ConnectionState.WaitAuth;t.onFirstConnect()};sockjs.onopen();sockjs.close=
|
|
|
|
|
function(){console.error("Close realtime")};sockjs.send=function(data){try{var obj=JSON.parse(data)}catch(e){console.error(e);return}if(channel)channel.event("CMD",obj)};sockjs.onmessage=function(e){t._onServerMessage(e.data)};return sockjs};DocsCoApi.prototype._onServerOpen=function(){if(this.reconnectTimeout){clearTimeout(this.reconnectTimeout);this.reconnectTimeout=null;this.attemptCount=0}this._state=ConnectionState.WaitAuth;this.onFirstConnect()};DocsCoApi.prototype._onServerMessage=function(data){var dataObject=
|
|
|
|
|
JSON.parse(data);switch(dataObject["type"]){case "auth":this._onAuth(dataObject);break;case "message":this._onMessages(dataObject,false);break;case "cursor":this._onCursor(dataObject);break;case "meta":this._onMeta(dataObject);break;case "getLock":this._onGetLock(dataObject);break;case "releaseLock":this._onReleaseLock(dataObject);break;case "connectState":this._onConnectionStateChanged(dataObject);break;case "saveChanges":this._onSaveChanges(dataObject);break;case "authChanges":this._onAuthChanges(dataObject);
|
|
|
|
|
break;case "saveLock":this._onSaveLock(dataObject);break;case "unSaveLock":this._onUnSaveLock(dataObject);break;case "savePartChanges":this._onSavePartChanges(dataObject);break;case "drop":this._onDrop(dataObject);break;case "waitAuth":break;case "error":this._onDrop(dataObject);break;case "documentOpen":this._documentOpen(dataObject);break;case "warning":this._onWarning(dataObject);break;case "license":this._onLicense(dataObject);break;case "session":this._onSession(dataObject);break;case "refreshToken":this._onRefreshToken(dataObject["messages"]);
|
|
|
|
|
break;case "expiredToken":this._onExpiredToken(dataObject);break;case "forceSaveStart":this._onForceSaveStart(dataObject["messages"]);break;case "forceSave":this._onForceSave(dataObject["messages"]);break}};DocsCoApi.prototype._onServerClose=function(evt){if(ConnectionState.SaveChanges===this._state){this._isReSaveAfterAuth=true;if(null!==this.saveCallbackErrorTimeOutId){clearTimeout(this.saveCallbackErrorTimeOutId);this.saveCallbackErrorTimeOutId=null}}this._state=ConnectionState.Reconnect;var bIsDisconnectAtAll=
|
|
|
|
|
c_oCloseCode.serverShutdown<=evt.code&&evt.code<=c_oCloseCode.drop||this.attemptCount>=this.maxAttemptCount;var code=null;if(bIsDisconnectAtAll){this._state=ConnectionState.ClosedAll;code=evt.code}if(this.onDisconnect)this.onDisconnect(evt.reason,code);if(!bIsDisconnectAtAll)this._tryReconnect()};DocsCoApi.prototype._reconnect=function(){delete this.sockjs;this._initSocksJs()};DocsCoApi.prototype._tryReconnect=function(){var t=this;if(this.reconnectTimeout){clearTimeout(this.reconnectTimeout);t.reconnectTimeout=
|
|
|
|
|
null}++this.attemptCount;this.reconnectTimeout=setTimeout(function(){t._reconnect()},this.reconnectInterval)};window["AscCommon"]=window["AscCommon"]||{};window["AscCommon"].CDocsCoApi=CDocsCoApi})(window);"use strict";
|
|
|
|
|
(function(window){var CSpellCheckApi=function(){this._SpellCheckApi=new SpellCheckApi;this._onlineWork=false;this.onDisconnect=null;this.onSpellCheck=null};CSpellCheckApi.prototype.init=function(docid){if(this._SpellCheckApi&&this._SpellCheckApi.isRightURL()){var t=this;this._SpellCheckApi.onDisconnect=function(e,isDisconnectAtAll,isCloseCoAuthoring){t.callback_OnDisconnect(e,isDisconnectAtAll,isCloseCoAuthoring)};this._SpellCheckApi.onSpellCheck=function(e){t.callback_OnSpellCheck(e)};this._SpellCheckApi.onInit=
|
|
|
|
|
function(e){t.callback_OnInit(e)};this._SpellCheckApi.init(docid);this._onlineWork=true}};CSpellCheckApi.prototype.set_url=function(url){if(this._SpellCheckApi)this._SpellCheckApi.set_url(url)};CSpellCheckApi.prototype.get_state=function(){if(this._SpellCheckApi)return this._SpellCheckApi.get_state();return 0};CSpellCheckApi.prototype.disconnect=function(){if(this._SpellCheckApi&&this._onlineWork)this._SpellCheckApi.disconnect()};CSpellCheckApi.prototype.spellCheck=function(spellCheckData){if(this._SpellCheckApi&&
|
|
|
|
|
this._onlineWork)this._SpellCheckApi.spellCheck(spellCheckData)};CSpellCheckApi.prototype.checkDictionary=function(lang){if(this._SpellCheckApi&&this._onlineWork)return this._SpellCheckApi.checkDictionary(lang);return true};CSpellCheckApi.prototype.callback_OnSpellCheck=function(e){if(this.onSpellCheck)return this.onSpellCheck(e)};CSpellCheckApi.prototype.callback_OnInit=function(e){if(this.onInit)return this.onInit(e)};CSpellCheckApi.prototype.callback_OnDisconnect=function(e,isDisconnectAtAll,isCloseCoAuthoring){if(this.onDisconnect)return this.onDisconnect(e,
|
|
|
|
|