lint compliance

This commit is contained in:
Tim de Koning 2012-06-27 11:14:14 +02:00
parent 823db83b19
commit 17c1018eef
3 changed files with 20 additions and 17 deletions

View File

@ -18,7 +18,9 @@
* @return {Promise} A promise that is resolved with {PDFDocumentProxy} object. * @return {Promise} A promise that is resolved with {PDFDocumentProxy} object.
*/ */
PDFJS.getDocument = function getDocument(source) { 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') { if (typeof source === 'string') {
url = source; url = source;
} else if (isArrayBuffer(source)) { } else if (isArrayBuffer(source)) {
@ -49,23 +51,27 @@ PDFJS.getDocument = function getDocument(source) {
{ {
url: url, url: url,
progress: function getPDFProgress(evt) { progress: function getPDFProgress(evt) {
if (evt.lengthComputable) if (evt.lengthComputable) {
workerReadyPromise.progress({ workerReadyPromise.progress({
loaded: evt.loaded, loaded: evt.loaded,
total: evt.total total: evt.total
}); });
}
}, },
error: function getPDFError(e) { error: function getPDFError(e) {
workerReadyPromise.reject('Unexpected server response of ' + workerReadyPromise.reject('Unexpected server response of ' +
e.target.status + '.'); e.target.status + '.');
}, },
headers: headers headers: headers
}, },
function getPDFLoad(data) { function getPDFLoad(data) {
//we have to wait for the WorkerTransport to finalize worker-support detection! This may take a while... // sometimes the pdf has finished downloading before the web worker-test
workerInitializedPromise.then(function () { // has finished. In that case the rendering of the final pdf would cause
transport.sendData(data, parameters); // 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. // Thus, we fallback to a faked worker.
globalScope.PDFJS.disableWorker = true; globalScope.PDFJS.disableWorker = true;
this.setupFakeWorker(); this.setupFakeWorker();
workerInitializedPromise.resolve(); workerInitializedPromise.resolve();
} }
WorkerTransport.prototype = { WorkerTransport.prototype = {
destroy: function WorkerTransport_destroy() { destroy: function WorkerTransport_destroy() {

View File

@ -20,10 +20,6 @@ function MessageHandler(name, comObj) {
warn(data); warn(data);
}]; }];
comObj.onerror = function(event){
throw new Error(event.message + " (" + event.filename + ":" + event.lineno + ")");
};
comObj.onmessage = function messageHandlerComObjOnMessage(event) { comObj.onmessage = function messageHandlerComObjOnMessage(event) {
var data = event.data; var data = event.data;
if (data.isReply) { if (data.isReply) {

View File

@ -6,7 +6,7 @@
// Checking if the typed arrays are supported // Checking if the typed arrays are supported
(function checkTypedArrayCompatibility() { (function checkTypedArrayCompatibility() {
if (typeof Uint8Array !== 'undefined') { 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') { if (typeof Uint8Array.prototype.subarray === 'undefined') {
Uint8Array.prototype.subarray = function subarray(start, end) { Uint8Array.prototype.subarray = function subarray(start, end) {
return new Uint8Array(this.slice(start, end)); return new Uint8Array(this.slice(start, end));
@ -79,9 +79,10 @@
// Object.defineProperty() ? // Object.defineProperty() ?
(function checkObjectDefinePropertyCompatibility() { (function checkObjectDefinePropertyCompatibility() {
// safari 5 cannot use this on DOM objects and thus is unusable, see http://kangax.github.com/es5-compat-table/ // safari 5 cannot use this on DOM objects and thus is unusable,
if ((typeof Object.defineProperty !== 'undefined') && /Safari\/5/.test(navigator.userAgent)) // see http://kangax.github.com/es5-compat-table/
return; if ((typeof Object.defineProperty !== 'undefined') &&
/Safari\/5/.test(navigator.userAgent)) return;
Object.defineProperty = function objectDefineProperty(obj, name, def) { Object.defineProperty = function objectDefineProperty(obj, name, def) {
delete obj[name]; delete obj[name];