1 var YMime = new function(){
  2 	var file_type=function(file){
  3 		if(file.type.length)return file.type;
  4 		var ext=file.name.split(".").pop().toLowerCase();
  5 		for(var type in acceptedTypes){
  6 			if(type.split("/")[1]==ext)return type;
  7 		}
  8 		return 'undefined/undefined';
  9 	};
 10 	this.fileType=function(file){
 11 //		if(!(file instanceof File))return null;
 12 	//	return file.type.length?file.type:this.filenameType(file.name);
 13 		return this.filenameType(file.name);
 14 	};
 15 	this.filenameType=function(filename){
 16 		var ext=filename.split("?")[0].split(".").pop().toLowerCase();
 17 		return this.types[ext]?this.types[ext]:"undefined/undefined";
 18 	};
 19 	this.types = {
 20 		'ai'      : 'application/postscript',	//Adobe PostScript Document PS, AI
 21 		'aif'     : 'audio/x-aiff',			//Audio IFF Compressed Sound AIFF, AIFC,	AIF, IFF, SND
 22 		'aifc'    : 'audio/x-aiff',			//Audio IFF Compressed Sound AIFC, AIFF,AIF, IFF, SND
 23 		'aiff'    : 'audio/x-aiff',
 24 		'asc'     : 'text/plain',
 25 		'asf'     : 'video/x-ms-asf',
 26 		'asx'     : 'video/x-ms-asf',
 27 		'as'      : 'text/flash-actionscript',
 28 		'au'      : 'audio/basic',
 29 		'avi'     : 'video/x-msvideo',
 30 		'bcpio'   : 'application/x-bcpio',
 31 		'bin'     : 'application/octet-stream',
 32 		'bmp'     : 'image/bmp',
 33 		'bz2'     : 'application/x-bzip2',
 34 		'cdf'     : 'application/x-netcdf',
 35 		'chrt'    : 'application/x-kchart',
 36 		'class'   : 'application/octet-stream',
 37 		'cpio'    : 'application/x-cpio',
 38 		'cpt'     : 'application/mac-compactpro',
 39 		'csh'     : 'application/x-csh',
 40 		'css'     : 'text/css',
 41 		'cur'     : 'image/cursor',
 42 		'dae'     : 'text/xml-collada',
 43 		'dcr'     : 'application/x-director',
 44 		'dir'     : 'application/x-director',
 45 		'djv'     : 'image/vnd.djvu',
 46 		'djvu'    : 'image/vnd.djvu',
 47 		'dll'     : 'application/octet-stream',
 48 		'dms'     : 'application/octet-stream',
 49 		'doc'     : 'application/msword',
 50 		'dvi'     : 'application/x-dvi',
 51 		'dxr'     : 'application/x-director',
 52 		'eps'     : 'application/postscript',
 53 		'etx'     : 'text/x-setext',
 54 		'exe'     : 'application/octet-stream',
 55 		'ez'      : 'application/andrew-inset',
 56 		'flv'     : 'video/x-flv',
 57 		'gif'     : 'image/gif',
 58 		'gtar'    : 'application/x-gtar',
 59 		'gz'      : 'application/x-gzip',
 60 		'hdf'     : 'application/x-hdf',
 61 		'hqx'     : 'application/mac-binhex40',
 62 		'htm'     : 'text/html',
 63 		'html'    : 'text/html',
 64 		'ice'     : 'x-conference/x-cooltalk',
 65 		'ief'     : 'image/ief',
 66 		'iges'    : 'model/iges',
 67 		'igs'     : 'model/iges',
 68 		'img'     : 'application/octet-stream',
 69 		'iso'     : 'application/octet-stream',
 70 		'jad'     : 'text/vnd.sun.j2me.app-descriptor',
 71 		'jar'     : 'application/x-java-archive',
 72 		'jnlp'    : 'application/x-java-jnlp-file',
 73 		'jpe'     : 'image/jpeg',
 74 		'jpeg'    : 'image/jpeg',
 75 		'jpg'     : 'image/jpeg',
 76 		'js'      : 'text/x-javascript',
 77 		'kar'     : 'audio/midi',
 78 		'kil'     : 'application/x-killustrator',
 79 		'kpr'     : 'application/x-kpresenter',
 80 		'kpt'     : 'application/x-kpresenter',
 81 		'ksp'     : 'application/x-kspread',
 82 		'kwd'     : 'application/x-kword',
 83 		'kwt'     : 'application/x-kword',
 84 		'latex'   : 'application/x-latex',
 85 		'lha'     : 'application/octet-stream',
 86 		'lzh'     : 'application/octet-stream',
 87 		'm3u'     : 'audio/x-mpegurl',
 88 		'man'     : 'application/x-troff-man',
 89 		'me'      : 'application/x-troff-me',
 90 		'mesh'    : 'model/mesh',
 91 		'mid'     : 'audio/midi',
 92 		'midi'    : 'audio/midi',
 93 		'mif'     : 'application/vnd.mif',
 94 		'mov'     : 'video/quicktime',
 95 		'movie'   : 'video/x-sgi-movie',
 96 		'mp2'     : 'audio/mpeg',
 97 		'mp3'     : 'audio/mpeg',
 98 		'mp4'     : 'video/mp4',
 99 		'mpe'     : 'video/mpeg',
100 		'mpeg'    : 'video/mpeg',
101 		'mpg'     : 'video/mpeg',
102 		'mpga'    : 'audio/mpeg',
103 		'ms'      : 'application/x-troff-ms',
104 		'msh'     : 'model/mesh',
105 		'mxu'     : 'video/vnd.mpegurl',
106 		'nc'      : 'application/x-netcdf',
107 		'odb'     : 'application/vnd.oasis.opendocument.database',
108 		'odc'     : 'application/vnd.oasis.opendocument.chart',
109 		'odf'     : 'application/vnd.oasis.opendocument.formula',
110 		'odg'     : 'application/vnd.oasis.opendocument.graphics',
111 		'odi'     : 'application/vnd.oasis.opendocument.image',
112 		'odm'     : 'application/vnd.oasis.opendocument.text-master',
113 		'odp'     : 'application/vnd.oasis.opendocument.presentation',
114 		'ods'     : 'application/vnd.oasis.opendocument.spreadsheet',
115 		'odt'     : 'application/vnd.oasis.opendocument.text',
116 		'ogg'     : 'application/ogg',
117 		'ogv'     : 'video/ogg',
118 		'otg'     : 'application/vnd.oasis.opendocument.graphics-template',
119 		'oth'     : 'application/vnd.oasis.opendocument.text-web',
120 		'otp'     : 'application/vnd.oasis.opendocument.presentation-template',
121 		'ots'     : 'application/vnd.oasis.opendocument.spreadsheet-template',
122 		'ott'     : 'application/vnd.oasis.opendocument.text-template',
123 		'pbm'     : 'image/x-portable-bitmap',
124 		'pdb'     : 'chemical/x-pdb',
125 		'pdf'     : 'application/pdf',
126 		'pgm'     : 'image/x-portable-graymap',
127 		'pgn'     : 'application/x-chess-pgn',//
128 		'php'     : 'text/x-httpd-php',
129 		'png'     : 'image/png',
130 		'pnm'     : 'image/x-portable-anymap',
131 		'ppm'     : 'image/x-portable-pixmap',
132 		'ppt'     : 'application/vnd.ms-powerpoint',
133 		'ps'      : 'application/postscript',
134 		'qt'      : 'video/quicktime',
135 		'ra'      : 'audio/x-realaudio',
136 		'ram'     : 'audio/x-pn-realaudio',
137 		'rar'     : 'application/rar',
138 		'ras'     : 'image/x-cmu-raster',
139 		'rgb'     : 'image/x-rgb',
140 		'rm'      : 'audio/x-pn-realaudio',
141 		'roff'    : 'application/x-troff',
142 		'rpm'     : 'application/x-rpm',
143 		'rtf'     : 'text/rtf',
144 		'rtx'     : 'text/richtext',
145 		'sgm'     : 'text/sgml',
146 		'sgml'    : 'text/sgml',
147 		'sh'      : 'application/x-sh',
148 		'shar'    : 'application/x-shar',
149 		'silo'    : 'model/mesh',
150 		'sis'     : 'application/vnd.symbian.install',
151 		'sit'     : 'application/x-stuffit',
152 		'skd'     : 'application/x-koan',
153 		'skm'     : 'application/x-koan',
154 		'skp'     : 'application/x-koan',
155 		'skt'     : 'application/x-koan',
156 		'smi'     : 'application/smil',
157 		'smil'    : 'application/smil',
158 		'snd'     : 'audio/basic',
159 		'so'      : 'application/octet-stream',
160 		'spl'     : 'application/x-futuresplash',
161 		'src'     : 'application/x-wais-source',
162 		'stc'     : 'application/vnd.sun.xml.calc.template',
163 		'std'     : 'application/vnd.sun.xml.draw.template',
164 		'sti'     : 'application/vnd.sun.xml.impress.template',
165 		'stw'     : 'application/vnd.sun.xml.writer.template',
166 		'sv4cpio' : 'application/x-sv4cpio',
167 		'sv4crc'  : 'application/x-sv4crc',
168 		'swf'     : 'application/x-shockwave-flash',
169 		'sxc'     : 'application/vnd.sun.xml.calc',
170 		'sxd'     : 'application/vnd.sun.xml.draw',
171 		'sxg'     : 'application/vnd.sun.xml.writer.global',
172 		'sxi'     : 'application/vnd.sun.xml.impress',
173 		'sxm'     : 'application/vnd.sun.xml.math',
174 		'sxw'     : 'application/vnd.sun.xml.writer',
175 		't'       : 'application/x-troff',
176 		'tar'     : 'application/x-tar',
177 		'tcl'     : 'application/x-tcl',
178 		'tex'     : 'application/x-tex',
179 		'texi'    : 'application/x-texinfo',
180 		'texinfo' : 'application/x-texinfo',
181 		'tgz'     : 'application/x-gzip',
182 		'tif'     : 'image/tiff',
183 		'tiff'    : 'image/tiff',
184 		'torrent' : 'application/x-bittorrent',
185 		'tr'      : 'application/x-troff',
186 		'tsv'     : 'text/tab-separated-values',
187 		'txt'     : 'text/plain',
188 		'ustar'   : 'application/x-ustar',
189 		'vcd'     : 'application/x-cdlink',
190 		'vrml'    : 'model/vrml',
191 		'wav'     : 'audio/x-wav',
192 		'wax'     : 'audio/x-ms-wax',
193 		'wbmp'    : 'image/vnd.wap.wbmp',
194 		'wbxml'   : 'application/vnd.wap.wbxml',
195 		'webm'		: "video/webm",
196 		'wm'      : 'video/x-ms-wm',
197 		'wma'     : 'audio/x-ms-wma',
198 		'wml'     : 'text/vnd.wap.wml',
199 		'wmlc'    : 'application/vnd.wap.wmlc',
200 		'wmls'    : 'text/vnd.wap.wmlscript',
201 		'wmlsc'   : 'application/vnd.wap.wmlscriptc',
202 		'wmv'     : 'video/x-ms-wmv',
203 		'wmx'     : 'video/x-ms-wmx',
204 		'wrl'     : 'model/vrml',
205 		'wvx'     : 'video/x-ms-wvx',
206 		'xbm'     : 'image/x-xbitmap',
207 		'xht'     : 'application/xhtml+xml',
208 		'xhtml'   : 'application/xhtml+xml',
209 		'xls'     : 'application/vnd.ms-excel',
210 		'xml'     : 'text/xml',
211 		'xpm'     : 'image/x-xpixmap',
212 		'xsl'     : 'text/xml',
213 		'xwd'     : 'image/x-xwindowdump',
214 		'xyz'     : 'chemical/x-xyz',
215 		'zip'     : 'application/zip'
216 	};
217 }();
218