RetroZilla/extensions/webservices/proxy/tests/primeproxytest.html

66 lines
1.7 KiB
HTML
Raw Normal View History

2015-10-21 05:03:22 +02:00
<script>
var factory = new WebServiceProxyFactory();
var lastNumber = 0;
var listener = {
onLoad : function(proxy) {
window.proxy = proxy;
ask();
},
onError : function(e) {
alert("error: "+e);
}
};
function ask() {
var talkToMe = {
isPrimeNumberCallback : function(isPrime, cx) {
// just a stupid test of the (ignorable) callcontext...
if(cx.methodName != "isPrimeNumber")
alert("I'm very confused");
lastNumber = number;
lastAnswer = isPrime;
ask();
},
onError : function(e, cx) {
alert("error: "+e);
}
};
var str = "";
if(lastNumber) {
str = ""+lastNumber+ (lastAnswer ? " is prime" : " is not prime")+"\n\n";
}
str += "Enter number (0 to quit)";
var number = prompt(str, "");
number = parseInt(number, 10);
if(number && !isNaN(number)) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
talkToMe.number = number;
proxy.setListener(talkToMe);
proxy.isPrimeNumber(number);
} catch(e) {
alert("error: "+e);
}
}
}
const ISPRIMEURL = "http://green.nscp.aoltw.net/vidur/wsdl/statistics.wsdl";
//const ISPRIMEURL = "http://bugsfree.nscp.aoltw.net/pub/statistics.wsdl";
//const ISPRIMEURL = "http://bugsfree.nscp.aoltw.net/pub/statistics2.wsdl";
//const ISPRIMEURL = "http://213.23.125.181:8080/statistics.wsdl";
const ISPRIMEPORT = "SpheonJSAOPStatisticsPort";
factory.createProxyAsync(ISPRIMEURL, ISPRIMEPORT, "foo", true, listener);
//factory.createProxyAsync(ISPRIMEURL, ISPRIMEPORT, "foo", false, listener);
</script>