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'));
9 <script type="text/javascript">
10 function evalScript() {
12 "var lambda = function() {" +
13 document.getElementById('script').value +
21 <center><h1>cloudeebus</h1></center>
23 <textarea style="width:80%" rows="32" id="script">
28 "org.cloudeebus.Sample"
33 cloudeebus.log = function(msg) {
34 document.getElementById("log").innerHTML += msg + "\n";
37 function logCB(result) {
38 cloudeebus.log(JSON.stringify(result));
41 function errorCB(error) {
42 cloudeebus.log(error.desc ? error.desc : error);
45 function gotDivResult(result) {
46 cloudeebus.log("gotDivResult: " + result);
49 function gotAddResult(result) {
50 cloudeebus.log("gotAddResult: " + result);
51 window.sampleProxy.Div(result,3.33).then(gotDivResult,errorCB);
54 function signalHandler(result) {
55 cloudeebus.log("signal 'ResultChanged': " + result);
58 function gotProxy(proxy) {
59 proxy.connectToSignal("org.cloudeebus.Sample", "ResultChanged", signalHandler);
61 window.sampleProxy = proxy;
65 function testProxy() {
66 var dictionary = {Name: "Mickey",
70 Friends: ["Donald", "Dingo"],
72 window.sampleProxy.Variant(dictionary).then(logCB,errorCB);
75 for (var i=-2; i<2; i++)
76 window.sampleProxy.Add(i,i*2).then(gotAddResult,errorCB);
79 function connectSuccess() {
80 cloudeebus.SessionBus().getObject("org.cloudeebus.Sample", "/org/cloudeebus/Sample", gotProxy, errorCB);
83 if (!window.sampleProxy)
84 cloudeebus.connect("ws://localhost:9002", manifest, connectSuccess, errorCB);
90 <input type="button" value="run script" onclick="evalScript()"/>
91 <input type="button" value="clear log" onclick="document.getElementById('log').innerHTML='';"/>
93 <pre id="log" style="height: 20em; overflow-x: auto; overflow-y: auto; background-color: #faa;"></pre>