Orbjson 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,69 +1,69 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
- <html xmlns="http://www.w3.org/1999/xhtml">
3
- <head>
4
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
- <title>Metatagging</title>
6
- <script type="text/javascript" src="./script/jsonrpc.js"></script>
7
- <script language="javascript" type="text/javascript">
8
- var jsonurl = "http://127.0.0.1:2222/json-rpc";
9
- var jsonrpc = null;
10
-
11
- function init() {
12
- jsonrpc = new JSONRpcClient( jsonurl );
13
- }
14
-
15
- function show_details( topic ) {
16
- var el = document.getElementById( 'details' );
17
- var html = jsonrpc.details.fetch( topic)
18
- el.innerHTML = html;
19
- }
20
-
21
- </script>
22
-
23
- <style type="text/css">
24
- #metatagFields #reset {
25
- text-align: right;
26
- }
27
- body {
28
- font-family: Verdana, Arial, Helvetica, sans-serif;
29
- color: #666666;
30
- }
31
- a {
32
- text-decoration: none;
33
- }
34
-
35
- fieldset {
36
- background-image: url(yellow_crossfade_01.gif);
37
- background-repeat: repeat-y;
38
- background-position: left top;
39
- }
40
-
41
- #metatagFields {
42
- width: 300px;
43
- margin-top: 10px;
44
- }
45
-
46
- #metatagFields legend {
47
- background-color: #FFFFFF;
48
- border: 1px dashed #333333;
49
- }
50
- </style>
51
-
52
- </head>
53
- <body onload='init()' >
54
-
55
- <div id='instructions'>Select a topic to seee more about it</div>
56
- <div id='curentItemList'>
57
- <a href='javascript:show_details( "JSON")'>JSON</a>, <a href='javascript:show_details( "JSON-RPC")'>JSON-RPC</a>, <a href='javascript:show_details( "Ruby")' >Ruby</a>
58
- </div>
59
-
60
- <div id='currentSelectionSet'>
61
- <form name='metatagForm' action='#' method="get">
62
- <fieldset id='metatagFields'>
63
- <legend>Topic info</legend>
64
- <div id='details'></div>
65
- </fieldset>
66
- </form>
67
- </div>
68
- </body>
69
- </html>
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <title>Metatagging</title>
6
+ <script type="text/javascript" src="./script/jsonrpc.js"></script>
7
+ <script language="javascript" type="text/javascript">
8
+ var jsonurl = "http://127.0.0.1:2222/json-rpc";
9
+ var jsonrpc = null;
10
+
11
+ function init() {
12
+ jsonrpc = new JSONRpcClient( jsonurl );
13
+ }
14
+
15
+ function show_details( topic ) {
16
+ var el = document.getElementById( 'details' );
17
+ var html = jsonrpc.details.fetch( topic)
18
+ el.innerHTML = html;
19
+ }
20
+
21
+ </script>
22
+
23
+ <style type="text/css">
24
+ #metatagFields #reset {
25
+ text-align: right;
26
+ }
27
+ body {
28
+ font-family: Verdana, Arial, Helvetica, sans-serif;
29
+ color: #666666;
30
+ }
31
+ a {
32
+ text-decoration: none;
33
+ }
34
+
35
+ fieldset {
36
+ background-image: url(yellow_crossfade_01.gif);
37
+ background-repeat: repeat-y;
38
+ background-position: left top;
39
+ }
40
+
41
+ #metatagFields {
42
+ width: 300px;
43
+ margin-top: 10px;
44
+ }
45
+
46
+ #metatagFields legend {
47
+ background-color: #FFFFFF;
48
+ border: 1px dashed #333333;
49
+ }
50
+ </style>
51
+
52
+ </head>
53
+ <body onload='init()' >
54
+
55
+ <div id='instructions'>Select a topic to seee more about it</div>
56
+ <div id='curentItemList'>
57
+ <a href='javascript:show_details( "JSON")'>JSON</a>, <a href='javascript:show_details( "JSON-RPC")'>JSON-RPC</a>, <a href='javascript:show_details( "Ruby")' >Ruby</a>
58
+ </div>
59
+
60
+ <div id='currentSelectionSet'>
61
+ <form name='metatagForm' action='#' method="get">
62
+ <fieldset id='metatagFields'>
63
+ <legend>Topic info</legend>
64
+ <div id='details'></div>
65
+ </fieldset>
66
+ </form>
67
+ </div>
68
+ </body>
69
+ </html>
@@ -0,0 +1,69 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <title>Metatagging</title>
6
+ <script type="text/javascript" src="./script/jsonrpc.js"></script>
7
+ <script language="javascript" type="text/javascript">
8
+ var jsonurl = "http://127.0.0.1:2222/json-rpc";
9
+ var jsonrpc = null;
10
+
11
+ function init() {
12
+ jsonrpc = new JSONRpcClient( jsonurl );
13
+ }
14
+
15
+ function show_details( topic ) {
16
+ var el = document.getElementById( 'details' );
17
+ var html = jsonrpc.details.fetch( topic)
18
+ el.innerHTML = html;
19
+ }
20
+
21
+ </script>
22
+
23
+ <style type="text/css">
24
+ #metatagFields #reset {
25
+ text-align: right;
26
+ }
27
+ body {
28
+ font-family: Verdana, Arial, Helvetica, sans-serif;
29
+ color: #666666;
30
+ }
31
+ a {
32
+ text-decoration: none;
33
+ }
34
+
35
+ fieldset {
36
+ background-image: url(yellow_crossfade_01.gif);
37
+ background-repeat: repeat-y;
38
+ background-position: left top;
39
+ }
40
+
41
+ #metatagFields {
42
+ width: 300px;
43
+ margin-top: 10px;
44
+ }
45
+
46
+ #metatagFields legend {
47
+ background-color: #FFFFFF;
48
+ border: 1px dashed #333333;
49
+ }
50
+ </style>
51
+
52
+ </head>
53
+ <body onload='init()' >
54
+
55
+ <div id='instructions'>Select a topic to seee more about it</div>
56
+ <div id='curentItemList'>
57
+ <a href='javascript:show_details( "JSON")'>JSON</a>, <a href='javascript:show_details( "JSON-RPC")'>JSON-RPC</a>, <a href='javascript:show_details( "Ruby")' >Ruby</a>
58
+ </div>
59
+
60
+ <div id='currentSelectionSet'>
61
+ <form name='metatagForm' action='#' method="get">
62
+ <fieldset id='metatagFields'>
63
+ <legend>Topic info</legend>
64
+ <div id='details'></div>
65
+ </fieldset>
66
+ </form>
67
+ </div>
68
+ </body>
69
+ </html>
@@ -1,187 +1,187 @@
1
- /*
2
- * JSON-RPC JavaScript client
3
- *
4
- * $Id: jsonrpc.js,v 1.1.1.1 2005/02/28 03:06:29 jamesgbritt Exp $
5
- *
6
- * Copyright (c) 2003-2004 Jan-Klaas Kollhof
7
- * Copyright (c) 2005 Michael Clark, Metaparadigm Pte Ltd
8
- *
9
- * This code is based on Jan-Klaas' JavaScript o lait library (jsolait).
10
- *
11
- * This library is free software; you can redistribute it and/or
12
- * modify it under the terms of the GNU Lesser General Public (LGPL)
13
- * License as published by the Free Software Foundation; either
14
- * version 2.1 of the License, or (at your option) any later version.
15
- *
16
- * This library is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
- * Lesser General Public License for more details: http://www.gnu.org/
20
- *
21
- */
22
-
23
- // TODO: Add async
24
- // TODO: Add HTTP auth (user, password)
25
-
26
- Object.prototype.toJSON = function Object_toJSON() {
27
- var v = [];
28
- for(attr in this) {
29
- if(this[attr] == null) v.push("\"" + attr + "\": null");
30
- else if(typeof this[attr] == "function"); // skip
31
- else v.push("\"" + attr + "\": " + this[attr].toJSON());
32
- }
33
- return "{" + v.join(", ") + "}";
34
- }
35
-
36
- String.prototype.toJSON = function String_toJSON() {
37
- return "\"" + this.replace(/([\"\\])/g, "\\$1") + "\"";
38
- }
39
-
40
- Number.prototype.toJSON = function Number_toJSON() {
41
- return this.toString();
42
- }
43
-
44
- Boolean.prototype.toJSON = function Boolean_toJSON() {
45
- return this.toString();
46
- }
47
-
48
- Date.prototype.toJSON = function Date_toJSON() {
49
- this.valueOf().toString();
50
- }
51
-
52
- Array.prototype.toJSON = function Array_toJSON() {
53
- var v = [];
54
- for(var i=0; i<this.length; i++) {
55
- if(this[i] == null) v.push("null");
56
- else v.push(this[i].toJSON());
57
- }
58
- return "[" + v.join(", ") + "]";
59
- }
60
-
61
- JSONRpcClient = function JSONRpcClient_ctor(serverURL, objectID) {
62
- this.serverURL = serverURL;
63
- this.objectID = objectID;
64
-
65
- // Lazy initialization of the XMLHttpRequest singleton
66
- if(!JSONRpcClient.http)
67
- JSONRpcClient.http = JSONRpcClient.getHTTPRequest();
68
-
69
- // Add standard methods
70
- this.addMethods(["system.listMethods"]);
71
-
72
- // Query the methods on the server and add them to this object
73
- var m = this.sendRequest("system.listMethods", []);
74
- this.addMethods(m);
75
- }
76
-
77
- JSONRpcClient.Exception = function JSONRpcClient_Exception_ctor(code, msg) {
78
- this.code = code;
79
- this.msg = msg;
80
- }
81
-
82
- JSONRpcClient.Exception.prototype.toString =
83
- function JSONRpcClient_Exception_toString(code, msg) {
84
- return "JSONRpcClientException: " + this.msg;
85
- }
86
-
87
- JSONRpcClient.Method =
88
- function JSONRpcClient_Method_ctor(client, methodName) {
89
- var fn=function() {
90
- var args = [];
91
- for(var i=0;i<arguments.length;i++) {
92
- args.push(arguments[i]);
93
- }
94
- return fn.client.sendRequest.call(fn.client, fn.methodName, args);
95
- }
96
- fn.client = client;
97
- fn.methodName = methodName;
98
- return fn;
99
- }
100
-
101
- JSONRpcClient.prototype.addMethods =
102
- function JSONRpcClient_addMethods(methodNames) {
103
- for(var i=0; i<methodNames.length; i++) {
104
- var obj = this;
105
- var names = methodNames[i].split(".");
106
- for(var n=0; n<names.length-1; n++){
107
- var name = names[n];
108
- if(obj[name]){
109
- obj = obj[name];
110
- }
111
- else {
112
- obj[name] = new Object();
113
- obj = obj[name];
114
- }
115
- }
116
- var name = names[names.length-1];
117
- if(!obj[name]){
118
- var method = new JSONRpcClient.Method(this, methodNames[i]);
119
- obj[name] = method;
120
- }
121
- }
122
- }
123
-
124
- JSONRpcClient.prototype.sendRequest =
125
- function JSONRpcClient_sendRequest(methodName, args) {
126
- // Make request object
127
- var obj = {"method" : methodName, "params" : args};
128
- if (this.objectID) obj.objectID = this.objectID;
129
-
130
- // Marshall the request object to a JSON string
131
- var req_data = obj.toJSON();
132
-
133
- // Send the request
134
- JSONRpcClient.http.open("POST", this.serverURL, false); // no async
135
- // setRequestHeader is missing in Opera 8 Beta
136
- try {
137
- JSONRpcClient.http.setRequestHeader("Content-type", "text/plain");
138
- }
139
- catch(e) {}
140
- JSONRpcClient.http.send(req_data);
141
-
142
- // Unmarshall the response
143
- // DEBUG
144
- try {
145
- eval("var obj = " + JSONRpcClient.http.responseText);
146
- }
147
- catch(e) {
148
- alert( e )
149
- alert( JSONRpcClient.http.responseText )
150
- obj.err = e.toString()
151
- }
152
- if( obj.error) {
153
- alert( JSONRpcClient.http.responseText )
154
- throw new JSONRpcClient.Exception(obj.error.code, obj.error.msg);
155
- }
156
- var res = obj.result;
157
-
158
- // Handle CallableProxy
159
- if(res && res.objectID && res.JSONRPCType == "CallableReference")
160
- return new JSONRpcClient(this.serverURL, res.objectID);
161
-
162
- return res;
163
- }
164
-
165
- JSONRpcClient.getHTTPRequest = function JSONRpcClient_getHTTPRequest() {
166
- try { // to get the mozilla httprequest object
167
- return new XMLHttpRequest();
168
- }
169
- catch(e) {}
170
-
171
- try { // to get MS HTTP request object
172
- return new ActiveXObject("Msxml2.XMLHTTP.4.0");
173
- }
174
- catch(e) {}
175
-
176
- try { // to get MS HTTP request object
177
- return new ActiveXObject("Msxml2.XMLHTTP");
178
- }
179
- catch(e) {}
180
-
181
- try {// to get the old MS HTTP request object
182
- return new ActiveXObject("microsoft.XMLHTTP");
183
- }
184
- catch(e) {}
185
-
186
- throw new JSONRpcClient.Exception(0, "Can't create XMLHttpRequest object");
187
- }
1
+ /*
2
+ * JSON-RPC JavaScript client
3
+ *
4
+ * $Id: jsonrpc.js,v 1.1.1.1 2005/02/28 03:06:29 jamesgbritt Exp $
5
+ *
6
+ * Copyright (c) 2003-2004 Jan-Klaas Kollhof
7
+ * Copyright (c) 2005 Michael Clark, Metaparadigm Pte Ltd
8
+ *
9
+ * This code is based on Jan-Klaas' JavaScript o lait library (jsolait).
10
+ *
11
+ * This library is free software; you can redistribute it and/or
12
+ * modify it under the terms of the GNU Lesser General Public (LGPL)
13
+ * License as published by the Free Software Foundation; either
14
+ * version 2.1 of the License, or (at your option) any later version.
15
+ *
16
+ * This library is distributed in the hope that it will be useful,
17
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
+ * Lesser General Public License for more details: http://www.gnu.org/
20
+ *
21
+ */
22
+
23
+ // TODO: Add async
24
+ // TODO: Add HTTP auth (user, password)
25
+
26
+ Object.prototype.toJSON = function Object_toJSON() {
27
+ var v = [];
28
+ for(attr in this) {
29
+ if(this[attr] == null) v.push("\"" + attr + "\": null");
30
+ else if(typeof this[attr] == "function"); // skip
31
+ else v.push("\"" + attr + "\": " + this[attr].toJSON());
32
+ }
33
+ return "{" + v.join(", ") + "}";
34
+ }
35
+
36
+ String.prototype.toJSON = function String_toJSON() {
37
+ return "\"" + this.replace(/([\"\\])/g, "\\$1") + "\"";
38
+ }
39
+
40
+ Number.prototype.toJSON = function Number_toJSON() {
41
+ return this.toString();
42
+ }
43
+
44
+ Boolean.prototype.toJSON = function Boolean_toJSON() {
45
+ return this.toString();
46
+ }
47
+
48
+ Date.prototype.toJSON = function Date_toJSON() {
49
+ this.valueOf().toString();
50
+ }
51
+
52
+ Array.prototype.toJSON = function Array_toJSON() {
53
+ var v = [];
54
+ for(var i=0; i<this.length; i++) {
55
+ if(this[i] == null) v.push("null");
56
+ else v.push(this[i].toJSON());
57
+ }
58
+ return "[" + v.join(", ") + "]";
59
+ }
60
+
61
+ JSONRpcClient = function JSONRpcClient_ctor(serverURL, objectID) {
62
+ this.serverURL = serverURL;
63
+ this.objectID = objectID;
64
+
65
+ // Lazy initialization of the XMLHttpRequest singleton
66
+ if(!JSONRpcClient.http)
67
+ JSONRpcClient.http = JSONRpcClient.getHTTPRequest();
68
+
69
+ // Add standard methods
70
+ this.addMethods(["system.listMethods"]);
71
+
72
+ // Query the methods on the server and add them to this object
73
+ var m = this.sendRequest("system.listMethods", []);
74
+ this.addMethods(m);
75
+ }
76
+
77
+ JSONRpcClient.Exception = function JSONRpcClient_Exception_ctor(code, msg) {
78
+ this.code = code;
79
+ this.msg = msg;
80
+ }
81
+
82
+ JSONRpcClient.Exception.prototype.toString =
83
+ function JSONRpcClient_Exception_toString(code, msg) {
84
+ return "JSONRpcClientException: " + this.msg;
85
+ }
86
+
87
+ JSONRpcClient.Method =
88
+ function JSONRpcClient_Method_ctor(client, methodName) {
89
+ var fn=function() {
90
+ var args = [];
91
+ for(var i=0;i<arguments.length;i++) {
92
+ args.push(arguments[i]);
93
+ }
94
+ return fn.client.sendRequest.call(fn.client, fn.methodName, args);
95
+ }
96
+ fn.client = client;
97
+ fn.methodName = methodName;
98
+ return fn;
99
+ }
100
+
101
+ JSONRpcClient.prototype.addMethods =
102
+ function JSONRpcClient_addMethods(methodNames) {
103
+ for(var i=0; i<methodNames.length; i++) {
104
+ var obj = this;
105
+ var names = methodNames[i].split(".");
106
+ for(var n=0; n<names.length-1; n++){
107
+ var name = names[n];
108
+ if(obj[name]){
109
+ obj = obj[name];
110
+ }
111
+ else {
112
+ obj[name] = new Object();
113
+ obj = obj[name];
114
+ }
115
+ }
116
+ var name = names[names.length-1];
117
+ if(!obj[name]){
118
+ var method = new JSONRpcClient.Method(this, methodNames[i]);
119
+ obj[name] = method;
120
+ }
121
+ }
122
+ }
123
+
124
+ JSONRpcClient.prototype.sendRequest =
125
+ function JSONRpcClient_sendRequest(methodName, args) {
126
+ // Make request object
127
+ var obj = {"method" : methodName, "params" : args};
128
+ if (this.objectID) obj.objectID = this.objectID;
129
+
130
+ // Marshall the request object to a JSON string
131
+ var req_data = obj.toJSON();
132
+
133
+ // Send the request
134
+ JSONRpcClient.http.open("POST", this.serverURL, false); // no async
135
+ // setRequestHeader is missing in Opera 8 Beta
136
+ try {
137
+ JSONRpcClient.http.setRequestHeader("Content-type", "text/plain");
138
+ }
139
+ catch(e) {}
140
+ JSONRpcClient.http.send(req_data);
141
+
142
+ // Unmarshall the response
143
+ // DEBUG
144
+ try {
145
+ eval("var obj = " + JSONRpcClient.http.responseText);
146
+ }
147
+ catch(e) {
148
+ alert( e )
149
+ alert( JSONRpcClient.http.responseText )
150
+ obj.err = e.toString()
151
+ }
152
+ if( obj.error) {
153
+ alert( JSONRpcClient.http.responseText )
154
+ throw new JSONRpcClient.Exception(obj.error.code, obj.error.msg);
155
+ }
156
+ var res = obj.result;
157
+
158
+ // Handle CallableProxy
159
+ if(res && res.objectID && res.JSONRPCType == "CallableReference")
160
+ return new JSONRpcClient(this.serverURL, res.objectID);
161
+
162
+ return res;
163
+ }
164
+
165
+ JSONRpcClient.getHTTPRequest = function JSONRpcClient_getHTTPRequest() {
166
+ try { // to get the mozilla httprequest object
167
+ return new XMLHttpRequest();
168
+ }
169
+ catch(e) {}
170
+
171
+ try { // to get MS HTTP request object
172
+ return new ActiveXObject("Msxml2.XMLHTTP.4.0");
173
+ }
174
+ catch(e) {}
175
+
176
+ try { // to get MS HTTP request object
177
+ return new ActiveXObject("Msxml2.XMLHTTP");
178
+ }
179
+ catch(e) {}
180
+
181
+ try {// to get the old MS HTTP request object
182
+ return new ActiveXObject("microsoft.XMLHTTP");
183
+ }
184
+ catch(e) {}
185
+
186
+ throw new JSONRpcClient.Exception(0, "Can't create XMLHttpRequest object");
187
+ }