Built files from Bizgaze WebServer
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ej2-file-utils.min.js 18KB

12345678910
  1. /*!
  2. * filename: ej2-file-utils.min.js
  3. * version : 19.1.54
  4. * Copyright Syncfusion Inc. 2001 - 2020. All rights reserved.
  5. * Use of this code is subject to the terms of our license.
  6. * A copy of the current license can be obtained at any time by e-mailing
  7. * licensing@syncfusion.com. Any infringement will be prosecuted under
  8. * applicable laws.
  9. */
  10. this.ej=this.ej||{},this.ej.fileutils=function(t){"use strict";function e(t,e){if(null===t||void 0===t)throw new Error("ArgumentException: "+e+" cannot be null or undefined")}var n=function(){function t(){}return t.save=function(t,e){if(null===t||void 0===t||""===t)throw new Error("ArgumentException: fileName cannot be undefined, null or empty");var n=t.substring(t.lastIndexOf(".")+1,t.length),i=this.getMimeType(n);if(""!==i&&(e=new Blob([e],{type:i})),this.isMicrosoftBrowser)navigator.msSaveBlob(e,t);else{var r=document.createElementNS("http://www.w3.org/1999/xhtml","a");this.saveInternal(t,n,e,r,"download"in r)}},t.saveInternal=function(t,e,n,i,r){if(r){i.download=t;var o=window.URL.createObjectURL(n);i.href=o;var s=document.createEvent("MouseEvent");s.initEvent("click",!0,!0),i.dispatchEvent(s),setTimeout(function(){window.URL.revokeObjectURL(o),o=void 0})}else if("docx"!==e&&"xlsx"!==e){var a=window.URL.createObjectURL(n);window.open(a,"_blank")||(window.location.href=a)}else{var h=new FileReader;h.onloadend=function(){window.open(h.result,"_blank")||(window.location.href=h.result)},h.readAsDataURL(n)}},t.getMimeType=function(t){var e="";switch(t){case"html":e="text/html";break;case"pdf":e="application/pdf";break;case"docx":e="application/vnd.openxmlformats-officedocument.wordprocessingml.document";break;case"xlsx":e="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";break;case"txt":e="text/plain"}return e},t}(),i=function(){function t(){this.contentPos=0,this.bufferText="",this.bufferBlob=new Blob([""],{type:"text/plain"}),this.currentState="Initial",this.namespaceStack=[],this.namespaceStack.push(new r),this.namespaceStack[0].set("xmlns","http://www.w3.org/2000/xmlns/","Special"),this.namespaceStack.push(new r),this.namespaceStack[1].set("xml","http://www.w3.org/XML/1998/namespace","Special"),this.namespaceStack.push(new r),this.namespaceStack[2].set("","","Implied"),this.elementStack=[],this.elementStack.push(new o),this.elementStack[0].set("","","",this.namespaceStack.length-1),this.attributeStack=[],n.isMicrosoftBrowser=!!navigator.msSaveBlob}return Object.defineProperty(t.prototype,"buffer",{get:function(){return this.flush(),this.bufferBlob},enumerable:!0,configurable:!0}),t.prototype.writeProcessingInstruction=function(t,e){if(void 0===t||null===t||0===t.length)throw new Error("ArgumentException: name should not be undefined, null or empty");if(this.checkName(t),void 0!==e&&null!==e||(e=""),3===t.length&&"xml"===t&&"Initial"!==this.currentState)throw new Error("InvalidArgumentException: Cannot write XML declaration.WriteStartDocument method has already written it");if("Initial"!==this.currentState||void 0===this.bufferBlob)throw new Error("InvalidOperationException: Wrong Token");this.writeStartDocument(),this.writeProcessingInstructionInternal(t,e)},t.prototype.writeStartDocument=function(t){if("Initial"!==this.currentState||void 0===this.bufferBlob)throw new Error("InvalidOperationException: Wrong Token");this.currentState="StartDocument",this.rawText('<?xml version="1.0" encoding="utf-8'),null!==t&&void 0!==t&&(this.rawText('" standalone="'),this.rawText(t?"yes":"no")),this.rawText('"?>')},t.prototype.writeEndDocument=function(){for(;this.elementStack.length-1>0;)this.writeEndElement();this.currentState="EndDocument",this.flush()},t.prototype.writeStartElement=function(t,e,n){if(void 0===this.bufferBlob)throw new Error("InvalidOperationException: Wrong Token");if(void 0===e||null===e||0===e.length)throw new Error("ArgumentException: localName cannot be undefined, null or empty");if(this.checkName(e),"Initial"===this.currentState&&this.writeStartDocument(),"StartElement"===this.currentState&&this.startElementContent(),this.currentState="StartElement",void 0===t||null===t)void 0!==n&&null!==n&&(t=this.lookupPrefix(n)),void 0!==t&&null!==t||(t="");else if(t.length>0&&(void 0!==n&&null!==n||(n=this.lookupNamespace(t)),void 0===n||null===n||void 0!==n&&0===n.length))throw new Error("ArgumentException: Cannot use a prefix with an empty namespace");void 0!==n&&null!==n||(n=this.lookupNamespace(t)),this.writeStartElementInternal(t,e,n)},t.prototype.writeEndElement=function(){"StartElement"===this.currentState?(this.startElementContent(),this.currentState="ElementContent"):"ElementContent"===this.currentState&&(this.currentState="ElementContent"),this.currentState="EndElement";var t=this.elementStack.length-1;this.writeEndElementInternal(this.elementStack[t].prefix,this.elementStack[t].localName),this.namespaceStack.splice(this.elementStack[t].previousTop+1),this.elementStack.splice(t),this.bufferText.length>10240&&this.flush()},t.prototype.writeElementString=function(t,e,n,i){this.writeStartElement(t,e,n),void 0!==i&&null!==i&&0!==i.length&&this.writeString(i),this.writeEndElement()},t.prototype.writeAttributeString=function(t,e,n,i){this.writeStartAttribute(t,e,n,i),this.writeStringInternal(i,!0),this.writeEndAttribute()},t.prototype.writeString=function(t){this.writeInternal(t,!1)},t.prototype.writeRaw=function(t){this.writeInternal(t,!0)},t.prototype.writeInternal=function(t,e){if(void 0!==t&&null!==t){if("StartElement"!==this.currentState&&"ElementContent"!==this.currentState)throw new Error("InvalidOperationException: Wrong Token");"StartElement"===this.currentState&&this.startElementContent(),this.currentState="ElementContent",e?this.rawText(t):this.writeStringInternal(t,!1)}},t.prototype.save=function(t){for(;this.elementStack.length-1>0;)this.writeEndElement();""!==this.bufferText&&this.flush(),n.save(t,this.buffer)},t.prototype.destroy=function(){this.bufferBlob=void 0;for(t=0;t<this.namespaceStack.length;t++)this.namespaceStack[t].destroy();this.namespaceStack=[];for(var t=0;t<this.elementStack.length;t++)this.elementStack[t].destroy();this.elementStack=[],this.bufferText="",this.contentPos=0},t.prototype.flush=function(){void 0!==this.bufferBlob&&(this.bufferBlob=new Blob([this.bufferBlob,this.bufferText],{type:"text/plain"}),this.bufferText="")},t.prototype.writeProcessingInstructionInternal=function(t,e){this.bufferText+="<?",this.rawText(t),e.length>0&&(this.bufferText+=" ",e=e.replace(/\?\>/g,"? >"),this.bufferText+=e),this.bufferText+="?",this.bufferText+=">"},t.prototype.writeStartAttribute=function(t,e,n,i){if(void 0===e||null===e||0===e.length){if("xmlns"!==t)throw new Error("ArgumentException: localName cannot be undefined, null or empty");e="xmlns",t=""}if("StartElement"!==this.currentState)throw new Error("InvalidOperationException: Wrong Token");this.checkName(e),this.writeStartAttributePrefixAndNameSpace(t,e,n,i)},t.prototype.writeStartAttributePrefixAndNameSpace=function(t,e,n,i){void 0!==t&&null!==t||(void 0!==n&&null!==n&&("xmlns"===e&&"http://www.w3.org/2000/xmlns/"===n||(t=this.lookupPrefix(n))),void 0!==t&&null!==t||(t="")),void 0!==n&&null!==n||(void 0!==t&&null!==t&&t.length>0&&(n=this.lookupNamespace(t)),void 0!==n&&null!==n||(n="")),this.writeStartAttributeSpecialAttribute(t,e,n,i)},t.prototype.writeStartAttributeSpecialAttribute=function(t,e,n,i){if(0===t.length){if("x"===e[0]&&"xmlns"===e)return this.skipPushAndWrite(t,e,n),void this.pushNamespaceExplicit("",i);n.length>0&&(t=this.lookupPrefix(n))}else{if("x"===t[0]){if("xmlns"===t)return this.skipPushAndWrite(t,e,n),void this.pushNamespaceExplicit(e,i);if("xml"===t&&("space"===e||"lang"===e))return void this.skipPushAndWrite(t,e,n)}0===n.length&&(t="")}void 0!==t&&null!==t&&0!==t.length&&this.pushNamespaceImplicit(t,n),this.skipPushAndWrite(t,e,n)},t.prototype.writeEndAttribute=function(){this.currentState="StartElement",this.bufferText+='"'},t.prototype.writeStartElementInternal=function(t,e,n){this.bufferText+="<",t.length>0&&(this.rawText(t),this.bufferText+=":"),this.rawText(e);var i=this.elementStack.length;this.elementStack.push(new o),this.elementStack[i].set(t,e,n,this.namespaceStack.length-1),this.pushNamespaceImplicit(t,n);for(var r=0;r<this.attributeStack.length;r++)this.attributeStack[r].destroy();this.attributeStack=[]},t.prototype.writeEndElementInternal=function(t,e){this.contentPos!==this.bufferText.length+1?(this.bufferText+="</",void 0!==t&&null!==t&&0!==t.length&&(this.rawText(t),this.bufferText+=":"),this.rawText(e),this.bufferText+=">"):(this.bufferText=this.bufferText.substring(0,this.bufferText.length-1),this.bufferText+=" />")},t.prototype.writeStartAttributeInternal=function(t,e,n){this.bufferText+=" ",void 0!==t&&null!==t&&t.length>0&&(this.rawText(t),this.bufferText+=":"),this.rawText(e),this.bufferText+="=",this.bufferText+='"'},t.prototype.writeNamespaceDeclaration=function(t,e){this.writeStartNamespaceDeclaration(t),this.writeStringInternal(e,!0),this.bufferText+='"'},t.prototype.writeStartNamespaceDeclaration=function(t){void 0===t||null===t||0===t.length?this.rawText(' xmlns="'):(this.rawText(" xmlns:"),this.rawText(t),this.bufferText+="=",this.bufferText+='"')},t.prototype.writeStringInternal=function(t,e){null!==t&&void 0!==t||(t=""),t=(t=(t=t.replace(/\&/g,"&amp;")).replace(/\</g,"&lt;")).replace(/\>/g,"&gt;"),e&&(t=t.replace(/\"/g,"&quot;")),this.bufferText+=t,e||(this.contentPos=0)},t.prototype.startElementContent=function(){for(var t=this.elementStack[this.elementStack.length-1].previousTop,e=this.namespaceStack.length-1;e>t;e--)"NeedToWrite"===this.namespaceStack[e].kind&&this.writeNamespaceDeclaration(this.namespaceStack[e].prefix,this.namespaceStack[e].namespaceUri);this.bufferText+=">",this.contentPos=this.bufferText.length+1},t.prototype.rawText=function(t){this.bufferText+=t},t.prototype.addNamespace=function(t,e,n){var i=this.namespaceStack.length;this.namespaceStack.push(new r),this.namespaceStack[i].set(t,e,n)},t.prototype.lookupPrefix=function(t){for(var e=this.namespaceStack.length-1;e>=0;e--)if(this.namespaceStack[e].namespaceUri===t)return this.namespaceStack[e].prefix},t.prototype.lookupNamespace=function(t){for(var e=this.namespaceStack.length-1;e>=0;e--)if(this.namespaceStack[e].prefix===t)return this.namespaceStack[e].namespaceUri},t.prototype.lookupNamespaceIndex=function(t){for(var e=this.namespaceStack.length-1;e>=0;e--)if(this.namespaceStack[e].prefix===t)return e;return-1},t.prototype.pushNamespaceImplicit=function(t,e){var n,i=this.lookupNamespaceIndex(t);if(-1!==i){if(i>this.elementStack[this.elementStack.length-1].previousTop){if(this.namespaceStack[i].namespaceUri!==e)throw new Error("XmlException namespace Uri needs to be the same as the one that is already declared");return}if("Special"===this.namespaceStack[i].kind){if("xml"!==t)throw new Error('InvalidArgumentException: Prefix "xmlns" is reserved for use by XML.');if(e!==this.namespaceStack[i].namespaceUri)throw new Error("InvalidArgumentException: Xml String");n="Implied"}else n=this.namespaceStack[i].namespaceUri===e?"Implied":"NeedToWrite"}else{if("http://www.w3.org/XML/1998/namespace"===e&&"xml"!==t||"http://www.w3.org/2000/xmlns/"===e&&"xmlns"!==t)throw new Error("InvalidArgumentException");n="NeedToWrite"}this.addNamespace(t,e,n)},t.prototype.pushNamespaceExplicit=function(t,e){var n=this.lookupNamespaceIndex(t);if(-1!==n&&n>this.elementStack[this.elementStack.length-1].previousTop)return void(this.namespaceStack[n].kind="Written");this.addNamespace(t,e,"Written")},t.prototype.addAttribute=function(t,e,n){var i=this.attributeStack.length;this.attributeStack.push(new s),this.attributeStack[i].set(t,e,n);for(var r=0;r<i;r++)if(this.attributeStack[r].isDuplicate(t,e,n))throw new Error("XmlException: duplicate attribute name")},t.prototype.skipPushAndWrite=function(t,e,n){this.addAttribute(t,e,n),this.writeStartAttributeInternal(t,e,n)},t.prototype.checkName=function(t){if(/[ !@#$%^&*()+\=\[\]{};':"\\|,<>\/?]/.test(t))throw new Error("InvalidArgumentException: invalid name character")},t}(),r=function(){function t(){}return t.prototype.set=function(t,e,n){this.prefix=t,this.namespaceUri=e,this.kind=n},t.prototype.destroy=function(){this.prefix=void 0,this.namespaceUri=void 0,this.kind=void 0},t}(),o=function(){function t(){}return t.prototype.set=function(t,e,n,i){this.previousTop=i,this.prefix=t,this.namespaceUri=n,this.localName=e},t.prototype.destroy=function(){this.previousTop=void 0,this.prefix=void 0,this.localName=void 0,this.namespaceUri=void 0},t}(),s=function(){function t(){}return t.prototype.set=function(t,e,n){this.prefix=t,this.namespaceUri=n,this.localName=e},t.prototype.isDuplicate=function(t,e,n){return this.localName===e&&(this.prefix===t||this.namespaceUri===n)},t.prototype.destroy=function(){this.prefix=void 0,this.namespaceUri=void 0,this.localName=void 0},t}(),a=function(){function t(t){this.emitBOM=!0,this.encodingType="Ansi",this.initBOM(t)}return Object.defineProperty(t.prototype,"includeBom",{get:function(){return this.emitBOM},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"type",{get:function(){return this.encodingType},set:function(t){this.encodingType=t},enumerable:!0,configurable:!0}),t.prototype.initBOM=function(t){this.emitBOM=void 0===t||null===t||t},t.prototype.getByteCount=function(t){return e(t,"string"),""===t?this.utf8Len(t.charCodeAt(0)):(null!==this.type&&void 0!==this.type||(this.type="Ansi"),this.getByteCountInternal(t,0,t.length))},t.prototype.utf8Len=function(t){return t<=127?1:t<=2047?2:t<=65535?3:t<=2097151?4:0},t.prototype.isHighSurrogate=function(t){return t>=55296&&t<=56319},t.prototype.toCodepoint=function(t,e){return((t=(1023&t)<<10)|1023&e)+65536},t.prototype.getByteCountInternal=function(t,e,n){var i=0;if("Utf8"===this.encodingType||"Unicode"===this.encodingType){for(var r="Utf8"===this.encodingType,o=0;o<n;o++){var s=t.charCodeAt(r?e:e++);if(this.isHighSurrogate(s))if(r){var a=s,h=t.charCodeAt(++e);i+=this.utf8Len(this.toCodepoint(a,h))}else i+=4,++o;else i+=r?this.utf8Len(s):2;r&&e++}return i}return i=n},t.prototype.getBytes=function(t,n,i){if(e(t,"string"),e(n,"charIndex"),e(i,"charCount"),n<0||i<0)throw new RangeError("Argument Out Of Range Exception: charIndex or charCount is less than zero");if(t.length-n<i)throw new RangeError("Argument Out Of Range Exception: charIndex and charCount do not denote a valid range in string");if(""===t)return new ArrayBuffer(0);null!==this.type&&void 0!==this.type||(this.type="Ansi");var r=this.getByteCountInternal(t,n,i);switch(this.type){case"Utf8":return this.getBytesOfUtf8Encoding(r,t,n,i);case"Unicode":return this.getBytesOfUnicodeEncoding(r,t,n,i);default:return this.getBytesOfAnsiEncoding(r,t,n,i)}},t.prototype.getString=function(t,n,i){if(e(t,"bytes"),e(n,"index"),e(i,"count"),n<0||i<0)throw new RangeError("Argument Out Of Range Exception: index or count is less than zero");if(t.byteLength-n<i)throw new RangeError("Argument Out Of Range Exception: index and count do not denote a valid range in bytes");if(0===t.byteLength||0===i)return"";null!==this.type&&void 0!==this.type||(this.type="Ansi");var r="",o=new Uint8Array(t);switch(this.type){case"Utf8":return this.getStringOfUtf8Encoding(o,n,i);case"Unicode":var s=new Uint16Array(t);return r=this.getStringofUnicodeEncoding(s,n,i);default:for(var a=n,h=0;h<i;h++){var c=o[a];r+=String.fromCharCode(c),a++}return r}},t.prototype.getBytesOfAnsiEncoding=function(t,e,n,i){for(var r=new ArrayBuffer(t),o=new Uint8Array(r),s=0,a=0;a<i;a++){var h=e.charCodeAt(n++);o[s]=h<2048?h:63,s++}return r},t.prototype.getBytesOfUtf8Encoding=function(t,e,n,i){for(var r=new ArrayBuffer(t),o=new Uint8Array(r),s=n,a=0,h=0;h<i;h++){var c=e.charCodeAt(s);c<=127?o[a]=c:c<2048?(o[a]=192|c>>6,o[++a]=128|63&c):c<55296||c>=57344?(o[a]=224|c>>12,o[++a]=128|c>>6&63,o[++a]=128|63&c):(o[a]=239,o[++a]=191,o[++a]=189),++a,++s}return r},t.prototype.getBytesOfUnicodeEncoding=function(t,e,n,i){for(var r=new ArrayBuffer(t),o=new Uint16Array(r),s=0;s<i;s++){var a=e.charCodeAt(s);o[s]=a}return r},t.prototype.getStringOfUtf8Encoding=function(t,e,n){var i=0,r=e,o="";for(i;i<n;i++){for(var s=t[r++];r>t.length;)return o;s>127&&(s>191&&s<224&&r<n?s=(31&s)<<6|63&t[r]:s>223&&s<240&&r<t.byteLength?s=(15&s)<<12|(63&t[r])<<6|63&t[++r]:s>239&&s<248&&r<t.byteLength&&(s=(7&s)<<18|(63&t[r])<<12|(63&t[++r])<<6|63&t[++r]),++r),o+=String.fromCharCode(s)}return o},t.prototype.getStringofUnicodeEncoding=function(t,e,n){if(n>t.length)throw new RangeError("ArgumentOutOfRange_Count");for(var i=new Uint16Array(n),r=0;r<n&&r<t.length;r++)i[r]=t[e++];return String.fromCharCode.apply(null,i)},t.prototype.destroy=function(){this.emitBOM=void 0,this.encodingType=void 0},t}(),h=function(){function t(t){this.bufferBlob=new Blob([""]),this.bufferText="",this.init(t),n.isMicrosoftBrowser=!!navigator.msSaveBlob}return Object.defineProperty(t.prototype,"buffer",{get:function(){return this.flush(),this.bufferBlob},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"encoding",{get:function(){return this.enc},enumerable:!0,configurable:!0}),t.prototype.init=function(t){null===t||void 0===t?(this.enc=new a(!1),this.enc.type="Utf8"):(this.enc=t,this.setBomByte())},t.prototype.setBomByte=function(){if(this.encoding.includeBom)switch(this.encoding.type){case"Unicode":var t=new ArrayBuffer(2),e=new Uint8Array(t);e[0]=255,e[1]=254,this.bufferBlob=new Blob([t]);break;case"Utf8":var n=new ArrayBuffer(3),i=new Uint8Array(n);i[0]=239,i[1]=187,i[2]=191,this.bufferBlob=new Blob([n]);break;default:this.bufferBlob=new Blob([""])}},t.prototype.save=function(t){""!==this.bufferText&&this.flush(),n.save(t,this.buffer)},t.prototype.write=function(t){if(void 0===this.encoding)throw new Error("Object Disposed Exception: current writer is disposed");e(t,"string"),this.bufferText+=t,this.bufferText.length>=10240&&this.flush()},t.prototype.flush=function(){if(void 0!==this.bufferText&&null!==this.bufferText&&0!==this.bufferText.length){var t=this.encoding.getBytes(this.bufferText,0,this.bufferText.length);this.bufferText="",this.bufferBlob=new Blob([this.bufferBlob,t])}},t.prototype.writeLine=function(t){if(void 0===this.encoding)throw new Error("Object Disposed Exception: current writer is disposed");e(t,"string"),this.bufferText=this.bufferText+t+"\r\n",this.bufferText.length>=10240&&this.flush()},t.prototype.destroy=function(){this.bufferBlob=void 0,this.bufferText=void 0,this.enc instanceof a&&this.enc.destroy(),this.enc=void 0},t}();return t.XmlWriter=i,t.Namespace=r,t.XmlElement=o,t.XmlAttribute=s,t.StreamWriter=h,t.Encoding=a,t.validateNullOrUndefined=e,t.Save=n,t}({}),this.ejs=ej;