Commit 1ae98fee by Edgar HIPP

Fix lint

parent 652a7641
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
"parser": "babel-eslint", "parser": "babel-eslint",
"globals":{ "globals":{
"saveAs": true, "saveAs": true,
"Uint8Array": true,
"JSZipUtils": true "JSZipUtils": true
}, },
"env": { "env": {
......
...@@ -114,28 +114,28 @@ function testStart() { ...@@ -114,28 +114,28 @@ function testStart() {
}); });
it("should work with base64 data", function () { it("should work with base64 data", function () {
const base64Image = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QIJBywfp3IOswAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAkUlEQVQY052PMQqDQBREZ1f/d1kUm3SxkeAF/FdIjpOcw2vpKcRWCwsRPMFPsaIQSIoMr5pXDGNUFd9j8TOn7kRW71fvO5HTq6qqtnWtzh20IqE3YXtL0zyKwAROQLQ5l/c9gHjfKK6wMZjADE6s49Dver4/smEAc2CuqgwAYI5jU9NcxhHEy60sni986H9+vwG1yDHfK1jitgAAAABJRU5ErkJggg==" const base64Image = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QIJBywfp3IOswAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAkUlEQVQY052PMQqDQBREZ1f/d1kUm3SxkeAF/FdIjpOcw2vpKcRWCwsRPMFPsaIQSIoMr5pXDGNUFd9j8TOn7kRW71fvO5HTq6qqtnWtzh20IqE3YXtL0zyKwAROQLQ5l/c9gHjfKK6wMZjADE6s49Dver4/smEAc2CuqgwAYI5jU9NcxhHEy60sni986H9+vwG1yDHfK1jitgAAAABJRU5ErkJggg==";
this.name = "imageExample.docx"; this.name = "imageExample.docx";
function base64DataURLToArrayBuffer(dataURL) { function base64DataURLToArrayBuffer(dataURL) {
const string_base64 = dataURL.replace(/^data:image\/(png|jpg);base64,/, ""); const stringBase64 = dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
var binary_string; let binaryString;
if (typeof window !== "undefined") { if (typeof window !== "undefined") {
binary_string = window.atob(string_base64); binaryString = window.atob(stringBase64);
} }
else { else {
binary_string = new Buffer(string_base64, 'base64').toString('binary'); binaryString = new Buffer(stringBase64, "base64").toString("binary");
} }
var len = binary_string.length; const len = binaryString.length;
var bytes = new Uint8Array(len); const bytes = new Uint8Array(len);
for (var i = 0; i < len; i++) { for (let i = 0; i < len; i++) {
var ascii = binary_string.charCodeAt(i); const ascii = binaryString.charCodeAt(i);
bytes[i] = ascii; bytes[i] = ascii;
} }
return bytes.buffer; return bytes.buffer;
}; }
this.opts.getImage = function (image) { this.opts.getImage = function (image) {
return image; return image;
} };
this.expectedName = "expectedBase64.docx"; this.expectedName = "expectedBase64.docx";
this.data = {image: base64DataURLToArrayBuffer(base64Image)}; this.data = {image: base64DataURLToArrayBuffer(base64Image)};
this.loadAndRender(); this.loadAndRender();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment