20 import Lomiri.Components 1.3
21 import Lomiri.Content 1.1 as CH
25 function resolveType(fileUrl) {
26 console.log(
"resolveContentType for file", fileUrl)
27 var extension = d.__fileExtension(fileUrl)
28 extension = extension.toLowerCase()
29 console.log(
"file extension:", extension)
30 var contentType = d.contentMap[extension]
32 if (contentType === undefined) {
33 console.log(
"Unrecognized extension", extension)
34 contentType = CH.ContentType.All
37 console.log(
"returning contentType:", contentType)
45 function __fileExtension(fileUrl) {
46 var lastDotIndex = fileUrl.lastIndexOf(
'.')
47 return lastDotIndex > -1 ? fileUrl.substring(lastDotIndex + 1) :
''
50 property var contentMap: {
51 'png': CH.ContentType.Pictures,
52 'jpg': CH.ContentType.Pictures,
53 'jpeg': CH.ContentType.Pictures,
54 'bmp': CH.ContentType.Pictures,
55 'gif': CH.ContentType.Pictures,
57 'mp3': CH.ContentType.Music,
58 'ogg': CH.ContentType.Music,
59 'wav': CH.ContentType.Music,
60 'm4a': CH.ContentType.Music,
61 'opus': CH.ContentType.Music,
62 'flac': CH.ContentType.Music,
64 'avi': CH.ContentType.Videos,
65 'mpeg': CH.ContentType.Videos,
66 'mp4': CH.ContentType.Videos,
67 'mkv': CH.ContentType.Videos,
68 'mov': CH.ContentType.Videos,
69 'wmv': CH.ContentType.Videos,
71 'txt': CH.ContentType.Documents,
72 'doc': CH.ContentType.Documents,
73 'docx': CH.ContentType.Documents,
74 'xls': CH.ContentType.Documents,
75 'xlsx': CH.ContentType.Documents,
76 'ppt': CH.ContentType.Documents,
77 'pptx': CH.ContentType.Documents,
78 'pdf': CH.ContentType.Documents,
79 'odt': CH.ContentType.Documents,
80 'ott': CH.ContentType.Documents,
81 'oth': CH.ContentType.Documents,
82 'ods': CH.ContentType.Documents,
83 'ots': CH.ContentType.Documents,
84 'html': CH.ContentType.Documents,
85 'odp': CH.ContentType.Documents,
86 'otp': CH.ContentType.Documents,
87 'odf': CH.ContentType.Documents,
88 'odg': CH.ContentType.Documents,
89 'otg': CH.ContentType.Documents,
90 'odm': CH.ContentType.Documents,
92 'vcard': CH.ContentType.Contacts,
93 'vcf': CH.ContentType.Contacts