| 1 | <html> |
|---|
| 2 | <head> |
|---|
| 3 | <title> |
|---|
| 4 | XDomain RPC Demo |
|---|
| 5 | </title> |
|---|
| 6 | <script src="../../../dojo/dojo.js" type="text/javascript" |
|---|
| 7 | djConfig="parseOnLoad: true, isDebug: true, popup: true"></script> |
|---|
| 8 | <script type="text/javascript"> |
|---|
| 9 | var last_response_id = ''; |
|---|
| 10 | |
|---|
| 11 | dojo.require("dojo.io.script") |
|---|
| 12 | dojo.require("dojox.rpc.XDomain"); |
|---|
| 13 | dojo.require("dijit._Widget"); |
|---|
| 14 | dojo.require("dojox.dtl._Templated"); |
|---|
| 15 | dojo.require("dojo.parser"); |
|---|
| 16 | |
|---|
| 17 | dojo.declare("EEEEMsgBoardWidget", [dijit._Widget, dojox.dtl._Templated], { |
|---|
| 18 | constructor: function(params, node){ |
|---|
| 19 | var mu = dojo.moduleUrl("dojox.rpc.SMDLibrary", "xdomain.smd"); |
|---|
| 20 | this.yahoo = new dojox.rpc.XDomain(mu); |
|---|
| 21 | }, |
|---|
| 22 | fetch: function(e){ |
|---|
| 23 | this.yahoo.fetchRecentMsg({ |
|---|
| 24 | user: "carrie.Public", |
|---|
| 25 | offset:0, |
|---|
| 26 | count:8, |
|---|
| 27 | order_by:"id:desc" |
|---|
| 28 | }).addCallback(this, function(results){ |
|---|
| 29 | console.dir(results); |
|---|
| 30 | this.results = results; |
|---|
| 31 | this.render(); |
|---|
| 32 | }); |
|---|
| 33 | }, |
|---|
| 34 | store: function(e){ |
|---|
| 35 | var _data = { |
|---|
| 36 | posturl:document.URL, |
|---|
| 37 | postkey:"carriezh", |
|---|
| 38 | host:document.location.host |
|---|
| 39 | }; |
|---|
| 40 | dojo.mixin(_data,{ |
|---|
| 41 | author:(dojo.byId("author").value=='')?"anonymous":dojo.byId("author").value, |
|---|
| 42 | message:(dojo.byId("message").value=='')?"blank":dojo.byId("message").value, |
|---|
| 43 | email:(dojo.byId("email").value=='')?"noEmailLink":dojo.byId("email").value |
|---|
| 44 | }); |
|---|
| 45 | |
|---|
| 46 | this.yahoo.storeData(_data).addCallback(this,function(results){ |
|---|
| 47 | if(this.yahoo._smd.postLastResponse){ |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | this.get_last_response(); |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | }); |
|---|
| 55 | }, |
|---|
| 56 | get_last_response: function(){ |
|---|
| 57 | this.yahoo._smd.services.getLastResponse.target = this.yahoo._smd.postLastResponseTarget+last_response_id; |
|---|
| 58 | this.yahoo.getLastResponse({ |
|---|
| 59 | }).addCallback(this,function(results){ |
|---|
| 60 | console.log(results.success); |
|---|
| 61 | this.response = (results.success == 1)?"success":"failed"; |
|---|
| 62 | this.render(); |
|---|
| 63 | }); |
|---|
| 64 | }, |
|---|
| 65 | templatePath: dojo.moduleUrl("dojox.rpc.demos.templates", "xdomain.html") |
|---|
| 66 | }); |
|---|
| 67 | </script> |
|---|
| 68 | </head> |
|---|
| 69 | <body> |
|---|
| 70 | <div dojoType="EEEEMsgBoardWidget"></div> |
|---|
| 71 | </body> |
|---|
| 72 | </html> |
|---|