Added the XHR upload attribute
Added the XHR upload attribute as defined by https://xhr.spec.whatwg.org/#the-upload-attribute and documented at MDN here https://developer.mozilla.org/de/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Monitoring_progress
This is required by https://github.com/doedje/jquery.soap/blob/master/jquery.soap.js#L281 and will throw a exception if not present.
This closes #84
diff --git a/template/cordovalib/XHRHelper.cs b/template/cordovalib/XHRHelper.cs
index 50120ca..02e115c 100644
--- a/template/cordovalib/XHRHelper.cs
+++ b/template/cordovalib/XHRHelper.cs
@@ -153,6 +153,28 @@
this.wrappedXHR.onreadystatechange = function() {
self.changeReadyState(self.wrappedXHR.readyState);
};
+ if (this.wrappedXHR && this.wrappedXHR.upload) {
+ this.wrappedXHR.upload.onprogress = function(e) {
+ if (typeof self.upload.onprogress === 'function') {
+ self.upload.onprogress(e);
+ }
+ };
+ this.wrappedXHR.upload.onload = function(e) {
+ if (typeof self.upload.onload === 'function') {
+ self.upload.onload(e);
+ }
+ };
+ this.wrappedXHR.upload.onerror = function(e) {
+ if (typeof self.upload.onerror === 'function') {
+ self.upload.onerror(e);
+ }
+ };
+ this.wrappedXHR.upload.onabort = function(e) {
+ if (typeof self.upload.onabort === 'function') {
+ self.upload.onabort(e);
+ }
+ };
+ }
}
return this.wrappedXHR.open(reqType, uri, isAsync, user, password);
}
@@ -276,7 +298,14 @@
this.isAsync ? setTimeout(funk, 0) : funk();
}
},
- status: 404
+ status: 404,
+ upload: {
+ addEventListener: function (type, listener, useCapture){
+ if (this.wrappedXHR && this.wrappedXHR.upload) {
+ this.wrappedXHR.upload.addEventListener(type, listener, useCapture);
+ }
+ }
+ }
};
}
})(window, document); ";