1/** 2 * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors 3 * SPDX-FileCopyrightText: 2015 ownCloud, Inc. 4 * SPDX-License-Identifier: AGPL-3.0-only 5 */ 6 7/** 8 * Namespace to hold functions related to convert mimetype to icons 9 * 10 * @namespace 11 */ 12OC.MimeType = { 13 14 /** 15 * Cache that maps mimeTypes to icon urls 16 */ 17 _mimeTypeIcons: {}, 18 19 /** 20 * Return the file icon we want to use for the given mimeType. 21 * The file needs to be present in the supplied file list 22 * 23 * @param {string} mimeType The mimeType we want an icon for 24 * @param {array} files The available icons in this theme 25 * @return {string} The icon to use or null if there is no match 26 */ 27 _getFile: function(mimeType, files) { 28 var icon = mimeType.replace(new RegExp('/', 'g'), '-'); 29 30 // Generate path 31 if (mimeType === 'dir' && files.includes('folder')) { 32 return 'folder'; 33 } else if (mimeType === 'dir-encrypted' && files.includes('folder-encrypted')) { 34 return 'folder-encrypted'; 35 } else if (mimeType === 'dir-shared' && files.includes('folder-shared')) { 36 return 'folder-shared'; 37 } else if (mimeType === 'dir-public' && files.includes('folder-public')) { 38 return 'folder-public'; 39 } else if ((mimeType === 'dir-external' || mimeType === 'dir-external-root') && files.includes('folder-external')) { 40 return 'folder-external'; 41 } else if (files.includes(icon)) { 42 return icon; 43 } else if (files.includes(icon.split('-')[0])) { 44 return icon.split('-')[0]; 45 } else if (files.includes('file')) { 46 return 'file'; 47 } 48 49 return null; 50 }, 51 52 /** 53 * Return the url to icon of the given mimeType 54 * 55 * @param {string} mimeType The mimeType to get the icon for 56 * @return {string} Url to the icon for mimeType 57 */ 58 getIconUrl: function(mimeType) { 59 if (typeof mimeType === 'undefined') { 60 return undefined; 61 } 62 63 while (mimeType in OC.MimeTypeList.aliases) { 64 mimeType = OC.MimeTypeList.aliases[mimeType]; 65 } 66 67 if (mimeType in OC.MimeType._mimeTypeIcons) { 68 return OC.MimeType._mimeTypeIcons[mimeType]; 69 } 70 71 // First try to get the correct icon from the current theme 72 var gotIcon = null; 73 var path = ''; 74 if (OC.theme.folder !== '' && Array.isArray(OC.MimeTypeList.themes[OC.theme.folder])) { 75 path = OC.getRootPath() + '/themes/' + OC.theme.folder + '/core/img/filetypes/'; 76 var icon = OC.MimeType._getFile(mimeType, OC.MimeTypeList.themes[OC.theme.folder]); 77 78 if (icon !== null) { 79 gotIcon = true; 80 path += icon; 81 } 82 } 83 if(OCA.Theming && gotIcon === null) { 84 path = OC.generateUrl('/apps/theming/img/core/filetypes/'); 85 path += OC.MimeType._getFile(mimeType, OC.MimeTypeList.files); 86 gotIcon = true; 87 } 88 89 // If we do not yet have an icon fall back to the default 90 if (gotIcon === null) { 91 path = OC.getRootPath() + '/core/img/filetypes/'; 92 path += OC.MimeType._getFile(mimeType, OC.MimeTypeList.files); 93 } 94 95 path += '.svg'; 96 97 if(OCA.Theming) { 98 path += "?v=" + OCA.Theming.cacheBuster; 99 } 100 101 // Cache the result 102 OC.MimeType._mimeTypeIcons[mimeType] = path; 103 return path; 104 } 105 106}; 107 108 109/** 110* This file is automatically generated 111* DO NOT EDIT MANUALLY! 112* 113* You can update the list of MimeType Aliases in config/mimetypealiases.json 114* The list of files is fetched from core/img/filetypes 115* To regenerate this file run ./occ maintenance:mimetype:update-js 116*/ 117OC.MimeTypeList={ 118 aliases: { 119 "application/coreldraw": "image", 120 "application/epub+zip": "text", 121 "application/font-sfnt": "font", 122 "application/font-woff": "font", 123 "application/gpx+xml": "location", 124 "application/gzip": "package/x-generic", 125 "application/illustrator": "image", 126 "application/internet-shortcut": "link", 127 "application/javascript": "text/code", 128 "application/json": "text/code", 129 "application/km": "mindmap", 130 "application/msaccess": "file", 131 "application/msexcel": "x-office/spreadsheet", 132 "application/msonenote": "x-office/document", 133 "application/mspowerpoint": "x-office/presentation", 134 "application/msword": "x-office/document", 135 "application/octet-stream": "file", 136 "application/postscript": "image", 137 "application/rss+xml": "application/xml", 138 "application/vnd.android.package-archive": "package/x-generic", 139 "application/vnd.excalidraw+json": "whiteboard", 140 "application/vnd.garmin.tcx+xml": "location", 141 "application/vnd.google-earth.kml+xml": "location", 142 "application/vnd.google-earth.kmz": "location", 143 "application/vnd.lotus-wordpro": "x-office/document", 144 "application/vnd.ms-excel.addin.macroEnabled.12": "x-office/spreadsheet", 145 "application/vnd.ms-excel.sheet.binary.macroEnabled.12": "x-office/spreadsheet", 146 "application/vnd.ms-excel.sheet.macroEnabled.12": "x-office/spreadsheet", 147 "application/vnd.ms-excel.template.macroEnabled.12": "x-office/spreadsheet", 148 "application/vnd.ms-excel": "x-office/spreadsheet", 149 "application/vnd.ms-fontobject": "font", 150 "application/vnd.ms-powerpoint.addin.macroEnabled.12": "x-office/presentation", 151 "application/vnd.ms-powerpoint.presentation.macroEnabled.12": "x-office/presentation", 152 "application/vnd.ms-powerpoint.slideshow.macroEnabled.12": "x-office/presentation", 153 "application/vnd.ms-powerpoint.template.macroEnabled.12": "x-office/presentation", 154 "application/vnd.ms-powerpoint": "x-office/presentation", 155 "application/vnd.ms-visio.drawing.macroEnabled.12": "application/vnd.visio", 156 "application/vnd.ms-visio.drawing": "application/vnd.visio", 157 "application/vnd.ms-visio.stencil.macroEnabled.12": "application/vnd.visio", 158 "application/vnd.ms-visio.stencil": "application/vnd.visio", 159 "application/vnd.ms-visio.template.macroEnabled.12": "application/vnd.visio", 160 "application/vnd.ms-visio.template": "application/vnd.visio", 161 "application/vnd.ms-word.document.macroEnabled.12": "x-office/document", 162 "application/vnd.ms-word.template.macroEnabled.12": "x-office/document", 163 "application/vnd.oasis.opendocument.graphics-flat-xml": "x-office/drawing", 164 "application/vnd.oasis.opendocument.graphics-template": "x-office/drawing", 165 "application/vnd.oasis.opendocument.graphics": "x-office/drawing", 166 "application/vnd.oasis.opendocument.presentation-flat-xml": "x-office/presentation", 167 "application/vnd.oasis.opendocument.presentation-template": "x-office/presentation", 168 "application/vnd.oasis.opendocument.presentation": "x-office/presentation", 169 "application/vnd.oasis.opendocument.spreadsheet-flat-xml": "x-office/spreadsheet", 170 "application/vnd.oasis.opendocument.spreadsheet-template": "x-office/spreadsheet", 171 "application/vnd.oasis.opendocument.spreadsheet": "x-office/spreadsheet", 172 "application/vnd.oasis.opendocument.text-flat-xml": "x-office/document", 173 "application/vnd.oasis.opendocument.text-master": "x-office/document", 174 "application/vnd.oasis.opendocument.text-template": "x-office/document", 175 "application/vnd.oasis.opendocument.text-web": "x-office/document", 176 "application/vnd.oasis.opendocument.text": "x-office/document", 177 "application/vnd.openxmlformats-officedocument.presentationml.presentation": "x-office/presentation", 178 "application/vnd.openxmlformats-officedocument.presentationml.slideshow": "x-office/presentation", 179 "application/vnd.openxmlformats-officedocument.presentationml.template": "x-office/presentation", 180 "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "x-office/spreadsheet", 181 "application/vnd.openxmlformats-officedocument.spreadsheetml.template": "x-office/spreadsheet", 182 "application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf": "x-office/form-template", 183 "application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform": "x-office/form", 184 "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "x-office/document", 185 "application/vnd.openxmlformats-officedocument.wordprocessingml.template": "x-office/document", 186 "application/vnd.visio": "x-office/document", 187 "application/vnd.wordperfect": "x-office/document", 188 "application/vnd.xmind.workbook": "mindmap", 189 "application/x-7z-compressed": "package/x-generic", 190 "application/x-bzip2": "package/x-generic", 191 "application/x-cbr": "text", 192 "application/x-dcraw": "image", 193 "application/x-deb": "package/x-generic", 194 "application/x-fictionbook+xml": "text", 195 "application/x-font": "font", 196 "application/x-freemind": "mindmap", 197 "application/x-gimp": "image", 198 "application/x-gzip": "application/gzip", 199 "application/x-iwork-keynote-sffkey": "x-office/presentation", 200 "application/x-iwork-numbers-sffnumbers": "x-office/spreadsheet", 201 "application/x-iwork-pages-sffpages": "x-office/document", 202 "application/x-mobipocket-ebook": "text", 203 "application/x-perl": "text/code", 204 "application/x-photoshop": "image", 205 "application/x-php": "text/code", 206 "application/x-rar-compressed": "package/x-generic", 207 "application/x-tar": "package/x-generic", 208 "application/x-tex": "text", 209 "application/xml": "text/html", 210 "application/yaml": "text/code", 211 "application/zip": "package/x-generic", 212 "application/zstd": "package/x-generic", 213 "database": "file", 214 "httpd/unix-directory": "dir", 215 "image/targa": "image/tga", 216 "image/x-emf": "image/emf", 217 "text/css": "text/code", 218 "text/csv": "x-office/spreadsheet", 219 "text/html": "text/code", 220 "text/x-c": "text/code", 221 "text/x-c++src": "text/code", 222 "text/x-h": "text/code", 223 "text/x-java-source": "text/code", 224 "text/x-ldif": "text/code", 225 "text/x-nfo": "text/code", 226 "text/x-python": "text/code", 227 "text/x-rst": "text", 228 "text/x-shellscript": "text/code", 229 "web": "text/code" 230}, 231 files: [ 232 "application", 233 "application-pdf", 234 "audio", 235 "file", 236 "folder", 237 "folder-drag-accept", 238 "folder-encrypted", 239 "folder-external", 240 "folder-public", 241 "folder-shared", 242 "folder-starred", 243 "font", 244 "image", 245 "link", 246 "location", 247 "mindmap", 248 "package-x-generic", 249 "text", 250 "text-calendar", 251 "text-code", 252 "text-vcard", 253 "video", 254 "whiteboard", 255 "x-office-document", 256 "x-office-drawing", 257 "x-office-form", 258 "x-office-form-template", 259 "x-office-presentation", 260 "x-office-spreadsheet" 261], 262 themes: [], 263 names: {'application/cmd': t('core', "Windows Command Script"), 264'application/epub+zip': t('core', "Electronic book document"), 265'application/font-sfnt': t('core', "TrueType Font Collection"), 266'application/font-woff': t('core', "Web Open Font Format"), 267'application/gpx+xml': t('core', "GPX geographic data"), 268'application/gzip': t('core', "Gzip archive"), 269'application/illustrator': t('core', "Adobe Illustrator document"), 270'application/java': t('core', "Java source code"), 271'application/javascript': t('core', "JavaScript source code"), 272'application/json': t('core', "JSON document"), 273'application/msaccess': t('core', "Microsoft Access database"), 274'application/msonenote': t('core', "Microsoft OneNote document"), 275'application/msword': t('core', "Microsoft Word document"), 276'application/octet-stream': t('core', "Unknown"), 277'application/pdf': t('core', "PDF document"), 278'application/postscript': t('core', "PostScript document"), 279'application/rss+xml': t('core', "RSS summary"), 280'application/vnd.android.package-archive': t('core', "Android package"), 281'application/vnd.google-earth.kml+xml': t('core', "KML geographic data"), 282'application/vnd.google-earth.kmz': t('core', "KML geographic compressed data"), 283'application/vnd.lotus-wordpro': t('core', "Lotus Word Pro document"), 284'application/vnd.ms-excel': t('core', "Excel spreadsheet"), 285'application/vnd.ms-excel.addin.macroEnabled.12': t('core', "Excel add-in"), 286'application/vnd.ms-excel.sheet.binary.macroEnabled.12': t('core', "Excel 2007 binary spreadsheet"), 287'application/vnd.ms-excel.sheet.macroEnabled.12': t('core', "Excel spreadsheet"), 288'application/vnd.ms-excel.template.macroEnabled.12': t('core', "Excel spreadsheet template"), 289'application/vnd.ms-outlook': t('core', "Outlook Message"), 290'application/vnd.ms-powerpoint': t('core', "PowerPoint presentation"), 291'application/vnd.ms-powerpoint.addin.macroEnabled.12': t('core', "PowerPoint add-in"), 292'application/vnd.ms-powerpoint.presentation.macroEnabled.12': t('core', "PowerPoint presentation"), 293'application/vnd.ms-powerpoint.slideshow.macroEnabled.12': t('core', "PowerPoint presentation"), 294'application/vnd.ms-powerpoint.template.macroEnabled.12': t('core', "PowerPoint presentation template"), 295'application/vnd.ms-word.document.macroEnabled.12': t('core', "Word document"), 296'application/vnd.oasis.opendocument.formula': t('core', "ODF formula"), 297'application/vnd.oasis.opendocument.graphics': t('core', "ODG drawing"), 298'application/vnd.oasis.opendocument.graphics-flat-xml': t('core', "ODG drawing (Flat XML)"), 299'application/vnd.oasis.opendocument.graphics-template': t('core', "ODG template"), 300'application/vnd.oasis.opendocument.presentation': t('core', "ODP presentation"), 301'application/vnd.oasis.opendocument.presentation-flat-xml': t('core', "ODP presentation (Flat XML)"), 302'application/vnd.oasis.opendocument.presentation-template': t('core', "ODP template"), 303'application/vnd.oasis.opendocument.spreadsheet': t('core', "ODS spreadsheet"), 304'application/vnd.oasis.opendocument.spreadsheet-flat-xml': t('core', "ODS spreadsheet (Flat XML)"), 305'application/vnd.oasis.opendocument.spreadsheet-template': t('core', "ODS template"), 306'application/vnd.oasis.opendocument.text': t('core', "ODT document"), 307'application/vnd.oasis.opendocument.text-flat-xml': t('core', "ODT document (Flat XML)"), 308'application/vnd.oasis.opendocument.text-template': t('core', "ODT template"), 309'application/vnd.openxmlformats-officedocument.presentationml.presentation': t('core', "PowerPoint 2007 presentation"), 310'application/vnd.openxmlformats-officedocument.presentationml.slideshow': t('core', "PowerPoint 2007 show"), 311'application/vnd.openxmlformats-officedocument.presentationml.template': t('core', "PowerPoint 2007 presentation template"), 312'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': t('core', "Excel 2007 spreadsheet"), 313'application/vnd.openxmlformats-officedocument.spreadsheetml.template': t('core', "Excel 2007 spreadsheet template"), 314'application/vnd.openxmlformats-officedocument.wordprocessingml.document': t('core', "Word 2007 document"), 315'application/vnd.openxmlformats-officedocument.wordprocessingml.template': t('core', "Word 2007 document template"), 316'application/vnd.visio': t('core', "Microsoft Visio document"), 317'application/vnd.wordperfect': t('core', "WordPerfect document"), 318'application/x-7z-compressed': t('core', "7-zip archive"), 319'application/x-blender': t('core', "Blender scene"), 320'application/x-bzip2': t('core', "Bzip2 archive"), 321'application/x-deb': t('core', "Debian package"), 322'application/x-fictionbook+xml': t('core', "FictionBook document"), 323'application/x-font': t('core', "Unknown font"), 324'application/x-krita': t('core', "Krita document"), 325'application/x-mobipocket-ebook': t('core', "Mobipocket e-book"), 326'application/x-msi': t('core', "Windows Installer package"), 327'application/x-perl': t('core', "Perl script"), 328'application/x-php': t('core', "PHP script"), 329'application/x-tar': t('core', "Tar archive"), 330'application/xml': t('core', "XML document"), 331'application/yaml': t('core', "YAML document"), 332'application/zip': t('core', "Zip archive"), 333'application/zstd': t('core', "Zstandard archive"), 334'audio/aac': t('core', "AAC audio"), 335'audio/flac': t('core', "FLAC audio"), 336'audio/mp4': t('core', "MPEG-4 audio"), 337'audio/mpeg': t('core', "MP3 audio"), 338'audio/ogg': t('core', "Ogg audio"), 339'audio/wav': t('core', "RIFF\/WAVe standard Audio"), 340'audio/webm': t('core', "WebM audio"), 341'audio/x-scpls': t('core', "MP3 ShoutCast playlist"), 342'image/bmp': t('core', "Windows BMP image"), 343'image/bpg': t('core', "Better Portable Graphics image"), 344'image/emf': t('core', "EMF image"), 345'image/gif': t('core', "GIF image"), 346'image/heic': t('core', "HEIC image"), 347'image/heif': t('core', "HEIF image"), 348'image/jp2': t('core', "JPEG-2000 JP2 image"), 349'image/jpeg': t('core', "JPEG image"), 350'image/png': t('core', "PNG image"), 351'image/svg+xml': t('core', "SVG image"), 352'image/tga': t('core', "Truevision Targa image"), 353'image/tiff': t('core', "TIFF image"), 354'image/webp': t('core', "WebP image"), 355'image/x-dc
355raw': t('core', "Digital raw image"), 356'image/x-icon': t('core', "Windows Icon"), 357'message/rfc822': t('core', "Email message"), 358'text/calendar': t('core', "VCS\/ICS calendar"), 359'text/css': t('core', "CSS stylesheet"), 360'text/csv': t('core', "CSV document"), 361'text/html': t('core', "HTML document"), 362'text/markdown': t('core', "Markdown document"), 363'text/org': t('core', "Org-mode file"), 364'text/plain': t('core', "Plain text document"), 365'text/rtf': t('core', "Rich Text document"), 366'text/vcard': t('core', "Electronic business card"), 367'text/x-c++src': t('core', "C++ source code"), 368'text/x-java-source': t('core', "Java source code"), 369'text/x-ldif': t('core', "LDIF address book"), 370'text/x-nfo': t('core', "NFO document"), 371'text/x-php': t('core', "PHP source"), 372'text/x-python': t('core', "Python script"), 373'text/x-rst': t('core', "ReStructuredText document"), 374'video/3gpp': t('core', "3GPP multimedia file"), 375'video/MP2T': t('core', "MPEG video"), 376'video/dv': t('core', "DV video"), 377'video/mp2t': t('core', "MPEG-2 transport stream"), 378'video/mp4': t('core', "MPEG-4 video"), 379'video/mpeg': t('core', "MPEG video"), 380'video/ogg': t('core', "Ogg video"), 381'video/quicktime': t('core', "QuickTime video"), 382'video/webm': t('core', "WebM video"), 383'video/x-flv': t('core', "Flash video"), 384'video/x-matroska': t('core', "Matroska video"), 385'video/x-ms-wmv': t('core', "Windows Media video"), 386'video/x-msvideo': t('core', "AVI video"), 387}, 388}; 389 390 391/** 392 * SPDX-FileCopyrightText: 2016 ownCloud Inc. 393 * SPDX-License-Identifier: AGPL-3.0-or-later 394 */ 395 396/* global Select2 */ 397 398/** 399 * Select2 extension for toggling values in a multi-select dropdown 400 */ 401(function(Select2) { 402 403 var Select2FindHighlightableChoices = Select2.class.multi.prototype.findHighlightableChoices; 404 Select2.class.multi.prototype.findHighlightableChoices = function () { 405 if (this.opts.toggleSelect) { 406 return this.results.find('.select2-result-selectable:not(.select2-disabled)'); 407 } 408 return Select2FindHighlightableChoices.apply(this, arguments); 409 }; 410 411 var Select2TriggerSelect = Select2.class.multi.prototype.triggerSelect; 412 Select2.class.multi.prototype.triggerSelect = function (data) { 413 if (this.opts.toggleSelect && this.val().indexOf(this.id(data)) !== -1) { 414 var self = this; 415 var val = this.id(data); 416 417 var selectionEls = this.container.find('.select2-search-choice').filter(function() { 418 return (self.id($(this).data('select2-data')) === val); 419 }); 420 421 if (this.unselect(selectionEls)) { 422 // also unselect in dropdown 423 this.results.find('.select2-result.select2-selected').each(function () { 424 var $this = $(this); 425 if (self.id($this.data('select2-data')) === val) { 426 $this.removeClass('select2-selected'); 427 } 428 }); 429 this.clearSearch(); 430 } 431 432 return false; 433 } else { 434 return Select2TriggerSelect.apply(this, arguments); 435 } 436 }; 437 438})(Select2); 439 440 441
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.