Commit 908385e7 by Edgar HIPP

Remove all unnecessary references to DocUtils.env

docxtemplater shouldn't have any references to browser or node specific
functionality, so that it can be used from both without some magic
tricks
parent a359fcc8
DocXTemplater=require('docxtemplater') DocXTemplater=require('docxtemplater')
DocUtils=DocXTemplater.DocUtils
vm=require('vm') vm=require('vm')
JSZip=require('jszip') JSZip=require('jszip')
...@@ -11,8 +10,6 @@ module.exports= class DocxQrCode ...@@ -11,8 +10,6 @@ module.exports= class DocxQrCode
@callbacked=false @callbacked=false
@data=imageData @data=imageData
if @data==undefined then throw new Error("data of qrcode can't be undefined") if @data==undefined then throw new Error("data of qrcode can't be undefined")
if DocUtils.env=='browser'
@base64Data=JSZip.base64.encode(@data)
@ready=false @ready=false
@result=null @result=null
decode:(@callback) -> decode:(@callback) ->
...@@ -27,9 +24,6 @@ module.exports= class DocxQrCode ...@@ -27,9 +24,6 @@ module.exports= class DocxQrCode
testdoc.render() testdoc.render()
_this.result=testdoc.content _this.result=testdoc.content
_this.searchImage() _this.searchImage()
if DocUtils.env=='browser'
@qr.decode("data:image/png;base64,#{@base64Data}")
else
@qr.decode(@data,@data.decoded) @qr.decode(@data,@data.decoded)
searchImage:() -> searchImage:() ->
cb=(err,@data=@data.data)=> cb=(err,@data=@data.data)=>
......
...@@ -52,10 +52,6 @@ module.exports= class ImgReplacer ...@@ -52,10 +52,6 @@ module.exports= class ImgReplacer
if imageTag==undefined then throw new Error('imageTag undefined') if imageTag==undefined then throw new Error('imageTag undefined')
replacement= DocUtils.xml2Str imageTag replacement= DocUtils.xml2Str imageTag
@xmlTemplater.content= @xmlTemplater.content.replace(match[0], replacement) @xmlTemplater.content= @xmlTemplater.content.replace(match[0], replacement)
if DocUtils.env=='browser'
@qr[u]= new DocxQrCode(oldFile.asBinary(),@xmlTemplater,imgName,num,@getDataFromString)
@qr[u].decode(@imageSetter)
else
mockedQrCode={xmlTemplater:@xmlTemplater,imgName:imgName,data:oldFile.asBinary(),num:num} mockedQrCode={xmlTemplater:@xmlTemplater,imgName:imgName,data:oldFile.asBinary(),num:num}
if /\.png$/.test(oldFile.name) if /\.png$/.test(oldFile.name)
do (imgName) => do (imgName) =>
......
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