UNPKG

vr-file-upload-preview

Version:

A simple file-upload lib that shows a preview of the uploaded image.

2,602 lines (2,561 loc) 57.5 kB
function dispatchEvent(event, element, detail) { element.dispatchEvent(new CustomEvent(event, { bubbles: false, composed: true, detail })); } function getSize(bytes) { const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; if (!bytes) { return '0 Byte'; } const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); return `${Math.round(bytes / Math.pow(1024, i))} ${sizes[i]}`; } function changeAttributes(element, attributes) { attributes === null || attributes === void 0 ? void 0 : attributes.forEach(attr => { if (!attr.onlyAttr) { element.setAttribute(attr.name, attr.value); return; } attr.value ? element.setAttribute(attr.name, attr.value) : element.removeAttribute(attr.name); }); } function createElement(tag, content, property) { var _property$attributes, _property$classes; const node = document.createElement(tag); if (property !== null && property !== void 0 && (_property$attributes = property.attributes) !== null && _property$attributes !== void 0 && _property$attributes.length) { property.attributes.forEach(element => { if (element.onlyAttr && !element.value) { return; } node.setAttribute(element.name, element.value); }); } if (property !== null && property !== void 0 && (_property$classes = property.classes) !== null && _property$classes !== void 0 && _property$classes.length) { node.classList.add(...property.classes); } if (property !== null && property !== void 0 && property.styles) { Object.assign(node.style, property.styles); } if (content) { node.textContent = content; } return node; } function mimeConvert(value) { const mime = MIME_TYPE.find(type => value.toLowerCase().trim() === type.value); return mime === null || mime === void 0 ? void 0 : mime.key; } const MIME_TYPE = [{ key: '.ez', value: 'application/andrew-inset' }, { key: '.aw', value: 'application/applixware' }, { key: '.atom', value: 'application/atom+xml' }, { key: '.atomcat', value: 'application/atomcat+xml' }, { key: '.atomsvc', value: 'application/atomsvc+xml' }, { key: '.ccxml', value: 'application/ccxml+xml' }, { key: '.cu', value: 'application/cu-seeme' }, { key: '.davmount', value: 'application/davmount+xml' }, { key: '.ecma', value: 'application/ecmascript' }, { key: '.emma', value: 'application/emma+xml' }, { key: '.epub', value: 'application/epub+zip' }, { key: '.pfr', value: 'application/font-tdpfr' }, { key: '.stk', value: 'application/hyperstudio' }, { key: '.jar', value: 'application/java-archive' }, { key: '.ser', value: 'application/java-serialized-object' }, { key: '.class', value: 'application/java-vm' }, { key: '.js', value: 'application/javascript' }, { key: '.json', value: 'application/json' }, { key: '.lostxml', value: 'application/lost+xml' }, { key: '.hqx', value: 'application/mac-binhex40' }, { key: '.cpt', value: 'application/mac-compactpro' }, { key: '.mrc', value: 'application/marc' }, { key: '.ma', value: 'application/mathematica' }, { key: '.nb', value: 'application/mathematica' }, { key: '.mb', value: 'application/mathematica' }, { key: '.mathml', value: 'application/mathml+xml' }, { key: '.mbox', value: 'application/mbox' }, { key: '.mscml', value: 'application/mediaservercontrol+xml' }, { key: '.mp4s', value: 'application/mp4' }, { key: '.doc', value: 'application/msword' }, { key: '.dot', value: 'application/msword' }, { key: '.mxf', value: 'application/mxf' }, { key: '.oda', value: 'application/oda' }, { key: '.opf', value: 'application/oebps-package+xml' }, { key: '.ogx', value: 'application/ogg' }, { key: '.onetoc', value: 'application/onenote' }, { key: '.onetoc2', value: 'application/onenote' }, { key: '.onetmp', value: 'application/onenote' }, { key: '.onepkg', value: 'application/onenote' }, { key: '.xer', value: 'application/patch-ops-error+xml' }, { key: '.pdf', value: 'application/pdf' }, { key: '.pgp', value: 'application/pgp-encrypted' }, { key: '.asc', value: 'application/pgp-signature' }, { key: '.sig', value: 'application/pgp-signature' }, { key: '.prf', value: 'application/pics-rules' }, { key: '.p10', value: 'application/pkcs10' }, { key: '.p7m', value: 'application/pkcs7-mime' }, { key: '.p7c', value: 'application/pkcs7-mime' }, { key: '.p7s', value: 'application/pkcs7-signature' }, { key: '.cer', value: 'application/pkix-cert' }, { key: '.crl', value: 'application/pkix-crl' }, { key: '.pkipath', value: 'application/pkix-pkipath' }, { key: '.pki', value: 'application/pkixcmp' }, { key: '.pls', value: 'application/pls+xml' }, { key: '.ai', value: 'application/postscript' }, { key: '.eps', value: 'application/postscript' }, { key: '.ps', value: 'application/postscript' }, { key: '.cww', value: 'application/prs.cww' }, { key: '.rdf', value: 'application/rdf+xml' }, { key: '.rif', value: 'application/reginfo+xml' }, { key: '.rnc', value: 'application/relax-ng-compact-syntax' }, { key: '.rl', value: 'application/resource-lists+xml' }, { key: '.rld', value: 'application/resource-lists-diff+xml' }, { key: '.rs', value: 'application/rls-services+xml' }, { key: '.rsd', value: 'application/rsd+xml' }, { key: '.rss', value: 'application/rss+xml' }, { key: '.rtf', value: 'application/rtf' }, { key: '.sbml', value: 'application/sbml+xml' }, { key: '.scq', value: 'application/scvp-cv-request' }, { key: '.scs', value: 'application/scvp-cv-response' }, { key: '.spq', value: 'application/scvp-vp-request' }, { key: '.spp', value: 'application/scvp-vp-response' }, { key: '.sdp', value: 'application/sdp' }, { key: '.setpay', value: 'application/set-payment-initiation' }, { key: '.setreg', value: 'application/set-registration-initiation' }, { key: '.shf', value: 'application/shf+xml' }, { key: '.smi', value: 'application/smil+xml' }, { key: '.smil', value: 'application/smil+xml' }, { key: '.rq', value: 'application/sparql-query' }, { key: '.srx', value: 'application/sparql-results+xml' }, { key: '.gram', value: 'application/srgs' }, { key: '.grxml', value: 'application/srgs+xml' }, { key: '.ssml', value: 'application/ssml+xml' }, { key: '.plb', value: 'application/vnd.3gpp.pic-bw-large' }, { key: '.psb', value: 'application/vnd.3gpp.pic-bw-small' }, { key: '.pvb', value: 'application/vnd.3gpp.pic-bw-var' }, { key: '.tcap', value: 'application/vnd.3gpp2.tcap' }, { key: '.pwn', value: 'application/vnd.3m.post-it-notes' }, { key: '.aso', value: 'application/vnd.accpac.simply.aso' }, { key: '.imp', value: 'application/vnd.accpac.simply.imp' }, { key: '.acu', value: 'application/vnd.acucobol' }, { key: '.atc', value: 'application/vnd.acucorp' }, { key: '.acutc', value: 'application/vnd.acucorp' }, { key: '.air', value: 'application/vnd.adobe.air-application-installer-package+zip' }, { key: '.xdp', value: 'application/vnd.adobe.xdp+xml' }, { key: '.xfdf', value: 'application/vnd.adobe.xfdf' }, { key: '.azf', value: 'application/vnd.airzip.filesecure.azf' }, { key: '.azs', value: 'application/vnd.airzip.filesecure.azs' }, { key: '.azw', value: 'application/vnd.amazon.ebook' }, { key: '.acc', value: 'application/vnd.americandynamics.acc' }, { key: '.ami', value: 'application/vnd.amiga.ami' }, { key: '.apk', value: 'application/vnd.android.package-archive' }, { key: '.cii', value: 'application/vnd.anser-web-certificate-issue-initiation' }, { key: '.fti', value: 'application/vnd.anser-web-funds-transfer-initiation' }, { key: '.atx', value: 'application/vnd.antix.game-component' }, { key: '.mpkg', value: 'application/vnd.apple.installer+xml' }, { key: '.swi', value: 'application/vnd.arastra.swi' }, { key: '.aep', value: 'application/vnd.audiograph' }, { key: '.mpm', value: 'application/vnd.blueice.multipass' }, { key: '.bmi', value: 'application/vnd.bmi' }, { key: '.rep', value: 'application/vnd.businessobjects' }, { key: '.cdxml', value: 'application/vnd.chemdraw+xml' }, { key: '.mmd', value: 'application/vnd.chipnuts.karaoke-mmd' }, { key: '.cdy', value: 'application/vnd.cinderella' }, { key: '.cla', value: 'application/vnd.claymore' }, { key: '.c4g', value: 'application/vnd.clonk.c4group' }, { key: '.c4d', value: 'application/vnd.clonk.c4group' }, { key: '..c4f', value: 'application/vnd.clonk.c4group' }, { key: '.c4p', value: 'application/vnd.clonk.c4group' }, { key: '.c4u', value: 'application/vnd.clonk.c4group' }, { key: '.csp', value: 'application/vnd.commonspace' }, { key: '.cdbcmsg', value: 'application/vnd.contact.cmsg' }, { key: '.cmc', value: 'application/vnd.cosmocaller' }, { key: '.clkx', value: 'application/vnd.crick.clicker' }, { key: '.clkk', value: 'application/vnd.crick.clicker.keyboard' }, { key: '.clkp', value: 'application/vnd.crick.clicker.palette' }, { key: '.clkt', value: 'application/vnd.crick.clicker.template' }, { key: '.clkw', value: 'application/vnd.crick.clicker.wordbank' }, { key: '.wbs', value: 'application/vnd.criticaltools.wbs+xml' }, { key: '.pml', value: 'application/vnd.ctc-posml' }, { key: '.ppd', value: 'application/vnd.cups-ppd' }, { key: '.car', value: 'application/vnd.curl.car' }, { key: '.pcurl', value: 'application/vnd.curl.pcurl' }, { key: '.rdz', value: 'application/vnd.data-vision.rdz' }, { key: '.fe_launch', value: 'application/vnd.denovo.fcselayout-link' }, { key: '.dna', value: 'application/vnd.dna' }, { key: '.mlp', value: 'application/vnd.dolby.mlp' }, { key: '.dpg', value: 'application/vnd.dpgraph' }, { key: '.dfac', value: 'application/vnd.dreamfactory' }, { key: '.geo', value: 'application/vnd.dynageo' }, { key: '.mag', value: 'application/vnd.ecowin.chart' }, { key: '.nml', value: 'application/vnd.enliven' }, { key: '.esf', value: 'application/vnd.epson.esf' }, { key: '.msf', value: 'application/vnd.epson.msf' }, { key: '.qam', value: 'application/vnd.epson.quickanime' }, { key: '.slt', value: 'application/vnd.epson.salt' }, { key: '.ssf', value: 'application/vnd.epson.ssf' }, { key: '.es3', value: 'application/vnd.eszigno3+xml' }, { key: '.et3', value: 'application/vnd.eszigno3+xml' }, { key: '.ez2', value: 'application/vnd.ezpix-album' }, { key: '.ez3', value: 'application/vnd.ezpix-package' }, { key: '.fdf', value: 'application/vnd.fdf' }, { key: '.mseed', value: 'application/vnd.fdsn.mseed' }, { key: '.seed', value: 'application/vnd.fdsn.seed' }, { key: '.dataless', value: 'application/vnd.fdsn.seed' }, { key: '.gph', value: 'application/vnd.flographit' }, { key: '.ftc', value: 'application/vnd.fluxtime.clip' }, { key: '.fm', value: 'application/vnd.framemaker' }, { key: '.frame', value: 'application/vnd.framemaker' }, { key: '.maker', value: 'application/vnd.framemaker' }, { key: '.book', value: 'application/vnd.framemaker' }, { key: '.fnc', value: 'application/vnd.frogans.fnc' }, { key: '.ltf', value: 'application/vnd.frogans.ltf' }, { key: '.fsc', value: 'application/vnd.fsc.weblaunch' }, { key: '.oas', value: 'application/vnd.fujitsu.oasys' }, { key: '.oa2', value: 'application/vnd.fujitsu.oasys2' }, { key: '.oa3', value: 'application/vnd.fujitsu.oasys3' }, { key: '.fg5', value: 'application/vnd.fujitsu.oasysgp' }, { key: '.bh2', value: 'application/vnd.fujitsu.oasysprs' }, { key: '.ddd', value: 'application/vnd.fujixerox.ddd' }, { key: '.xdw', value: 'application/vnd.fujixerox.docuworks' }, { key: '.xbd', value: 'application/vnd.fujixerox.docuworks.binder' }, { key: '.fzs', value: 'application/vnd.fuzzysheet' }, { key: '.txd', value: 'application/vnd.genomatix.tuxedo' }, { key: '.ggb', value: 'application/vnd.geogebra.file' }, { key: '.ggt', value: 'application/vnd.geogebra.tool' }, { key: '.gex', value: 'application/vnd.geometry-explorer' }, { key: '.gre', value: 'application/vnd.geometry-explorer' }, { key: '.gmx', value: 'application/vnd.gmx' }, { key: '.kml', value: 'application/vnd.google-earth.kml+xml' }, { key: '.kmz', value: 'application/vnd.google-earth.kmz' }, { key: '.gqf', value: 'application/vnd.grafeq' }, { key: '.gqs', value: 'application/vnd.grafeq' }, { key: '.gac', value: 'application/vnd.groove-account' }, { key: '.ghf', value: 'application/vnd.groove-help' }, { key: '.gim', value: 'application/vnd.groove-identity-message' }, { key: '.grv', value: 'application/vnd.groove-injector' }, { key: '.gtm', value: 'application/vnd.groove-tool-message' }, { key: '.tpl', value: 'application/vnd.groove-tool-template' }, { key: '.vcg', value: 'application/vnd.groove-vcard' }, { key: '.zmm', value: 'application/vnd.handheld-entertainment+xml' }, { key: '.hbci', value: 'application/vnd.hbci' }, { key: '.les', value: 'application/vnd.hhe.lesson-player' }, { key: '.hpgl', value: 'application/vnd.hp-hpgl' }, { key: '.hpid', value: 'application/vnd.hp-hpid' }, { key: '.hps', value: 'application/vnd.hp-hps' }, { key: '.jlt', value: 'application/vnd.hp-jlyt' }, { key: '.pcl', value: 'application/vnd.hp-pcl' }, { key: '.pclxl', value: 'application/vnd.hp-pclxl' }, { key: '.sfd-hdstx', value: 'application/vnd.hydrostatix.sof-data' }, { key: '.x3d', value: 'application/vnd.hzn-3d-crossword' }, { key: '.mpy', value: 'application/vnd.ibm.minipay' }, { key: '.afp', value: 'application/vnd.ibm.modcap' }, { key: '.listafp', value: 'application/vnd.ibm.modcap' }, { key: '.list3820', value: 'application/vnd.ibm.modcap' }, { key: '.irm', value: 'application/vnd.ibm.rights-management' }, { key: '.sc', value: 'application/vnd.ibm.secure-container' }, { key: '.icc', value: 'application/vnd.iccprofile' }, { key: '.icm', value: 'application/vnd.iccprofile' }, { key: '.igl', value: 'application/vnd.igloader' }, { key: '.ivp', value: 'application/vnd.immervision-ivp' }, { key: '.ivu', value: 'application/vnd.immervision-ivu' }, { key: '.xpw,.xpx', value: 'application/vnd.intercon.formnet' }, { key: '.qbo', value: 'application/vnd.intu.qbo' }, { key: '.qfx', value: 'application/vnd.intu.qfx' }, { key: '.rcprofile', value: 'application/vnd.ipunplugged.rcprofile' }, { key: '.irp', value: 'application/vnd.irepository.package+xml' }, { key: '.xpr', value: 'application/vnd.is-xpr' }, { key: '.jam', value: 'application/vnd.jam' }, { key: '.rms', value: 'application/vnd.jcp.javame.midlet-rms' }, { key: '.jisp', value: 'application/vnd.jisp' }, { key: '.joda', value: 'application/vnd.joost.joda-archive' }, { key: '.ktz,.ktr', value: 'application/vnd.kahootz' }, { key: '.karbon', value: 'application/vnd.kde.karbon' }, { key: '.chrt', value: 'application/vnd.kde.kchart' }, { key: '.kfo', value: 'application/vnd.kde.kformula' }, { key: '.flw', value: 'application/vnd.kde.kivio' }, { key: '.kon', value: 'application/vnd.kde.kontour' }, { key: '.kpr', value: 'application/vnd.kde.kpresenter' }, { key: '.kpt', value: 'application/vnd.kde.kpresenter' }, { key: '.ksp', value: 'application/vnd.kde.kspread' }, { key: '.kwd', value: 'application/vnd.kde.kword' }, { key: '.kwt', value: 'application/vnd.kde.kword' }, { key: '.htke', value: 'application/vnd.kenameaapp' }, { key: '.kia', value: 'application/vnd.kidspiration' }, { key: '.kne', value: 'application/vnd.kinar' }, { key: '.knp', value: 'application/vnd.kinar' }, { key: '.skp', value: 'application/vnd.koan' }, { key: '.skd', value: 'application/vnd.koan' }, { key: '.skt', value: 'application/vnd.koan' }, { key: '.skm', value: 'application/vnd.koan' }, { key: '.sse', value: 'application/vnd.kodak-descriptor' }, { key: '.lbd', value: 'application/vnd.llamagraphics.life-balance.desktop' }, { key: '.lbe', value: 'application/vnd.llamagraphics.life-balance.exchange+xml' }, { key: '.123', value: 'application/vnd.lotus-1-2-3' }, { key: '.apr', value: 'application/vnd.lotus-approach' }, { key: '.pre', value: 'application/vnd.lotus-freelance' }, { key: '.nsf', value: 'application/vnd.lotus-notes' }, { key: '.org', value: 'application/vnd.lotus-organizer' }, { key: '.scm', value: 'application/vnd.lotus-screencam' }, { key: '.lwp', value: 'application/vnd.lotus-wordpro' }, { key: '.portpkg', value: 'application/vnd.macports.portpkg' }, { key: '.mcd', value: 'application/vnd.mcd' }, { key: '.mc1', value: 'application/vnd.medcalcdata' }, { key: '.cdkey', value: 'application/vnd.mediastation.cdkey' }, { key: '.mwf', value: 'application/vnd.mfer' }, { key: '.mfm', value: 'application/vnd.mfmp' }, { key: '.flo', value: 'application/vnd.micrografx.flo' }, { key: '.igx', value: 'application/vnd.micrografx.igx' }, { key: '.mif', value: 'application/vnd.mif' }, { key: '.daf', value: 'application/vnd.mobius.daf' }, { key: '.dis', value: 'application/vnd.mobius.dis' }, { key: '.mbk', value: 'application/vnd.mobius.mbk' }, { key: '.mqy', value: 'application/vnd.mobius.mqy' }, { key: '.msl', value: 'application/vnd.mobius.msl' }, { key: '.plc', value: 'application/vnd.mobius.plc' }, { key: '.txf', value: 'application/vnd.mobius.txf' }, { key: '.mpn', value: 'application/vnd.mophun.application' }, { key: '.mpc', value: 'application/vnd.mophun.certificate' }, { key: '.xul', value: 'application/vnd.mozilla.xul+xml' }, { key: '.cil', value: 'application/vnd.ms-artgalry' }, { key: '.cab', value: 'application/vnd.ms-cab-compressed' }, { key: '.xls', value: 'application/vnd.ms-excel' }, { key: '.xlm', value: 'application/vnd.ms-excel' }, { key: '.xla', value: 'application/vnd.ms-excel' }, { key: '.xlc', value: 'application/vnd.ms-excel' }, { key: '.xlt', value: 'application/vnd.ms-excel' }, { key: '.xlw', value: 'application/vnd.ms-excel' }, { key: '.xlam', value: 'application/vnd.ms-excel.addin.macroenabled.12' }, { key: '.xlsb', value: 'application/vnd.ms-excel.sheet.binary.macroenabled.12' }, { key: '.xlsm', value: 'application/vnd.ms-excel.sheet.macroenabled.12' }, { key: '.xltm', value: 'application/vnd.ms-excel.template.macroenabled.12' }, { key: '.eot', value: 'application/vnd.ms-fontobject' }, { key: '.chm', value: 'application/vnd.ms-htmlhelp' }, { key: '.ims', value: 'application/vnd.ms-ims' }, { key: '.lrm', value: 'application/vnd.ms-lrm' }, { key: '.cat', value: 'application/vnd.ms-pki.seccat' }, { key: '.stl', value: 'application/vnd.ms-pki.stl' }, { key: '.ppt', value: 'application/vnd.ms-powerpoint' }, { key: '.pps', value: 'application/vnd.ms-powerpoint' }, { key: '.pot', value: 'application/vnd.ms-powerpoint' }, { key: '.ppam', value: 'application/vnd.ms-powerpoint.addin.macroenabled.12' }, { key: '.pptm', value: 'application/vnd.ms-powerpoint.presentation.macroenabled.12' }, { key: '.sldm', value: 'application/vnd.ms-powerpoint.slide.macroenabled.12' }, { key: '.ppsm', value: 'application/vnd.ms-powerpoint.slideshow.macroenabled.12' }, { key: '.potm', value: 'application/vnd.ms-powerpoint.template.macroenabled.12' }, { key: '.mpp', value: 'application/vnd.ms-project' }, { key: '.mpt', value: 'application/vnd.ms-project' }, { key: '.docm', value: 'application/vnd.ms-word.document.macroenabled.12' }, { key: '.dotm', value: 'application/vnd.ms-word.template.macroenabled.12' }, { key: '.wps', value: 'application/vnd.ms-works' }, { key: '.wks', value: 'application/vnd.ms-works' }, { key: '.wcm', value: 'application/vnd.ms-works' }, { key: '.wdb', value: 'application/vnd.ms-works' }, { key: '.wpl', value: 'application/vnd.ms-wpl' }, { key: '.xps', value: 'application/vnd.ms-xpsdocument' }, { key: '.mseq', value: 'application/vnd.mseq' }, { key: '.mus', value: 'application/vnd.musician' }, { key: '.msty', value: 'application/vnd.muvee.style' }, { key: '.nlu', value: 'application/vnd.neurolanguage.nlu' }, { key: '.nnd', value: 'application/vnd.noblenet-directory' }, { key: '.nns', value: 'application/vnd.noblenet-sealer' }, { key: '.nnw', value: 'application/vnd.noblenet-web' }, { key: '.ngdat', value: 'application/vnd.nokia.n-gage.data' }, { key: '.n-gage', value: 'application/vnd.nokia.n-gage.symbian.install' }, { key: '.rpst', value: 'application/vnd.nokia.radio-preset' }, { key: '.rpss', value: 'application/vnd.nokia.radio-presets' }, { key: '.edm', value: 'application/vnd.novadigm.edm' }, { key: '.edx', value: 'application/vnd.novadigm.edx' }, { key: '.ext', value: 'application/vnd.novadigm.ext' }, { key: '.odc', value: 'application/vnd.oasis.opendocument.chart' }, { key: '.otc', value: 'application/vnd.oasis.opendocument.chart-template' }, { key: '.odb', value: 'application/vnd.oasis.opendocument.database' }, { key: '.odf', value: 'application/vnd.oasis.opendocument.formula' }, { key: '.odft', value: 'application/vnd.oasis.opendocument.formula-template' }, { key: '.odg', value: 'application/vnd.oasis.opendocument.graphics' }, { key: '.otg', value: 'application/vnd.oasis.opendocument.graphics-template' }, { key: '.odi', value: 'application/vnd.oasis.opendocument.image' }, { key: '.oti', value: 'application/vnd.oasis.opendocument.image-template' }, { key: '.odp', value: 'application/vnd.oasis.opendocument.presentation' }, { key: '.ods', value: 'application/vnd.oasis.opendocument.spreadsheet' }, { key: '.ots', value: 'application/vnd.oasis.opendocument.spreadsheet-template' }, { key: '.odt', value: 'application/vnd.oasis.opendocument.text' }, { key: '.otm', value: 'application/vnd.oasis.opendocument.text-master' }, { key: '.ott', value: 'application/vnd.oasis.opendocument.text-template' }, { key: '.oth', value: 'application/vnd.oasis.opendocument.text-web' }, { key: '.xo', value: 'application/vnd.olpc-sugar' }, { key: '.dd2', value: 'application/vnd.oma.dd2+xml' }, { key: '.oxt', value: 'application/vnd.openofficeorg.extension' }, { key: '.pptx', value: 'application/vnd.openxmlformats-officedocument.presentationml.presentation' }, { key: '.sldx', value: 'application/vnd.openxmlformats-officedocument.presentationml.slide' }, { key: '.ppsx', value: 'application/vnd.openxmlformats-officedocument.presentationml.slideshow' }, { key: '.potx', value: 'application/vnd.openxmlformats-officedocument.presentationml.template' }, { key: '.xlsx', value: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }, { key: '.xltx', value: 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' }, { key: '.docx', value: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' }, { key: '.dotx', value: 'application/vnd.openxmlformats-officedocument.wordprocessingml.template' }, { key: '.dp', value: 'application/vnd.osgi.dp' }, { key: '.pdb', value: 'application/vnd.palm' }, { key: '.pqa', value: 'application/vnd.palm' }, { key: '.oprc', value: 'application/vnd.palm' }, { key: '.str', value: 'application/vnd.pg.format' }, { key: '.ei6', value: 'application/vnd.pg.osasli' }, { key: '.efif', value: 'application/vnd.picsel' }, { key: '.plf', value: 'application/vnd.pocketlearn' }, { key: '.pbd', value: 'application/vnd.powerbuilder6' }, { key: '.box', value: 'application/vnd.previewsystems.box' }, { key: '.mgz', value: 'application/vnd.proteus.magazine' }, { key: '.qps', value: 'application/vnd.publishare-delta-tree' }, { key: '.ptid', value: 'application/vnd.pvi.ptid1' }, { key: '.qxd', value: 'application/vnd.quark.quarkxpress' }, { key: '.qxt', value: 'application/vnd.quark.quarkxpress' }, { key: '.qwd', value: 'application/vnd.quark.quarkxpress' }, { key: '.qwt', value: 'application/vnd.quark.quarkxpress' }, { key: '.qxl', value: 'application/vnd.quark.quarkxpress' }, { key: '.qxb', value: 'application/vnd.quark.quarkxpress' }, { key: '.mxl', value: 'application/vnd.recordare.musicxml' }, { key: '.musicxml', value: 'application/vnd.recordare.musicxml+xml' }, { key: '.cod', value: 'application/vnd.rim.cod' }, { key: '.rm', value: 'application/vnd.rn-realmedia' }, { key: '.link66', value: 'application/vnd.route66.link66+xml' }, { key: '.see', value: 'application/vnd.seemail' }, { key: '.sema', value: 'application/vnd.sema' }, { key: '.semd', value: 'application/vnd.semd' }, { key: '.semf', value: 'application/vnd.semf' }, { key: '.ifm', value: 'application/vnd.shana.informed.formdata' }, { key: '.itp', value: 'application/vnd.shana.informed.formtemplate' }, { key: '.iif', value: 'application/vnd.shana.informed.interchange' }, { key: '.ipk', value: 'application/vnd.shana.informed.package' }, { key: '.twd', value: 'application/vnd.simtech-mindmapper' }, { key: '.twds', value: 'application/vnd.simtech-mindmapper' }, { key: '.mmf', value: 'application/vnd.smaf' }, { key: '.teacher', value: 'application/vnd.smart.teacher' }, { key: '.sdkm', value: 'application/vnd.solent.sdkm+xml' }, { key: '.sdkd', value: 'application/vnd.solent.sdkm+xml' }, { key: '.dxp', value: 'application/vnd.spotfire.dxp' }, { key: '.sfs', value: 'application/vnd.spotfire.sfs' }, { key: '.sdc', value: 'application/vnd.stardivision.calc' }, { key: '.sda', value: 'application/vnd.stardivision.draw' }, { key: '.sdd', value: 'application/vnd.stardivision.impress' }, { key: '.smf', value: 'application/vnd.stardivision.math' }, { key: '.sdw', value: 'application/vnd.stardivision.writer' }, { key: '.vor', value: 'application/vnd.stardivision.writer' }, { key: '.sgl', value: 'application/vnd.stardivision.writer-global' }, { key: '.sxc', value: 'application/vnd.sun.xml.calc' }, { key: '.stc', value: 'application/vnd.sun.xml.calc.template' }, { key: '.sxd', value: 'application/vnd.sun.xml.draw' }, { key: '.std', value: 'application/vnd.sun.xml.draw.template' }, { key: '.sxi', value: 'application/vnd.sun.xml.impress' }, { key: '.sti', value: 'application/vnd.sun.xml.impress.template' }, { key: '.sxm', value: 'application/vnd.sun.xml.math' }, { key: '.sxw', value: 'application/vnd.sun.xml.writer' }, { key: '.sxg', value: 'application/vnd.sun.xml.writer.global' }, { key: '.stw', value: 'application/vnd.sun.xml.writer.template' }, { key: '.sus', value: 'application/vnd.sus-calendar' }, { key: '.susp', value: 'application/vnd.sus-calendar' }, { key: '.svd', value: 'application/vnd.svd' }, { key: '.sis', value: 'application/vnd.symbian.install' }, { key: '.sisx', value: 'application/vnd.symbian.install' }, { key: '.xsm', value: 'application/vnd.syncml+xml' }, { key: '.bdm', value: 'application/vnd.syncml.dm+wbxml' }, { key: '.xdm', value: 'application/vnd.syncml.dm+xml' }, { key: '.tao', value: 'application/vnd.tao.intent-module-archive' }, { key: '.tmo', value: 'application/vnd.tmobile-livetv' }, { key: '.tpt', value: 'application/vnd.trid.tpt' }, { key: '.mxs', value: 'application/vnd.triscape.mxs' }, { key: '.tra', value: 'application/vnd.trueapp' }, { key: '.ufd', value: 'application/vnd.ufdl' }, { key: '.ufdl', value: 'application/vnd.ufdl' }, { key: '.utz', value: 'application/vnd.uiq.theme' }, { key: '.umj', value: 'application/vnd.umajin' }, { key: '.unityweb', value: 'application/vnd.unity' }, { key: '.uoml', value: 'application/vnd.uoml+xml' }, { key: '.vcx', value: 'application/vnd.vcx' }, { key: '.vsd', value: 'application/vnd.visio' }, { key: '.vst', value: 'application/vnd.visio' }, { key: '.vss', value: 'application/vnd.visio' }, { key: '.vst', value: 'application/vnd.visio' }, { key: '.vss', value: 'application/vnd.visio' }, { key: '.vsw', value: 'application/vnd.visio' }, { key: '.vis', value: 'application/vnd.visionary' }, { key: '.vsf', value: 'application/vnd.vsf' }, { key: '.wbxml', value: 'application/vnd.wap.wbxml' }, { key: '.wmlc', value: 'application/vnd.wap.wmlc' }, { key: '.wmlsc', value: 'application/vnd.wap.wmlscriptc' }, { key: '.wtb', value: 'application/vnd.webturbo' }, { key: '.wpd', value: 'application/vnd.wordperfect' }, { key: '.wqd', value: 'application/vnd.wqd' }, { key: '.stf', value: 'application/vnd.wt.stf' }, { key: '.xar', value: 'application/vnd.xara' }, { key: '.xfdl', value: 'application/vnd.xfdl' }, { key: '.hvd', value: 'application/vnd.yamaha.hv-dic' }, { key: '.hvs', value: 'application/vnd.yamaha.hv-script' }, { key: '.hvp', value: 'application/vnd.yamaha.hv-voice' }, { key: '.osf', value: 'application/vnd.yamaha.openscoreformat' }, { key: '.osfpvg', value: 'application/vnd.yamaha.openscoreformat.osfpvg+xml' }, { key: '.saf', value: 'application/vnd.yamaha.smaf-audio' }, { key: '.spf', value: 'application/vnd.yamaha.smaf-phrase' }, { key: '.cmp', value: 'application/vnd.yellowriver-custom-menu' }, { key: '.zir', value: 'application/vnd.zul' }, { key: '.zirz', value: 'application/vnd.zul' }, { key: '.zaz', value: 'application/vnd.zzazz.deck+xml' }, { key: '.vxml', value: 'application/voicexml+xml' }, { key: '.hlp', value: 'application/winhlp' }, { key: '.wsdl', value: 'application/wsdl+xml' }, { key: '.wspolicy', value: 'application/wspolicy+xml' }, { key: '.abw', value: 'application/x-abiword' }, { key: '.ace', value: 'application/x-ace-compressed' }, { key: '.aab', value: 'application/x-authorware-bin' }, { key: '.x32', value: 'application/x-authorware-bin' }, { key: '.u32', value: 'application/x-authorware-bin' }, { key: '.vox', value: 'application/x-authorware-bin' }, { key: '.aam', value: 'application/x-authorware-map' }, { key: '.aas', value: 'application/x-authorware-seg' }, { key: '.bcpio', value: 'application/x-bcpio' }, { key: '.torrent', value: 'application/x-bittorrent' }, { key: '.bz', value: 'application/x-bzip' }, { key: '.bz2', value: 'application/x-bzip2' }, { key: '.boz', value: 'application/x-bzip2' }, { key: '.vcd', value: 'application/x-cdlink' }, { key: '.chat', value: 'application/x-chat' }, { key: '.pgn', value: 'application/x-chess-pgn' }, { key: '.cpio', value: 'application/x-cpio' }, { key: '.csh', value: 'application/x-csh' }, { key: '.deb', value: 'application/x-debian-package' }, { key: '.udeb', value: 'application/x-debian-package' }, { key: '.dir', value: 'application/x-director' }, { key: '.dcr', value: 'application/x-director' }, { key: '.dxr', value: 'application/x-director' }, { key: '.cst', value: 'application/x-director' }, { key: '.cct', value: 'application/x-director' }, { key: '.cxt', value: 'application/x-director' }, { key: '.w3d', value: 'application/x-director' }, { key: '.fgd', value: 'application/x-director' }, { key: '.swa', value: 'application/x-director' }, { key: '.wad', value: 'application/x-doom' }, { key: '.ncx', value: 'application/x-dtbncx+xml' }, { key: '.dtb', value: 'application/x-dtbook+xml' }, { key: '.res', value: 'application/x-dtbresource+xml' }, { key: '.dvi', value: 'application/x-dvi' }, { key: '.bdf', value: 'application/x-font-bdf' }, { key: '.gsf', value: 'application/x-font-ghostscript' }, { key: '.psf', value: 'application/x-font-linux-psf' }, { key: '.otf', value: 'application/x-font-otf' }, { key: '.pcf', value: 'application/x-font-pcf' }, { key: '.snf', value: 'application/x-font-snf' }, { key: '.ttf', value: 'application/x-font-ttf' }, { key: '.ttc', value: 'application/x-font-ttf' }, { key: '.woff', value: 'application/font-woff' }, { key: '.pfa', value: 'application/x-font-type1' }, { key: '.pfb', value: 'application/x-font-type1' }, { key: '.pfm', value: 'application/x-font-type1' }, { key: '.afm', value: 'application/x-font-type1' }, { key: '.spl', value: 'application/x-futuresplash' }, { key: '.gnumeric', value: 'application/x-gnumeric' }, { key: '.gtar', value: 'application/x-gtar' }, { key: '.hdf', value: 'application/x-hdf' }, { key: '.jnlp', value: 'application/x-java-jnlp-file' }, { key: '.latex', value: 'application/x-latex' }, { key: '.prc', value: 'application/x-mobipocket-ebook' }, { key: '.mobi', value: 'application/x-mobipocket-ebook' }, { key: '.application', value: 'application/x-ms-application' }, { key: '.wmd', value: 'application/x-ms-wmd' }, { key: '.wmz', value: 'application/x-ms-wmz' }, { key: '.xbap', value: 'application/x-ms-xbap' }, { key: '.mdb', value: 'application/x-msaccess' }, { key: '.obd', value: 'application/x-msbinder' }, { key: '.crd', value: 'application/x-mscardfile' }, { key: '.clp', value: 'application/x-msclip' }, { key: '.exe', value: 'application/x-msdownload' }, { key: '.dll', value: 'application/x-msdownload' }, { key: '.com', value: 'application/x-msdownload' }, { key: '.bat', value: 'application/x-msdownload' }, { key: '.msi', value: 'application/x-msdownload' }, { key: '.mvb', value: 'application/x-msmediaview' }, { key: '.m13', value: 'application/x-msmediaview' }, { key: '.m14', value: 'application/x-msmediaview' }, { key: '.wmf', value: 'application/x-msmetafile' }, { key: '.mny', value: 'application/x-msmoney' }, { key: '.pub', value: 'application/x-mspublisher' }, { key: '.scd', value: 'application/x-msschedule' }, { key: '.trm', value: 'application/x-msterminal' }, { key: '.wri', value: 'application/x-mswrite' }, { key: '.nc', value: 'application/x-netcdf' }, { key: '.cdf', value: 'application/x-netcdf' }, { key: '.p12', value: 'application/x-pkcs12' }, { key: '.pfx', value: 'application/x-pkcs12' }, { key: '.p7b', value: 'application/x-pkcs7-certificates' }, { key: '.spc', value: 'application/x-pkcs7-certificates' }, { key: '.p7r', value: 'application/x-pkcs7-certreqresp' }, { key: '.rar', value: 'application/x-rar-compressed' }, { key: '.sh', value: 'application/x-sh' }, { key: '.shar', value: 'application/x-shar' }, { key: '.swf', value: 'application/x-shockwave-flash' }, { key: '.xap', value: 'application/x-silverlight-app' }, { key: '.sit', value: 'application/x-stuffit' }, { key: '.sitx', value: 'application/x-stuffitx' }, { key: '.sv4cpio', value: 'application/x-sv4cpio' }, { key: '.sv4crc', value: 'application/x-sv4crc' }, { key: '.tar', value: 'application/x-tar' }, { key: '.tcl', value: 'application/x-tcl' }, { key: '.tex', value: 'application/x-tex' }, { key: '.tfm', value: 'application/x-tex-tfm' }, { key: '.texinfo', value: 'application/x-texinfo' }, { key: '.texi', value: 'application/x-texinfo' }, { key: '.ustar', value: 'application/x-ustar' }, { key: '.src', value: 'application/x-wais-source' }, { key: '.der', value: 'application/x-x509-ca-cert' }, { key: '.crt', value: 'application/x-x509-ca-cert' }, { key: '.fig', value: 'application/x-xfig' }, { key: '.xpi', value: 'application/x-xpinstall' }, { key: '.xenc', value: 'application/xenc+xml' }, { key: '.xhtml', value: 'application/xhtml+xml' }, { key: '.xht', value: 'application/xhtml+xml' }, { key: '.xml', value: 'application/xml' }, { key: '.xsl', value: 'application/xml' }, { key: '.dtd', value: 'application/xml-dtd' }, { key: '.xop', value: 'application/xop+xml' }, { key: '.xslt', value: 'application/xslt+xml' }, { key: '.xspf', value: 'application/xspf+xml' }, { key: '.mxml', value: 'application/xv+xml' }, { key: '.xhvml', value: 'application/xv+xml' }, { key: '.xvml', value: 'application/xv+xml' }, { key: '.xvm', value: 'application/xv+xml' }, { key: '.zip', value: 'application/zip' }, { key: '.adp', value: 'audio/adpcm' }, { key: '.au', value: 'audio/basic' }, { key: '.snd', value: 'audio/basic' }, { key: '.mid', value: 'audio/midi' }, { key: '.midi', value: 'audio/midi' }, { key: '.kar', value: 'audio/midi' }, { key: '.rmi', value: 'audio/midi' }, { key: '.mp4a', value: 'audio/mp4' }, { key: '.m4a', value: 'audio/mp4a-latm' }, { key: '.m4p', value: 'audio/mp4a-latm' }, { key: '.mpga', value: 'audio/mpeg' }, { key: '.mp2', value: 'audio/mpeg' }, { key: '.mp2a', value: 'audio/mpeg' }, { key: '.mp3', value: 'audio/mpeg' }, { key: '.m2a', value: 'audio/mpeg' }, { key: '.m3a', value: 'audio/mpeg' }, { key: '.oga', value: 'audio/ogg' }, { key: '.ogg', value: 'audio/ogg' }, { key: '.spx', value: 'audio/ogg' }, { key: '.eol', value: 'audio/vnd.digital-winds' }, { key: '.dts', value: 'audio/vnd.dts' }, { key: '.dtshd', value: 'audio/vnd.dts.hd' }, { key: '.lvp', value: 'audio/vnd.lucent.voice' }, { key: '.pya', value: 'audio/vnd.ms-playready.media.pya' }, { key: '.ecelp4800', value: 'audio/vnd.nuera.ecelp4800' }, { key: '.ecelp7470', value: 'audio/vnd.nuera.ecelp7470' }, { key: '.ecelp9600', value: 'audio/vnd.nuera.ecelp9600' }, { key: '.aac', value: 'audio/x-aac' }, { key: '.aif', value: 'audio/x-aiff' }, { key: '.aiff', value: 'audio/x-aiff' }, { key: '.aifc', value: 'audio/x-aiff' }, { key: '.m3u', value: 'audio/x-mpegurl' }, { key: '.wax', value: 'audio/x-ms-wax' }, { key: '.wma', value: 'audio/x-ms-wma' }, { key: '.ram', value: 'audio/x-pn-realaudio' }, { key: '.ra', value: 'audio/x-pn-realaudio' }, { key: '.rmp', value: 'audio/x-pn-realaudio-plugin' }, { key: '.wav', value: 'audio/x-wav' }, { key: '.cdx', value: 'chemical/x-cdx' }, { key: '.cif', value: 'chemical/x-cif' }, { key: '.cmdf', value: 'chemical/x-cmdf' }, { key: '.cml', value: 'chemical/x-cml' }, { key: '.csml', value: 'chemical/x-csml' }, { key: '.xyz', value: 'chemical/x-xyz' }, { key: '.bmp', value: 'image/bmp' }, { key: '.cgm', value: 'image/cgm' }, { key: '.g3', value: 'image/g3fax' }, { key: '.gif', value: 'image/gif' }, { key: '.ief', value: 'image/ief' }, { key: '.jp2', value: 'image/jp2' }, { key: '.jpg', value: 'image/jpeg' }, { key: '.jpeg', value: 'image/jpeg' }, { key: '.jpe', value: 'image/jpeg' }, { key: '.pict', value: 'image/pict' }, { key: '.pic', value: 'image/pict' }, { key: '.pct', value: 'image/pict' }, { key: '.png', value: 'image/png' }, { key: '.btif', value: 'image/prs.btif' }, { key: '.svg', value: 'image/svg+xml' }, { key: '.svgz', value: 'image/svg+xml' }, { key: '.tiff', value: 'image/tiff' }, { key: '.tif', value: 'image/tiff' }, { key: '.psd', value: 'image/vnd.adobe.photoshop' }, { key: '.djvu', value: 'image/vnd.djvu' }, { key: '.djv', value: 'image/vnd.djvu' }, { key: '.dwg', value: 'image/vnd.dwg' }, { key: '.dxf', value: 'image/vnd.dxf' }, { key: '.fbs', value: 'image/vnd.fastbidsheet' }, { key: '.fpx', value: 'image/vnd.fpx' }, { key: '.fst', value: 'image/vnd.fst' }, { key: '.mmr', value: 'image/vnd.fujixerox.edmics-mmr' }, { key: '.rlc', value: 'image/vnd.fujixerox.edmics-rlc' }, { key: '.mdi', value: 'image/vnd.ms-modi' }, { key: '.npx', value: 'image/vnd.net-fpx' }, { key: '.wbmp', value: 'image/vnd.wap.wbmp' }, { key: '.xif', value: 'image/vnd.xiff' }, { key: '.ras', value: 'image/x-cmu-raster' }, { key: '.cmx', value: 'image/x-cmx' }, { key: '.fh', value: 'image/x-freehand' }, { key: '.fhc', value: 'image/x-freehand' }, { key: '.fh4', value: 'image/x-freehand' }, { key: '.fh5', value: 'image/x-freehand' }, { key: '.fh7', value: 'image/x-freehand' }, { key: '.ico', value: 'image/x-icon' }, { key: '.pntg', value: 'image/x-macpaint' }, { key: '.pnt', value: 'image/x-macpaint' }, { key: '.mac', value: 'image/x-macpaint' }, { key: '.pcx', value: 'image/x-pcx' }, { key: '.pic', value: 'image/x-pict' }, { key: '.pct', value: 'image/x-pict' }, { key: '.pnm', value: 'image/x-portable-anymap' }, { key: '.pbm', value: 'image/x-portable-bitmap' }, { key: '.pgm', value: 'image/x-portable-graymap' }, { key: '.ppm', value: 'image/x-portable-pixmap' }, { key: '.qtif', value: 'image/x-quicktime' }, { key: '.qti', value: 'image/x-quicktime' }, { key: '.rgb', value: 'image/x-rgb' }, { key: '.xbm', value: 'image/x-xbitmap' }, { key: '.xpm', value: 'image/x-xpixmap' }, { key: '.xwd', value: 'image/x-xwindowdump' }, { key: '.eml', value: 'message/rfc822' }, { key: '.mime', value: 'message/rfc822' }, { key: '.igs', value: 'model/iges' }, { key: '.iges', value: 'model/iges' }, { key: '.msh', value: 'model/mesh' }, { key: '.mesh', value: 'model/mesh' }, { key: '.silo', value: 'model/mesh' }, { key: '.dwf', value: 'model/vnd.dwf' }, { key: '.gdl', value: 'model/vnd.gdl' }, { key: '.gtw', value: 'model/vnd.gtw' }, { key: '.mts', value: 'model/vnd.mts' }, { key: '.vtu', value: 'model/vnd.vtu' }, { key: '.wrl', value: 'model/vrml' }, { key: '.vrml', value: 'model/vrml' }, { key: '.ics', value: 'text/calendar' }, { key: '.ifb', value: 'text/calendar' }, { key: '.css', value: 'text/css' }, { key: '.csv', value: 'text/csv' }, { key: '.html', value: 'text/html' }, { key: '.htm', value: 'text/html' }, { key: '.txt', value: 'text/plain' }, { key: '.text', value: 'text/plain' }, { key: '.conf', value: 'text/plain' }, { key: '.def', value: 'text/plain' }, { key: '.list', value: 'text/plain' }, { key: '.log', value: 'text/plain' }, { key: '.in', value: 'text/plain' }, { key: '.dsc', value: 'text/prs.lines.tag' }, { key: '.rtx', value: 'text/richtext' }, { key: '.sgml', value: 'text/sgml' }, { key: '.sgm', value: 'text/sgml' }, { key: '.tsv', value: 'text/tab-separated-values' }, { key: '.t', value: 'text/troff' }, { key: '.tr', value: 'text/troff' }, { key: '.roff', value: 'text/troff' }, { key: '.man', value: 'text/troff' }, { key: '.me', value: 'text/troff' }, { key: '.ms', value: 'text/troff' }, { key: '.uri', value: 'text/uri-list' }, { key: '.uris', value: 'text/uri-list' }, { key: '.urls', value: 'text/uri-list' }, { key: '.curl', value: 'text/vnd.curl' }, { key: '.dcurl', value: 'text/vnd.curl.dcurl' }, { key: '.scurl', value: 'text/vnd.curl.scurl' }, { key: '.mcurl', value: 'text/vnd.curl.mcurl' }, { key: '.fly', value: 'text/vnd.fly' }, { key: '.flx', value: 'text/vnd.fmi.flexstor' }, { key: '.gv', value: 'text/vnd.graphviz' }, { key: '.3dml', value: 'text/vnd.in3d.3dml' }, { key: '.spot', value: 'text/vnd.in3d.spot' }, { key: '.jad', value: 'text/vnd.sun.j2me.app-descriptor' }, { key: '.wml', value: 'text/vnd.wap.wml' }, { key: '.wmls', value: 'text/vnd.wap.wmlscript' }, { key: '.s', value: 'text/x-asm' }, { key: '.asm', value: 'text/x-asm' }, { key: '.c', value: 'text/x-c' }, { key: '.cc', value: 'text/x-c' }, { key: '.cxx', value: 'text/x-c' }, { key: '.cpp', value: 'text/x-c' }, { key: '.h', value: 'text/x-c' }, { key: '.hh', value: 'text/x-c' }, { key: '.dic', value: 'text/x-c' }, { key: '.f', value: 'text/x-fortran' }, { key: '.for', value: 'text/x-fortran' }, { key: '.f77', value: 'text/x-fortran' }, { key: '.f90', value: 'text/x-fortran' }, { key: '.p', value: 'text/x-pascal' }, { key: '.pas', value: 'text/x-pascal' }, { key: '.java', value: 'text/x-java-source' }, { key: '.etx', value: 'text/x-setext' }, { key: '.uu', value: 'text/x-uuencode' }, { key: '.vcs', value: 'text/x-vcalendar' }, { key: '.vcf', value: 'text/x-vcard' }, { key: '.3gp', value: 'video/3gpp' }, { key: '.3g2', value: 'video/3gpp2' }, { key: '.h261', value: 'video/h261' }, { key: '.h263', value: 'video/h263' }, { key: '.h264', value: 'video/h264' }, { key: '.jpgv', value: 'video/jpeg' }, { key: '.jpm', value: 'video/jpm' }, { key: '.jpgm', value: 'video/jpm' }, { key: '.mj2', value: 'video/mj2' }, { key: '.mjp2', value: 'video/mj2' }, { key: '.mp4', value: 'video/mp4' }, { key: '.mp4v', value: 'video/mp4' }, { key: '.mpg4', value: 'video/mp4' }, { key: '.m4v', value: 'video/mp4' }, { key: '.webm', value: 'video/webm' }, { key: '.mpeg', value: 'video/mpeg' }, { key: '.mpg', value: 'video/mpeg' }, { key: '.mpe', value: 'video/mpeg' }, { key: '.m1v', value: 'video/mpeg' }, { key: '.m2v', value: 'video/mpeg' }, { key: '.ogv', value: 'video/ogg' }, { key: '.qt', value: 'video/quicktime' }, { key: '.mov', value: 'video/quicktime' }, { key: '.fvt', value: 'video/vnd.fvt' }, { key: '.mxu', value: 'video/vnd.mpegurl' }, { key: '.m4u', value: 'video/vnd.mpegurl' }, { key: '.pyv', value: 'video/vnd.ms-playready.media.pyv' }, { key: '.viv', value: 'video/vnd.vivo' }, { key: '.dv', value: 'video/x-dv' }, { key: '.dif', value: 'video/x-dv' }, { key: '.f4v', value: 'video/x-f4v' }, { key: '.fli', value: 'video/x-fli' }, { key: '.flv', value: 'video/x-flv' }, { key: '.m4v', value: 'video/x-m4v' }, { key: '.asf', value: 'video/x-ms-asf' }, { key: '.asx', value: 'video/x-ms-asf' }, { key: '.wm', value: 'video/x-ms-wm' }, { key: '.wmv', value: 'video/x-ms-wmv' }, { key: '.wmx', value: 'video/x-ms-wmx' }, { key: '.wvx', value: 'video/x-ms-wvx' }, { key: '.avi', value: 'video/x-msvideo' }, { key: '.movie', value: 'video/x-sgi-movie' }, { key: '.ice', value: 'x-conference/x-cooltalk' }, { key: '.indd', value: 'application/x-indesign' }, { key: '.dat', value: 'application/octet-stream' }, { key: '.gz', value: 'application/x-gzip' }, { key: '.tgz', value: 'application/x-tar' }, { key: '.tar', value: 'application/x-tar' }, { key: '.epub', value: 'application/epub+zip' }, { key: '.mobi', value: 'application/x-mobipocket-ebook' }]; function uuidv4() { return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)); } const VR_FILE_ERROR_TYPE = { FORMAT: 'FORMAT', MAX_FILES: 'MAX_FILES', MAX_SIZE: 'MAX_SIZE' }; const VR_FILE_CLASS = { PREVIEW: 'vr-preview', IMAGE: 'vr-preview-image', REMOVE: 'vr-preview-remove', SOURCE: 'vr-preview-source', INFO: 'vr-preview-info', HIGHLIGHT: 'vr-highlight-dropzone' }; customElements.define('vr-file-upload-preview', class extends HTMLElement { /** The current selected files. */ files = []; /** Sign that the component is rendered. */ rendered; /** Reference to input element for file selection. */ inputRef; /** Reference to button element. */ uploadRef; /** Reference to container for displaying file previews. */ containerRef; static get observedAttributes() { return ['preview', 'multiple', 'accept', 'max-files', 'max-size']; } /** * A selector or group of selectors pointing to the container for previewing files. * @returns {string} */ get preview() { return this.getAttribute('preview'); } /** * Acceptable file types. * @returns {string} */ get accept() { return this.getAttribute('accept'); } /** * Multiple selection of files. * @returns {boolean} */ get multiple() { const value = this.getAttribute('multiple'); return value === '' || value === 'true'; } /** * Maximum number of files. * @returns {number | null} */ get maxFiles() { const value = parseInt(this.getAttribute('max-files')); return !isNaN(value) ? value : null; } /** Maximum file size. */ get maxSize() { const value = parseInt(this.getAttribute('max-size')); return !isNaN(value) ? value : null; } /** * File drag and drop. * @returns {boolean} */ get dropzone() { const value = this.getAttribute('dropzone'); return value === '' || value === 'true'; } constructor() { super(); } onSelect = e => this.inputRef.click(); onChange = e => this.changeHandler(e); onRemove = e => this.removeHandler(e); onDrop = e => this.filesHandler(e.dataTransfer.files); onHighlight = e => this.uploadRef.classList.add(VR_FILE_CLASS.HIGHLIGHT); onUnhighlight = e => this.uploadRef.classList.remove(VR_FILE_CLASS.HIGHLIGHT); connectedCallback() { this.render(); this.rendered = true; } disconnectedCallback() { this.defaultEventListners(false); this.dragOnDropEventListners(false); } attributeChangedCallback(name, oldValue, newValue) { if (!this.rendered) { return; } switch (name) { case 'accept': case 'max-files': case 'max-size': { changeAttributes(this.inputRef, [{ name, value: newValue }]); return; } case 'multiple': { changeAttributes(this.inputRef, [{ name, value: newValue === '' || newValue === 'true', onlyAttr: true }]); return; } case 'preview': {