forked from sheetjs/sheetjs
		
	webpack demo avoid readAsBinaryString [ci skip]
This commit is contained in:
		
							parent
							
								
									0a0244cdfa
								
							
						
					
					
						commit
						7c0b869c7f
					
				| @ -1,5 +1,5 @@ | ||||
| TOOL=webpack | ||||
| WPOPTS=--display-modules --display-reasons --profile | ||||
| WPOPTS=--display-modules --display-reasons --profile --mode=development  | ||||
| .PHONY: all | ||||
| all: main.min.js core.out.js full.out.js app.out.js | ||||
| 
 | ||||
|  | ||||
| @ -87,10 +87,6 @@ var b64it = window.b64it = (function() { | ||||
| })(); | ||||
| 
 | ||||
| var do_file = (function() { | ||||
| 	var rABS = typeof FileReader !== "undefined" && (FileReader.prototype||{}).readAsBinaryString; | ||||
| 	var domrabs = document.getElementsByName("userabs")[0]; | ||||
| 	if(!rABS) domrabs.disabled = !(domrabs.checked = false); | ||||
| 
 | ||||
| 	var use_worker = typeof Worker !== 'undefined'; | ||||
| 	var domwork = document.getElementsByName("useworker")[0]; | ||||
| 	if(!use_worker) domwork.disabled = !(domwork.checked = false); | ||||
| @ -104,23 +100,21 @@ var do_file = (function() { | ||||
| 				case XW.msg: cb(JSON.parse(e.data.d)); break; | ||||
| 			} | ||||
| 		}; | ||||
| 		worker.postMessage({d:data,b:rABS?'binary':'array'}); | ||||
| 		worker.postMessage({d:data,b:'array'}); | ||||
| 	}; | ||||
| 
 | ||||
| 	return function do_file(files) { | ||||
| 		rABS = domrabs.checked; | ||||
| 		use_worker = domwork.checked; | ||||
| 		var f = files[0]; | ||||
| 		var reader = new FileReader(); | ||||
| 		reader.onload = function(e) { | ||||
| 			if(typeof console !== 'undefined') console.log("onload", new Date(), rABS, use_worker); | ||||
| 			if(typeof console !== 'undefined') console.log("onload", new Date(), use_worker); | ||||
| 			var data = e.target.result; | ||||
| 			if(!rABS) data = new Uint8Array(data); | ||||
| 			data = new Uint8Array(data); | ||||
| 			if(use_worker) xw(data, process_wb); | ||||
| 			else process_wb(X.read(data, {type: rABS ? 'binary' : 'array'})); | ||||
| 			else process_wb(X.read(data, {type: 'array'})); | ||||
| 		}; | ||||
| 		if(rABS) reader.readAsBinaryString(f); | ||||
| 		else reader.readAsArrayBuffer(f); | ||||
| 		reader.readAsArrayBuffer(f); | ||||
| 	}; | ||||
| })(); | ||||
| 
 | ||||
|  | ||||
| @ -41,7 +41,6 @@ Output Format: <select name="format" onchange="setfmt()"> | ||||
| <input type="button" id="dotext" value="Click here to process the base64 text" onclick="b64it();"/><br /> | ||||
| <b>Advanced Demo Options:</b> | ||||
| Use Web Workers: (when available) <input type="checkbox" name="useworker" checked> | ||||
| Use readAsBinaryString: (when available) <input type="checkbox" name="userabs" checked> | ||||
| </pre> | ||||
| <pre id="out"></pre> | ||||
| <div id="htmlout"></div> | ||||
|  | ||||
| @ -41,7 +41,6 @@ Output Format: <select name="format" onchange="setfmt()"> | ||||
| <input type="button" id="dotext" value="Click here to process the base64 text" onclick="b64it();"/><br /> | ||||
| <b>Advanced Demo Options:</b> | ||||
| Use Web Workers: (when available) <input type="checkbox" name="useworker" checked> | ||||
| Use readAsBinaryString: (when available) <input type="checkbox" name="userabs" checked> | ||||
| </pre> | ||||
| <pre id="out"></pre> | ||||
| <div id="htmlout"></div> | ||||
|  | ||||
| @ -41,7 +41,6 @@ Output Format: <select name="format" onchange="setfmt()"> | ||||
| <input type="button" id="dotext" value="Click here to process the base64 text" onclick="b64it();"/><br /> | ||||
| <b>Advanced Demo Options:</b> | ||||
| Use Web Workers: (when available) <input type="checkbox" name="useworker" checked> | ||||
| Use readAsBinaryString: (when available) <input type="checkbox" name="userabs" checked> | ||||
| </pre> | ||||
| <pre id="out"></pre> | ||||
| <div id="htmlout"></div> | ||||
|  | ||||
| @ -2,6 +2,7 @@ | ||||
| module.exports = { | ||||
| 	/* ensure that the XLSX variable is exported */ | ||||
| 	output: { | ||||
| 		path: __dirname, | ||||
| 		libraryTarget: 'var', | ||||
| 		library: 'XLSX' | ||||
| 	}, | ||||
| @ -23,4 +24,4 @@ module.exports = { | ||||
| 		process: false, | ||||
| 		Buffer: false | ||||
| 	} | ||||
| } | ||||
| }; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user