1var StepModel = Backbone.Epoxy.Model.extend({ 2 3 checkExtension : function(filename){ 4 var filename = filename.split('/'); 5 filename = filename[filename.length - 1]; 6 var extension = filename.split('.').pop().toLowerCase(); 7 8 var impl_type = ''; 9 switch(extension) { 10 11 // 0 = HTML 12 case "html": 13 case "htm": 14 impl_type = 0; 15 break; 16 17 // 3 = XML 18 case "xml": 19 impl_type = 3; 20 break; 21 22 // 4 = XLS 23 case "xlsx": 24 case "xls": 25 case "xlsm": 26 case "xltx": 27 case "xltm": 28 case "xlsb": 29 case "xlam": 30 case "xll": 31 impl_type = 4; 32 break; 33 34 // 5 = PDF 35 case "pdf": 36 impl_type = 5; 37 break; 38 39 // 6 = DOC 40 case "doc": 41 case "docx": 42 case "docm": 43 case "dotx": 44 case "dotm": 45 impl_type = 6; 46 break; 47 48 // 7 = ODT 49 case "odt": 50 impl_type = 7; 51 break; 52 53 // 9 = ODS 54 case "ods": 55 impl_type = 9; 56 break; 57 58 // 10 = CSV 59 case "csv": 60 case "txt": 61 impl_type = 10; 62 break; 63 64 // 11 = KML 65 case "kml": 66 impl_type = 11; 67 break; 68 69 // 12 = KMZ 70 case "kmz": 71 impl_type = 12; 72 break; 73 74 // 18 = IMAGE 75 case "png": 76 case "jpg": 77 case "jpeg": 78 case "gif": 79 case "tif": 80 case "tiff": 81 impl_type = 18; 82 break; 83 84 // 19 = ZIP 85 case "zip": 86 case "rar": 87 case "tar": 88 case "gz": 89 case "gzip": 90 case "7z": 91 impl_type = 19; 92 break; 93 94 // 20 = TSV 95 case "tsv": 96 case "tab": 97 impl_type = 20; 98 break; 99 100 // 24 = RDF 101 case "rdf": 102 impl_type = 24; 103 break; 104 105 // 25 = JSON 106 case "json": 107 case "ajson": 108 impl_type = 25; 109 break; 110 111 } 112 113 return impl_type; 114 }, 115 116 setImplementationTypeByMimeType : function(mimeType){ 117 118 var impl_type = '', 119 mimeType = mimeType.split(";")[0].trim(), 120 end_point = this.get('end_point'); 121 122 switch(mimeType) { 123 124 // 0 = HTML 125 case "text/html": 126 impl_type = 0; 127 break; 128 129 // 3 = XML 130 case "application/xml": 131 impl_type = 3; 132 break; 133 case "text/xml": 134 impl_type = this.checkExtension(end_point); 135 if(impl_type == ''){ 136 impl_type = 3 137 } 138 break; 139 140 // 4 = XLS 141 case "application/vnd.ms-excel": 142 case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": 143 impl_type = 4; 144 break; 145 146 // 5 = PDF 147 case "application/pdf": 148 impl_type = 5; 149 break; 150 151 // 6 = DOC 152 case "application/msword": 153 case "application/vnd.ms-xpsdocument": 154 impl_type = 6; 155 break; 156 157 // 7 = ODT 158 case "application/vnd.oasis.opendocument.text": 159 case "application/vnd.oasis.opendocument.text-web": 160 impl_type = 7; 161 break; 162 163 // 9 = ODS 164 case "application/vnd.oasis.opendocument.spreadsheet": 165 impl_type = 9; 166 break; 167 168 // 10 = CSV / TXT 169 case "text/x-comma-separated-values": 170 case "application/csv": 171 case "text/plain": 172 case "text/csv": 173 impl_type = 10; 174 break; 175 176 // 11 = KML 177 case "application/kml": 178 case "application/vnd.google-earth.kml+xml" : 179 impl_type = 11; 180 break; 181 182 // 12 = KMZ 183 case "application/kmz": 184 case "application/vnd.google-earth.kmz": 185 case "application/vnd.google-earth.kmz .kmz": 186 impl_type = 12; 187 break; 188 189 // 18 = IMAGE 190 case "image/png": 191 case "image/gif": 192 case "image/jpeg": 193 case "image/tiff": 194 impl_type = 18; 195 break; 196 197 // 19 = ZIP 198 case "application/x-compressed": 199 case "application/x-zip-compressed": 200 case "application/zip": 201 case "multipart/x-zip": 202 case "application/x-tar": 203 case "application/x-compressed": 204 case "application/x-gzip": 205 case "application/x-gzip": 206 case "multipart/x-gzip": 207 case "application/x-rar-compressed": 208 case "application/x-7z-compressed": 209 impl_type = 19; 210 break; 211 212 // 20 = TSV 213 case "text/tab-separated-values": 214 impl_type = 20; 215 break; 216 217 // 24 = RDF 218 case "text/turtle": 219 impl_type = 24; 220 break; 221 222 // 25 = JSON 223 case "application/json": 224 impl_type = 25; 225 break; 226 227 // An unknown file type 228 case "application/octet-stream": 229 impl_type = this.checkExtension(end_point); 230 break; 231 232 // Default: set to 0 233 default: 234 impl_type = 0; 235 236 } 237 238 return impl_type; 239 240 } 241 242});
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.