mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-11 17:06:43 -05:00
reinstate the chaosmonkey
This commit is contained in:
parent
1ad27bb6ed
commit
1b70e08f82
1 changed files with 20 additions and 0 deletions
|
@ -116,6 +116,26 @@ define [
|
|||
flush: () ->
|
||||
@doc?.flushPendingOps()
|
||||
|
||||
chaosMonkey: (line = 0, char = "a") ->
|
||||
orig = char
|
||||
copy = null
|
||||
pos = 0
|
||||
timer = () =>
|
||||
unless copy? and copy.length
|
||||
copy = orig.slice() + ' ' + new Date() + '\n'
|
||||
line += if Math.random() > 0.1 then 1 else -2
|
||||
line = 0 if line < 0
|
||||
pos = 0
|
||||
char = copy[0]
|
||||
copy = copy.slice(1)
|
||||
@ace.session.insert({row: line, column: pos}, char)
|
||||
pos += 1
|
||||
@_cm = setTimeout timer, 100 + if Math.random() < 0.1 then 1000 else 0
|
||||
@_cm = timer()
|
||||
|
||||
clearChaosMonkey: () ->
|
||||
clearTimeout @_cm
|
||||
|
||||
pollSavedStatus: () ->
|
||||
# returns false if doc has ops waiting to be acknowledged or
|
||||
# sent that haven't changed since the last time we checked.
|
||||
|
|
Loading…
Reference in a new issue