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