>4);e[1]=((a[1]&15)<<4)|(a[2]>>2);e[2]=((a[2]&3)<<6)|a[3];d[b++]=String.fromCharCode(e[0]);if(a[2]!=64){d[b++]=String.fromCharCode(e[1])}if(a[3]!=64){d[b++]=String.fromCharCode(e[2])}}return d.join("")}};
--------------------------------------------------------------------------------
/lib/jquery-qunit/addons/junitlogger/junitlogger.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | var count = 0, suiteCount = 0, currentSuite, currentTest, suites = [], assertCount, start, results = {failed:0, passed:0, total:0, time:0};
3 |
4 | QUnit.jUnitReport = function(data) {
5 | // Gets called when a report is generated
6 | };
7 |
8 | QUnit.moduleStart(function(data) {
9 | currentSuite = {
10 | name: data.name,
11 | tests: [],
12 | failures: 0,
13 | time: 0,
14 | stdout : '',
15 | stderr : ''
16 | };
17 |
18 | suites.push(currentSuite);
19 | });
20 |
21 | QUnit.moduleDone(function(data) {
22 | });
23 |
24 | QUnit.testStart(function(data) {
25 | if(!start){ start = new Date(); }
26 |
27 | assertCount = 0;
28 |
29 | currentTest = {
30 | name: data.name,
31 | failures: [],
32 | start: new Date()
33 | };
34 |
35 | // Setup default suite if no module was specified
36 | if (!currentSuite) {
37 | currentSuite = {
38 | name: "default",
39 | tests: [],
40 | failures: 0,
41 | time: 0,
42 | stdout : '',
43 | stderr : ''
44 | };
45 |
46 | suites.push(currentSuite);
47 | }
48 |
49 | currentSuite.tests.push(currentTest);
50 | });
51 |
52 | QUnit.testDone(function(data) {
53 | currentTest.failed = data.failed;
54 | currentTest.total = data.total;
55 | currentSuite.failures += data.failed;
56 |
57 | results.failed += data.failed;
58 | results.passed += data.passed;
59 | results.total += data.total;
60 | });
61 |
62 | QUnit.log(function(data) {
63 | assertCount++;
64 |
65 | if (!data.result) {
66 | currentTest.failures.push(data.message);
67 |
68 | // Add log message of failure to make it easier to find in jenkins UI
69 | currentSuite.stdout += '[' + currentSuite.name + ', ' + currentTest.name + ', ' + assertCount + '] ' + data.message + '\n';
70 | }
71 | });
72 |
73 | QUnit.done(function(data) {
74 | function ISODateString(d) {
75 | function pad(n) {
76 | return n < 10 ? '0' + n : n;
77 | }
78 |
79 | return d.getUTCFullYear() + '-' +
80 | pad(d.getUTCMonth() + 1)+'-' +
81 | pad(d.getUTCDate()) + 'T' +
82 | pad(d.getUTCHours()) + ':' +
83 | pad(d.getUTCMinutes()) + ':' +
84 | pad(d.getUTCSeconds()) + 'Z';
85 | }
86 |
87 | // Generate XML report
88 | var i, ti, fi, test, suite,
89 | xmlWriter = new XmlWriter({
90 | linebreak_at : "testsuites,testsuite,testcase,failure,system-out,system-err"
91 | }),
92 | now = new Date();
93 |
94 | xmlWriter.start('testsuites');
95 |
96 | for (i = 0; i < suites.length; i++) {
97 | suite = suites[i];
98 |
99 | // Calculate time
100 | for (ti = 0; ti < suite.tests.length; ti++) {
101 | test = suite.tests[ti];
102 |
103 | test.time = (now.getTime() - test.start.getTime()) / 1000;
104 | suite.time += test.time;
105 | }
106 |
107 | xmlWriter.start('testsuite', {
108 | id: "" + i,
109 | name: suite.name,
110 | errors: "0",
111 | failures: suite.failures,
112 | hostname: "localhost",
113 | tests: suite.tests.length,
114 | time: Math.round(suite.time * 1000) / 1000,
115 | timestamp: ISODateString(now)
116 | });
117 |
118 | for (ti = 0; ti < suite.tests.length; ti++) {
119 | test = suite.tests[ti];
120 |
121 | xmlWriter.start('testcase', {
122 | name: test.name,
123 | total: test.total,
124 | failed: test.failed,
125 | time: Math.round(test.time * 1000) / 1000
126 | });
127 |
128 | for (fi = 0; fi < test.failures.length; fi++) {
129 | xmlWriter.start('failure', {type: "AssertionFailedError", message: test.failures[fi]}, true);
130 | }
131 |
132 | xmlWriter.end('testcase');
133 | }
134 |
135 | if (suite.stdout) {
136 | xmlWriter.start('system-out');
137 | xmlWriter.cdata('\n' + suite.stdout);
138 | xmlWriter.end('system-out');
139 | }
140 |
141 | if (suite.stderr) {
142 | xmlWriter.start('system-err');
143 | xmlWriter.cdata('\n' + suite.stderr);
144 | xmlWriter.end('system-err');
145 | }
146 |
147 | xmlWriter.end('testsuite');
148 | }
149 |
150 | xmlWriter.end('testsuites');
151 |
152 | results.time = new Date() - start;
153 |
154 | QUnit.jUnitReport({
155 | results:results,
156 | xml: xmlWriter.getString()
157 | });
158 | });
159 |
160 | function XmlWriter(settings) {
161 | function addLineBreak(name) {
162 | if (lineBreakAt[name] && data[data.length - 1] !== '\n') {
163 | data.push('\n');
164 | }
165 | }
166 |
167 | function makeMap(items, delim, map) {
168 | var i;
169 |
170 | items = items || [];
171 |
172 | if (typeof(items) === "string") {
173 | items = items.split(',');
174 | }
175 |
176 | map = map || {};
177 |
178 | i = items.length;
179 | while (i--) {
180 | map[items[i]] = {};
181 | }
182 |
183 | return map;
184 | }
185 |
186 | function encode(text) {
187 | var baseEntities = {
188 | '"' : '"',
189 | "'" : ''',
190 | '<' : '<',
191 | '>' : '>',
192 | '&' : '&'
193 | };
194 |
195 | return ('' + text).replace(/[<>&\"\']/g, function(chr) {
196 | return baseEntities[chr] || chr;
197 | });
198 | }
199 |
200 | var data = [], stack = [], lineBreakAt;
201 |
202 | settings = settings || {};
203 | lineBreakAt = makeMap(settings.linebreak_at || 'mytag');
204 |
205 | this.start = function(name, attrs, empty) {
206 | if (!empty) {
207 | stack.push(name);
208 | }
209 |
210 | data.push('<', name);
211 |
212 | for (var aname in attrs) {
213 | data.push(" " + encode(aname), '="', encode(attrs[aname]), '"');
214 | }
215 |
216 | data.push(empty ? ' />' : '>');
217 | addLineBreak(name);
218 | };
219 |
220 | this.end = function(name) {
221 | stack.pop();
222 | addLineBreak(name);
223 | data.push('', name, '>');
224 | addLineBreak(name);
225 | };
226 |
227 | this.text = function(text) {
228 | data.push(encode(text));
229 | };
230 |
231 | this.cdata = function(text) {
232 | data.push('');
233 | };
234 |
235 | this.comment = function(text) {
236 | data.push('');
237 | };
238 |
239 | this.pi = function(name, text) {
240 | if (text) {
241 | data.push('', name, ' ', text, '?>\n');
242 | } else {
243 | data.push('', name, '?>\n');
244 | }
245 | };
246 |
247 | this.doctype = function(text) {
248 | data.push('\n');
249 | };
250 |
251 | this.getString = function() {
252 | for (var i = stack.length - 1; i >= 0; i--) {
253 | this.end(stack[i]);
254 | }
255 |
256 | stack = [];
257 |
258 | return data.join('').replace(/\n$/, '');
259 | };
260 |
261 | this.reset = function() {
262 | data = [];
263 | stack = [];
264 | };
265 |
266 | this.pi(settings.xmldecl || 'xml version="1.0" encoding="UTF-8"');
267 | }
268 | })();
--------------------------------------------------------------------------------
/wordpress.obfuscate.js:
--------------------------------------------------------------------------------
1 | function WordPress(b,c,a){this.url=b;this.username=c;this.password=a;this.request=new XmlRpcRequest(this.url);}WordPress.prototype.getPost=function(c,b,a){this.request.methodName="wp.getPost";this.request.addParam(c);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(b);this.request.addParam(a);var d=this.request.send();this.request.clearParams();return d.parseXML();};WordPress.prototype.getPosts=function(b,c,a){this.request.methodName="wp.getPosts";this.request.addParam(b);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(c);this.request.addParam(a);var d=this.request.send();this.request.clearParams();return d.parseXML();};WordPress.prototype.newPost=function(a,b){this.request.methodName="wp.newPost";this.request.addParam(a);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(b);var c=this.request.send();this.request.clearParams();return c.parseXML();};WordPress.prototype.editPost=function(b,a,c){this.request.methodName="wp.editPost";this.request.addParam(b);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(a);this.request.addParam(c);var d=this.request.send();this.request.clearParams();return d.parseXML();};WordPress.prototype.deletePost=function(b,a){this.request.methodName="wp.deletePost";this.request.addParam(b);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(a);var c=this.request.send();this.request.clearParams();return c.parseXML();};WordPress.prototype.getPostType=function(b,c,a){this.request.methodName="wp.getPostType";this.request.addParam(b);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(c);this.request.addParam(a);var d=this.request.send();this.request.clearParams();return d.parseXML();};WordPress.prototype.getPostTypes=function(b,c,a){this.request.methodName="wp.getPostTypes";this.request.addParam(b);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(c);this.request.addParam(a);var d=this.request.send();this.request.clearParams();return d.parseXML();};WordPress.prototype.getPostFormats=function(a,b){this.request.methodName="wp.getPostFormats";this.request.addParam(a);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(b);var c=this.request.send();this.request.clearParams();return c.parseXML();};WordPress.prototype.getPostStatusList=function(a){this.request.methodName="wp.getPostStatusList";this.request.addParam(a);this.request.addParam(this.username);this.request.addParam(this.password);var b=this.request.send();this.request.clearParams();return b.parseXML();};WordPress.prototype.getTaxonomy=function(b,a){this.request.methodName="wp.getTaxonomy";this.request.addParam(b);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(a);var c=this.request.send();this.request.clearParams();return c.parseXML();};WordPress.prototype.getTaxonomies=function(a){this.request.methodName="wp.getTaxonomies";this.request.addParam(a);this.request.addParam(this.username);this.request.addParam(this.password);var b=this.request.send();this.request.clearParams();return b.parseXML();};WordPress.prototype.getTerm=function(b,a,c){this.request.methodName="wp.getTerm";this.request.addParam(b);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(a);this.request.addParam(c);var d=this.request.send();this.request.clearParams();return d.parseXML();};WordPress.prototype.getTerms=function(b,a,c){this.request.methodName="wp.getTerms";this.request.addParam(b);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(a);this.request.addParam(c);var d=this.request.send();this.request.clearParams();return d.parseXML();};WordPress.prototype.newTerm=function(a,b){this.request.methodName="wp.newTerm";this.request.addParam(a);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(b);var c=this.request.send();this.request.clearParams();return c.parseXML();};WordPress.prototype.editTerm=function(a,c,b){this.request.methodName="wp.editTerm";this.request.addParam(a);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(c);this.request.addParam(b);var d=this.request.send();this.request.clearParams();return d.parseXML();};WordPress.prototype.deleteTerm=function(b,a,c){this.request.methodName="wp.deleteTerm";this.request.addParam(b);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(a);this.request.addParam(c);var d=this.request.send();this.request.clearParams();return d.parseXML();};WordPress.prototype.getMediaItem=function(b,a){this.request.methodName="wp.getMediaItem";this.request.addParam(b);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(a);var c=this.request.send();this.request.clearParams();return c.parseXML();};WordPress.prototype.getMediaLibrary=function(a,b){this.request.methodName="wp.getMediaLibrary";this.request.addParam(a);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(b);var c=this.request.send();this.request.clearParams();return c.parseXML();};WordPress.prototype.uploadFile=function(a,b){this.request.methodName="wp.uploadFile";this.request.addParam(a);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(b);var c=this.request.send();this.request.clearParams();return c.parseXML();};WordPress.prototype.getCommentCount=function(b,a){this.request.methodName="wp.getCommentCount";this.request.addParam(b);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(a);var c=this.request.send();this.request.clearParams();return c.parseXML();};WordPress.prototype.getComment=function(a,b){this.request.methodName="wp.getComment";this.request.addParam(a);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(b);var c=this.request.send();this.request.clearParams();return c.parseXML();};WordPress.prototype.getComments=function(a,b){this.request.methodName="wp.getComments";this.request.addParam(a);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(b);var c=this.request.send();this.request.clearParams();return c.parseXML();};WordPress.prototype.newComment=function(b,a,c){this.request.methodName="wp.newComment";this.request.addParam(b);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(a);this.request.addParam(c);var d=this.request.send();this.request.clearParams();return d.parseXML();};WordPress.prototype.editComment=function(a,b,d){this.request.methodName="wp.editComment";this.request.addParam(a);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(b);this.request.addParam(d);var c=this.request.send();this.request.clearParams();return c.parseXML();};WordPress.prototype.deleteComment=function(a,b){this.request.methodName="wp.deleteComment";this.request.addParam(a);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(b);var c=this.request.send();this.request.clearParams();return c.parseXML();};WordPress.prototype.getCommentStatusList=function(a){this.request.methodName="wp.getCommentStatusList";this.request.addParam(a);this.request.addParam(this.username);this.request.addParam(this.password);var b=this.request.send();this.request.clearParams();return b.parseXML();};WordPress.prototype.getOptions=function(b,a){this.request.methodName="wp.getOptions";this.request.addParam(b);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(a);var c=this.request.send();this.request.clearParams();return c.parseXML();};WordPress.prototype.setOptions=function(b,a){this.request.methodName="wp.setOptions";this.request.addParam(b);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(a);var c=this.request.send();this.request.clearParams();return c.parseXML();};WordPress.prototype.getUsersBlogs=function(){this.request.methodName="wp.getUsersBlogs";this.request.addParam(this.username);this.request.addParam(this.password);var a=this.request.send();this.request.clearParams();return a.parseXML();};WordPress.prototype.getAuthors=function(a){this.request.methodName="wp.getAuthors";this.request.addParam(a);this.request.addParam(this.username);this.request.addParam(this.password);var b=this.request.send();this.request.clearParams();return b.parseXML();};
--------------------------------------------------------------------------------
/wordpress.min.js:
--------------------------------------------------------------------------------
1 | function WordPress(url,username,password){this.url=url;this.username=username;this.password=password;this.request=new XmlRpcRequest(this.url);}WordPress.prototype.getPost=function(blog_id,post_id,fields){this.request.methodName="wp.getPost";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(post_id);this.request.addParam(fields);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.getPosts=function(blog_id,filter,fields){this.request.methodName="wp.getPosts";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(filter);this.request.addParam(fields);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.newPost=function(blog_id,content){this.request.methodName="wp.newPost";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(content);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.editPost=function(blog_id,post_id,content){this.request.methodName="wp.editPost";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(post_id);this.request.addParam(content);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.deletePost=function(blog_id,post_id){this.request.methodName="wp.deletePost";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(post_id);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.getPostType=function(blog_id,post_type_name,fields){this.request.methodName="wp.getPostType";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(post_type_name);this.request.addParam(fields);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.getPostTypes=function(blog_id,filter,fields){this.request.methodName="wp.getPostTypes";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(filter);this.request.addParam(fields);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.getPostFormats=function(blog_id,filter){this.request.methodName="wp.getPostFormats";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(filter);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.getPostStatusList=function(blog_id){this.request.methodName="wp.getPostStatusList";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.getTaxonomy=function(blog_id,taxonomy){this.request.methodName="wp.getTaxonomy";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(taxonomy);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.getTaxonomies=function(blog_id){this.request.methodName="wp.getTaxonomies";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.getTerm=function(blog_id,taxonomy,term_id){this.request.methodName="wp.getTerm";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(taxonomy);this.request.addParam(term_id);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.getTerms=function(blog_id,taxonomy,filter){this.request.methodName="wp.getTerms";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(taxonomy);this.request.addParam(filter);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.newTerm=function(blog_id,content){this.request.methodName="wp.newTerm";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(content);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.editTerm=function(blog_id,term_id,content){this.request.methodName="wp.editTerm";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(term_id);this.request.addParam(content);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.deleteTerm=function(blog_id,taxonomy,term_id){this.request.methodName="wp.deleteTerm";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(taxonomy);this.request.addParam(term_id);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.getMediaItem=function(blog_id,attachment_id){this.request.methodName="wp.getMediaItem";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(attachment_id);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.getMediaLibrary=function(blog_id,filter){this.request.methodName="wp.getMediaLibrary";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(filter);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.uploadFile=function(blog_id,data){this.request.methodName="wp.uploadFile";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(data);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.getCommentCount=function(blog_id,post_id){this.request.methodName="wp.getCommentCount";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(post_id);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.getComment=function(blog_id,comment_id){this.request.methodName="wp.getComment";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(comment_id);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.getComments=function(blog_id,filter){this.request.methodName="wp.getComments";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(filter);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.newComment=function(blog_id,post_id,content){this.request.methodName="wp.newComment";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(post_id);this.request.addParam(content);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.editComment=function(blog_id,comment_id,comment){this.request.methodName="wp.editComment";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(comment_id);this.request.addParam(comment);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.deleteComment=function(blog_id,comment_id){this.request.methodName="wp.deleteComment";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(comment_id);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.getCommentStatusList=function(blog_id){this.request.methodName="wp.getCommentStatusList";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.getOptions=function(blog_id,options){this.request.methodName="wp.getOptions";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(options);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.setOptions=function(blog_id,options){this.request.methodName="wp.setOptions";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);this.request.addParam(options);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.getUsersBlogs=function(){this.request.methodName="wp.getUsersBlogs";this.request.addParam(this.username);this.request.addParam(this.password);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};WordPress.prototype.getAuthors=function(blog_id){this.request.methodName="wp.getAuthors";this.request.addParam(blog_id);this.request.addParam(this.username);this.request.addParam(this.password);var resp=this.request.send();this.request.clearParams();return resp.parseXML();};
--------------------------------------------------------------------------------
/lib/jquery-qunit/test/test.js:
--------------------------------------------------------------------------------
1 | test("module without setup/teardown (default)", function() {
2 | expect(1);
3 | ok(true);
4 | });
5 |
6 | test("expect in test", 3, function() {
7 | ok(true);
8 | ok(true);
9 | ok(true);
10 | });
11 |
12 | test("expect in test", 1, function() {
13 | ok(true);
14 | });
15 |
16 | QUnit.module("assertion helpers");
17 |
18 | QUnit.test( "QUnit.assert compatibility", function( assert ) {
19 | QUnit.expect(4);
20 |
21 | assert.ok( true, "Calling method on `assert` argument to test() callback" );
22 |
23 | // Should also work, although not documented
24 | QUnit.assert.ok( true, "Calling method on QUnit.assert object" );
25 |
26 | // Test compatibility aliases
27 | QUnit.ok( true, "Calling aliased method in QUnit root object" );
28 | ok( true, "Calling aliased function in global namespace" );
29 | });
30 |
31 | module("setup test", {
32 | setup: function() {
33 | ok(true);
34 | }
35 | });
36 |
37 | test("module with setup", function() {
38 | expect(2);
39 | ok(true);
40 | });
41 |
42 | test("module with setup, expect in test call", 2, function() {
43 | ok(true);
44 | });
45 |
46 | var state;
47 |
48 | module("setup/teardown test", {
49 | setup: function() {
50 | state = true;
51 | ok(true);
52 | x = 1;
53 | },
54 | teardown: function() {
55 | ok(true);
56 | // can introduce and delete globals in setup/teardown
57 | // without noglobals sounding the alarm
58 | delete x;
59 | }
60 | });
61 |
62 | test("module with setup/teardown", function() {
63 | expect(3);
64 | ok(true);
65 | });
66 |
67 | module("setup/teardown test 2");
68 |
69 | test("module without setup/teardown", function() {
70 | expect(1);
71 | ok(true);
72 | });
73 |
74 | if (typeof setTimeout !== 'undefined') {
75 | state = 'fail';
76 |
77 | module("teardown and stop", {
78 | teardown: function() {
79 | equal(state, "done", "Test teardown.");
80 | }
81 | });
82 |
83 | test("teardown must be called after test ended", function() {
84 | expect(1);
85 | stop();
86 | setTimeout(function() {
87 | state = "done";
88 | start();
89 | }, 13);
90 | });
91 |
92 | test("parameter passed to stop increments semaphore n times", function() {
93 | expect(1);
94 | stop(3);
95 | setTimeout(function() {
96 | state = "not enough starts";
97 | start(), start();
98 | }, 13);
99 | setTimeout(function() {
100 | state = "done";
101 | start();
102 | }, 15);
103 | });
104 |
105 | test("parameter passed to start decrements semaphore n times", function() {
106 | expect(1);
107 | stop(), stop(), stop();
108 | setTimeout(function() {
109 | state = "done";
110 | start(3);
111 | }, 18);
112 | });
113 |
114 | module("async setup test", {
115 | setup: function() {
116 | stop();
117 | setTimeout(function(){
118 | ok(true);
119 | start();
120 | }, 500);
121 | }
122 | });
123 |
124 | asyncTest("module with async setup", function() {
125 | expect(2);
126 | ok(true);
127 | start();
128 | });
129 |
130 | module("async teardown test", {
131 | teardown: function() {
132 | stop();
133 | setTimeout(function(){
134 | ok(true);
135 | start();
136 | }, 500);
137 | }
138 | });
139 |
140 | asyncTest("module with async teardown", function() {
141 | expect(2);
142 | ok(true);
143 | start();
144 | });
145 |
146 | module("asyncTest");
147 |
148 | asyncTest("asyncTest", function() {
149 | expect(2);
150 | ok(true);
151 | setTimeout(function() {
152 | state = "done";
153 | ok(true);
154 | start();
155 | }, 13);
156 | });
157 |
158 | asyncTest("asyncTest", 2, function() {
159 | ok(true);
160 | setTimeout(function() {
161 | state = "done";
162 | ok(true);
163 | start();
164 | }, 13);
165 | });
166 |
167 | test("sync", 2, function() {
168 | stop();
169 | setTimeout(function() {
170 | ok(true);
171 | start();
172 | }, 13);
173 | stop();
174 | setTimeout(function() {
175 | ok(true);
176 | start();
177 | }, 125);
178 | });
179 |
180 | test("test synchronous calls to stop", 2, function() {
181 | stop();
182 | setTimeout(function(){
183 | ok(true, 'first');
184 | start();
185 | stop();
186 | setTimeout(function(){
187 | ok(true, 'second');
188 | start();
189 | }, 150);
190 | }, 150);
191 | });
192 | }
193 |
194 | module("save scope", {
195 | setup: function() {
196 | this.foo = "bar";
197 | },
198 | teardown: function() {
199 | deepEqual(this.foo, "bar");
200 | }
201 | });
202 | test("scope check", function() {
203 | expect(2);
204 | deepEqual(this.foo, "bar");
205 | });
206 |
207 | module("simple testEnvironment setup", {
208 | foo: "bar",
209 | bugid: "#5311" // example of meta-data
210 | });
211 | test("scope check", function() {
212 | deepEqual(this.foo, "bar");
213 | });
214 | test("modify testEnvironment",function() {
215 | expect(0);
216 | this.foo="hamster";
217 | });
218 | test("testEnvironment reset for next test",function() {
219 | deepEqual(this.foo, "bar");
220 | });
221 |
222 | module("testEnvironment with object", {
223 | options:{
224 | recipe:"soup",
225 | ingredients:["hamster","onions"]
226 | }
227 | });
228 | test("scope check", function() {
229 | deepEqual(this.options, {recipe:"soup",ingredients:["hamster","onions"]}) ;
230 | });
231 | test("modify testEnvironment",function() {
232 | expect(0);
233 | // since we do a shallow copy, the testEnvironment can be modified
234 | this.options.ingredients.push("carrots");
235 | });
236 | test("testEnvironment reset for next test",function() {
237 | deepEqual(this.options, {recipe:"soup",ingredients:["hamster","onions","carrots"]}, "Is this a bug or a feature? Could do a deep copy") ;
238 | });
239 |
240 |
241 | module("testEnvironment tests");
242 |
243 | function makeurl() {
244 | var testEnv = QUnit.current_testEnvironment;
245 | var url = testEnv.url || 'http://example.com/search';
246 | var q = testEnv.q || 'a search test';
247 | return url + '?q='+encodeURIComponent(q);
248 | }
249 |
250 | test("makeurl working",function() {
251 | equal( QUnit.current_testEnvironment, this, 'The current testEnvironment is global');
252 | equal( makeurl(), 'http://example.com/search?q=a%20search%20test', 'makeurl returns a default url if nothing specified in the testEnvironment');
253 | });
254 |
255 | module("testEnvironment with makeurl settings", {
256 | url: 'http://google.com/',
257 | q: 'another_search_test'
258 | });
259 | test("makeurl working with settings from testEnvironment", function() {
260 | equal( makeurl(), 'http://google.com/?q=another_search_test', 'rather than passing arguments, we use test metadata to from the url');
261 | });
262 |
263 | module("jsDump");
264 | test("jsDump output", function() {
265 | equal( QUnit.jsDump.parse([1, 2]), "[\n 1,\n 2\n]" );
266 | equal( QUnit.jsDump.parse({top: 5, left: 0}), "{\n \"left\": 0,\n \"top\": 5\n}" );
267 | if (typeof document !== 'undefined' && document.getElementById("qunit-header")) {
268 | equal( QUnit.jsDump.parse(document.getElementById("qunit-header")), "" );
269 | equal( QUnit.jsDump.parse(document.getElementsByTagName("h1")), "[\n \n]" );
270 | }
271 | });
272 |
273 | module("assertions");
274 | test("raises",function() {
275 | function CustomError( message ) {
276 | this.message = message;
277 | }
278 |
279 | CustomError.prototype.toString = function() {
280 | return this.message;
281 | };
282 |
283 | throws(
284 | function() {
285 | throw "my error"
286 | }
287 | );
288 |
289 | throws(
290 | function() {
291 | throw "my error"
292 | },
293 | "simple string throw, no 'expected' value given"
294 | );
295 |
296 | throws(
297 | function() {
298 | throw new CustomError();
299 | },
300 | CustomError,
301 | 'thrown error is an instance of CustomError'
302 | );
303 |
304 | throws(
305 | function() {
306 | throw new CustomError("some error description");
307 | },
308 | /description/,
309 | "use a regex to match against the stringified error"
310 | );
311 |
312 | throws(
313 | function() {
314 | throw new CustomError("some error description");
315 | },
316 | function( err ) {
317 | if ( (err instanceof CustomError) && /description/.test(err) ) {
318 | return true;
319 | }
320 | },
321 | "custom validation function"
322 | );
323 |
324 | throws(
325 | function() {
326 | ( window.execScript || function( data ) {
327 | window["eval"].call( window, data );
328 | })( "throw 'error'" );
329 | },
330 | 'globally-executed errors caught'
331 | );
332 |
333 | this.CustomError = CustomError;
334 |
335 | throws(
336 | function() {
337 | throw new this.CustomError("some error description");
338 | },
339 | /description/,
340 | "throw error from property of 'this' context"
341 | );
342 |
343 | raises(
344 | function() {
345 | throw "error"
346 | },
347 | "simple throw, asserting with deprecated raises() function"
348 | );
349 |
350 | });
351 |
352 | if (typeof document !== "undefined") {
353 |
354 | module("fixture");
355 | test("setup", function() {
356 | expect(0);
357 | document.getElementById("qunit-fixture").innerHTML = "foobar";
358 | });
359 | test("basics", function() {
360 | equal( document.getElementById("qunit-fixture").innerHTML, "test markup", "automatically reset" );
361 | });
362 |
363 | test("running test name displayed", function() {
364 | expect(2);
365 |
366 | var displaying = document.getElementById("qunit-testresult");
367 |
368 | ok( /running test name displayed/.test(displaying.innerHTML), "Expect test name to be found in displayed text" );
369 | ok( /fixture/.test(displaying.innerHTML), "Expect module name to be found in displayed text" );
370 | });
371 |
372 | }
373 |
374 | module("custom assertions");
375 | (function() {
376 | function mod2(value, expected, message) {
377 | var actual = value % 2;
378 | QUnit.push(actual == expected, actual, expected, message);
379 | }
380 | test("mod2", function() {
381 | mod2(2, 0, "2 % 2 == 0");
382 | mod2(3, 1, "3 % 2 == 1");
383 | });
384 | })();
385 |
386 |
387 | module("recursions");
388 |
389 | function Wrap(x) {
390 | this.wrap = x;
391 | if (x == undefined) this.first = true;
392 | }
393 |
394 | function chainwrap(depth, first, prev) {
395 | depth = depth || 0;
396 | var last = prev || new Wrap();
397 | first = first || last;
398 |
399 | if (depth == 1) {
400 | first.wrap = last;
401 | }
402 | if (depth > 1) {
403 | last = chainwrap(depth-1, first, new Wrap(last));
404 | }
405 |
406 | return last;
407 | }
408 |
409 | test("check jsDump recursion", function() {
410 | expect(4);
411 |
412 | var noref = chainwrap(0);
413 | var nodump = QUnit.jsDump.parse(noref);
414 | equal(nodump, '{\n "first": true,\n "wrap": undefined\n}');
415 |
416 | var selfref = chainwrap(1);
417 | var selfdump = QUnit.jsDump.parse(selfref);
418 | equal(selfdump, '{\n "first": true,\n "wrap": recursion(-1)\n}');
419 |
420 | var parentref = chainwrap(2);
421 | var parentdump = QUnit.jsDump.parse(parentref);
422 | equal(parentdump, '{\n "wrap": {\n "first": true,\n "wrap": recursion(-2)\n }\n}');
423 |
424 | var circref = chainwrap(10);
425 | var circdump = QUnit.jsDump.parse(circref);
426 | ok(new RegExp("recursion\\(-10\\)").test(circdump), "(" +circdump + ") should show -10 recursion level");
427 | });
428 |
429 | test("check (deep-)equal recursion", function() {
430 | var noRecursion = chainwrap(0);
431 | equal(noRecursion, noRecursion, "I should be equal to me.");
432 | deepEqual(noRecursion, noRecursion, "... and so in depth.");
433 |
434 | var selfref = chainwrap(1);
435 | equal(selfref, selfref, "Even so if I nest myself.");
436 | deepEqual(selfref, selfref, "... into the depth.");
437 |
438 | var circref = chainwrap(10);
439 | equal(circref, circref, "Or hide that through some levels of indirection.");
440 | deepEqual(circref, circref, "... and checked on all levels!");
441 | });
442 |
443 |
444 | test('Circular reference with arrays', function() {
445 |
446 | // pure array self-ref
447 | var arr = [];
448 | arr.push(arr);
449 |
450 | var arrdump = QUnit.jsDump.parse(arr);
451 |
452 | equal(arrdump, '[\n recursion(-1)\n]');
453 | equal(arr, arr[0], 'no endless stack when trying to dump arrays with circular ref');
454 |
455 |
456 | // mix obj-arr circular ref
457 | var obj = {};
458 | var childarr = [obj];
459 | obj.childarr = childarr;
460 |
461 | var objdump = QUnit.jsDump.parse(obj);
462 | var childarrdump = QUnit.jsDump.parse(childarr);
463 |
464 | equal(objdump, '{\n "childarr": [\n recursion(-2)\n ]\n}');
465 | equal(childarrdump, '[\n {\n "childarr": recursion(-2)\n }\n]');
466 |
467 | equal(obj.childarr, childarr, 'no endless stack when trying to dump array/object mix with circular ref');
468 | equal(childarr[0], obj, 'no endless stack when trying to dump array/object mix with circular ref');
469 |
470 | });
471 |
472 |
473 | test('Circular reference - test reported by soniciq in #105', function() {
474 | var MyObject = function() {};
475 | MyObject.prototype.parent = function(obj) {
476 | if (obj === undefined) { return this._parent; }
477 | this._parent = obj;
478 | };
479 | MyObject.prototype.children = function(obj) {
480 | if (obj === undefined) { return this._children; }
481 | this._children = obj;
482 | };
483 |
484 | var a = new MyObject(),
485 | b = new MyObject();
486 |
487 | var barr = [b];
488 | a.children(barr);
489 | b.parent(a);
490 |
491 | equal(a.children(), barr);
492 | deepEqual(a.children(), [b]);
493 | });
494 |
495 | (function() {
496 | var reset = QUnit.reset;
497 | module("reset");
498 | test("reset runs assertions", function() {
499 | expect(0);
500 | QUnit.reset = function() {
501 | ok( false, "reset should not modify test status" );
502 | reset.apply( this, arguments );
503 | };
504 | });
505 | test("reset runs assertions, cleanup", function() {
506 | expect(0);
507 | QUnit.reset = reset;
508 | });
509 | })();
510 |
511 | if (typeof setTimeout !== 'undefined') {
512 | function testAfterDone(){
513 | var testName = "ensure has correct number of assertions";
514 |
515 | function secondAfterDoneTest(){
516 | QUnit.config.done = [];
517 | //QUnit.done = function(){};
518 | //because when this does happen, the assertion count parameter doesn't actually
519 | //work we use this test to check the assertion count.
520 | module("check previous test's assertion counts");
521 | test('count previous two test\'s assertions', function(){
522 | var spans = document.getElementsByTagName('span'),
523 | tests = [],
524 | countNodes;
525 |
526 | //find these two tests
527 | for (var i = 0; i < spans.length; i++) {
528 | if (spans[i].innerHTML.indexOf(testName) !== -1) {
529 | tests.push(spans[i]);
530 | }
531 | }
532 |
533 | //walk dom to counts
534 | countNodes = tests[0].nextSibling.nextSibling.getElementsByTagName('b');
535 | equal(countNodes[1].innerHTML, "99");
536 | countNodes = tests[1].nextSibling.nextSibling.getElementsByTagName('b');
537 | equal(countNodes[1].innerHTML, "99");
538 | });
539 | }
540 | QUnit.config.done = [];
541 | QUnit.done(secondAfterDoneTest);
542 |
543 | module("Synchronous test after load of page");
544 |
545 | asyncTest('Async test', function(){
546 | start();
547 | for (var i = 1; i < 100; i++) {
548 | ok(i);
549 | }
550 | });
551 |
552 | test(testName, 99, function(){
553 | for (var i = 1; i < 100; i++) {
554 | ok(i);
555 | }
556 | });
557 |
558 | //we need two of these types of tests in order to ensure that assertions
559 | //don't move between tests.
560 | test(testName + ' 2', 99, function(){
561 | for (var i = 1; i < 100; i++) {
562 | ok(i);
563 | }
564 | });
565 |
566 |
567 | }
568 |
569 | QUnit.done(testAfterDone);
570 |
571 | }
572 |
--------------------------------------------------------------------------------
/lib/mimic_2.2/source/mimic.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * Mimic (XML-RPC Client for JavaScript) v2.2
3 | * Copyright (C) 2005-2012 Carlos Eduardo Goncalves (cadu.goncalves@gmail.com)
4 | *
5 | * Mimic is dual licensed under the MIT (http://opensource.org/licenses/mit-license.php)
6 | * and GPLv3 (http://opensource.org/licenses/gpl-3.0.html) licenses.
7 | */
8 |
9 | /**
10 | * XmlRpc helper.
11 | */
12 | function XmlRpc() {
13 |
14 | };
15 |
16 | /**
17 | *
18 | * XML-RPC document prolog.
19 | *
20 | */
21 | XmlRpc.PROLOG = "\n";
22 |
23 | /**
24 | *
25 | * XML-RPC methodCall node template.
26 | *
27 | */
28 | XmlRpc.REQUEST = "\n${METHOD}\n\n${DATA}\n";
29 |
30 | /**
31 | *
32 | * XML-RPC param node template.
33 | *
34 | */
35 | XmlRpc.PARAM = "\n\n${DATA}\n\n";
36 |
37 | /**
38 | *
39 | * XML-RPC array node template.
40 | *
41 | */
42 | XmlRpc.ARRAY = "\n\n${DATA}\n\n";
43 |
44 | /**
45 | *
46 | * XML-RPC struct node template.
47 | *
48 | */
49 | XmlRpc.STRUCT = "\n${DATA}\n";
50 |
51 | /**
52 | *
53 | * XML-RPC member node template.
54 | *
55 | */
56 | XmlRpc.MEMBER = "\n${DATA}\n";
57 |
58 | /**
59 | *
60 | * XML-RPC name node template.
61 | *
62 | */
63 | XmlRpc.NAME = "${DATA}\n";
64 |
65 | /**
66 | *
67 | * XML-RPC value node template.
68 | *
69 | */
70 | XmlRpc.VALUE = "\n${DATA}\n";
71 |
72 | /**
73 | *
74 | * XML-RPC scalar node template (int, i4, double, string, boolean, base64,
75 | * dateTime.iso8601).
76 | *
77 | */
78 | XmlRpc.SCALAR = "<${TYPE}>${DATA}${TYPE}>\n";
79 |
80 | /**
81 | *
82 | * Get the tag name used to represent a JavaScript object in the XMLRPC
83 | * protocol.
84 | *
85 | *
86 | * @param data
87 | * A JavaScript object.
88 | * @return String with XMLRPC object type.
89 | */
90 | XmlRpc.getDataTag = function(data) {
91 | try {
92 | // Vars
93 | var tag = typeof data;
94 |
95 | switch (tag.toLowerCase()) {
96 | case "number":
97 | tag = (Math.round(data) == data) ? "int" : "double";
98 | break;
99 | case "object":
100 | if (data.constructor == Base64) {
101 | tag = "base64";
102 | } else if (data.constructor == String) {
103 | tag = "string";
104 | } else if (data.constructor == Boolean) {
105 | tag = "boolean";
106 | } else if (data.constructor == Array) {
107 | tag = "array";
108 | } else if (data.constructor == Date) {
109 | tag = "dateTime.iso8601";
110 | } else if (data.constructor == Number) {
111 | tag = (Math.round(data) == data) ? "int" : "double";
112 | } else {
113 | tag = "struct";
114 | }
115 | break;
116 | }
117 | return tag;
118 | } catch (e) {
119 | return null;
120 | }
121 | };
122 |
123 | /**
124 | *
125 | * Get JavaScript object type represented by XMLRPC protocol tag.
126 | *
127 | *
128 | * @param tag
129 | * A XMLRPC tag name.
130 | * @return A JavaScript object.
131 | */
132 | XmlRpc.getTagData = function(tag) {
133 | // Vars
134 | var data = null;
135 |
136 | switch (tag) {
137 | case "struct":
138 | data = new Object();
139 | break;
140 | case "array":
141 | data = new Array();
142 | break;
143 | case "datetime.iso8601":
144 | data = new Date();
145 | break;
146 | case "boolean":
147 | data = new Boolean();
148 | break;
149 | case "int":
150 | case "i4":
151 | case "double":
152 | data = new Number();
153 | break;
154 | case "string":
155 | data = new String();
156 | break;
157 | case "base64":
158 | data = new Base64();
159 | break;
160 | }
161 | return data;
162 | };
163 |
164 | /**
165 | * XmlRpcRequest.
166 | *
167 | * @param url
168 | * Server url.
169 | * @param method
170 | * Server side method do call.
171 | */
172 | function XmlRpcRequest(url, method) {
173 | this.serviceUrl = url;
174 | this.methodName = method;
175 | this.params = [];
176 | };
177 |
178 | /**
179 | *
180 | * Add a new request parameter.
181 | *
182 | *
183 | * @param data
184 | * New parameter value.
185 | */
186 | XmlRpcRequest.prototype.addParam = function(data) {
187 | // Vars
188 | var type = typeof data;
189 |
190 | switch (type.toLowerCase()) {
191 | case "function":
192 | return;
193 | case "object":
194 | if (!data.constructor.name){
195 | return;
196 | }
197 | }
198 | this.params.push(data);
199 | };
200 |
201 | /**
202 | *
203 | * Clear all request parameters.
204 | *
205 | *
206 | * @param data
207 | * New parameter value.
208 | */
209 | XmlRpcRequest.prototype.clearParams = function() {
210 | this.params.splice(0, this.params.length);
211 | };
212 |
213 | /**
214 | *
215 | * Execute a synchronous XML-RPC request.
216 | *
217 | *
218 | * @return XmlRpcResponse object.
219 | */
220 | XmlRpcRequest.prototype.send = function() {
221 | // Vars
222 | var xml_params = "",
223 | i = 0,
224 | xml_call, xhr;
225 |
226 | for (i = 0; i < this.params.length; i++) {
227 | xml_params += XmlRpc.PARAM.replace("${DATA}", this.marshal(this.params[i]));
228 | }
229 | xml_call = XmlRpc.REQUEST.replace("${METHOD}", this.methodName);
230 | xml_call = XmlRpc.PROLOG + xml_call.replace("${DATA}", xml_params);
231 | xhr = Builder.buildXHR();
232 | xhr.open("POST", this.serviceUrl, false);
233 | xhr.send(Builder.buildDOM(xml_call));
234 | return new XmlRpcResponse(xhr.responseXML);
235 | };
236 |
237 | /**
238 | *
239 | * Marshal request parameters.
240 | *
241 | *
242 | * @param data
243 | * A request parameter.
244 | * @return String with XML-RPC element notation.
245 | */
246 | XmlRpcRequest.prototype.marshal = function(data) {
247 | // Vars
248 | var type = XmlRpc.getDataTag(data),
249 | scalar_type = XmlRpc.SCALAR.replace(/\$\{TYPE\}/g, type),
250 | xml = "",
251 | value, i, member;
252 |
253 | switch (type) {
254 | case "struct":
255 | member = "";
256 | for (i in data) {
257 | value = "";
258 | value += XmlRpc.NAME.replace("${DATA}", i);
259 | value += XmlRpc.VALUE.replace("${DATA}", this.marshal(data[i]));
260 | member += XmlRpc.MEMBER.replace("${DATA}", value);
261 | }
262 | xml = XmlRpc.STRUCT.replace("${DATA}", member);
263 | break;
264 | case "array":
265 | value = "";
266 | for (i = 0; i < data.length; i++) {
267 | value += XmlRpc.VALUE.replace("${DATA}", this.marshal(data[i]));
268 | }
269 | xml = XmlRpc.ARRAY.replace("${DATA}", value);
270 | break;
271 | case "dateTime.iso8601":
272 | xml = scalar_type.replace("${DATA}", data.toIso8601());
273 | break;
274 | case "boolean":
275 | xml = scalar_type.replace("${DATA}", (data == true) ? 1 : 0);
276 | break;
277 | case "base64":
278 | xml = scalar_type.replace("${DATA}", data.encode());
279 | break;
280 | default:
281 | xml = scalar_type.replace("${DATA}", data);
282 | break;
283 | }
284 | return xml;
285 | };
286 |
287 | /**
288 | * XmlRpcResponse.
289 | *
290 | * @param xml
291 | * Response XML document.
292 | */
293 | function XmlRpcResponse(xml) {
294 | this.xmlData = xml;
295 | };
296 |
297 | /**
298 | *
299 | * Indicate if response is a fault.
300 | *
301 | *
302 | * @return Boolean flag indicating fault status.
303 | */
304 | XmlRpcResponse.prototype.isFault = function() {
305 | return this.faultValue;
306 | };
307 |
308 | /**
309 | *
310 | * Parse XML response to JavaScript.
311 | *
312 | *
313 | * @return JavaScript object parsed from XML-RPC document.
314 | */
315 | XmlRpcResponse.prototype.parseXML = function() {
316 | // Vars
317 | var i, nodesLength;
318 |
319 | nodesLength = this.xmlData.childNodes.length;
320 | this.faultValue = undefined;
321 | this.currentIsName = false;
322 | this.propertyName = "";
323 | this.params = [];
324 | for (i = 0; i < nodesLength; i++) {
325 | this.unmarshal(this.xmlData.childNodes[i], 0);
326 | }
327 | return this.params[0];
328 | };
329 |
330 | /**
331 | *
332 | * Unmarshal response parameters.
333 | *
334 | *
335 | * @param node
336 | * Current document node under processing.
337 | * @param parent
338 | * Current node' parent node.
339 | */
340 | XmlRpcResponse.prototype.unmarshal = function(node, parent) {
341 | // Vars
342 | var obj, tag, i, nodesLength;
343 |
344 | if (node.nodeType == 1) {
345 | obj = null;
346 | tag = node.tagName.toLowerCase();
347 | switch (tag) {
348 | case "fault":
349 | this.faultValue = true;
350 | break;
351 | case "name":
352 | this.currentIsName = true;
353 | break;
354 | default:
355 | obj = XmlRpc.getTagData(tag);
356 | break;
357 | }
358 | if (obj != null) {
359 | this.params.push(obj);
360 | if (tag == "struct" || tag == "array") {
361 | if (this.params.length > 1) {
362 | switch (XmlRpc.getDataTag(this.params[parent])) {
363 | case "struct":
364 | this.params[parent][this.propertyName] = this.params[this.params.length - 1];
365 | break;
366 | case "array":
367 | this.params[parent].push(this.params[this.params.length - 1]);
368 | break;
369 | }
370 | }
371 | parent = this.params.length - 1;
372 | }
373 | }
374 | nodesLength = node.childNodes.length;
375 | for (i = 0; i < nodesLength; i++) {
376 | this.unmarshal(node.childNodes[i], parent);
377 | }
378 | }
379 | if ((node.nodeType == 3) && (/[^\t\n\r ]/.test(node.nodeValue))) {
380 | if (this.currentIsName == true) {
381 | this.propertyName = node.nodeValue;
382 | this.currentIsName = false;
383 | } else {
384 | switch (XmlRpc.getDataTag(this.params[this.params.length - 1])) {
385 | case "dateTime.iso8601":
386 | this.params[this.params.length - 1] = Date.fromIso8601(node.nodeValue);
387 | break;
388 | case "boolean":
389 | this.params[this.params.length - 1] = (node.nodeValue == "1") ? true : false;
390 | break;
391 | case "int":
392 | case "double":
393 | this.params[this.params.length - 1] = new Number(node.nodeValue);
394 | break;
395 | case "string":
396 | this.params[this.params.length - 1] = new String(node.nodeValue);
397 | break;
398 | case "base64":
399 | this.params[this.params.length - 1] = new Base64(node.nodeValue);
400 | break;
401 | }
402 | if (this.params.length > 1) {
403 | switch (XmlRpc.getDataTag(this.params[parent])) {
404 | case "struct":
405 | this.params[parent][this.propertyName] = this.params[this.params.length - 1];
406 | break;
407 | case "array":
408 | this.params[parent].push(this.params[this.params.length - 1]);
409 | break;
410 | }
411 | }
412 | }
413 | }
414 | };
415 |
416 | /**
417 | * Builder helper for W3C / ActiveX objects
418 | */
419 | function Builder() {
420 |
421 | };
422 |
423 | /**
424 | *
425 | * Build a valid XMLHttpRequest object
426 | *
427 | *
428 | * @return XMLHttpRequest object.
429 | */
430 | Builder.buildXHR = function() {
431 | return (typeof XMLHttpRequest != "undefined") ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
432 | };
433 |
434 | /**
435 | *
436 | * Build a valid XML document from string markup.
437 | *
438 | *
439 | * @param xml
440 | * Document markup.
441 | * @return XMLDocument object.
442 | */
443 | Builder.buildDOM = function(xml) {
444 | // Vars
445 | var parser, names, i;
446 |
447 | if (typeof DOMParser != "undefined") {
448 | parser = new DOMParser();
449 | return parser.parseFromString(xml, "text/xml");
450 | } else {
451 | names = [ "Microsoft.XMLDOM", "MSXML2.DOMDocument", "MSXML.DOMDocument" ];
452 | for (i = 0; i < names.length; i++) {
453 | try {
454 | parser = new ActiveXObject(names[i]);
455 | parser.loadXML(xml);
456 | return parser;
457 | } catch (e) {
458 | /* Ignore */
459 | }
460 | }
461 | }
462 | return null;
463 | };
464 |
465 | /**
466 | * Date extensions.
467 | */
468 |
469 | /**
470 | *
471 | * Convert a GMT date to ISO8601.
472 | *
473 | *
474 | * @return String with an ISO8601 date.
475 | */
476 | Date.prototype.toIso8601 = function() {
477 | // Vars
478 | var year = this.getYear(),
479 | month = this.getMonth() + 1,
480 | day = this.getDate(),
481 | time = this.toTimeString().substr(0, 8);
482 |
483 | // Normalization
484 | if (year < 1900) {
485 | year += 1900;
486 | }
487 | if (month < 10) {
488 | month = "0" + month;
489 | }
490 | if (day < 10) {
491 | day = "0" + day;
492 | }
493 |
494 | return year + month + day + "T" + time;
495 | };
496 |
497 | /**
498 | *
499 | * Convert ISO8601 date to GMT.
500 | *
501 | *
502 | * @param value
503 | * ISO8601 date.
504 | * @return GMT date.
505 | */
506 | Date.fromIso8601 = function(value) {
507 | // Vars
508 | var year = value.substr(0, 4),
509 | month = value.substr(4, 2),
510 | day = value.substr(6, 2),
511 | hour = value.substr(9, 2),
512 | minute = value.substr(12, 2),
513 | sec = value.substr(15, 2);
514 |
515 | return new Date(year, month - 1, day, hour, minute, sec, 0);
516 | };
517 |
518 | /**
519 | * Base64 implementation.
520 | */
521 | function Base64(value) {
522 | this.bytes = value;
523 | };
524 |
525 | /**
526 | *
527 | * Base64 characters map.
528 | *
529 | */
530 | Base64.CHAR_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
531 |
532 | /**
533 | *
534 | * Encode the object bytes using base64 algorithm.
535 | *
536 | *
537 | * @return Encoded string.
538 | */
539 | Base64.prototype.encode = function() {
540 | if (typeof btoa == "function") {
541 | return btoa(this.bytes);
542 | } else {
543 | // Vars
544 | var _byte = [],
545 | _char = [],
546 | _result = [],
547 | j = 0, i = 0;
548 |
549 | for (i = 0; i < this.bytes.length; i += 3) {
550 | _byte[0] = this.bytes.charCodeAt(i);
551 | _byte[1] = this.bytes.charCodeAt(i + 1);
552 | _byte[2] = this.bytes.charCodeAt(i + 2);
553 | _char[0] = _byte[0] >> 2;
554 | _char[1] = ((_byte[0] & 3) << 4) | (_byte[1] >> 4);
555 | _char[2] = ((_byte[1] & 15) << 2) | (_byte[2] >> 6);
556 | _char[3] = _byte[2] & 63;
557 | if (isNaN(_byte[1])) {
558 | _char[2] = _char[3] = 64;
559 | } else if (isNaN(_byte[2])) {
560 | _char[3] = 64;
561 | }
562 | _result[j++] = Base64.CHAR_MAP.charAt(_char[0])
563 | + Base64.CHAR_MAP.charAt(_char[1])
564 | + Base64.CHAR_MAP.charAt(_char[2])
565 | + Base64.CHAR_MAP.charAt(_char[3]);
566 | }
567 | return _result.join("");
568 | }
569 | };
570 |
571 | /**
572 | *
573 | * Decode the object bytes using base64 algorithm.
574 | *
575 | *
576 | * @return Decoded string.
577 | */
578 | Base64.prototype.decode = function() {
579 | if (typeof atob == "function") {
580 | return atob(this.bytes);
581 | } else {
582 | // Vars
583 | var _byte = [],
584 | _char = [],
585 | _result = [],
586 | j = 0, i = 0;
587 |
588 | while ((this.bytes.length % 4) != 0) {
589 | this.bytes += "=";
590 | }
591 | for (i = 0; i < this.bytes.length; i += 4) {
592 | _char[0] = Base64.CHAR_MAP.indexOf(this.bytes.charAt(i));
593 | _char[1] = Base64.CHAR_MAP.indexOf(this.bytes.charAt(i + 1));
594 | _char[2] = Base64.CHAR_MAP.indexOf(this.bytes.charAt(i + 2));
595 | _char[3] = Base64.CHAR_MAP.indexOf(this.bytes.charAt(i + 3));
596 | _byte[0] = (_char[0] << 2) | (_char[1] >> 4);
597 | _byte[1] = ((_char[1] & 15) << 4) | (_char[2] >> 2);
598 | _byte[2] = ((_char[2] & 3) << 6) | _char[3];
599 | _result[j++] = String.fromCharCode(_byte[0]);
600 | if (_char[2] != 64) {
601 | _result[j++] = String.fromCharCode(_byte[1]);
602 | }
603 | if (_char[3] != 64) {
604 | _result[j++] = String.fromCharCode(_byte[2]);
605 | }
606 | }
607 | return _result.join("");
608 | }
609 | };
--------------------------------------------------------------------------------
/lib/mimic_2.2/test/mimic-test.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * Mimic (XML-RPC Client for JavaScript) v2.2
3 | * Copyright (C) 2005-2012 Carlos Eduardo Goncalves (cadu.goncalves@gmail.com)
4 | *
5 | * Mimic is dual licensed under the MIT (http://opensource.org/licenses/mit-license.php)
6 | * and GPLv3 (http://opensource.org/licenses/gpl-3.0.html) licenses.
7 | */
8 |
9 | // -----------------------------------------------------------------------
10 | // JavaScript Type detection
11 | // -----------------------------------------------------------------------
12 | module("JavaScript Types");
13 |
14 | test("Boolean detection", function() {
15 | expect(2);
16 | equal(XmlRpc.getDataTag(false), "boolean", "Match literal");
17 | equal(XmlRpc.getDataTag(new Boolean(true)), "boolean", "Match object");
18 | });
19 |
20 | test("Array detection", function() {
21 | expect(2);
22 | equal(XmlRpc.getDataTag( [ 1, "name", false ]), "array", "Match literal");
23 | equal(XmlRpc.getDataTag(new Array()), "array", "Match object");
24 | });
25 |
26 | test("String detection", function() {
27 | expect(2);
28 | equal(XmlRpc.getDataTag("hello"), "string", "Match literal");
29 | equal(XmlRpc.getDataTag(new String()), "string", "Match object");
30 | });
31 |
32 | test("Number detection", function() {
33 | expect(4);
34 | equal(XmlRpc.getDataTag(1000), "int", "Match literal");
35 | equal(XmlRpc.getDataTag(10.33), "double", "Match literal");
36 | equal(XmlRpc.getDataTag(new Number(3.14159265)), "double", "Match object");
37 | equal(XmlRpc.getDataTag(new Number(2)), "int", "Match object");
38 | });
39 |
40 | test("Date detection", function() {
41 | expect(2);
42 | equal(XmlRpc.getDataTag(new Date()), "dateTime.iso8601", "Match object");
43 | equal(XmlRpc.getDataTag(new Date(9999999)), "dateTime.iso8601", "Match object");
44 | });
45 |
46 | test("Base64 detection", function() {
47 | expect(2);
48 | equal(XmlRpc.getDataTag(new Base64("")), "base64", "Match object");
49 | equal(XmlRpc.getDataTag(new Base64("base64")), "base64", "Match object");
50 | });
51 |
52 | test("Object detection", function() {
53 | expect(2);
54 | equal(XmlRpc.getDataTag( {
55 | name : "Mimic"
56 | }), "struct", "Match literal");
57 | equal(XmlRpc.getDataTag(new Object()), "struct", "Match object");
58 | });
59 |
60 |
61 | // -----------------------------------------------------------------------
62 | // XML-RPC Type Detection
63 | // -----------------------------------------------------------------------
64 | module("XML-RPC Types");
65 |
66 | test("Boolean detection", function() {
67 | // Fixture
68 | var value = XmlRpc.getTagData("boolean");
69 | // Test
70 | expect(2);
71 | ok(typeof value !== "boolean", "Is not literal");
72 | ok(value.constructor === Boolean, "Is new Boolean");
73 | });
74 |
75 | test("Array detection", function() {
76 | // Fixture
77 | var value = XmlRpc.getTagData("array");
78 | // Test
79 | expect(2);
80 | ok(typeof value !== "array", "Is not literal");
81 | ok(value.constructor === Array, "Is new Array");
82 | });
83 |
84 | test("String detection", function() {
85 | // Fixture
86 | var value = XmlRpc.getTagData("string");
87 | // Test
88 | expect(2);
89 | ok(typeof value !== "string", "Is not literal");
90 | ok(value.constructor === String, "Is new String");
91 | });
92 |
93 | test("Int detection", function() {
94 | // Fixture
95 | var value = XmlRpc.getTagData("int");
96 | // Test
97 | expect(4);
98 | ok(typeof value !== "number", "Is not literal");
99 | ok(value.constructor === Number, "Is new Number");
100 |
101 | // Fixture
102 | value = XmlRpc.getTagData("double");
103 | // Test
104 | ok(typeof value !== "number", "Is not literal");
105 | ok(value.constructor === Number, "Is new Number");
106 | });
107 |
108 | test("Double detection", function() {
109 | // Fixture
110 | var value = XmlRpc.getTagData("double");
111 | // Test
112 | expect(2);
113 | ok(typeof value !== "number", "Is not literal");
114 | ok(value.constructor === Number, "Is new Number");
115 | });
116 |
117 | test("DateTime.iso8601 detection", function() {
118 | // Fixture
119 | var value = XmlRpc.getTagData("datetime.iso8601");
120 | // Test
121 | expect(2);
122 | ok(typeof value === "object", "Is object");
123 | ok(value.constructor === Date, "Is new Date");
124 | });
125 |
126 | test("Base64 detection", function() {
127 | // Fixture
128 | var value = XmlRpc.getTagData("base64");
129 | // Test
130 | expect(2);
131 | ok(typeof value === "object", "Is object");
132 | ok(value.constructor === Base64, "Is new Base64")
133 | });
134 |
135 | test("Struct detection", function() {
136 | // Test
137 | expect(1);
138 | ok(typeof XmlRpc.getTagData("struct") === "object", "Is Object");
139 | });
140 |
141 |
142 | // -----------------------------------------------------------------------
143 | // Marshal
144 | // -----------------------------------------------------------------------
145 | module("Marshal");
146 |
147 | test("Boolean marshal", function() {
148 | // Fixture
149 | var request, valueA, valueB;
150 | request = new XmlRpcRequest();
151 | valueA = new Boolean(false);
152 | valueB = true;
153 | // Test
154 | expect(4);
155 | ok(/^\0\<\/boolean\>\n$/.test(request.marshal(valueA)), "Serialization is ok");
156 | ok(/^\1\<\/boolean\>\n$/.test(request.marshal(valueB)), "Serialization is ok");
157 | notEqual(request.marshal(valueA), request.marshal(valueB), "Values must be different");
158 | equal(request.marshal(valueA), request.marshal(valueA), "Values must be equal");
159 | });
160 |
161 | test("Array marshal", function() {
162 | // Fixture
163 | var request, valueA, valueB;
164 | request = new XmlRpcRequest();
165 | valueA = [ 1, 2, 3 ];
166 | valueB = new Array();
167 | valueB.push("1");
168 | valueB.push("2");
169 | valueB.push("3");
170 | // Test
171 | expect(4);
172 | ok(/^\(.*)/.test(request.marshal(valueA)), "Serialization is ok");
173 | ok(/^\(.*)/.test(request.marshal(valueB)), "Serialization is ok");
174 | notEqual(request.marshal(valueA), request.marshal(valueB), "Values must be different");
175 | equal(request.marshal(valueA), request.marshal(valueA), "Values must be equal");
176 | });
177 |
178 | test("Array of Array marshal", function() {
179 | // Fixture
180 | var request, valueA, valueB;
181 | request = new XmlRpcRequest();
182 | valueA = [[1,2], ["a", "b"]];
183 | // Test
184 | expect(1);
185 | ok(/^\\n\\n\\n\(.*)/.test(request.marshal(valueA)), "Serialization is ok");
186 | });
187 |
188 | test("String marshal", function() {
189 | // Fixture
190 | var request, valueA, valueB;
191 | request = new XmlRpcRequest();
192 | valueA = "Jonh";
193 | valueB = new String("Mary");
194 | // Test
195 | expect(4);
196 | ok(/^\Jonh\<\/string\>\n$/.test(request.marshal(valueA)), "Serialization is ok");
197 | ok(/^\Mary\<\/string\>\n$/.test(request.marshal(valueB)), "Serialization is ok");
198 | notEqual(request.marshal(valueA), request.marshal(valueB), "Values must be different");
199 | equal(request.marshal(valueA), request.marshal(valueA), "Values must be equal");
200 | });
201 |
202 | test("Number marshal", function() {
203 | // Fixture
204 | var request, valueIntA, valueIntB, valueDoubleA, valueDoubleB;
205 | request = new XmlRpcRequest();
206 | valueIntA = 33;
207 | valueIntB = new Number(9999);
208 | valueDoubleA = 33.01;
209 | valueDoubleB = new Number(9999.01);
210 |
211 | // Test
212 | expect(8);
213 | ok(/^\33\<\/int\>\n$/.test(request.marshal(valueIntA)), "Serialization is ok");
214 | ok(/^\9999\<\/int\>\n$/.test(request.marshal(valueIntB)), "Serialization is ok");
215 | ok(/^\33.01\<\/double\>\n$/.test(request.marshal(valueDoubleA)), "Serialization is ok");
216 | ok(/^\9999.01\<\/double\>\n$/.test(request.marshal(valueDoubleB)), "Serialization is ok");
217 | notEqual(request.marshal(valueIntA), request.marshal(valueIntB), "Values must be different");
218 | notEqual(request.marshal(valueDoubleA), request.marshal(valueDoubleB), "Values must be different");
219 | equal(request.marshal(valueIntA), request.marshal(valueIntA), "Values must be equal");
220 | equal(request.marshal(valueDoubleA), request.marshal(valueDoubleA), "Values must be equal");
221 | });
222 |
223 | test("Date marshal", function() {
224 | // Fixture
225 | var request, valueA, valueB;
226 | request = new XmlRpcRequest();
227 | valueA = new Date();
228 | valueB = new Date(9999999);
229 | // Test
230 | expect(4);
231 | ok(/^\(.*)\<\/dateTime.iso8601\>\n$/.test(request.marshal(valueA)), "Serialization is ok");
232 | ok(/^\(.*)\<\/dateTime.iso8601\>\n$/.test(request.marshal(valueB)), "Serialization is ok");
233 | notEqual(request.marshal(valueA), request.marshal(valueB), "Values must be different");
234 | equal(request.marshal(valueA), request.marshal(valueA), "Values must be equal");
235 | });
236 |
237 | test("Base64 marshal", function() {
238 | // Fixture
239 | var request, valueA, valueB;
240 | request = new XmlRpcRequest();
241 | valueA = new Base64("user");
242 | valueB = new Base64("password");
243 | // Test
244 | expect(4);
245 | ok(/^\(.*)\<\/base64\>\n$/.test(request.marshal(valueA)), "Serialization is ok");
246 | ok(/^\(.*)\<\/base64\>\n$/.test(request.marshal(valueB)), "Serialization is ok");
247 | notEqual(request.marshal(valueA), request.marshal(valueB), "Values must be different");
248 | equal(request.marshal(valueA), request.marshal(valueA), "Values must be equal");
249 | });
250 |
251 | test("Object marshal", function() {
252 | // Fixture
253 | var request, valueA, valueB;
254 | request = new XmlRpcRequest();
255 | valueA = {
256 | name: "Mimic",
257 | version: 2.01
258 | };
259 | valueB = new Object();
260 | valueB.name = "Other";
261 | valueB.version = 2.01;
262 |
263 | // Test
264 | expect(4);
265 | ok(/^\(.*)/.test(request.marshal(valueA)), "Serialization is ok");
266 | ok(/^\(.*)/.test(request.marshal(valueB)), "Serialization is ok");
267 | notEqual(request.marshal(valueA), request.marshal(valueB), "Values must be different");
268 | equal(request.marshal(valueA), request.marshal(valueA), "Values must be equal");
269 | });
270 |
271 |
272 | // -----------------------------------------------------------------------
273 | // Unmarshal
274 | // -----------------------------------------------------------------------
275 | module("Unmarshal");
276 |
277 | test("Boolean unmarshal", function() {
278 | // Fixture
279 | var xml, response;
280 | xml = [];
281 | xml.push("","");
282 | xml.push("");
283 | xml.push("", "0", "")
284 | xml.push("", "1", "")
285 | xml.push("");
286 | xml.push("","");
287 | response = new XmlRpcResponse(Builder.buildDOM(xml.join("")));
288 | // Test
289 | expect(2);
290 | response.parseXML();
291 | equal(response.params[0], false, "Match false");
292 | equal(response.params[1], true, "Match true");
293 | });
294 |
295 | test("Array unmarshal", function() {
296 | // Fixture
297 | var xml, response;
298 | xml = [];
299 | xml.push("","");
300 | xml.push("");
301 | xml.push("", "");
302 | xml.push("", "friends", "");
303 | xml.push("", "preferences", "");
304 | xml.push("", "likes", "");
305 | xml.push("", "", "");
306 | xml.push("", "10", "");
307 | xml.push("", "20", "");
308 | xml.push("", "30", "");
309 | xml.push("", "", "");
310 | xml.push("", "");
311 | xml.push("");
312 | xml.push("","");
313 | response = new XmlRpcResponse(Builder.buildDOM(xml.join("")));
314 | // Test
315 | expect(4);
316 | response.parseXML();
317 | equal(response.params[0][0], "friends", "Value match");
318 | equal(response.params[0][1], "preferences", "Value match");
319 | equal(response.params[0][2], "likes", "Value match");
320 | deepEqual(response.params[0][3], [10, 20, 30], "Inner array match");
321 | });
322 |
323 | test("String unmarshal", function() {
324 | // Fixture
325 | var xml, response;
326 | xml = [];
327 | xml.push("","");
328 | xml.push("");
329 | xml.push("", "Hello world", "")
330 | xml.push("");
331 | xml.push("","");
332 | response = new XmlRpcResponse(Builder.buildDOM(xml.join("")));
333 | // Test
334 | expect(1);
335 | response.parseXML();
336 | equal(response.params[0], "Hello world");
337 | });
338 |
339 | test("Int unmarshal", function() {
340 | // Fixture
341 | var xml, response;
342 | xml = [];
343 | xml.push("","");
344 | xml.push("");
345 | xml.push("", "9129932", "")
346 | xml.push("", "4", "")
347 | xml.push("");
348 | xml.push("","");
349 | response = new XmlRpcResponse(Builder.buildDOM(xml.join("")));
350 | // Test
351 | expect(2);
352 | response.parseXML();
353 | equal(response.params[0], 9129932, "Match number");
354 | equal(response.params[1], 4, "Match number");
355 | });
356 |
357 | test("Double unmarshal", function() {
358 | // Fixture
359 | var xml, response;
360 | xml = [];
361 | xml.push("","");
362 | xml.push("");
363 | xml.push("", "9129.932", "")
364 | xml.push("", "4", "")
365 | xml.push("");
366 | xml.push("","");
367 | response = new XmlRpcResponse(Builder.buildDOM(xml.join("")));
368 | // Test
369 | expect(2);
370 | response.parseXML();
371 | equal(response.params[0], 9129.932, "Match number");
372 | equal(response.params[1], 4, "Match number");
373 | });
374 |
375 | test("Date unmarshal", function() {
376 | // Fixture
377 | var xml, response;
378 | xml = [];
379 | xml.push("","");
380 | xml.push("");
381 | xml.push("", "20120120T15:08:55", "")
382 | xml.push("");
383 | xml.push("","");
384 | response = new XmlRpcResponse(Builder.buildDOM(xml.join("")));
385 | // Test
386 | expect(1);
387 | response.parseXML();
388 | ok(response.params[0].constructor === Date, "Must match Date");
389 | });
390 |
391 | test("Base64 unmarshal", function() {
392 | // Fixture
393 | var xml, response;
394 | xml = [];
395 | xml.push("","");
396 | xml.push("");
397 | xml.push("", "eW91IGNhbid0IHJlYWQgdGhpcyE=", "")
398 | xml.push("");
399 | xml.push("","");
400 | response = new XmlRpcResponse(Builder.buildDOM(xml.join("")));
401 | // Test
402 | expect(1);
403 | response.parseXML();
404 | ok(response.params[0].constructor === Base64, "Must match Bas64");
405 | });
406 |
407 | test("Struct unmarshal", function() {
408 | // Fixture
409 | var xml, response;
410 | xml = [];
411 | xml.push("","");
412 | xml.push("");
413 | xml.push("");
414 | // Hash
415 | xml.push("");
416 | xml.push("", "hash", "");
417 | xml.push("", "eW91IGNhbid0IHJlYWQgdGhpcyE=", "");
418 | xml.push("");
419 | // Age
420 | xml.push("");
421 | xml.push("", "age", "");
422 | xml.push("", "365", "");
423 | xml.push("");
424 | // User
425 | xml.push("");
426 | xml.push("", "user", "");
427 | xml.push("", "johndoe", "");
428 | xml.push("");
429 | // Friends
430 | xml.push("");
431 | xml.push("", "friends", "");
432 | xml.push("", "", "");
433 | xml.push("", "mary", "");
434 | xml.push("", "carlos", "");
435 | xml.push("", "nadia", "");
436 | xml.push("", "", "");
437 | xml.push("");
438 | xml.push("");
439 | xml.push("");
440 | xml.push("","");
441 | response = new XmlRpcResponse(Builder.buildDOM(xml.join("")));
442 | // Test
443 | expect(4);
444 | response.parseXML();
445 | ok(response.params[0].hash.constructor === Base64, "Hash match");
446 | equal(response.params[0].age, "365", "Age match");
447 | equal(response.params[0].user, "johndoe", "User match");
448 | deepEqual(response.params[0].friends, ["mary", "carlos", "nadia"], "Array of friends match");
449 | });
450 |
451 |
452 | // -----------------------------------------------------------------------
453 | // Miscellaneous
454 | // -----------------------------------------------------------------------
455 | module("Miscellaneous");
456 |
457 | test("Request params", function() {
458 | // Fixture
459 | var request = new XmlRpcRequest();
460 |
461 | // Test
462 | expect(3);
463 | request.addParam("username");
464 | request.addParam(false);
465 | ok(request.params.length == 2, "Two params");
466 | request.clearParams();
467 | ok(request.params.length == 0, "No params");
468 | request.addParam(12);
469 | ok(request.params.length == 1, "One param");
470 | });
471 |
472 |
473 | test("Fault response", function() {
474 | // Fixture
475 | var xml, response;
476 | xml = [];
477 | xml.push("", "", "");
478 | xml.push("");
479 | // Fault code
480 | xml.push("");
481 | xml.push("", "faultCode", "");
482 | xml.push("", "404", "");
483 | xml.push("");
484 | // Fault string
485 | xml.push("");
486 | xml.push("", "faultString", "");
487 | xml.push("", "Not found", "");
488 | xml.push("");
489 | xml.push("");
490 | xml.push("","","");
491 | response = new XmlRpcResponse(Builder.buildDOM(xml.join("")));
492 | // Test
493 | expect(1);
494 | response.parseXML();
495 | ok(response.faultValue, "Is fault response");
496 | });
--------------------------------------------------------------------------------
/lib/jquery-qunit/addons/themes/gabe.css:
--------------------------------------------------------------------------------
1 | /**
2 | * QUnit Theme by Gabe Hendry
3 | *
4 | * http://docs.jquery.com/QUnit
5 | *
6 | * Copyright (c) 2012 John Resig, Jörn Zaefferer
7 | * Dual licensed under the MIT (MIT-LICENSE.txt)
8 | * or GPL (GPL-LICENSE.txt) licenses.
9 | */
10 |
11 | /** General Styles and Page Sturcture */
12 | body {
13 | font-family:Arial, 'sans serif';
14 | padding:20px 20px 0 20px;
15 | position:relative;
16 | }
17 |
18 | h1, h2, h3, h4, h5, h6, #qunit-header, #qunit-banner {
19 | font-family:Calibri, Arial, 'sans-serif';
20 | }
21 |
22 | h2 #qunit-tests, h2 #qunit-testrunner-toolbar, h2 #qunit-userAgent, #qunit-testresult {
23 | font-family: Arial, 'sans-serif';
24 | }
25 |
26 | #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
27 | #qunit-tests { font-size: smaller; }
28 |
29 |
30 | /** Resets */
31 |
32 | #qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
33 | margin: 0;
34 | padding: 0;
35 | }
36 |
37 |
38 | /** Headers */
39 |
40 | #qunit-header {
41 | padding: 10px 0px 25px 0px;
42 | color: #3B73B9;
43 | font-size: 1.8em;
44 | font-weight: normal;
45 | height:2em;
46 | }
47 |
48 | #qunit-header a {
49 | text-decoration: none;
50 | color: #3B73B9;
51 | font-weight:bold;
52 | padding-right:22px;
53 | float:left;
54 |
55 | }
56 |
57 | #qunit-header label {
58 | font-size:14px;
59 | color:#6BC9ED;
60 | float:right;
61 | font-family:Arial, 'sans-serif';
62 | display: inline-block;
63 | }
64 |
65 | #qunit-header a + label:after {
66 | content: ' }';
67 | }
68 |
69 | #qunit-header label + label {
70 | margin-right:8px;
71 | }
72 |
73 | #qunit-header a:hover, #qunit-header a:focus {
74 | color: #3B73B9;
75 | background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAcCAYAAABoMT8aAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2RpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo4RjRENzREMkRFMzBFMTExQkZCM0YxOUI1MEUyRUQ0OCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpERkFDNTFBMjMwREYxMUUxQTA3RjlDQkNDQzY3MkI4MCIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpERkFDNTFBMTMwREYxMUUxQTA3RjlDQkNDQzY3MkI4MCIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1IFdpbmRvd3MiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo4RjRENzREMkRFMzBFMTExQkZCM0YxOUI1MEUyRUQ0OCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo4RjRENzREMkRFMzBFMTExQkZCM0YxOUI1MEUyRUQ0OCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PjKftvwAAAFqSURBVHja5NTNKwVRHMbxey9X3rrXStlY2ljJRiQLGytLIkUpIks7lIUFC9laCX+DhUiSlMRdsFBSdkqSt4u8ju+vnqkxZriZheTUp1NzzvxmzjnPTNxxnFiUlohFbL9fIL9xeOUf7EEiSgEbf8XUTwv04A59mIuyB2VowyqKvytQjkU8YwaFul6CJmQ+5MB38zSGUIAs8vCi3loc6bA3mECvJl2o0Jhn/B47qAorMIgU9lGJBc/YDZbQgNugAt1I4gGtepq1ZTxiHu2B34L6LpRiD6ee8UPUqfe2lPbl0i1Qoz4T8JCgm89hf6IKdwnX6tM5ZGIEb1py1i2wporNORToUDa2LStugVntdPKr3GvMUnmFUe8p2No3FNOBkCIWsn7NOcC6Pwd2EicoUiZsnVvYxZNutpM601F/CpIFpNazH5bIel1LqOAmqrWEwG/BirQorp3KgL3yMSZxFBYkf7OJ43/jp/ouwAB8JktCUeXXIAAAAABJRU5ErkJggg==') center right no-repeat;
76 | }
77 |
78 | h2, p {
79 | padding: 10px 0 10px 0;
80 | margin:0;
81 | font-size:1.3em;
82 | }
83 |
84 | p {
85 | padding-top:0;
86 | font-size:small;
87 | color:#7B7979;
88 | line-height:1.6em;
89 | }
90 |
91 | h2#qunit-banner {
92 | height: 16px;
93 | padding:5px 5px 5px 25px;
94 | line-height:16px;
95 | margin:0px 0 15px 0;
96 | border-radius: 5px;
97 | -moz-border-radius: 5px;
98 | -webkit-border-radius: 5px;
99 | background-position:0px;
100 | background-repeat:no-repeat;
101 | font-size:1em;
102 | font-weight:normal;
103 | }
104 |
105 | h2#qunit-banner.qunit-pass {
106 | background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyBpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBXaW5kb3dzIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjc1RjgyNEY5MzE2NzExRTFCQTA0RTIzMEVFNkY4ODM2IiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjc1RjgyNEZBMzE2NzExRTFCQTA0RTIzMEVFNkY4ODM2Ij4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NzVGODI0RjczMTY3MTFFMUJBMDRFMjMwRUU2Rjg4MzYiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6NzVGODI0RjgzMTY3MTFFMUJBMDRFMjMwRUU2Rjg4MzYiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz4C94F5AAAAwklEQVR42mL8//8/AyWAiYFCQLEBLOW7GEnVYwzEaUC8B4hXs5CoWRCIVwGxEtQQE1K9ANMMN5AUAzqA2AWJ/x6IzxJrAMi55WhiriBDYAYoEQi0DjSxdJDtsGgESd4F4jNYDAIF2m4oDQOzoBieDsqRbDoDpWEAXfMeqO0oCWkPmo1noH6eiWbYPSAOw5YSQYKr0cRnQg1BDvEwKI1hAEyyAk9AVsACDV9e6MRhSydyoBHKTKuh8bsHSTM+lzEABBgAXD0oIFydPtEAAAAASUVORK5CYII=');
107 | color:#76B900;
108 | }
109 |
110 | h2#qunit-banner.qunit-pass:after {
111 | content:'Congrats! All of your tests passed!';
112 | }
113 |
114 | h2#qunit-banner.qunit-fail {
115 | background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyBpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBXaW5kb3dzIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjU5QUIzNEU2MzE2NzExRTE4ODc3OEVFNEY2NzhDMjM4IiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjU5QUIzNEU3MzE2NzExRTE4ODc3OEVFNEY2NzhDMjM4Ij4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NTlBQjM0RTQzMTY3MTFFMTg4Nzc4RUU0RjY3OEMyMzgiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6NTlBQjM0RTUzMTY3MTFFMTg4Nzc4RUU0RjY3OEMyMzgiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz46NEjgAAAAzElEQVR42mL8//8/AyWABUS8N1EFUS5AfA+KcQFBIE6DsjsFz9yGGAAEu6EGgEA6EM/CoRmkzhiJX8EE5bggKZyJZAsuzQwwNhMOp6IbsgpNM9jn8DCAOnsmFkNgNrlg0dyJbMAsNE0MOPgwza5AfBbdC7OgLsEHUDRjCwNChqBoxhWIxngMQI8dDAPKsSlCM2AmLgNAkh04/I3TECZcJiNFrys+Q2AGhOLQPAsaaLgMwZkS0fMDLkPgBqzGoxnZEBMg3gM1CBzdAAEGABpTMr+umvCXAAAAAElFTkSuQmCC');
116 | color:#ee3324;
117 | }
118 |
119 | h2#qunit-banner.qunit-fail:after {
120 | content:'Oops! One or more tests failed!';
121 | }
122 |
123 | /** Test Runner Result Styles */
124 |
125 | #qunit-testrunner-toolbar {
126 | position:absolute;
127 | top:55px;
128 | right:20px;
129 | color:#6BC9ED;
130 | font-size:14px;
131 | }
132 |
133 | #qunit-testrunner-toolbar:after {
134 | content:' }';
135 | }
136 |
137 | h2#qunit-userAgent {
138 | padding: 0;
139 | color: #7B7979;
140 | border:0;
141 | font-size:small;
142 | font-family: Arial, 'sans-serif';
143 | font-weight:normal;
144 | font-style:italic;
145 | }
146 |
147 | h2#qunit-userAgent:before {
148 | content:'User Agents: ';
149 | }
150 |
151 |
152 | /** Tests: Pass/Fail */
153 |
154 | #qunit-tests {
155 | list-style-position: inside;
156 | list-style-type:none;
157 | }
158 |
159 | #qunit-tests li {
160 | padding: 4px 10px;
161 | list-style-position:outside;
162 | border-radius: 5px;
163 | -moz-border-radius: 5px;
164 | -webkit-border-radius: 5px;
165 | margin-bottom:5px;
166 | position:relative;
167 | *zoom:1;
168 | list-style-type:none;
169 | }
170 |
171 | #qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
172 | display: none;
173 | }
174 |
175 | #qunit-tests li strong {
176 | cursor: pointer;
177 | }
178 |
179 | #qunit-tests li a {
180 | display:block;
181 | position:absolute;
182 | right:10px;
183 | padding:0px 16px 0 0;
184 | font-size:0.8em;
185 | background:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAYCAYAAADOMhxqAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2RpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo4RjRENzREMkRFMzBFMTExQkZCM0YxOUI1MEUyRUQ0OCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpENEZDRDdDQTMxODUxMUUxOTc3NEQ0OTUxNjc4REFEQiIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpENEZDRDdDOTMxODUxMUUxOTc3NEQ0OTUxNjc4REFEQiIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1IFdpbmRvd3MiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo5MDRENzREMkRFMzBFMTExQkZCM0YxOUI1MEUyRUQ0OCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo4RjRENzREMkRFMzBFMTExQkZCM0YxOUI1MEUyRUQ0OCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PpE8SAQAAAD3SURBVHjaYsw5+YYBC5gGxN+BuBhdgoUBO1AFYlMgFgXiOGQJJjSFrEDcC8RaQMwPxEFAvBuXDSDFP6D4F1SMG4gtgFgBiB+g2/ATiL8C8UIgPgMV+wvEujDFyBoWQRVPB+IsqOa3QCyFrBhZgysQMwLxFCjfB4hFgPgVlH8DiOcha/jHgBu0ALEMEH9G1rAXqikHi4ZkIP4DxEuQNaQBMReUngjEdkAcDPU8KKROAPFp5GAFBSUPNHZToZEFM+wsEHtgiziQJmYg7gPiy0B8HIiTgNgRX0yD/FFzYdXZK0B8Fchei5GWgBI40xJQbjQtjdi0BBBgAAsUYVWmfe1CAAAAAElFTkSuQmCC') bottom right no-repeat;
186 | color: #3b73b9;
187 | text-decoration: none;
188 | height:12px;
189 | top:5px;
190 | }
191 | #qunit-tests li a:hover,
192 | #qunit-tests li a:focus {
193 | color: #6bc9ed;
194 | background:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAYCAYAAADOMhxqAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2RpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo4RjRENzREMkRFMzBFMTExQkZCM0YxOUI1MEUyRUQ0OCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpENEZDRDdDQTMxODUxMUUxOTc3NEQ0OTUxNjc4REFEQiIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpENEZDRDdDOTMxODUxMUUxOTc3NEQ0OTUxNjc4REFEQiIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1IFdpbmRvd3MiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo5MDRENzREMkRFMzBFMTExQkZCM0YxOUI1MEUyRUQ0OCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo4RjRENzREMkRFMzBFMTExQkZCM0YxOUI1MEUyRUQ0OCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PpE8SAQAAAD3SURBVHjaYsw5+YYBC5gGxN+BuBhdgoUBO1AFYlMgFgXiOGQJJjSFrEDcC8RaQMwPxEFAvBuXDSDFP6D4F1SMG4gtgFgBiB+g2/ATiL8C8UIgPgMV+wvEujDFyBoWQRVPB+IsqOa3QCyFrBhZgysQMwLxFCjfB4hFgPgVlH8DiOcha/jHgBu0ALEMEH9G1rAXqikHi4ZkIP4DxEuQNaQBMReUngjEdkAcDPU8KKROAPFp5GAFBSUPNHZToZEFM+wsEHtgiziQJmYg7gPiy0B8HIiTgNgRX0yD/FFzYdXZK0B8Fchei5GWgBI40xJQbjQtjdi0BBBgAAsUYVWmfe1CAAAAAElFTkSuQmCC') top right no-repeat;
195 | }
196 | #qunit-tests li.pass strong > span {color:#76B900;}
197 | #qunit-tests li.pass strong:first-child {
198 | padding-left:20px;
199 | background:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2RpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo5MTRENzREMkRFMzBFMTExQkZCM0YxOUI1MEUyRUQ0OCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDozODgyNDY5QzMxN0ExMUUxOTdFMkVCQkNENjFBMjc3RSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDozODgyNDY5QjMxN0ExMUUxOTdFMkVCQkNENjFBMjc3RSIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1IFdpbmRvd3MiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo5MTRENzREMkRFMzBFMTExQkZCM0YxOUI1MEUyRUQ0OCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo5MTRENzREMkRFMzBFMTExQkZCM0YxOUI1MEUyRUQ0OCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pv7qI08AAAClSURBVHjaYvz//z8DKYClfBcjMeqUgFgQiM+yEKEYpHA3VFMYExEaVkEVg20ipKEDiF2g7LNAPIsJaqUgFsVpQFwOZb8H4nQQzQR13zuoAhgwhpoOA2FQGxiYkNw3E4phnoTZWgHEe2A6maC63yM54y6S4llA3InsTiaobhOYlUiKz0JNZ0DXAAL3gNgViFcjeRLZZkRMI7FhioyhBrzHFs4AAQYAz08iXvWgossAAAAASUVORK5CYII=') center left no-repeat;
200 | }
201 |
202 | #qunit-tests li.fail strong > span {color:#EE3324;}
203 | #qunit-tests li.fail strong:first-child {
204 | padding-left:20px;
205 | background:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2RpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo5MTRENzREMkRFMzBFMTExQkZCM0YxOUI1MEUyRUQ0OCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo0MzNBNEM0QzMxN0ExMUUxQjk0MUYyOEJCODA0OTM1OSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo0MzNBNEM0QjMxN0ExMUUxQjk0MUYyOEJCODA0OTM1OSIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1IFdpbmRvd3MiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo5MTRENzREMkRFMzBFMTExQkZCM0YxOUI1MEUyRUQ0OCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo5MTRENzREMkRFMzBFMTExQkZCM0YxOUI1MEUyRUQ0OCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PnO7dSIAAACtSURBVHjaYnxnrMIABEpA/B6K0YEgEBsD8VnBM7ffM0E5d6HYGIvi3UiYgQkqiCyJrAmZbwzTcBaKYZrOAHEaEM9E05wOIlig7nZFM20mmtM6gXgWzAYGJE1nsXgapLACxmFCkniPQwOKGLKGmVC3owMUcZiGDjTFs9BMhmuCxUM5muJ0qJ9Wo2lCcRII7IEFH9RPYbDQgaUCFqjVYdDkMQuLH9Khau6BOAABBgDmhyuetyQ3ywAAAABJRU5ErkJggg==') center left no-repeat;
206 | }
207 |
208 | #qunit-tests li ol {
209 | margin:0;
210 | padding:10px 0 0 0;
211 | background-color: #fff;
212 | }
213 |
214 | #qunit-tests li ol li {
215 | list-style-position: inside;
216 | list-style-type:decimal;
217 | *list-style-position: outside;
218 | }
219 |
220 | #qunit-tests table {
221 | border-collapse: collapse;
222 | margin-top: .2em;
223 | }
224 |
225 | #qunit-tests th {
226 | text-align: right;
227 | vertical-align: top;
228 | padding: 0 .5em 0 0;
229 | }
230 |
231 | #qunit-tests td {
232 | vertical-align: top;
233 | }
234 |
235 | #qunit-tests pre {
236 | margin: 0;
237 | white-space: pre-wrap;
238 | word-wrap: break-word;
239 | }
240 |
241 | #qunit-tests del {
242 | background-color: #add566;
243 | color: #555;
244 | text-decoration: none;
245 | }
246 |
247 | #qunit-tests ins {
248 | background-color: #f5857c;
249 | color: #555;
250 | text-decoration: none;
251 | }
252 |
253 | /*** Test Counts */
254 |
255 | #qunit-tests b.counts {
256 | color: #7B7979;
257 | font-size:0.8em;
258 | margin-left:10px;
259 | }
260 |
261 | b.counts b.passed, b.counts b.failed {
262 | display:inline-block;
263 | padding:0px 1px;
264 | border-radius: 3px;
265 | -moz-border-radius: 3px;
266 | -webkit-border-radius: 3px;
267 | color:#FFF;
268 | }
269 |
270 | b.counts b.passed {
271 | background:#76b900;
272 | }
273 |
274 | b.counts b.failed {
275 | background:#ee3324;
276 | }
277 |
278 |
279 | #qunit-tests li li {
280 | margin:0 0 5px;
281 | padding: 0.4em 0.5em 0.4em 0.5em;
282 | background-color: #fff;
283 | border-bottom: none;
284 | border-radius: 3px;
285 | -moz-border-radius: 3px;
286 | -webkit-border-radius: 3px;
287 | overflow:auto;
288 | }
289 |
290 | /*** Passing Styles */
291 |
292 | #qunit-tests li li.pass {
293 | color: #7B7979;
294 | background-color: #fff;
295 | border-left: 20px solid #76B900;
296 | }
297 |
298 | #qunit-tests .pass { color: #76B900; background-color: #FFF; border: 1px solid #add566; }
299 |
300 | #qunit-tests .pass .test-actual,
301 | #qunit-tests .pass .test-expected { color: #999999; }
302 |
303 |
304 | /*** Failing Styles */
305 | #qunit-tests li.fail ol {
306 | background:#f7f7f7;
307 | }
308 |
309 | #qunit-tests li li.fail {
310 | color: #7B7979;
311 | background-color: #fff;
312 | border-left: 20px solid #EE3324;
313 | white-space: pre;
314 | }
315 |
316 | #qunit-tests .fail { color: #EE3324; border: 1px solid #f5857c; background-color: #f7f7f7; }
317 |
318 |
319 | #qunit-tests .fail .test-actual,
320 | #qunit-tests .fail .test-expected { color: #999999; }
321 |
322 |
323 |
324 | /** Result */
325 |
326 | p#qunit-testresult {
327 | padding: 10px 0;
328 | font-weight:bold;
329 | line-height:1.6em;
330 | color: #7B7979;
331 | }
332 |
333 | p#qunit-testresult span.passed, p#qunit-testresult span.failed {
334 | font-size:1.5em;
335 | font-weight:bold;
336 | display:inline-block;
337 | padding:3px;
338 | border-radius: 5px;
339 | -moz-border-radius: 5px;
340 | -webkit-border-radius: 5px;
341 | }
342 |
343 | p#qunit-testresult span.passed {
344 | color:#FFF;
345 | background:#76b900
346 | }
347 |
348 | p#qunit-testresult span.failed {
349 | color:#FFF;
350 | background:#ee3324;
351 | }
352 |
353 |
354 | /** Fixture */
355 |
356 | #qunit-fixture {
357 | position: absolute;
358 | top: -10000px;
359 | left: -10000px;
360 | width: 1000px;
361 | height: 1000px;
362 | }
363 |
--------------------------------------------------------------------------------
/wordpress.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The software is licensed under The MIT License (MIT)
3 | * http://www.opensource.org/licenses/mit-license.php
4 | *
5 | * Copyright (c) 2012 Hezhiqiang
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
8 | * associated documentation files (the"Software"), to deal in the Software without restriction,
9 | * including without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14 |
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | *
23 | */
24 |
25 | /**
26 | * XML-RPC WordPress API
27 | *
28 | * http://codex.wordpress.org/XML-RPC_WordPress_API
29 | *
30 | *
31 | * @param string
32 | * url
33 | * @param string
34 | * username
35 | * @param string
36 | * password
37 | * @returns {WordPress}
38 | */
39 |
40 | function WordPress(url, username, password) {
41 | this.url = url;
42 | this.username = username;
43 | this.password = password;
44 | this.request = new XmlRpcRequest(this.url);
45 | }
46 |
47 | /**
48 | * === XML-RPC WordPress API/Posts ===
49 | *
50 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Posts
51 | *
52 | */
53 | /**
54 | * Retrieve a post of any registered post type.
55 | *
56 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.getPost
57 | *
58 | * @param int
59 | * blog_id
60 | * @param int
61 | * post_id
62 | * @param array
63 | * bields
64 | *
65 | * @returns object
66 | */
67 | WordPress.prototype.getPost = function(blog_id, post_id, fields) {
68 |
69 | this.request.methodName = "wp.getPost";
70 |
71 | this.request.addParam(blog_id);
72 | this.request.addParam(this.username);
73 | this.request.addParam(this.password);
74 | this.request.addParam(post_id);
75 | this.request.addParam(fields);
76 |
77 | var resp = this.request.send();
78 |
79 | this.request.clearParams();
80 | return resp.parseXML();
81 | };
82 |
83 | /**
84 | * Retrieve list of posts of any registered post type.
85 | *
86 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.getPosts
87 | *
88 | * @param int
89 | * blog_id
90 | * @param object
91 | * filter
92 | * @param array fields
93 | *
94 | * @returns object
95 | */
96 | WordPress.prototype.getPosts = function(blog_id, filter, fields) {
97 |
98 | this.request.methodName = "wp.getPosts";
99 |
100 | this.request.addParam(blog_id);
101 | this.request.addParam(this.username);
102 | this.request.addParam(this.password);
103 | this.request.addParam(filter);
104 | this.request.addParam(fields);
105 |
106 | var resp = this.request.send();
107 | this.request.clearParams();
108 | return resp.parseXML();
109 | };
110 |
111 | /**
112 | * Create a new post of any registered post type.
113 | *
114 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.newPost
115 | *
116 | * @param int
117 | * blog_id
118 | * @param object
119 | * content
120 | *
121 | * @returns post_id int
122 | */
123 | WordPress.prototype.newPost = function(blog_id, content) {
124 |
125 | this.request.methodName = "wp.newPost";
126 |
127 | this.request.addParam(blog_id);
128 | this.request.addParam(this.username);
129 | this.request.addParam(this.password);
130 | this.request.addParam(content);
131 |
132 | var resp = this.request.send();
133 | this.request.clearParams();
134 | return resp.parseXML();
135 | };
136 |
137 | /**
138 | * Edit an existing post of any registered post type.
139 | *
140 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.editPost
141 | *
142 | * @param int
143 | * blog_id
144 | * @param int
145 | * post_id
146 | * @param object
147 | * content
148 | *
149 | * @returns boolean
150 | */
151 | WordPress.prototype.editPost = function(blog_id, post_id, content) {
152 | this.request.methodName = "wp.editPost";
153 |
154 | this.request.addParam(blog_id);
155 | this.request.addParam(this.username);
156 | this.request.addParam(this.password);
157 | this.request.addParam(post_id);
158 | this.request.addParam(content);
159 |
160 | var resp = this.request.send();
161 | this.request.clearParams();
162 | return resp.parseXML();
163 | };
164 |
165 | /**
166 | * Delete an existing post of any registered post type.
167 | *
168 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.deletePost
169 | *
170 | * @param int
171 | * blog_id
172 | * @param int
173 | * post_id
174 | *
175 | * @returns boolean
176 | */
177 | WordPress.prototype.deletePost = function(blog_id, post_id) {
178 | this.request.methodName = "wp.deletePost";
179 |
180 | this.request.addParam(blog_id);
181 | this.request.addParam(this.username);
182 | this.request.addParam(this.password);
183 | this.request.addParam(post_id);
184 |
185 | var resp = this.request.send();
186 | this.request.clearParams();
187 | /*
188 | * TODO:: Exceptions handling 无权限 401: If the user does not have permission
189 | * to delete the post. 不存在 404: If no post with that post_id exists.
190 | *
191 | */
192 | return resp.parseXML();
193 | };
194 |
195 | /**
196 | * Retrieve a registered post type.
197 | *
198 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.getPostType
199 | *
200 | * @param int
201 | * blog_id
202 | * @param string
203 | * post_type_name
204 | * @param array
205 | * fields
206 | *
207 | * @returns object
208 | */
209 | WordPress.prototype.getPostType = function(blog_id, post_type_name, fields) {
210 | this.request.methodName = "wp.getPostType";
211 |
212 | this.request.addParam(blog_id);
213 | this.request.addParam(this.username);
214 | this.request.addParam(this.password);
215 | this.request.addParam(post_type_name);
216 | this.request.addParam(fields);
217 |
218 | var resp = this.request.send();
219 | this.request.clearParams();
220 | return resp.parseXML();
221 | };
222 |
223 | /**
224 | * Retrieve list of registered post types.
225 | *
226 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.getPostTypes
227 | *
228 | * @param int
229 | * blog_id
230 | * @param array
231 | * filter
232 | * @param array
233 | * fields
234 | *
235 | * @returns object
236 | */
237 | WordPress.prototype.getPostTypes = function(blog_id, filter, fields) {
238 | this.request.methodName = "wp.getPostTypes";
239 |
240 | this.request.addParam(blog_id);
241 | this.request.addParam(this.username);
242 | this.request.addParam(this.password);
243 | this.request.addParam(filter);
244 | this.request.addParam(fields);
245 |
246 | var resp = this.request.send();
247 | this.request.clearParams();
248 | return resp.parseXML();
249 | };
250 |
251 | /**
252 | * Retrieve list of post formats.
253 | *
254 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.getPostFormats
255 | *
256 | * @param int
257 | * blog_id
258 | * @param array
259 | * filter
260 | *
261 | * @returns object
262 | */
263 | WordPress.prototype.getPostFormats = function(blog_id, filter) {
264 | this.request.methodName = "wp.getPostFormats";
265 |
266 | this.request.addParam(blog_id);
267 | this.request.addParam(this.username);
268 | this.request.addParam(this.password);
269 | this.request.addParam(filter);
270 |
271 | var resp = this.request.send();
272 | this.request.clearParams();
273 | return resp.parseXML();
274 | };
275 |
276 | /**
277 | * Retrieve list of supported values for post_status field on posts.
278 | *
279 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.getPostStatusList
280 | *
281 | * @param int
282 | * blog_id
283 | *
284 | * @returns object
285 | */
286 | WordPress.prototype.getPostStatusList = function(blog_id) {
287 | this.request.methodName = "wp.getPostStatusList";
288 | this.request.addParam(blog_id);
289 | this.request.addParam(this.username);
290 | this.request.addParam(this.password);
291 |
292 | var resp = this.request.send();
293 | this.request.clearParams();
294 | return resp.parseXML();
295 | };
296 |
297 | /**
298 | * === XML-RPC WordPress API/Taxonomies ===
299 | *
300 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies
301 | *
302 | * These XML-RPC methods are for interacting with taxonomies and terms.
303 | * Taxonomies (for categories, tags, and custom taxonomies) - Added in WordPress
304 | * 3.4
305 | */
306 |
307 | /**
308 | * Retrieve information about a taxonomy.
309 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.getTaxonomy
310 | *
311 | * @param int
312 | * blog_id
313 | * @param string
314 | * taxonomy
315 | *
316 | * @returns object
317 | */
318 | WordPress.prototype.getTaxonomy = function(blog_id, taxonomy) {
319 | this.request.methodName = "wp.getTaxonomy";
320 |
321 | this.request.addParam(blog_id);
322 | this.request.addParam(this.username);
323 | this.request.addParam(this.password);
324 | this.request.addParam(taxonomy);
325 |
326 | var resp = this.request.send();
327 | this.request.clearParams();
328 | return resp.parseXML();
329 | };
330 |
331 | /**
332 | * Retrieve a list of taxonomies.
333 | *
334 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.getTaxonomies
335 | *
336 | * @param int
337 | * blog_id
338 | *
339 | * @returns object
340 | */
341 | WordPress.prototype.getTaxonomies = function(blog_id) {
342 | this.request.methodName = "wp.getTaxonomies";
343 |
344 | this.request.addParam(blog_id);
345 | this.request.addParam(this.username);
346 | this.request.addParam(this.password);
347 |
348 | var resp = this.request.send();
349 | this.request.clearParams();
350 | return resp.parseXML();
351 | };
352 |
353 | /**
354 | * Retrieve a taxonomy term.
355 | *
356 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.getTerm
357 | *
358 | * @param int
359 | * blog_id
360 | * @param string
361 | * taxonomy
362 | * @param term_id
363 | *
364 | * @returns object
365 | */
366 | WordPress.prototype.getTerm = function(blog_id, taxonomy, term_id) {
367 | this.request.methodName = "wp.getTerm";
368 |
369 | this.request.addParam(blog_id);
370 | this.request.addParam(this.username);
371 | this.request.addParam(this.password);
372 | this.request.addParam(taxonomy);
373 | this.request.addParam(term_id);
374 |
375 | var resp = this.request.send();
376 | this.request.clearParams();
377 | return resp.parseXML();
378 | };
379 |
380 | /**
381 | * Retrieve list of terms in a taxonomy.
382 | *
383 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.getTerms
384 | *
385 | * @param int
386 | * blog_id
387 | * @param string
388 | * taxonomy
389 | * @param object
390 | * filter
391 | *
392 | * @returns array
393 | *
394 | */
395 | WordPress.prototype.getTerms = function(blog_id, taxonomy, filter) {
396 | this.request.methodName = "wp.getTerms";
397 |
398 | this.request.addParam(blog_id);
399 | this.request.addParam(this.username);
400 | this.request.addParam(this.password);
401 | this.request.addParam(taxonomy);
402 | this.request.addParam(filter);
403 |
404 | var resp = this.request.send();
405 | this.request.clearParams();
406 | return resp.parseXML();
407 | };
408 |
409 | /**
410 | * Create a new taxonomy term.
411 | *
412 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.newTerm
413 | *
414 | * @param int
415 | * blog_id
416 | * @param object
417 | * content
418 | *
419 | * @returns int term_id
420 | *
421 | */
422 | WordPress.prototype.newTerm = function(blog_id, content) {
423 | this.request.methodName = "wp.newTerm";
424 |
425 | this.request.addParam(blog_id);
426 | this.request.addParam(this.username);
427 | this.request.addParam(this.password);
428 | this.request.addParam(content);
429 |
430 | var resp = this.request.send();
431 | this.request.clearParams();
432 | return resp.parseXML();
433 | };
434 |
435 | /**
436 | * Edit an existing taxonomy term.
437 | *
438 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.editTerm
439 | *
440 | * @param int
441 | * blog_id
442 | * @param int
443 | * term_id
444 | * @param object
445 | * content
446 | *
447 | * @returns boolean
448 | */
449 | WordPress.prototype.editTerm = function(blog_id, term_id, content) {
450 | this.request.methodName = "wp.editTerm";
451 |
452 | this.request.addParam(blog_id);
453 | this.request.addParam(this.username);
454 | this.request.addParam(this.password);
455 | this.request.addParam(term_id);
456 | this.request.addParam(content);
457 |
458 | var resp = this.request.send();
459 | this.request.clearParams();
460 | return resp.parseXML();
461 | };
462 |
463 | /**
464 | * Delete an existing taxonomy term.
465 | *
466 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.deleteTerm
467 | *
468 | * @param int
469 | * blog_id
470 | * @param string
471 | * taxonomy
472 | * @param int
473 | * term_id
474 | *
475 | * @returns boolean
476 | */
477 | WordPress.prototype.deleteTerm = function(blog_id, taxonomy, term_id) {
478 | this.request.methodName = "wp.deleteTerm";
479 |
480 | this.request.addParam(blog_id);
481 | this.request.addParam(this.username);
482 | this.request.addParam(this.password);
483 | this.request.addParam(taxonomy);
484 | this.request.addParam(term_id);
485 |
486 | var resp = this.request.send();
487 | this.request.clearParams();
488 | return resp.parseXML();
489 | };
490 |
491 | /**
492 | * XML-RPC WordPress API/Media
493 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Media
494 | *
495 | */
496 |
497 | /**
498 | * Retrieve a media item (i.e, attachment).
499 | *
500 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Media#wp.getMediaItem
501 | *
502 | * @param int
503 | * blog_id
504 | * @param int
505 | * attachment_id
506 | *
507 | * @returns object
508 | */
509 | WordPress.prototype.getMediaItem = function(blog_id, attachment_id) {
510 | this.request.methodName = "wp.getMediaItem";
511 |
512 | this.request.addParam(blog_id);
513 | this.request.addParam(this.username);
514 | this.request.addParam(this.password);
515 | this.request.addParam(attachment_id);
516 |
517 | var resp = this.request.send();
518 | this.request.clearParams();
519 | return resp.parseXML();
520 | };
521 |
522 | /**
523 | * Retrieve list of media items.
524 | *
525 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Media#wp.getMediaLibrary
526 | *
527 | * @param int
528 | * blog_id
529 | * @param object
530 | * filter
531 | *
532 | * @returns array
533 | */
534 | WordPress.prototype.getMediaLibrary = function(blog_id, filter) {
535 | this.request.methodName = "wp.getMediaLibrary";
536 |
537 | this.request.addParam(blog_id);
538 | this.request.addParam(this.username);
539 | this.request.addParam(this.password);
540 | this.request.addParam(filter);
541 |
542 | var resp = this.request.send();
543 | this.request.clearParams();
544 | return resp.parseXML();
545 | };
546 |
547 | /**
548 | * Upload a media file.
549 | *
550 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Media#wp.uploadFile
551 | *
552 | * @param int
553 | * blog_id
554 | * @param object
555 | * data
556 | *
557 | * @returns object
558 | */
559 | WordPress.prototype.uploadFile = function(blog_id, data) {
560 | this.request.methodName = "wp.uploadFile";
561 |
562 | this.request.addParam(blog_id);
563 | this.request.addParam(this.username);
564 | this.request.addParam(this.password);
565 | this.request.addParam(data);
566 |
567 | var resp = this.request.send();
568 | this.request.clearParams();
569 | return resp.parseXML();
570 | };
571 |
572 | /**
573 | * === XML-RPC WordPress API/Comments ===
574 | *
575 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Comments
576 | */
577 |
578 | /**
579 | * Retrieve comment count for a specific post.
580 | *
581 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.getCommentCount
582 | *
583 | * @param int
584 | * blog_id
585 | * @param string
586 | * post_id
587 | *
588 | * @returns array
589 | *
590 | */
591 | WordPress.prototype.getCommentCount = function(blog_id, post_id) {
592 | this.request.methodName = "wp.getCommentCount";
593 |
594 | this.request.addParam(blog_id);
595 | this.request.addParam(this.username);
596 | this.request.addParam(this.password);
597 | this.request.addParam(post_id);
598 |
599 | var resp = this.request.send();
600 | this.request.clearParams();
601 | return resp.parseXML();
602 | };
603 |
604 | /**
605 | * Retrieve a comment.
606 | *
607 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.getComment
608 | *
609 | * @param int
610 | * blog_id
611 | * @param int
612 | * comment_id
613 | *
614 | * @returns object
615 | */
616 | WordPress.prototype.getComment = function(blog_id, comment_id) {
617 | this.request.methodName = "wp.getComment";
618 |
619 | this.request.addParam(blog_id);
620 | this.request.addParam(this.username);
621 | this.request.addParam(this.password);
622 | this.request.addParam(comment_id);
623 |
624 | var resp = this.request.send();
625 | this.request.clearParams();
626 | return resp.parseXML();
627 | };
628 |
629 | /**
630 | * Retrieve list of comments.
631 | *
632 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.getComments
633 | *
634 | * @param int
635 | * blog_id
636 | * @param object
637 | * filter
638 | *
639 | * @return array
640 | */
641 | WordPress.prototype.getComments = function(blog_id, filter) {
642 | this.request.methodName = "wp.getComments";
643 |
644 | this.request.addParam(blog_id);
645 | this.request.addParam(this.username);
646 | this.request.addParam(this.password);
647 | this.request.addParam(filter);
648 |
649 | var resp = this.request.send();
650 | this.request.clearParams();
651 | return resp.parseXML();
652 | };
653 |
654 | /**
655 | * Create a new comment.
656 | *
657 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.newComment
658 | *
659 | * @param int
660 | * blog_id
661 | * @param int
662 | * post_id
663 | * @param object
664 | * comment
665 | *
666 | * @returns int comment_id
667 | */
668 | WordPress.prototype.newComment = function(blog_id, post_id, content) {
669 | this.request.methodName = "wp.newComment";
670 |
671 | this.request.addParam(blog_id);
672 | this.request.addParam(this.username);
673 | this.request.addParam(this.password);
674 | this.request.addParam(post_id);
675 | this.request.addParam(content);
676 |
677 | var resp = this.request.send();
678 | this.request.clearParams();
679 | return resp.parseXML();
680 | };
681 |
682 | /**
683 | * Edit an existing comment.
684 | *
685 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.editComment
686 | *
687 | * @param int
688 | * blog_id
689 | * @param int
690 | * comment_id
691 | * @param object
692 | * comment
693 | *
694 | * @returns boolean
695 | */
696 | WordPress.prototype.editComment = function(blog_id, comment_id, comment) {
697 | this.request.methodName = "wp.editComment";
698 |
699 | this.request.addParam(blog_id);
700 | this.request.addParam(this.username);
701 | this.request.addParam(this.password);
702 | this.request.addParam(comment_id);
703 | this.request.addParam(comment);
704 |
705 | var resp = this.request.send();
706 | this.request.clearParams();
707 | return resp.parseXML();
708 | };
709 |
710 | /**
711 | * Remove an existing comment.
712 | *
713 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.deleteComment
714 | *
715 | * @param int
716 | * blog_id
717 | * @param int
718 | * comment_id
719 | *
720 | * @return boolean
721 | */
722 | WordPress.prototype.deleteComment = function(blog_id, comment_id) {
723 | this.request.methodName = "wp.deleteComment";
724 |
725 | this.request.addParam(blog_id);
726 | this.request.addParam(this.username);
727 | this.request.addParam(this.password);
728 | this.request.addParam(comment_id);
729 |
730 | var resp = this.request.send();
731 | this.request.clearParams();
732 | return resp.parseXML();
733 | };
734 |
735 | /**
736 | * Retrieve list of comment statuses.
737 | *
738 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.getCommentStatusList
739 | *
740 | * @param int
741 | * blog_id
742 | *
743 | * @returns array
744 | * struct
745 | * string (key): status value
746 | * string (value): status description
747 | */
748 | WordPress.prototype.getCommentStatusList = function(blog_id) {
749 | this.request.methodName = "wp.getCommentStatusList";
750 |
751 | this.request.addParam(blog_id);
752 | this.request.addParam(this.username);
753 | this.request.addParam(this.password);
754 |
755 | var resp = this.request.send();
756 | this.request.clearParams();
757 | return resp.parseXML();
758 | };
759 |
760 | /**
761 | * === XML-RPC WordPress API/Options ===
762 | *
763 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Options
764 | */
765 |
766 | /**
767 | * Retrieve blog options.
768 | *
769 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Options#wp.getOptions
770 | *
771 | * @param int
772 | * blog_id
773 | * @param array
774 | * options List of option names to retrieve. If omitted, all options
775 | * will be retrieved.
776 | *
777 | * @returns
778 | * struct
779 | * string desc
780 | * string value
781 | * bool readonly
782 | *
783 | * This method will only return white-listed options. If a
784 | * non-white-listed option is included in options, it will be omitted
785 | * from the response.
786 | */
787 | WordPress.prototype.getOptions = function(blog_id, options) {
788 | this.request.methodName = "wp.getOptions";
789 |
790 | this.request.addParam(blog_id);
791 | this.request.addParam(this.username);
792 | this.request.addParam(this.password);
793 | this.request.addParam(options);
794 |
795 | var resp = this.request.send();
796 | this.request.clearParams();
797 | return resp.parseXML();
798 | };
799 |
800 | /**
801 | * Edit blog options.
802 | *
803 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Options#wp.setOptions
804 | *
805 | * @param int
806 | * blog_id
807 | * @param array
808 | * options keys are option names, values are the new option values.
809 | *
810 | * @returns array the options with updated values.
811 | */
812 | WordPress.prototype.setOptions = function(blog_id, options) {
813 | this.request.methodName = "wp.setOptions";
814 |
815 | this.request.addParam(blog_id);
816 | this.request.addParam(this.username);
817 | this.request.addParam(this.password);
818 | this.request.addParam(options);
819 |
820 | var resp = this.request.send();
821 | this.request.clearParams();
822 | return resp.parseXML();
823 | };
824 |
825 | /**
826 | * === XML-RPC WordPress API/Users ===
827 | *
828 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Users
829 | */
830 |
831 | /**
832 | * Retrieve list of blogs for this user.
833 | *
834 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Users#wp.getUsersBlogs
835 | *
836 | * @return array
837 | */
838 | WordPress.prototype.getUsersBlogs = function() {
839 | this.request.methodName = "wp.getUsersBlogs";
840 |
841 | this.request.addParam(this.username);
842 | this.request.addParam(this.password);
843 |
844 | var resp = this.request.send();
845 | this.request.clearParams();
846 | return resp.parseXML();
847 | };
848 |
849 | /**
850 | * Retrieve list of all authors.
851 | *
852 | * http://codex.wordpress.org/XML-RPC_WordPress_API/Users#wp.getAuthors
853 | *
854 | * @param int
855 | * blog_id
856 | * @returns array
857 | */
858 | WordPress.prototype.getAuthors = function(blog_id) {
859 | this.request.methodName = "wp.getAuthors";
860 |
861 | this.request.addParam(blog_id);
862 | this.request.addParam(this.username);
863 | this.request.addParam(this.password);
864 |
865 | var resp = this.request.send();
866 | this.request.clearParams();
867 | return resp.parseXML();
868 | };
869 |
870 |
--------------------------------------------------------------------------------