Change code regarding sending message
authorYunchan Cho <yunchan.cho@samsung.com>
Fri, 10 May 2013 05:43:19 +0000 (14:43 +0900)
committerYunchan Cho <yunchan.cho@samsung.com>
Fri, 10 May 2013 05:48:07 +0000 (14:48 +0900)
Change-Id: Ib82f91829d47c26f700d465f166e72b7bd64efd5

box/index.html
pd/index.html

index d152616..7a6c3f2 100755 (executable)
@@ -2,22 +2,18 @@
 <html>
     <head>
         <meta name="viewport" content="width=device-width, initial-scale=1" />
-        <title>DynamicBox</title>
+        <title>Web Dynamic Box</title>
         <script>
-            window.onmessage = function(e) {
-                document.getElementById("message").innerHTML += e.data;
-                pdWindow.document.getElementById("fromBox").innerHTML += "<br>[web messaging] Hello, DropView";
-            }
-            window.addEventListener("pdevent",
+            window.addEventListener("pdmessage",
             function(e) {
-                document.getElementById("message").innerHTML += e.detail.message;
-                pdWindow.document.getElementById("fromBox").innerHTML += "<br>[custom event] Hello, DropView";
+                document.getElementById("fromPd").innerHTML += unescape(e) + "<br>";
+                window.appwidget.sendMessageToPd("Hello, Drop View");
             }, false);
         </script>
     </head>
         <body bgcolor="#99CCFF" text="#FFFFFF">
-        <div id="demo">DynamicBox Sample</div>
+        <div id="demo">Web Dynamic Box</div>
         <div id="demo">This is a Box.</div>
-        <div id="message"></div>
+        <div id="fromPd"></div>
     </body>
 </html>
index f91bc31..8a20de5 100755 (executable)
@@ -1,27 +1,16 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 <html>
     <head>
-        <meta name="viewport" content="initial-scale=1" />
-        <title>Test</title>
+        <meta name="viewport" content="width=device-width, initial-scale=1" />
+        <title>Drop View</title>
         <script>
-            function accessParentElement() {
-                window.opener.document.body.style.backgroundColor = "#BBFFFF";
-            }
-            function accessWebMessaging() {
-                window.opener.postMessage ("web messaging!<br>", "*");
-            }
+            window.addEventListener("boxmessage",
+            function(e) {
+                document.getElementById("fromBox").innerHTML += unescape(e) + '<br>';
+            }, false);
 
-            // create custom event
-            var event = new CustomEvent("pdevent", {
-                detail: {
-                message: "custom event!<br>",
-                time: new Date(),
-                },
-                bubbles: true,
-                cancelable: true
-            });
-            function accessCustomEvent() {
-                window.opener.dispatchEvent(event);
+            function send () {
+                window.appwidget.sendMessageToBox("Hello, Dynamic Box");
             }
         </script>
         <style>
         </style>
     </head>
     <body bgcolor="#FF9966" text="#FFFFFF">
-        This is a DropView.<br>A DropView can control the Box.<br>
-        <input type="button" value="ColorChange" onclick="accessParentElement()" />
-        <input type="button" value="WebMessage" onclick="accessWebMessaging()" />
-        <input type="button" value="CustomEvent" onclick="accessCustomEvent()" />
+        This is a Drop View.<br>A Drop View can control the Box.<br>
+        <input type="button" value="Send message to Box" onclick="send()" />
         <div id="fromBox"></div>
     </body>
 </html>