commit cb647aa6077a6d2d53bec9b0197362aa122c1596
parent ed47e0c84c899fac6160efefcf1c882d0d3a9ba6
Author: Simon Kornblith <simon@simonster.com>
Date: Mon, 26 Jun 2006 16:32:19 +0000
remove vestigial code pieces and make usage clearer for Scholar.Utilities.HTTP
Diffstat:
1 file changed, 32 insertions(+), 18 deletions(-)
diff --git a/chrome/chromeFiles/content/scholar/xpcom/utilities.js b/chrome/chromeFiles/content/scholar/xpcom/utilities.js
@@ -968,8 +968,15 @@ Scholar.Utilities.HTTP = new function() {
* Send an HTTP GET request via XMLHTTPRequest
*
* Returns false if browser is offline
+ *
+ * doGet can be called as:
+ * Scholar.Utilities.HTTP.doGet(url, onDone)
+ * Scholar.Utilities.HTTP.doGet(url, onStatus, onDone)
+ *
+ * The status handler, which doesn't really serve a very noticeable purpose
+ * in our code, is required for compatiblity with the Piggy Bank project
**/
- function doGet(url, onStatus, onDone) {
+ function doGet(url, callback1, callback2) {
if (this.browserIsOffline()){
return false;
}
@@ -980,7 +987,7 @@ Scholar.Utilities.HTTP = new function() {
var test = xmlhttp.open('GET', url, true);
xmlhttp.onreadystatechange = function(){
- _stateChange(xmlhttp, onStatus, onDone);
+ _stateChange(xmlhttp, callback1, callback2);
};
xmlhttp.send(null);
@@ -993,23 +1000,26 @@ Scholar.Utilities.HTTP = new function() {
* Send an HTTP POST request via XMLHTTPRequest
*
* Returns false if browser is offline
+ *
+ * doPost can be called as:
+ * Scholar.Utilities.HTTP.doPost(url, body, onDone)
+ * Scholar.Utilities.HTTP.doPost(url, body, onStatus, onDone)
+ *
+ * The status handler, which doesn't really serve a very noticeable purpose
+ * in our code, is required for compatiblity with the Piggy Bank project
**/
- function doPost(url, body, onStatus, onDone) {
+ function doPost(url, body, callback1, callback2) {
if (this.browserIsOffline()){
return false;
}
- if(this.proxiedURL) {
- url = Scholar.Ingester.ProxyMonitor.properToProxy(url);
- }
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance();
xmlhttp.open('POST', url, true);
- var me = this;
xmlhttp.onreadystatechange = function(){
- _stateChange(xmlhttp, onStatus, onDone);
+ _stateChange(xmlhttp, callback1, callback2);
};
xmlhttp.send(body);
@@ -1021,24 +1031,25 @@ Scholar.Utilities.HTTP = new function() {
/**
* Send an HTTP OPTIONS request via XMLHTTPRequest
*
- * Returns false if browser is offline
+ * doOptions can be called as:
+ * Scholar.Utilities.HTTP.doOptions(url, body, onDone)
+ * Scholar.Utilities.HTTP.doOptions(url, body, onStatus, onDone)
+ *
+ * The status handler, which doesn't really serve a very noticeable purpose
+ * in our code, is required for compatiblity with the Piggy Bank project
**/
- function doOptions(url, body, onStatus, onDone) {
+ function doOptions(url, body, callback1, callback2) {
if (this.browserIsOffline()){
return false;
}
- if(this.proxiedURL) {
- url = Scholar.Ingester.ProxyMonitor.properToProxy(url);
- }
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance();
xmlhttp.open('OPTIONS', url, true);
- var me = this;
xmlhttp.onreadystatechange = function(){
- _stateChange(xmlhttp, onStatus, onDone);
+ _stateChange(xmlhttp, callback1, callback2);
};
xmlhttp.send(body);
@@ -1053,10 +1064,13 @@ Scholar.Utilities.HTTP = new function() {
}
- function _stateChange(xmlhttp, onStatus, onDone){
- if(!onDone) {
+ function _stateChange(xmlhttp, callback1, callback2){
+ if(callback2) {
+ onStatus = callback1;
+ onDone = callback2;
+ } else {
+ onDone = callback1;
onStatus = null;
- onDone = onStatus;
}
switch (xmlhttp.readyState){
// Request not yet made