Statistics
| Branch: | Revision:

root / src / pithos / content / mimes.js @ 46:f16f6e0e5b69

History | View | Annotate | Download (5.5 kB)

1
// The Pithos File Manager Firefox Extension is funded by GRNET S.A.
2
// (http://www.grnet.gr)
3
//
4
// Copyright (c) 2009, Christos KK Loverdos, Vassilios Karakoidas.
5
// All rights reserved.
6
//
7
// Redistribution and use in source and binary forms, with or without
8
// modification, are permitted provided that the following conditions are
9
// met:
10
//
11
//   - Redistributions of source code must retain the above copyright
12
//     notice, this list of conditions and the following disclaimer.
13
//   - Redistributions in binary form must reproduce the above
14
//     copyright notice, this list of conditions and the following
15
//     disclaimer in the documentation and/or other materials provided
16
//     with the distribution.
17
//   - Neither the name of GRNET S.A. nor the names of its contributors
18
//     may be used to endorse or promote products derived from this
19
//     software without specific prior written permission.
20
//
21
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32

    
33
mimes = null;
34

    
35
function Mimes() {
36
        // private properties
37
        var mimeList = new Array();
38
        var extList = new Array();
39
        
40
        // public functions
41
        this.getMime = function(key, status) {
42
                if (key == 'directory') {
43
                        if (status) {
44
                                return '../skin/gss/folder_outbox.png';
45
                        } else {
46
                                return '../skin/gss/folder_green.png';
47
                        }
48
                }
49
                
50
                var r = mimeList[key];
51
                if(r == undefined) {
52
                        // assuming that mime type look like 'image/png'
53
                        r = mimeList[key.split('/')[0] + '/'];
54
                }
55
                
56
                if (r != undefined) {
57
                        if(status) {
58
                                return r[1];
59
                        } else { 
60
                                return r[0];
61
                        }
62
                }
63
                
64
                if (status) {
65
                        return '../skin/gss/mimetypes/document_shared.png';
66
                } else {
67
                        return '../skin/gss/mimetypes/document.png';
68
                }
69
        }
70
        
71
        this.getByExtension = function(filename) {
72
                var arr = filename.split('.');
73
                var ext = ('.' + arr[arr.length - 1]).toLowerCase();
74
                var result = extList[ext];
75
                
76
                if (result == undefined) {
77
                        return 'default';
78
                } else {
79
                        return result;
80
                }
81
        }
82
        
83
        // initialization
84
        // extension list
85
        extList['.pdf'] = 'application/pdf';
86
        extList['.xls'] = 'application/vnd.ms-excel';
87
        extList['.doc'] = 'application/msword';
88
        extList['.docx'] = 'application/msword';
89
        extList['.pps'] = 'application/vnd.ms-powerpoint';
90
        extList['.ppt'] = 'application/vnd.ms-powerpoint';
91
        extList['.zip'] = 'application/zip';
92
        extList['.gz'] = 'application/x-gzip';
93
        extList['.gzip'] = 'application/x-gzip';
94
        extList['.tgz'] = 'application/x-gzip';
95
        extList['.tar'] = 'application/x-tar';
96
        extList['.html'] = 'text/html';
97
        extList['.htm'] = 'text/html';
98
        extList['.txt'] = 'text/plain';
99
        extList['.text'] = 'text/plain';
100
        extList['.bat'] = 'text/plain';
101
        extList['.jpg'] = 'image/jpg';
102
        extList['.png'] = 'image/png';
103
        extList['.gif'] = 'image/gif';
104
        extList['.tiff'] = 'image/tiff';
105
        extList['.jpeg'] = 'image/jpeg';
106
        extList['.bmp'] = 'image/bmp';
107
        extList['.ico'] = 'image/ico';
108
        extList['.avi'] = 'video/avi';
109
        extList['.wmv'] = 'video/wmv';
110
        extList['.mkv'] = 'video/mkv';
111
        extList['.mpg'] = 'video/mpg';
112
        extList['.mpeg'] = 'video/mpeg';
113
        extList['.wav'] = 'audio/wav';
114
        extList['.mp3'] = 'audio/mp3';
115
        extList['.mid'] = 'audio/mid';
116
        extList['.ogg'] = 'audio/ogg';
117
        
118
        // mime-type = non-shared, shared
119
        mimeList['default'] = [ '../skin/gss/mimetypes/document.png', '../skin/gss/mimetypes/document_shared.png' ];
120
        mimeList['application/pdf'] = [ '../skin/gss/mimetypes/acroread.png', '../skin/gss/mimetypes/acroread_shared.png' ];
121
        mimeList['application/vnd.ms-excel'] = [ '../skin/gss/mimetypes/log.png', '../skin/gss/mimetypes/log_shared.png' ];
122
        mimeList['application/msword'] = [ '../skin/gss/mimetypes/kcmfontinst.png', '../skin/gss/mimetypes/kcmfontinst_shared.png' ];
123
        mimeList['application/vnd.ms-powerpoint'] = [ '../skin/gss/mimetypes/kpresenter_kpr.png', '../skin/gss/mimetypes/kpresenter_kpr_shared.png' ];
124
        mimeList['application/zip'] = [ '../skin/gss/mimetypes/ark2.png', '../skin/gss/mimetypes/ark2_shared.png' ];
125
        mimeList['application/gzip'] = [ '../skin/gss/mimetypes/ark2.png', '../skin/gss/mimetypes/ark2_shared.png' ];
126
        mimeList['application/x-gzip'] = [ '../skin/gss/mimetypes/ark2.png', '../skin/gss/mimetypes/ark2_shared.png' ];
127
        mimeList['application/x-tar'] = [ '../skin/gss/mimetypes/ark2.png', '../skin/gss/mimetypes/ark2_shared.png' ];
128
        mimeList['application/x-gtar'] = [ '../skin/gss/mimetypes/ark2.png', '../skin/gss/mimetypes/ark2_shared.png' ];
129
        mimeList['text/html'] = [ '../skin/gss/mimetypes/html.png', '../skin/gss/mimetypes/html_shared.png' ];
130
        mimeList['text/plain'] = [ '../skin/gss/mimetypes/txt.png', '../skin/gss/mimetypes/txt_shared.png' ];
131
        mimeList['image/'] = [ '../skin/gss/mimetypes/image.png', '../skin/gss/mimetypes/image_shared.png' ];
132
        mimeList['video/'] = [ '../skin/gss/mimetypes/video2.png', '../skin/gss/mimetypes/video2_shared.png' ];
133
        mimeList['audio/'] = [ '../skin/gss/mimetypes/knotify.png', '../skin/gss/mimetypes/knotify_shared.png' ];
134
}