genia.likes.science@gmail.com | c5f82a2 | 2013-05-08 02:44:35 -0700 | [diff] [blame] | 1 | <!doctype html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>easyXDM.Widget</title> |
| 5 | <script type="text/javascript" src="../easyXDM.debug.js"> |
| 6 | </script> |
| 7 | <script type="text/javascript"> |
| 8 | easyXDM.DomHelper.requiresJSON("../json2.js"); |
| 9 | </script> |
| 10 | <script type="text/javascript" src="../easyXDM.Widgets.debug.js"> |
| 11 | </script> |
| 12 | <script type="text/javascript"> |
| 13 | easyXDM.whenReady(function(){ |
| 14 | var widget = new easyXDM.Widget({ |
| 15 | subscriptions: ["testtopic"], |
| 16 | swf: "../easyxdm.swf", |
| 17 | initialize: function(widget, widgetManager){ |
| 18 | // Set up the widget |
| 19 | var _container, _btnPublish; |
| 20 | |
| 21 | // Render the UI |
| 22 | _container = document.body.appendChild(document.createElement("div")); |
| 23 | _btnPublish = _container.appendChild(document.createElement("button")); |
| 24 | _btnPublish.innerHTML = "Publish"; |
| 25 | easyXDM.DomHelper.on(_btnPublish, "click", function(){ |
| 26 | widget.publish("testtopic", { |
| 27 | latitude: 1, |
| 28 | longitude: 2 |
| 29 | }); |
| 30 | }); |
| 31 | |
| 32 | // Register the handler for incoming messages |
| 33 | widget.registerMessageHandler(function(url, topic, data){ |
| 34 | _container.appendChild(document.createElement("div")).innerHTML = "got data on topic " + topic + " from " + url; |
| 35 | }); |
| 36 | }, |
| 37 | initialized: function(widget, widgetManager){ |
| 38 | widget.publish("testtopic", { |
| 39 | latitude: 1, |
| 40 | longitude: 2 |
| 41 | }); |
| 42 | } |
| 43 | }); |
| 44 | }); |
| 45 | </script> |
| 46 | </head> |
| 47 | <body> |
| 48 | </body> |
| 49 | </html> |