Use subarray rather than slice (as IE10 lacks slice).

This commit is contained in:
Michael Jumper
2013-09-23 20:59:42 -07:00
parent 94c0ec1f17
commit 4620abbb5b

View File

@@ -1047,10 +1047,9 @@ GuacUI.Client.attach = function(guac) {
e.stopPropagation(); e.stopPropagation();
} }
function _get_base64(buffer) { function _get_base64(bytes) {
var data = ""; var data = "";
var bytes = new Uint8Array(buffer);
// Produce binary string from bytes in buffer // Produce binary string from bytes in buffer
for (var i=0; i<bytes.byteLength; i++) for (var i=0; i<bytes.byteLength; i++)
@@ -1070,13 +1069,13 @@ GuacUI.Client.attach = function(guac) {
// Open file for writing // Open file for writing
GuacUI.Client.attachedClient.openFile(index, file.type, file.name); GuacUI.Client.attachedClient.openFile(index, file.type, file.name);
var buffer = reader.result; var bytes = new Uint8Array(reader.result);
var offset = 0; var offset = 0;
function continueUpload() { function continueUpload() {
// Encode packet as base64 // Encode packet as base64
var slice = buffer.slice(offset, offset+4096); var slice = bytes.subarray(offset, offset+4096);
var base64 = _get_base64(slice); var base64 = _get_base64(slice);
// "Write" packet // "Write" packet
@@ -1084,7 +1083,7 @@ GuacUI.Client.attach = function(guac) {
// Advance to next packet, or close if EOF // Advance to next packet, or close if EOF
offset += 4096; offset += 4096;
if (offset < buffer.byteLength) if (offset < bytes.length)
window.setTimeout(continueUpload, 500); window.setTimeout(continueUpload, 500);
else else
GuacUI.Client.attachedClient.closeFile(index); GuacUI.Client.attachedClient.closeFile(index);