Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
55
gaia/apps/operatorvariant/js/resources.js
Executable file
55
gaia/apps/operatorvariant/js/resources.js
Executable file
|
|
@ -0,0 +1,55 @@
|
|||
/* exported Resources */
|
||||
|
||||
'use strict';
|
||||
|
||||
var Resources = {
|
||||
load: function r_load(url, type, onsuccess, onerror) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url, true);
|
||||
xhr.responseType = type;
|
||||
var mimetype = this.getMimetype(url);
|
||||
if (mimetype) {
|
||||
xhr.overrideMimeType(mimetype);
|
||||
}
|
||||
xhr.onload = function() {
|
||||
if (xhr.status === 200) {
|
||||
onsuccess && onsuccess(xhr.response);
|
||||
} else {
|
||||
console.error('Resources.js: Failed to fetch file ' + url + '. ' +
|
||||
xhr.statusText);
|
||||
onerror && onerror(xhr.statusText);
|
||||
}
|
||||
};
|
||||
// Workaround due to https://bugzilla.mozilla.org/show_bug.cgi?id=827243
|
||||
try {
|
||||
xhr.send();
|
||||
} catch (e) {
|
||||
// TODO Remove when 827243 will be fixed.
|
||||
console.error('Resources.js: Failed to fetch file ' + url + '. ' +
|
||||
xhr.statusText);
|
||||
onerror && onerror('404: due to bug 827243');
|
||||
}
|
||||
},
|
||||
|
||||
getMimetype: function r_getMimetype(fileName) {
|
||||
var fileExtension = fileName.split('.').pop();
|
||||
var mimetype = false;
|
||||
if (fileExtension) {
|
||||
switch (fileExtension) {
|
||||
case 'ogg':
|
||||
mimetype = 'audio/ogg';
|
||||
break;
|
||||
case 'json':
|
||||
mimetype = 'application/json';
|
||||
break;
|
||||
case 'mp3':
|
||||
mimetype = 'audio/mpeg';
|
||||
break;
|
||||
case 'mp4':
|
||||
mimetype = 'audio/mp4';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return mimetype;
|
||||
}
|
||||
};
|
||||
Loading…
Reference in a new issue