Skip to content

Instantly share code, notes, and snippets.

@leejsinclair
Created April 1, 2014 10:54
Show Gist options
  • Save leejsinclair/9911801 to your computer and use it in GitHub Desktop.
Save leejsinclair/9911801 to your computer and use it in GitHub Desktop.
Check if a mime-type/content-type belongs to a document.
var isDocument = (function(){
var cts = [ "application/msword", "application/vnd.ms-excel", "application/vnd.ms-excel.addin.macroEnabled.12", "application/vnd.ms-excel.sheet.binary.macroEnabled.12", "application/vnd.ms-excel.sheet.macroEnabled.12", "application/vnd.ms-excel.template.macroEnabled.12", "application/vnd.ms-powerpoint", "application/vnd.ms-powerpoint.addin.macroEnabled.12", "application/vnd.ms-powerpoint.presentation.macroEnabled.1", "application/vnd.ms-powerpoint.slideshow.macroEnabled.12", "application/vnd.ms-powerpoint.template.macroEnabled.12", "application/vnd.ms-word.template.macroEnabled.12", "application/vnd.oasis.opendocument.chart", "application/vnd.oasis.opendocument.database", "application/vnd.oasis.opendocument.formula", "application/vnd.oasis.opendocument.graphics", "application/vnd.oasis.opendocument.graphics-template", "application/vnd.oasis.opendocument.image", "application/vnd.oasis.opendocument.presentation", "application/vnd.oasis.opendocument.presentation-template", "application/vnd.oasis.opendocument.spreadsheet", "application/vnd.oasis.opendocument.spreadsheet-template", "application/vnd.oasis.opendocument.text", "application/vnd.oasis.opendocument.text-master", "application/vnd.oasis.opendocument.text-template", "application/vnd.oasis.opendocument.text-web", "application/vnd.openofficeorg.extension", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.presentationml.slideshow ", "application/vnd.openxmlformats-officedocument.presentationml.template", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.spreadsheetml.template", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.wordprocessingml.template", "application/vnd.stardivision.calc", "application/vnd.stardivision.draw", "application/vnd.stardivision.impress", "application/vnd.stardivision.math", "application/vnd.stardivision.writer", "application/vnd.stardivision.writer-global", "application/vnd.stepmania.stepchart", "application/vnd.sun.xml.draw", "application/vnd.sun.xml.draw.template", "application/vnd.sun.xml.impress", "application/x-msmetafile", "application/xhtml+xml", "image/bmp", "image/gif", "image/jpeg", "image/png", "image/svg+xml", "image/tiff", "image/x-cmu-raster", "image/x-portable-bitmap", "image/x-portable-graymap", "image/x-portable-pixmap", "image/x-xpixmap", "text/csv"];
return function( fileContentType ) {
return cts.indexOf( fileContentType )>=0;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment