Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
ed36c9c2
Commit
ed36c9c2
authored
Oct 26, 2016
by
konovalovsergey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
History.Is_Modified->Have_Changes, onDisconnect error interface, session idle/absolute timeout
parent
6ef43c8b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
28 deletions
+60
-28
cell/Local/api.js
cell/Local/api.js
+4
-4
cell/api.js
cell/api.js
+5
-5
cell/model/History.js
cell/model/History.js
+8
-2
common/apiBase.js
common/apiBase.js
+19
-7
common/docscoapi.js
common/docscoapi.js
+24
-10
No files found.
cell/Local/api.js
View file @
ed36c9c2
...
...
@@ -74,7 +74,7 @@ var c_oAscError = Asc.c_oAscError;
DesktopOfflineUpdateLocalName
(
this
);
this
.
onUpdateDocumentModified
(
AscCommon
.
History
.
Is_Modified
());
this
.
onUpdateDocumentModified
(
AscCommon
.
History
.
Have_Changes
());
};
asc
[
'
spreadsheet_api
'
].
prototype
.
_onNeedParams
=
function
(
data
,
opt_isPassword
)
...
...
@@ -162,7 +162,7 @@ AscCommon.CHistory.prototype.Reset_SavedIndex = function(IsUserSave)
}
};
AscCommon
.
CHistory
.
prototype
.
Is_Modified
=
function
(
IsNotUserSave
,
IsNoSavedNoModifyed
)
AscCommon
.
CHistory
.
prototype
.
Have_Changes
=
function
(
IsNotUserSave
,
IsNoSavedNoModifyed
)
{
var
checkIndex
=
(
this
.
Is_UserSaveMode
()
&&
!
IsNotUserSave
)
?
this
.
UserSavedIndex
:
this
.
SavedIndex
;
if
(
-
1
===
this
.
Index
&&
null
===
checkIndex
&&
false
===
this
.
ForceSave
)
...
...
@@ -198,7 +198,7 @@ window["Asc"]['spreadsheet_api'].prototype.onUpdateDocumentModified = function(b
this
.
_onUpdateDocumentCanSave
();
if
(
undefined
!==
window
[
"
AscDesktopEditor
"
])
{
window
[
"
AscDesktopEditor
"
][
"
onDocumentModifiedChanged
"
](
AscCommon
.
History
?
AscCommon
.
History
.
Is_Modified
(
undefined
,
true
)
:
bValue
);
window
[
"
AscDesktopEditor
"
][
"
onDocumentModifiedChanged
"
](
AscCommon
.
History
?
AscCommon
.
History
.
Have_Changes
(
undefined
,
true
)
:
bValue
);
}
}
};
...
...
@@ -260,7 +260,7 @@ window["DesktopOfflineAppDocumentEndSave"] = function(error)
else
AscCommon
.
History
.
UserSavedIndex
=
window
[
"
Asc
"
][
"
editor
"
].
LastUserSavedIndex
;
window
[
"
Asc
"
][
"
editor
"
].
onUpdateDocumentModified
(
AscCommon
.
History
.
Is_Modified
());
window
[
"
Asc
"
][
"
editor
"
].
onUpdateDocumentModified
(
AscCommon
.
History
.
Have_Changes
());
window
[
"
Asc
"
][
"
editor
"
].
LastUserSavedIndex
=
undefined
;
if
(
2
==
error
)
...
...
cell/api.js
View file @
ed36c9c2
...
...
@@ -874,8 +874,8 @@ var editor;
if
(
!
this
.
canSave
||
this
.
asc_getCellEditMode
())
{
// Пока идет сохранение или редактирование ячейки, мы не закрываем документ
return
true
;
}
else
if
(
History
&&
History
.
Is_Modified
)
{
return
History
.
Is_Modified
();
}
else
if
(
History
&&
History
.
Have_Changes
)
{
return
History
.
Have_Changes
();
}
return
false
;
};
...
...
@@ -1532,7 +1532,7 @@ var editor;
t
.
sync_EndAction
(
c_oAscAsyncActionType
.
Information
,
c_oAscAsyncAction
.
Save
);
// Обновляем состояние возможности сохранения документа
t
.
onUpdateDocumentModified
(
History
.
Is_Modified
());
t
.
onUpdateDocumentModified
(
History
.
Have_Changes
());
if
(
undefined
!==
window
[
"
AscDesktopEditor
"
])
{
window
[
"
AscDesktopEditor
"
][
"
OnSave
"
]();
...
...
@@ -3051,7 +3051,7 @@ var editor;
!
History
.
IsEndTransaction
()
||
!
this
.
canSave
)
{
return
;
}
if
(
!
History
.
Is_Modified
(
true
)
&&
!
(
this
.
collaborativeEditing
.
getCollaborativeEditing
()
&&
0
!==
this
.
collaborativeEditing
.
getOwnLocksLength
()))
{
if
(
!
History
.
Have_Changes
(
true
)
&&
!
(
this
.
collaborativeEditing
.
getCollaborativeEditing
()
&&
0
!==
this
.
collaborativeEditing
.
getOwnLocksLength
()))
{
if
(
this
.
collaborativeEditing
.
getFast
()
&&
this
.
collaborativeEditing
.
haveOtherChanges
())
{
AscCommon
.
CollaborativeEditing
.
Clear_CollaborativeMarks
();
...
...
@@ -3078,7 +3078,7 @@ var editor;
spreadsheet_api
.
prototype
.
_onUpdateDocumentCanSave
=
function
()
{
// Можно модифицировать это условие на более быстрое (менять самим состояние в аргументах, а не запрашивать каждый раз)
var
tmp
=
History
.
Is_Modified
()
||
(
this
.
collaborativeEditing
.
getCollaborativeEditing
()
&&
0
!==
this
.
collaborativeEditing
.
getOwnLocksLength
());
var
tmp
=
History
.
Have_Changes
()
||
(
this
.
collaborativeEditing
.
getCollaborativeEditing
()
&&
0
!==
this
.
collaborativeEditing
.
getOwnLocksLength
());
if
(
tmp
!==
this
.
isDocumentCanSave
)
{
this
.
isDocumentCanSave
=
tmp
;
this
.
handlers
.
trigger
(
'
asc_onDocumentCanSaveChanged
'
,
this
.
isDocumentCanSave
);
...
...
cell/model/History.js
View file @
ed36c9c2
...
...
@@ -173,6 +173,12 @@ CHistory.prototype.init = function(workbook) {
CHistory
.
prototype
.
Is_UserSaveMode
=
function
()
{
return
this
.
UserSaveMode
;
};
CHistory
.
prototype
.
Is_Clear
=
function
()
{
if
(
this
.
Points
.
length
<=
0
)
return
true
;
return
false
;
};
CHistory
.
prototype
.
Clear
=
function
()
{
this
.
Index
=
-
1
;
...
...
@@ -709,7 +715,7 @@ CHistory.prototype._sendCanUndoRedo = function()
{
this
.
workbook
.
handlers
.
trigger
(
"
setCanUndo
"
,
this
.
Can_Undo
());
this
.
workbook
.
handlers
.
trigger
(
"
setCanRedo
"
,
this
.
Can_Redo
());
this
.
workbook
.
handlers
.
trigger
(
"
setDocumentModified
"
,
this
.
Is_Modified
());
this
.
workbook
.
handlers
.
trigger
(
"
setDocumentModified
"
,
this
.
Have_Changes
());
};
CHistory
.
prototype
.
SetSelection
=
function
(
range
)
{
...
...
@@ -835,7 +841,7 @@ CHistory.prototype.Get_DeleteIndex = function () {
return
DeleteIndex
;
};
/** @returns {boolean} */
CHistory
.
prototype
.
Is_Modified
=
function
(
IsNotUserSave
)
{
CHistory
.
prototype
.
Have_Changes
=
function
(
IsNotUserSave
)
{
var
checkIndex
=
(
this
.
Is_UserSaveMode
()
&&
!
IsNotUserSave
)
?
this
.
UserSavedIndex
:
this
.
SavedIndex
;
if
(
-
1
===
this
.
Index
&&
null
===
checkIndex
&&
false
===
this
.
ForceSave
)
{
return
false
;
...
...
common/apiBase.js
View file @
ed36c9c2
...
...
@@ -589,14 +589,21 @@
this
.
CoAuthoringApi
.
onSession
=
function
(
data
)
{
var
code
=
data
[
"
code
"
];
var
reason
=
data
[
"
reason
"
];
var
interval
=
data
[
"
interval
"
];
var
extendSession
=
true
;
if
(
c_oCloseCode
.
sessionIdle
==
code
)
{
extendSession
=
false
;
var
lastTime
=
new
Date
().
getTime
();
var
idleTime
=
new
Date
().
getTime
()
-
lastTime
;
if
(
idleTime
<
interval
)
{
t
.
CoAuthoringApi
.
extendSession
(
idleTime
);
}
else
{
extendSession
=
false
;
}
}
else
if
(
c_oCloseCode
.
sessionAbsolute
==
code
)
{
extendSession
=
false
;
}
if
(
!
extendSession
)
{
if
(
true
!=
History
.
Is_Clear
())
{
if
(
History
.
Have_Changes
())
{
//enter view mode because save async
t
.
sendEvent
(
'
asc_onCoAuthoringDisconnect
'
);
t
.
asc_setViewMode
(
true
);
...
...
@@ -606,8 +613,13 @@
t
.
CoAuthoringApi
.
disconnect
(
code
,
reason
);
};
AscCommon
.
CollaborativeEditing
.
Apply_Changes
();
AscCommon
.
CollaborativeEditing
.
Send_Changes
();
if
(
t
.
collaborativeEditing
.
applyChanges
)
{
t
.
collaborativeEditing
.
applyChanges
();
t
.
collaborativeEditing
.
sendChanges
();
}
else
{
AscCommon
.
CollaborativeEditing
.
Apply_Changes
();
AscCommon
.
CollaborativeEditing
.
Send_Changes
();
}
}
else
{
t
.
CoAuthoringApi
.
disconnect
(
code
,
reason
);
}
...
...
@@ -619,19 +631,19 @@
* @param {Bool} isDisconnectAtAll окончательно ли отсоединяемся(true) или будем пробовать сделать reconnect(false) + сами отключились
* @param {Bool} isCloseCoAuthoring
*/
this
.
CoAuthoringApi
.
onDisconnect
=
function
(
e
,
isDisconnectAtAll
,
isCloseCoAuthoring
)
this
.
CoAuthoringApi
.
onDisconnect
=
function
(
e
,
errorCode
)
{
if
(
AscCommon
.
ConnectionState
.
None
===
t
.
CoAuthoringApi
.
get_state
())
{
t
.
asyncServerIdEndLoaded
();
}
if
(
isDisconnectAtAll
)
if
(
null
!=
errorCode
)
{
// Посылаем наверх эвент об отключении от сервера
t
.
sendEvent
(
'
asc_onCoAuthoringDisconnect
'
);
// И переходим в режим просмотра т.к. мы не можем сохранить файл
t
.
asc_setViewMode
(
true
);
t
.
sendEvent
(
'
asc_onError
'
,
isCloseCoAuthoring
?
c_oAscError
.
ID
.
UserDrop
:
c_oAscError
.
ID
.
CoAuthoringDisconnect
,
c_oAscError
.
Level
.
NoCritical
);
t
.
sendEvent
(
'
asc_onError
'
,
errorCode
,
c_oAscError
.
Level
.
NoCritical
);
}
};
this
.
CoAuthoringApi
.
onDocumentOpen
=
function
(
inputWrap
)
...
...
common/docscoapi.js
View file @
ed36c9c2
...
...
@@ -102,8 +102,8 @@
this
.
_CoAuthoringApi
.
onLocksReleasedEnd
=
function
()
{
t
.
callback_OnLocksReleasedEnd
();
};
this
.
_CoAuthoringApi
.
onDisconnect
=
function
(
e
,
isDisconnectAtAll
,
isCloseCoAuthoring
)
{
t
.
callback_OnDisconnect
(
e
,
isDisconnectAtAll
,
isCloseCoAuthoring
);
this
.
_CoAuthoringApi
.
onDisconnect
=
function
(
e
,
errorCode
)
{
t
.
callback_OnDisconnect
(
e
,
errorCode
);
};
this
.
_CoAuthoringApi
.
onWarning
=
function
(
e
)
{
t
.
callback_OnWarning
(
e
);
...
...
@@ -328,9 +328,9 @@
}
};
CDocsCoApi
.
prototype
.
extendSession
=
function
()
{
CDocsCoApi
.
prototype
.
extendSession
=
function
(
idleTime
)
{
if
(
this
.
_CoAuthoringApi
&&
this
.
_onlineWork
)
{
this
.
_CoAuthoringApi
.
extendSession
();
this
.
_CoAuthoringApi
.
extendSession
(
idleTime
);
}
};
...
...
@@ -394,9 +394,9 @@
* @param {Bool} isDisconnectAtAll окончательно ли отсоединяемся(true) или будем пробовать сделать reconnect(false) + сами отключились
* @param {Bool} isCloseCoAuthoring
*/
CDocsCoApi
.
prototype
.
callback_OnDisconnect
=
function
(
e
,
isDisconnectAtAll
,
isCloseCoAuthoring
)
{
CDocsCoApi
.
prototype
.
callback_OnDisconnect
=
function
(
e
,
errorCode
)
{
if
(
this
.
onDisconnect
)
{
this
.
onDisconnect
(
e
,
isDisconnectAtAll
,
isCloseCoAuthoring
);
this
.
onDisconnect
(
e
,
errorCode
);
}
};
...
...
@@ -786,8 +786,8 @@
}
};
DocsCoApi
.
prototype
.
extendSession
=
function
()
{
this
.
_send
({
'
type
'
:
'
extendSession
'
});
DocsCoApi
.
prototype
.
extendSession
=
function
(
idleTime
)
{
this
.
_send
({
'
type
'
:
'
extendSession
'
,
'
idletime
'
:
idleTime
});
};
DocsCoApi
.
prototype
.
openDocument
=
function
(
data
)
{
...
...
@@ -1162,7 +1162,7 @@
DocsCoApi
.
prototype
.
_onDrop
=
function
(
data
)
{
this
.
disconnect
();
this
.
onDisconnect
(
data
?
data
[
'
description
'
]
:
''
,
t
rue
,
this
.
isCloseCoAuthoring
);
this
.
onDisconnect
(
data
?
data
[
'
description
'
]
:
''
,
t
his
.
_getDisconnectErrorCode
()
);
};
DocsCoApi
.
prototype
.
_onWarning
=
function
(
data
)
{
...
...
@@ -1301,6 +1301,7 @@
'
block
'
:
this
.
ownedLockBlocks
,
'
sessionId
'
:
this
.
_id
,
'
sessionTimeConnect
'
:
this
.
_sessionTimeConnect
,
'
sessionTimeIdle
'
:
0
,
'
documentFormatSave
'
:
this
.
_documentFormatSave
,
'
view
'
:
this
.
_isViewer
,
'
isCloseCoAuthoring
'
:
this
.
isCloseCoAuthoring
,
...
...
@@ -1404,11 +1405,13 @@
t
.
_state
=
ConnectionState
.
Reconnect
;
var
bIsDisconnectAtAll
=
(
c_oCloseCode
.
serverShutdown
===
evt
.
code
||
c_oCloseCode
.
sessionIdle
===
evt
.
code
||
c_oCloseCode
.
sessionAbsolute
===
evt
.
code
||
t
.
attemptCount
>=
t
.
maxAttemptCount
);
var
errorCode
=
null
;
if
(
bIsDisconnectAtAll
)
{
t
.
_state
=
ConnectionState
.
ClosedAll
;
errorCode
=
t
.
_getDisconnectErrorCode
(
evt
.
code
);
}
if
(
t
.
onDisconnect
)
{
t
.
onDisconnect
(
evt
.
reason
,
bIsDisconnectAtAll
,
t
.
isCloseCoAuthoring
);
t
.
onDisconnect
(
evt
.
reason
,
errorCode
);
}
//Try reconect
if
(
!
bIsDisconnectAtAll
)
{
...
...
@@ -1437,6 +1440,17 @@
return
window
[
'
SockJS
'
]
?
window
[
'
SockJS
'
]
:
require
(
'
sockjs
'
);
};
DocsCoApi
.
prototype
.
_getDisconnectErrorCode
=
function
(
opt_closeCode
)
{
if
(
c_oCloseCode
.
serverShutdown
===
opt_closeCode
)
{
return
Asc
.
c_oAscError
.
ID
.
CoAuthoringDisconnect
;
}
else
if
(
c_oCloseCode
.
sessionIdle
===
opt_closeCode
){
return
Asc
.
c_oAscError
.
ID
.
CoAuthoringDisconnect
;
}
else
if
(
c_oCloseCode
.
sessionAbsolute
===
opt_closeCode
){
return
Asc
.
c_oAscError
.
ID
.
CoAuthoringDisconnect
;
}
return
this
.
isCloseCoAuthoring
?
Asc
.
c_oAscError
.
ID
.
UserDrop
:
Asc
.
c_oAscError
.
ID
.
CoAuthoringDisconnect
;
};
//----------------------------------------------------------export----------------------------------------------------
window
[
'
AscCommon
'
]
=
window
[
'
AscCommon
'
]
||
{};
window
[
'
AscCommon
'
].
CDocsCoApi
=
CDocsCoApi
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment