3 load_lib('JSON_v1.js');
6 var __jsonopensrfreqid = 1;
7 var __jsonopensrfreq_hash = {};
9 function JSONOpenSRFRequest () {
10 // Cache this for later ...
11 this._hash_id = __jsonopensrfreqid;
15 JSONOpenSRFRequest.method('create',function (service) {
16 this._service = service;
17 __jsonopensrfreq_hash['id' + this._hash_id] = {};
20 JSONOpenSRFRequest.method('open',function (service, method, async) {
21 this._service = service;
22 this._method = method;
23 this._async = (async ? 1 : 0);
24 __jsonopensrfreq_hash['id' + this._hash_id] = {};
27 JSONOpenSRFRequest.method('close',function () {
31 __jsonopensrfreq_hash['id' + this._hash_id] = {};
34 JSONOpenSRFRequest.method('call',function (method, async) {
35 this._method = method;
36 this._async = (async ? 1 : 0);
39 JSONOpenSRFRequest.method('connect', function (service) {
41 if (service) this._service = service;
44 throw "call .open with a service before calling .connect";
46 _OILS_FUNC_jsonopensrfrequest_connect(this._hash_id,this._service);
48 alert("Sorry, no JSONOpenSRFRequest support");
51 this.connected = __jsonopensrfreq_hash['id' + this._hash_id].connected;
54 JSONOpenSRFRequest.method('disconnect', function () {
57 throw "call .connect before calling .disconnect";
59 _OILS_FUNC_jsonopensrfrequest_disconnect(this._hash_id);
61 alert("Sorry, no JSONOpenSRFRequest support");
64 this.connected = __jsonopensrfreq_hash['id' + this._hash_id].connected;
67 JSONOpenSRFRequest.method('finish', function () {
70 throw "call .connect before calling .finish";
72 _OILS_FUNC_jsonopensrfrequest_disconnect(this._hash_id);
73 _OILS_FUNC_jsonopensrfrequest_finish(this._hash_id);
75 alert("Sorry, no JSONOpenSRFRequest support");
78 this.connected = __jsonopensrfreq_hash['id' + this._hash_id].connected;
81 JSONOpenSRFRequest.method('send', function () {
84 throw "call .open with a service and a method before calling .send";
87 for (var i = 0; i < arguments.length; i++) {
88 data[i] = arguments[i];
92 //log_debug( this._hash_id + " -> " + this._service + " -> " + this._method + " -> " + this._async + " -> " + js2JSON(data));
93 _OILS_FUNC_jsonopensrfrequest_send(this._hash_id,this._service,this._method,this._async,js2JSON(data));
95 alert("Sorry, no JSONOpenSRFRequest support");
98 this.responseText = __jsonopensrfreq_hash['id' + this._hash_id].responseText;
99 this.readyState = __jsonopensrfreq_hash['id' + this._hash_id].readyState;
100 this.status = __jsonopensrfreq_hash['id' + this._hash_id].status;
101 this.statusText = __jsonopensrfreq_hash['id' + this._hash_id].statusText;
102 this.responseJSON = JSON2js(this.responseText);
105 this.onreadystatechange();