mirror of
https://github.com/paradoxxxzero/butterfly.git
synced 2026-05-31 09:29:40 +00:00
Limit rate on paste
This commit is contained in:
@@ -142,11 +142,19 @@
|
||||
});
|
||||
|
||||
addEventListener('paste', function(e) {
|
||||
var data;
|
||||
var data, send, size;
|
||||
butterfly.bell("pasted");
|
||||
data = e.clipboardData.getData('text/plain');
|
||||
data = data.replace(/\r\n/g, '\n').replace(/\n/g, '\r');
|
||||
butterfly.send(data);
|
||||
size = 1024;
|
||||
send = function() {
|
||||
butterfly.send(data.substring(0, size));
|
||||
data = data.substring(size);
|
||||
if (data.length) {
|
||||
return setTimeout(send, 25);
|
||||
}
|
||||
};
|
||||
send();
|
||||
return e.preventDefault();
|
||||
});
|
||||
|
||||
|
||||
@@ -33,9 +33,18 @@ addEventListener 'copy', copy = (e) ->
|
||||
e.clipboardData.setData 'text/plain', data.slice(0, -1)
|
||||
e.preventDefault()
|
||||
|
||||
|
||||
addEventListener 'paste', (e) ->
|
||||
butterfly.bell "pasted"
|
||||
data = e.clipboardData.getData 'text/plain'
|
||||
data = data.replace(/\r\n/g, '\n').replace(/\n/g, '\r')
|
||||
butterfly.send data
|
||||
# Send big data in chunks to prevent data loss
|
||||
size = 1024
|
||||
send = ->
|
||||
butterfly.send data.substring(0, size)
|
||||
data = data.substring(size)
|
||||
if data.length
|
||||
setTimeout send, 25
|
||||
send()
|
||||
|
||||
e.preventDefault()
|
||||
|
||||
Reference in New Issue
Block a user