diff --git a/www/js/app.js b/www/js/app.js index 05bd1ac9..72d1b2ea 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -2616,7 +2616,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki }); } }; - state.selectedArchive.getDirEntryByTitle(title).then(readFile).fail(function (err) { + state.selectedArchive.getDirEntryByTitle(title).then(readFile).catch(function (err) { console.error('Failed to read ' + title, err); messagePort.postMessage({ 'action': 'giveContent', @@ -2935,7 +2935,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki cssBlobCache.set(newURL[0], newURL[1]); injectCSS(); //DO NOT move this: it must run within .then function to pass correct values }); - }).fail(function (e) { + }).catch(function (e) { console.error("could not find DirEntry for CSS : " + title, e); //@TODO Change this to push an array of [title, title] afters simplified code in injectCSS() blobArray.push(title); @@ -3473,7 +3473,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki uiUtil.feedNodeWithBlob(script, 'src', content, 'text/javascript', params.allowHTMLExtraction); }); } - }).fail(function (e) { + }).catch(function (e) { console.error("could not find DirEntry for javascript : " + title, e); }); }); @@ -3537,7 +3537,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki $('.alert').hide(); readArticle(dirEntry); } - }).fail(function () { + }).catch(function () { console.error("Error reading article with title " + title); if (params.appIsLaunching) goToMainArticle(); // Line below prevents bootloop diff --git a/www/js/lib/filecache.js b/www/js/lib/filecache.js index d086deb3..073c048a 100644 --- a/www/js/lib/filecache.js +++ b/www/js/lib/filecache.js @@ -144,16 +144,16 @@ define(['q'], function(Q) { }); }; var readInternal = function(file, begin, end) { - var deferred = Q.defer(); - var reader = new FileReader(); - reader.onload = function(e) { - deferred.resolve(new Uint8Array(e.target.result)); - }; - reader.onerror = reader.onabort = function(e) { - deferred.reject(e); - }; - reader.readAsArrayBuffer(file.slice(begin, end)); - return deferred.promise; + return Q.Promise(function(resolve, reject) { + var reader = new FileReader(); + reader.readAsArrayBuffer(file.slice(begin, end)); + reader.onload = function(e) { + resolve(new Uint8Array(e.target.result)); + }; + reader.onerror = reader.onabort = function(e) { + reject(e); + }; + }); }; return { diff --git a/www/js/lib/images.js b/www/js/lib/images.js index f9cb04ba..bd65f4c4 100644 --- a/www/js/lib/images.js +++ b/www/js/lib/images.js @@ -94,7 +94,7 @@ define(['uiUtil'], function (uiUtil) { image.style.transition = 'opacity 0.5s ease-in'; image.style.opacity = '1'; }); - }).fail(function (e) { + }).catch(function (e) { console.error('Could not find DirEntry for image: ' + title, e); checkBatch(); }); diff --git a/www/js/lib/zimArchive.js b/www/js/lib/zimArchive.js index afce3447..57a04e0a 100644 --- a/www/js/lib/zimArchive.js +++ b/www/js/lib/zimArchive.js @@ -315,7 +315,7 @@ define(['zimfile', 'zimDirEntry', 'util', 'utf8'], callback(data); }); } - }).fail(function (e) { + }).catch(function (e) { console.warn("Metadata with key " + key + " not found in the archive", e); callback(); }); diff --git a/www/js/lib/zimfile.js b/www/js/lib/zimfile.js index c5d6d337..93270a64 100644 --- a/www/js/lib/zimfile.js +++ b/www/js/lib/zimfile.js @@ -241,7 +241,7 @@ define(['xzdec_wrapper', 'util', 'utf8', 'q', 'zimDirEntry'], function(xz, util, } } return typeMap; - }).fail(function(err) { + }).catch(function(err) { console.error('Unable to read MIME type list', err); return new Map; });