]> git.parisson.com Git - pdf.js.git/commitdiff
lint compliance
authorTim de Koning <github@kingsquare.nl>
Wed, 27 Jun 2012 09:14:14 +0000 (11:14 +0200)
committerTim de Koning <github@kingsquare.nl>
Wed, 27 Jun 2012 09:14:14 +0000 (11:14 +0200)
src/api.js
src/worker.js
web/compatibility.js

index 88cc6e288569d25bf2e99f82dd73c57af85bddef..1d166f0662175b53f1b5a81bcd07be118a123637 100644 (file)
@@ -18,7 +18,9 @@
  * @return {Promise} A promise that is resolved with {PDFDocumentProxy} object.
  */
 PDFJS.getDocument = function getDocument(source) {
-  var url, data, headers, password, parameters = {}, workerInitializedPromise, workerReadyPromise, transport;
+  var url, data, headers, password, parameters = {}, workerInitializedPromise,
+    workerReadyPromise, transport;
+
   if (typeof source === 'string') {
     url = source;
   } else if (isArrayBuffer(source)) {
@@ -49,23 +51,27 @@ PDFJS.getDocument = function getDocument(source) {
       {
         url: url,
         progress: function getPDFProgress(evt) {
-          if (evt.lengthComputable)
-                         workerReadyPromise.progress({
+          if (evt.lengthComputable) {
+            workerReadyPromise.progress({
               loaded: evt.loaded,
               total: evt.total
             });
+          }
         },
         error: function getPDFError(e) {
-                       workerReadyPromise.reject('Unexpected server response of ' +
+          workerReadyPromise.reject('Unexpected server response of ' +
             e.target.status + '.');
         },
         headers: headers
       },
       function getPDFLoad(data) {
-               //we have to wait for the WorkerTransport to finalize worker-support detection! This may take a while...
-               workerInitializedPromise.then(function () {
-               transport.sendData(data, parameters);
-               });
+        // sometimes the pdf has finished downloading before the web worker-test
+        // has finished. In that case the rendering of the final pdf would cause
+        // errors. We have to wait for the WorkerTransport to finalize worker-
+        // support detection
+        workerInitializedPromise.then(function workerInitialized() {
+          transport.sendData(data, parameters);
+        });
       });
   }
 
@@ -479,7 +485,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
     // Thus, we fallback to a faked worker.
     globalScope.PDFJS.disableWorker = true;
     this.setupFakeWorker();
-       workerInitializedPromise.resolve();
+    workerInitializedPromise.resolve();
   }
   WorkerTransport.prototype = {
     destroy: function WorkerTransport_destroy() {
index 161814f69b451d39c30a8bdd8e5d7edb1edd93e1..c1dfa79af5b1523f74269f17241ec1e589cf9e9e 100644 (file)
@@ -20,10 +20,6 @@ function MessageHandler(name, comObj) {
     warn(data);
   }];
 
-  comObj.onerror = function(event){
-    throw new Error(event.message + " (" + event.filename + ":" + event.lineno + ")");
-  };
-
   comObj.onmessage = function messageHandlerComObjOnMessage(event) {
     var data = event.data;
     if (data.isReply) {
index 39580ef2a4588ab8ac6ba9279111af464f114200..ed4fae3389024e6581c9ad9fe8c1578d365cb9eb 100644 (file)
@@ -6,7 +6,7 @@
 // Checking if the typed arrays are supported
 (function checkTypedArrayCompatibility() {
   if (typeof Uint8Array !== 'undefined') {
-    // some mobile versions do not support subarray (e.g. safari 5 / iPhone / iPad)
+    // some mobile versions do not support subarray (e.g. safari 5 / iOS)
     if (typeof Uint8Array.prototype.subarray === 'undefined') {
         Uint8Array.prototype.subarray = function subarray(start, end) {
           return new Uint8Array(this.slice(start, end));
 
 // Object.defineProperty() ?
 (function checkObjectDefinePropertyCompatibility() {
-  // safari 5 cannot use this on DOM objects and thus is unusable, see http://kangax.github.com/es5-compat-table/
-  if ((typeof Object.defineProperty !== 'undefined') && /Safari\/5/.test(navigator.userAgent))
-    return;
+  // safari 5 cannot use this on DOM objects and thus is unusable,
+  // see http://kangax.github.com/es5-compat-table/
+  if ((typeof Object.defineProperty !== 'undefined') &&
+    /Safari\/5/.test(navigator.userAgent)) return;
 
   Object.defineProperty = function objectDefineProperty(obj, name, def) {
     delete obj[name];