jszip-utils-ie.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*!
  2. JSZipUtils - A collection of cross-browser utilities to go along with JSZip.
  3. <http://stuk.github.io/jszip-utils>
  4. (c) 2014 Stuart Knightley, David Duponchel
  5. Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip-utils/master/LICENSE.markdown.
  6. */
  7. ;(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  8. var global=typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};/* jshint evil: true, newcap: false */
  9. /* global IEBinaryToArray_ByteStr, IEBinaryToArray_ByteStr_Last */
  10. "use strict";
  11. // Adapted from http://stackoverflow.com/questions/1095102/how-do-i-load-binary-image-data-using-javascript-and-xmlhttprequest
  12. var IEBinaryToArray_ByteStr_Script =
  13. "<!-- IEBinaryToArray_ByteStr -->\r\n"+
  14. "<script type='text/vbscript'>\r\n"+
  15. "Function IEBinaryToArray_ByteStr(Binary)\r\n"+
  16. " IEBinaryToArray_ByteStr = CStr(Binary)\r\n"+
  17. "End Function\r\n"+
  18. "Function IEBinaryToArray_ByteStr_Last(Binary)\r\n"+
  19. " Dim lastIndex\r\n"+
  20. " lastIndex = LenB(Binary)\r\n"+
  21. " if lastIndex mod 2 Then\r\n"+
  22. " IEBinaryToArray_ByteStr_Last = Chr( AscB( MidB( Binary, lastIndex, 1 ) ) )\r\n"+
  23. " Else\r\n"+
  24. " IEBinaryToArray_ByteStr_Last = "+'""'+"\r\n"+
  25. " End If\r\n"+
  26. "End Function\r\n"+
  27. "</script>\r\n";
  28. // inject VBScript
  29. document.write(IEBinaryToArray_ByteStr_Script);
  30. global.JSZipUtils._getBinaryFromXHR = function (xhr) {
  31. var binary = xhr.responseBody;
  32. var byteMapping = {};
  33. for ( var i = 0; i < 256; i++ ) {
  34. for ( var j = 0; j < 256; j++ ) {
  35. byteMapping[ String.fromCharCode( i + (j << 8) ) ] =
  36. String.fromCharCode(i) + String.fromCharCode(j);
  37. }
  38. }
  39. var rawBytes = IEBinaryToArray_ByteStr(binary);
  40. var lastChr = IEBinaryToArray_ByteStr_Last(binary);
  41. return rawBytes.replace(/[\s\S]/g, function( match ) {
  42. return byteMapping[match];
  43. }) + lastChr;
  44. };
  45. // enforcing Stuk's coding style
  46. // vim: set shiftwidth=4 softtabstop=4:
  47. },{}]},{},[1])
  48. ;