mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-12-27 19:31:33 +00:00
Rewrite cursorActivity with multi listener style
- adjust function order to prevent standard lint failure
This commit is contained in:
parent
b86ecb1342
commit
d7c068cbfd
1 changed files with 17 additions and 17 deletions
|
@ -2699,10 +2699,23 @@ editorInstance.on('focus', function (cm) {
|
|||
window.personalInfo['cursor'] = editor.getCursor()
|
||||
socket.emit('cursor focus', editor.getCursor())
|
||||
})
|
||||
editorInstance.on('cursorActivity', function (cm) {
|
||||
updateStatusBar()
|
||||
cursorActivity()
|
||||
})
|
||||
|
||||
const cursorActivity = _.debounce(cursorActivityInner, cursorActivityDebounce)
|
||||
|
||||
function cursorActivityInner () {
|
||||
if (editorHasFocus() && !Visibility.hidden()) {
|
||||
for (var i = 0; i < window.onlineUsers.length; i++) {
|
||||
if (window.onlineUsers[i].id === window.personalInfo.id) {
|
||||
window.onlineUsers[i].cursor = editor.getCursor()
|
||||
}
|
||||
}
|
||||
window.personalInfo['cursor'] = editor.getCursor()
|
||||
socket.emit('cursor activity', editor.getCursor())
|
||||
}
|
||||
}
|
||||
|
||||
editorInstance.on('cursorActivity', updateStatusBar)
|
||||
editorInstance.on('cursorActivity', cursorActivity)
|
||||
|
||||
editorInstance.on('beforeSelectionChange', updateStatusBar)
|
||||
editorInstance.on('beforeSelectionChange', function (doc, selections) {
|
||||
|
@ -2737,19 +2750,6 @@ editorInstance.on('beforeSelectionChange', function (doc, selections) {
|
|||
}
|
||||
})
|
||||
|
||||
var cursorActivity = _.debounce(cursorActivityInner, cursorActivityDebounce)
|
||||
|
||||
function cursorActivityInner () {
|
||||
if (editorHasFocus() && !Visibility.hidden()) {
|
||||
for (var i = 0; i < window.onlineUsers.length; i++) {
|
||||
if (window.onlineUsers[i].id === window.personalInfo.id) {
|
||||
window.onlineUsers[i].cursor = editor.getCursor()
|
||||
}
|
||||
}
|
||||
window.personalInfo['cursor'] = editor.getCursor()
|
||||
socket.emit('cursor activity', editor.getCursor())
|
||||
}
|
||||
}
|
||||
editorInstance.on('blur', function (cm) {
|
||||
for (var i = 0; i < window.onlineUsers.length; i++) {
|
||||
if (window.onlineUsers[i].id === window.personalInfo.id) {
|
||||
|
|
Loading…
Reference in a new issue