change to dino mail address for auction cron
[namibia] / public / demo.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3         <head>
4                 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
5                 <title>APE jQuery Test - Color Changer</title>
6
7                 <script type="text/javascript" language="javascript" src="/js/vendor/jquery-1.9.1.min.js"></script>
8                 <script type="text/javascript" language="javascript" src="/js/vendor/ape.js"></script>
9                 <script type="text/javascript" language="javascript" src="/js/vendor/ape-config.js"></script>
10         </head>
11         <body>
12                 <input id="chat" type="text"></input>
13                 <button id="myButton" type="button">speaketh</button>
14                 <button id="myButton2" type="button">who am i</button>
15
16                 <div id="wrapper"></div>
17
18                 <div id="debug">
19                         <h2>Debug</h2>
20                 </div>
21         </body>
22 </html>
23 <script type="text/javaScript">
24
25 $(document).ready(function() {
26
27         var apeChat = false;
28
29         $('#myButton').click(function () {
30           if (apeChat)
31             apeChat.send($('#chat').val());
32         });
33
34         $('#myButton2').click(function () {
35           if (apeChat)
36             apeChat.request.send('whoami', {});
37         });
38
39         // create our new shiney APE client
40         var client = new APE.Client;
41
42     //Load APE Core
43     client.load();
44
45         // set to false to disable debugging
46         var debug = true;
47
48         // load the APE client
49         client.addEvent('load', function() {
50             //3) Call core start function to connect to APE Server, and prompt the user for a nickname
51             client.core.start({"name": prompt('Your name?'), "ident": 123456789});
52         });
53
54         // listen for ready event to know when we are connected
55         client.addEvent('ready', function() {
56                 debug && console.log('Your client is now connected');
57         //1) join 'testChannel'
58         client.core.join('synchv1');
59
60         //2) Intercept multiPipeCreate event
61         client.addEvent('multiPipeCreate', function(pipe, options) {
62                 //3) Send the message on the pipe
63                 apeChat = pipe;
64                 pipe.send('Hello world!');
65                 debug && console.log('Sending Hello world');
66         });
67
68         //4) Intercept receipt of the new message.
69         client.onRaw('data', function(raw, pipe) {
70                 alert(JSON.stringify(raw.data));
71         });
72
73         //5) Push messages from the server.
74         client.onRaw('postmsg', function(raw, pipe) {
75                 alert(JSON.stringify(raw));
76                 //alert(raw.data.message);
77                 debug && console.log('Receiving : ' + unescape(raw.data.message));
78         });
79
80
81     });
82 });
83
84 </script>