blob: 47eaeed0ce6fa6f1790f25774baa79bbf361e918 [file] [log] [blame]
genia.likes.science@gmail.comc5f82a22013-05-08 02:44:35 -07001<!doctype html>
2<html>
3 <head>
4 <title>easyXDM</title>
5 <script type="text/javascript" src="../easyXDM.debug.js">
6 </script>
7 <script type="text/javascript">
8 var serializer = {
9 /**
10 * Serializes a hashtable and returns it as a string
11 * @param {Object} data The data to serialize
12 * @returns The serialized string
13 * @type {String}
14 */
15 stringify: function(data){
16 var message = "";
17 for (var key in data) {
18 if (data.hasOwnProperty(key)) {
19 message += key + "=" + escape(data[key]) + "&";
20 }
21 }
22 return message.substring(0, message.length - 1);
23 },
24 /**
25 * Deserializes a string and returns a hashtable
26 * @param {String} message The string to deserialize
27 * @returns An hashtable populated with key-value pairs
28 * @type {Object}
29 */
30 parse: function(message){
31 var data = {};
32 var d = message.split("&");
33 var pair, key, value;
34 for (var i = 0, len = d.length; i < len; i++) {
35 pair = d[i];
36 key = pair.substring(0, pair.indexOf("="));
37 value = pair.substring(key.length + 1);
38 data[key] = unescape(value);
39 }
40 return data;
41 }
42 };
43
44 var channel;
45 var REMOTE = (function(){
46 var remote = location.href;
47 switch (location.host) {
48 case "provider.easyxdm.net":
49 location.href = remote.replace("provider", "consumer");
50 break;
51 case "easyxdm.net":
52 remote = remote.replace("easyxdm.net", "consumer.easyxdm.net");
53 break;
54 case "consumer.easyxdm.net":
55 remote = remote.replace("consumer", "provider");
56 break;
57 case "xdm1":
58 remote = remote.replace("xdm1", "xdm2");
59 break;
60 }
61 return remote.substring(0, remote.lastIndexOf("/"));
62 }());
63 window.onload = function(){
64 /**
65 * When the window is finished loading start setting up the channel
66 */
67 channel = new easyXDM.Socket(/** The configuration */{
68 /**
69 * Register the url to hash.html, this must be an absolute path
70 * or a path relative to the root.
71 * @field
72 */
73 local: "../name.html",
74 swf: REMOTE + "/../easyxdm.swf",
75 /**
76 * Register the url to the remote interface
77 * @field
78 */
79 remote: REMOTE + "/remotedata.html",
80 remoteHelper: REMOTE + "/../name.html",
81 onReady: function(){
82 /**
83 * Send some data to the other side
84 */
85 channel.postMessage(serializer.stringify({
86 propA: "abc",
87 propB: "def",
88 propC: 44
89 }));
90 }
91 });
92 };
93 </script>
94 </head>
95 <body>
96 <div style="border:1px solid black;padding:3px;margin:10px;">
97 <a href="index.html">Index of examples</a>
98 | <a href="http://github.com/oyvindkinsey/easyXDM/#readme">Readme at github</a>
99 |
100 | <a href="http://easyxdm.net/">easyXDM.net</a>
101 | <a href="http://groups.google.com/group/easyxdm">easyXDM at Google Groups</a>
102 <br/>
103 The examples are executing slower than the production build due to the extensive tracing.
104 <br/>
105 If you are alerted about a popup, then this is only the trace log feature. You can ignore this.
106 </div>
107 <!-- easyXDM.Debug.trace(msg) will output its messages to any element with the id "log" -->
108 <div id="log" style="height:100px;border:1px dotted black;overflow:auto">
109 </div>
110 </div>
111 <br/>
112 <br/>
113 <input type="text" id="code" size="100" value="channel.postMessage(serializer.stringify({propC:'c',procD:'d',propE:88}))"/>
114 <button onclick="eval(document.getElementById('code').value);">
115 eval code
116 </button>
117 <script type="text/javascript">
118 var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
119 document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
120 </script>
121 <script type="text/javascript">
122 if (location.host.indexOf("easyxdm.net") !== -1) {
123 try {
124 var pageTracker = _gat._getTracker("UA-9535591-3");
125 pageTracker._setDomainName(".easyxdm.net");
126 pageTracker._trackPageview();
127 }
128 catch (err) {
129 }
130 }
131 </script>
132</body>
133</html>