From: Benoît Pin Date: Wed, 14 Aug 2013 10:08:11 +0000 (+0200) Subject: Ajout d'une implémentation alternative de XMLHttpRequest.sendAsBinary. L'upload javas... X-Git-Url: https://svn.cri.ensmp.fr/git/Plinn.git/commitdiff_plain/61f77ffd5dea8200c9f33d6deb59f86c994539b7?ds=sidebyside Ajout d'une implémentation alternative de XMLHttpRequest.sendAsBinary. L'upload javascript est opérationnel sur Chrome mais pas sur Safari… --- diff --git a/skins/ajax_scripts/sarissa.js b/skins/ajax_scripts/sarissa.js index 29621a1..880b23b 100644 --- a/skins/ajax_scripts/sarissa.js +++ b/skins/ajax_scripts/sarissa.js @@ -1066,3 +1066,23 @@ Sarissa.setRemoteJsonCallback = function(url, callback, callbackParam) { }; // EOF + +/*\ +|*| +|*| :: XMLHttpRequest.prototype.sendAsBinary() Polifyll :: +|*| +|*| https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#sendAsBinary() +|*| +\*/ + +if (!XMLHttpRequest.prototype.sendAsBinary) { + XMLHttpRequest.prototype.sendAsBinary = function (sData) { + var nBytes = sData.length, ui8Data = new Uint8Array(nBytes); + for (var nIdx = 0; nIdx < nBytes; nIdx++) { + ui8Data[nIdx] = sData.charCodeAt(nIdx) & 0xff; + } + /* send as ArrayBufferView...: */ + this.send(ui8Data); + /* ...or as ArrayBuffer (legacy)...: this.send(ui8Data.buffer); */ + }; +}