/*
-** $Id: pz2.js,v 1.57 2007-09-14 09:46:49 jakub Exp $
+** $Id: pz2.js,v 1.59 2007-09-28 10:14:09 jakub Exp $
** pz2.js - pazpar2's javascript client library.
*/
pz2.prototype =
{
+ //error handler for async error throws
+ throwError: function (errMsg, errCode)
+ {
+ var err = new Error(errMsg);
+ if (errCode) err.code = errCode;
+
+ if (__myself.errorHandler) {
+ __myself.errorHandler(err);
+ }
+ else {
+ throw err;
+ }
+ },
+
// stop activity by clearing tiemouts
stop: function ()
{
else
// if it gets here the http return code was 200 (pz2 errors are 417)
// but the response was invalid, it should never occur
- setTimeout("__myself.init()", 1000);
+ // setTimeout("__myself.init()", 1000);
+ __myself.throwError('Init failed. Malformed WS resonse.', 110);
}
);
// when through proxy no need to init
else
// if it gets here the http return code was 200 (pz2 errors are 417)
// but the response was invalid, it should never occur
- setTimeout("__myself.ping()", 1000);
+ // setTimeout("__myself.ping()", 1000);
+ __myself.throwError('Ping failed. Malformed WS resonse.', 111);
}
);
},
else
// if it gets here the http return code was 200 (pz2 errors are 417)
// but the response was invalid, it should never occur
- setTimeout("__myself.search(__myself.currQuery)", 500);
+ // setTimeout("__myself.search(__myself.currQuery)", 500);
+ __myself.throwError('Search failed. Malformed WS resonse.', 112);
}
);
},
else
// if it gets here the http return code was 200 (pz2 errors are 417)
// but the response was invalid, it should never occur
- __myself.statTimer = setTimeout("__myself.stat()", __myself.statTime / 4);
+ //__myself.statTimer = setTimeout("__myself.stat()", __myself.statTime / 4);
+ __myself.throwError('Stat failed. Malformed WS resonse.', 113);
}
);
},
else
// if it gets here the http return code was 200 (pz2 errors are 417)
// but the response was invalid, it should never occur
- __myself.showTimer = setTimeout("__myself.show()", __myself.showTime / 4);
+ // __myself.showTimer = setTimeout("__myself.show()", __myself.showTime / 4);
+ __myself.throwError('Show failed. Malformed WS resonse.', 114);
}
);
},
else
// if it gets here the http return code was 200 (pz2 errors are 417)
// but the response was invalid, it should never occur
- setTimeout("__myself.record(__myself.currRecID)", 500);
+ // setTimeout("__myself.record(__myself.currRecID)", 500);
+ __myself.throwError('Record failed. Malformed WS resonse.', 115);
}
);
},
else
// if it gets here the http return code was 200 (pz2 errors are 417)
// but the response was invalid, it should never occur
- __myself.termTimer = setTimeout("__myself.termlist()", __myself.termTime / 4);
+ // __myself.termTimer = setTimeout("__myself.termlist()", __myself.termTime / 4);
+ __myself.throwError('Termlist failed. Malformed WS resonse.', 116);
}
);
else
// if it gets here the http return code was 200 (pz2 errors are 417)
// but the response was invalid, it should never occur
- __myself.bytargetTimer = setTimeout("__myself.bytarget()", __myself.bytargetTime / 4);
+ // __myself.bytargetTimer = setTimeout("__myself.bytarget()", __myself.bytargetTime / 4);
+ __myself.throwError('Bytarget failed. Malformed WS resonse.', 117);
}
);
},
return doc;
}
+DOMDoc.transformToDoc = function (xmlDoc, xslDoc)
+{
+ if ( window.XSLTProcessor ) {
+ var proc = new XSLTProcessor();
+ proc.importStylesheet( xslDoc );
+ return proc.transformToDocument(xmlDoc);
+ } else if ( window.ActiveXObject ) {
+ return document.parseXmlFromString(xmlDoc.transformNode(xslDoc));
+ } else {
+ alert( 'Unable to perform XSLT transformation in this browser' );
+ }
+}
+
// DOMElement
Element_removeFromDoc = function (DOM_Element)