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
d5f6213c
Commit
d5f6213c
authored
Feb 15, 2017
by
konovalovsergey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
force save on timeout
parent
9a001478
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
7 deletions
+62
-7
common/apiBase.js
common/apiBase.js
+7
-0
common/docscoapi.js
common/docscoapi.js
+54
-6
common/docscoapicommon.js
common/docscoapicommon.js
+1
-1
No files found.
common/apiBase.js
View file @
d5f6213c
...
@@ -644,6 +644,13 @@
...
@@ -644,6 +644,13 @@
}
}
}
}
};
};
this
.
CoAuthoringApi
.
onForceSave
=
function
(
data
)
{
if
(
AscCommon
.
c_oAscForceSaveTypes
.
Button
===
data
.
type
)
{
t
.
sendEvent
(
'
asc_onForceSaveButton
'
);
}
else
if
(
AscCommon
.
c_oAscForceSaveTypes
.
Timeout
===
data
.
type
)
{
t
.
sendEvent
(
'
asc_onForceSaveTimeout
'
,
data
.
saved
);
}
};
/**
/**
* Event об отсоединении от сервера
* Event об отсоединении от сервера
* @param {jQuery} e event об отсоединении с причиной
* @param {jQuery} e event об отсоединении с причиной
...
...
common/docscoapi.js
View file @
d5f6213c
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
var
c_oEditorId
=
AscCommon
.
c_oEditorId
;
var
c_oEditorId
=
AscCommon
.
c_oEditorId
;
var
c_oCloseCode
=
AscCommon
.
c_oCloseCode
;
var
c_oCloseCode
=
AscCommon
.
c_oCloseCode
;
var
c_oAscServerCommandErrors
=
AscCommon
.
c_oAscServerCommandErrors
;
var
c_oAscServerCommandErrors
=
AscCommon
.
c_oAscServerCommandErrors
;
var
c_oAscForceSaveTypes
=
AscCommon
.
c_oAscForceSaveTypes
;
// Класс надстройка, для online и offline работы
// Класс надстройка, для online и offline работы
function
CDocsCoApi
(
options
)
{
function
CDocsCoApi
(
options
)
{
...
@@ -53,6 +54,7 @@
...
@@ -53,6 +54,7 @@
this
.
onCursor
=
options
.
onCursor
;
this
.
onCursor
=
options
.
onCursor
;
this
.
onMeta
=
options
.
onMeta
;
this
.
onMeta
=
options
.
onMeta
;
this
.
onSession
=
options
.
onSession
;
this
.
onSession
=
options
.
onSession
;
this
.
onForceSave
=
options
.
onForceSave
;
this
.
onLocksAcquired
=
options
.
onLocksAcquired
;
this
.
onLocksAcquired
=
options
.
onLocksAcquired
;
this
.
onLocksReleased
=
options
.
onLocksReleased
;
this
.
onLocksReleased
=
options
.
onLocksReleased
;
this
.
onLocksReleasedEnd
=
options
.
onLocksReleasedEnd
;
// ToDo переделать на массив release locks
this
.
onLocksReleasedEnd
=
options
.
onLocksReleasedEnd
;
// ToDo переделать на массив release locks
...
@@ -93,6 +95,9 @@
...
@@ -93,6 +95,9 @@
};
};
this
.
_CoAuthoringApi
.
onSession
=
function
(
e
)
{
this
.
_CoAuthoringApi
.
onSession
=
function
(
e
)
{
t
.
callback_OnSession
(
e
);
t
.
callback_OnSession
(
e
);
};
this
.
_CoAuthoringApi
.
onForceSave
=
function
(
e
)
{
t
.
callback_OnForceSave
(
e
);
};
};
this
.
_CoAuthoringApi
.
onLocksAcquired
=
function
(
e
)
{
this
.
_CoAuthoringApi
.
onLocksAcquired
=
function
(
e
)
{
t
.
callback_OnLocksAcquired
(
e
);
t
.
callback_OnLocksAcquired
(
e
);
...
@@ -391,6 +396,12 @@
...
@@ -391,6 +396,12 @@
this
.
onSession
(
e
);
this
.
onSession
(
e
);
}
}
};
};
CDocsCoApi
.
prototype
.
callback_OnForceSave
=
function
(
e
)
{
if
(
this
.
onForceSave
)
{
this
.
onForceSave
(
e
);
}
};
CDocsCoApi
.
prototype
.
callback_OnLocksAcquired
=
function
(
e
)
{
CDocsCoApi
.
prototype
.
callback_OnLocksAcquired
=
function
(
e
)
{
if
(
this
.
onLocksAcquired
)
{
if
(
this
.
onLocksAcquired
)
{
...
@@ -507,6 +518,7 @@
...
@@ -507,6 +518,7 @@
this
.
onCursor
=
options
.
onCursor
;
this
.
onCursor
=
options
.
onCursor
;
this
.
onMeta
=
options
.
onMeta
;
this
.
onMeta
=
options
.
onMeta
;
this
.
onSession
=
options
.
onSession
;
this
.
onSession
=
options
.
onSession
;
this
.
onForceSave
=
options
.
onForceSave
;
this
.
onLocksAcquired
=
options
.
onLocksAcquired
;
this
.
onLocksAcquired
=
options
.
onLocksAcquired
;
this
.
onLocksReleased
=
options
.
onLocksReleased
;
this
.
onLocksReleased
=
options
.
onLocksReleased
;
this
.
onLocksReleasedEnd
=
options
.
onLocksReleasedEnd
;
// ToDo переделать на массив release locks
this
.
onLocksReleasedEnd
=
options
.
onLocksReleasedEnd
;
// ToDo переделать на массив release locks
...
@@ -542,7 +554,9 @@
...
@@ -542,7 +554,9 @@
this
.
jwtTimeOutId
=
null
;
this
.
jwtTimeOutId
=
null
;
this
.
_id
=
null
;
this
.
_id
=
null
;
this
.
_sessionTimeConnect
=
null
;
this
.
_sessionTimeConnect
=
null
;
this
.
_lastForceSaveId
=
null
;
this
.
_allChangesSaved
=
null
;
this
.
_lastForceSaveTime
=
null
;
this
.
_lastForceSaveButtonTime
=
null
;
this
.
_indexUser
=
-
1
;
this
.
_indexUser
=
-
1
;
// Если пользователей больше 1, то совместно редактируем
// Если пользователей больше 1, то совместно редактируем
this
.
isCoAuthoring
=
false
;
this
.
isCoAuthoring
=
false
;
...
@@ -559,6 +573,7 @@
...
@@ -559,6 +573,7 @@
this
.
arrayChanges
=
null
;
this
.
arrayChanges
=
null
;
// Время последнего сохранения (для разрыва соединения)
// Время последнего сохранения (для разрыва соединения)
this
.
lastOtherSaveTime
=
-
1
;
this
.
lastOtherSaveTime
=
-
1
;
this
.
lastOwnSaveTime
=
-
1
;
// Локальный индекс изменений
// Локальный индекс изменений
this
.
changesIndex
=
0
;
this
.
changesIndex
=
0
;
// Дополнительная информация для Excel
// Дополнительная информация для Excel
...
@@ -840,7 +855,7 @@
...
@@ -840,7 +855,7 @@
};
};
DocsCoApi
.
prototype
.
forceSave
=
function
()
{
DocsCoApi
.
prototype
.
forceSave
=
function
()
{
this
.
_send
({
'
type
'
:
'
force
save
'
,
'
saveid
'
:
new
Date
().
getTime
()
});
this
.
_send
({
'
type
'
:
'
force
SaveStart
'
});
};
};
DocsCoApi
.
prototype
.
openDocument
=
function
(
data
)
{
DocsCoApi
.
prototype
.
openDocument
=
function
(
data
)
{
...
@@ -941,13 +956,36 @@
...
@@ -941,13 +956,36 @@
}
}
};
};
DocsCoApi
.
prototype
.
_onForceSave
=
function
(
data
)
{
DocsCoApi
.
prototype
.
_onForceSave
Start
=
function
(
data
)
{
if
(
data
[
'
code
'
]
===
c_oAscServerCommandErrors
.
NoError
)
{
if
(
data
[
'
code
'
]
===
c_oAscServerCommandErrors
.
NoError
)
{
this
.
_lastForceSave
Id
=
data
[
'
saveid
'
];
this
.
_lastForceSave
ButtonTime
=
data
[
'
time
'
];
}
else
if
(
data
[
'
code
'
]
!==
c_oAscServerCommandErrors
.
NotModified
)
{
}
else
if
(
data
[
'
code
'
]
!==
c_oAscServerCommandErrors
.
NotModified
)
{
this
.
onWarning
(
c_oAscError
.
ID
.
Unknown
);
this
.
onWarning
(
c_oAscError
.
ID
.
Unknown
);
}
}
};
};
DocsCoApi
.
prototype
.
_onForceSave
=
function
(
data
)
{
if
(
c_oAscForceSaveTypes
.
Button
===
data
[
'
type
'
])
{
if
(
this
.
_lastForceSaveButtonTime
==
data
[
'
time
'
])
{
this
.
onForceSave
({
type
:
c_oAscForceSaveTypes
.
Button
,
saved
:
true
});
}
}
else
if
(
c_oAscForceSaveTypes
.
Timeout
===
data
[
'
type
'
])
{
this
.
_lastForceSaveTime
=
data
[
'
time
'
];
this
.
_checkLastForceSave
();
}
};
DocsCoApi
.
prototype
.
_checkLastForceSave
=
function
(
data
)
{
if
(
null
!=
this
.
_lastForceSaveTime
)
{
var
newState
=
false
;
if
((
-
1
==
this
.
lastOtherSaveTime
||
this
.
lastOtherSaveTime
<=
this
.
_lastForceSaveTime
)
&&
(
-
1
==
this
.
lastOwnSaveTime
||
this
.
lastOwnSaveTime
<=
this
.
_lastForceSaveTime
))
{
newState
=
true
;
}
if
(
newState
!=
this
.
_allChangesSaved
){
this
.
_allChangesSaved
=
newState
;
this
.
onForceSave
({
type
:
c_oAscForceSaveTypes
.
Timeout
,
saved
:
this
.
_allChangesSaved
});
}
}
};
DocsCoApi
.
prototype
.
_onGetLock
=
function
(
data
)
{
DocsCoApi
.
prototype
.
_onGetLock
=
function
(
data
)
{
if
(
this
.
check_state
()
&&
data
[
"
locks
"
])
{
if
(
this
.
check_state
()
&&
data
[
"
locks
"
])
{
...
@@ -1104,7 +1142,12 @@
...
@@ -1104,7 +1142,12 @@
if
(
-
1
!==
data
[
'
index
'
])
{
if
(
-
1
!==
data
[
'
index
'
])
{
this
.
changesIndex
=
data
[
'
index
'
];
this
.
changesIndex
=
data
[
'
index
'
];
}
}
if
(
-
1
!==
data
[
'
time
'
])
{
this
.
lastOwnSaveTime
=
data
[
'
time
'
];
this
.
_checkLastForceSave
();
}
if
(
this
.
onUnSaveLock
)
{
if
(
this
.
onUnSaveLock
)
{
this
.
onUnSaveLock
();
this
.
onUnSaveLock
();
}
}
...
@@ -1124,6 +1167,7 @@
...
@@ -1124,6 +1167,7 @@
this
.
onSaveChanges
(
JSON
.
parse
(
changesOneUser
),
change
[
'
useridoriginal
'
],
bFirstLoad
);
this
.
onSaveChanges
(
JSON
.
parse
(
changesOneUser
),
change
[
'
useridoriginal
'
],
bFirstLoad
);
}
}
}
}
this
.
_checkLastForceSave
();
}
}
}
}
};
};
...
@@ -1306,6 +1350,7 @@
...
@@ -1306,6 +1350,7 @@
this
.
_state
=
ConnectionState
.
Authorized
;
this
.
_state
=
ConnectionState
.
Authorized
;
this
.
_id
=
data
[
'
sessionId
'
];
this
.
_id
=
data
[
'
sessionId
'
];
this
.
_sessionTimeConnect
=
data
[
'
sessionTimeConnect
'
];
this
.
_sessionTimeConnect
=
data
[
'
sessionTimeConnect
'
];
this
.
_lastForceSaveTime
=
data
[
'
lastForceSaveTime
'
];
this
.
_onAuthParticipantsChanged
(
data
[
'
participants
'
]);
this
.
_onAuthParticipantsChanged
(
data
[
'
participants
'
]);
...
@@ -1496,7 +1541,10 @@
...
@@ -1496,7 +1541,10 @@
case
'
refreshToken
'
:
case
'
refreshToken
'
:
t
.
_onRefreshToken
(
dataObject
[
"
messages
"
]);
t
.
_onRefreshToken
(
dataObject
[
"
messages
"
]);
break
;
break
;
case
'
forcesave
'
:
case
'
forceSaveStart
'
:
t
.
_onForceSaveStart
(
dataObject
[
"
messages
"
]);
break
;
case
'
forceSave
'
:
t
.
_onForceSave
(
dataObject
[
"
messages
"
]);
t
.
_onForceSave
(
dataObject
[
"
messages
"
]);
break
;
break
;
}
}
...
...
common/docscoapicommon.js
View file @
d5f6213c
This diff is collapsed.
Click to expand it.
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