diff options
Diffstat (limited to 'apps/samples/miles')
-rw-r--r-- | apps/samples/miles/miles.html | 2 | ||||
-rw-r--r-- | apps/samples/miles/miles.js | 32 | ||||
-rw-r--r-- | apps/samples/miles/miles.scxml | 16 |
3 files changed, 31 insertions, 19 deletions
diff --git a/apps/samples/miles/miles.html b/apps/samples/miles/miles.html index 019ead4..9cee058 100644 --- a/apps/samples/miles/miles.html +++ b/apps/samples/miles/miles.html @@ -10,7 +10,7 @@ <script type="text/javascript"> </script> - <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.8.3/dojo/dojo.js"></script> + <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.9.1/dojo/dojo.js"></script> <script src="miles.js"></script> <script type="text/javascript"> diff --git a/apps/samples/miles/miles.js b/apps/samples/miles/miles.js index b9348e8..22d536a 100644 --- a/apps/samples/miles/miles.js +++ b/apps/samples/miles/miles.js @@ -13,8 +13,8 @@ function Miles(element, params) { this.imageIteration = 0; // private attributes - var scxmlURL = "127.0.0.1:8080" - var reflectorIp = "127.0.0.1" + var scxmlURL = "localhost:8080" + var reflectorIp = "localhost" var email = "me@somehost.de"; var problemName = "some really hard problem"; @@ -29,7 +29,7 @@ function Miles(element, params) { self.xhr.post({ // The URL to request url: "http://" + scxmlURL + "/miles/connect", - handleAs:"json", + // handleAs:"text", postData: dojo.toJson({ reflectorIp: reflectorIp, email: email, @@ -37,7 +37,10 @@ function Miles(element, params) { }), headers:{ "X-Requested-With": null, - "Content-Type": "application/json", + "Content-Type": "application/json" + }, + error: function(err) { + console.log(err); }, load: function(result) { // we expect nothing in return @@ -52,15 +55,15 @@ function Miles(element, params) { self.xhr.get({ // The URL to request url: "http://" + scxmlURL + "/miles/image", - handleAs:"text", - postData: dojo.toJson({ - reflectorIp: reflectorIp, - email: email, - problemName: problemName - }), headers:{ - "X-Requested-With": null, - "Content-Type": "application/json", + "X-Requested-With":null + }, + error: function(err) { + console.log(err); + if (self.connected) { + self.messageElem.innerHTML = self.imageIteration++; + refreshImage(); + } }, load: function(result) { self.pictureElem.src = "data:image/jpeg;base64," + result; @@ -97,7 +100,7 @@ function Miles(element, params) { <tr>\ <td valign="top">\ <div style="position: relative; padding: 0px">\ - <img class="picture" src="test.jpeg"></img>\ + <img class="picture" src="test1.jpeg"></img>\ <div style="position: absolute; left: 10px; top: 10px">\ <table></tr>\ <td class="control" style="vertical-align: middle"></td>\ @@ -124,6 +127,9 @@ function Miles(element, params) { self.controlDropDown = new DropDownButton({ label: "Connect", dropDown: self.controlToolTip }); self.controlElem.appendChild(self.controlDropDown.domNode); + // self.connected = true; + // refreshImage(); + self.connect(); }) diff --git a/apps/samples/miles/miles.scxml b/apps/samples/miles/miles.scxml index 7014502..746e37f 100644 --- a/apps/samples/miles/miles.scxml +++ b/apps/samples/miles/miles.scxml @@ -5,9 +5,11 @@ <param name="foo" expr="'asdf'" /> <finalize> <if cond="_event.data.origin"> - <!-- log label="Reply-length" expr="_event.data.base64.length" / --> + <!-- <log label="Reply-length" expr="_event.data.base64.length" /> --> <respond status="200" to="_event.data.origin"> - <header name="Content-Type" value="text/ascii" /> + <header name="Cache-Control" value="no-cache" /> <!-- force IE to actually reload --> + <header name="Content-Type" value="text/plain" /> + <header name="Access-Control-Allow-Origin" value="*" /> <content expr="_event.data.base64" /> </respond> </if> @@ -20,8 +22,8 @@ <script>//dump(_event);</script> <respond status="200" to="_event.origin"> <header name="Access-Control-Allow-Origin" value="*" /> - <header name="Access-Control-Allow-Methods" value="GET, OPTIONS" /> - <header name="Access-Control-Allow-Headers" value="X-Requested-With" /> + <header name="Access-Control-Allow-Methods" value="POST, GET, OPTIONS" /> + <header name="Access-Control-Allow-Headers" value="X-Requested-With, Content-Type" /> </respond> </transition> @@ -36,7 +38,11 @@ <param name="email" expr="_event.data.content.email" /> <param name="problemName" expr="_event.data.content.problemName" /> </send> - <respond status="200" to="_event.origin" /> + <respond status="200" to="_event.origin"> + <header name="Connection" value="close" /> + <header name="Content-Type" value="application/json" /> + <header name="Access-Control-Allow-Origin" value="*" /> + </respond> <elseif cond="_event.data.pathComponent[1] === 'disconnect'" /> <send target="#_miles" event="disconnect"> |