updated changelog
[contrib/cloudeebus.git] / doc / sample / cloudeebus.html
1 <!DOCTYPE html>
2 <html>
3     <head>
4         <!-- Do not load autobahn or cloudeebus if already provided by Crosswalk browser extensions. -->
5         <script type="text/javascript">
6           typeof cloudeebus != 'undefined' ||
7           document.write(unescape('%3Cscript src=%27../../lib/autobahn.min.js%27%3E %3C/script%3E %3Cscript src=%27../../cloudeebus/cloudeebus.js%27%3E%3C/script%3E'));
8         </script>
9         <script type="text/javascript">
10                 function evalScript() {
11                         eval(
12                                 "var lambda = function() {" +
13                                         document.getElementById('script').value +
14                                 "};" + 
15                                 "lambda();"
16                         );
17                 }
18         </script>
19     </head>
20    <body>
21         <center><h1>cloudeebus</h1></center>
22         <br>
23                 <textarea style="width:80%" rows="32" id="script">
24 var manifest = {
25         name: "cloudeebus",
26         key: "secret",
27         permissions: [
28                 "org.freedesktop.DBus",
29                 "org.freedesktop.Notifications"
30         ]
31 };
32
33 cloudeebus.log = function(msg) {
34   document.getElementById("log").innerHTML += msg + "\n";
35 }
36
37 function errorCB(error) {
38   cloudeebus.log("error: " + error + "\n");
39 }
40
41 function logCB(result) {
42   cloudeebus.log(JSON.stringify(result));
43 }
44
45 function gotNotifProxy(proxy) {
46   for (var ifproxy in proxy.interfaceProxies)
47     cloudeebus.log(ifproxy);
48   proxy.getInterface("org.freedesktop.Notifications").Notify("Cloudeebus",0,"","Cloudeebus says:", "Hello, world !", [], {}, 0);
49 }
50
51 function gotBusProxy(proxy) {
52   proxy.ListNames().then(logCB, errorCB);
53 }
54
55 function connectSuccess() {
56   cloudeebus.SessionBus().getObject("org.freedesktop.DBus", "/org/freedesktop/DBus", gotBusProxy, errorCB);
57   cloudeebus.SessionBus().getObject("org.freedesktop.Notifications", "/org/freedesktop/Notifications", gotNotifProxy, errorCB);
58 }
59
60 cloudeebus.connect("ws://localhost:9000", manifest, connectSuccess, errorCB);
61 </textarea>
62                 <br>
63                 <input type="button" value="run script" onclick="evalScript()"/>
64                 <input type="button" value="clear log" onclick="document.getElementById('log').innerHTML='';"/>
65                 <br>
66                 <pre id="log" style="height: 20em; overflow-x: auto; overflow-y: auto; background-color: #faa;"></pre>
67    </body>
68 </html>