File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < meta charset ="utf-8 "/>
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+
7+ < script src ="webxdc.js "> </ script >
8+ </ head >
9+ < body >
10+ < h1 > Hello World!</ h1 >
11+ < form >
12+ < input id ="input " type ="text " placeholder ="Message " autofocus />
13+ < input type ="submit " onclick ="sendMsg(); return false; " value ="Send " />
14+ </ form >
15+ < p id ="output "> </ p >
16+ < p > < em > < small id ="deviceName "> </ small > </ em > </ p >
17+ < script >
18+ // handle past and future state updates
19+ window . webxdc . setUpdateListener ( function ( update ) {
20+ document . getElementById ( 'output' ) . innerHTML += "<strong>" + update . payload . name + ":</strong> " + update . payload . msg + "<br>" ;
21+ } ) ;
22+
23+ function sendMsg ( ) {
24+ msg = document . getElementById ( "input" ) . value ;
25+ info = 'someone typed "' + msg + '"' ;
26+ document . getElementById ( "input" ) . value = '' ;
27+
28+ // send new updates
29+ window . webxdc . sendUpdate ( {
30+ payload : {
31+ name : window . webxdc . selfName ,
32+ msg,
33+ } ,
34+ info,
35+ } , info ) ;
36+ }
37+
38+ ( function ( ) {
39+ window . deviceName . innerHTML = 'You are: ' + window . webxdc . selfName ;
40+ } ) ( )
41+ </ script >
42+ </ body >
43+ </ html >
You can’t perform that action at this time.
0 commit comments