imcplugin demo: Extend to support stat() call
[nativeclient.git] / tests / srpc / srpc_display_shm.html
blob7e6ec1c74c7d7f14d0928fed1a2915fab259d5ce
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html>
4 <!-- Copyright 2008 Google Inc. All rights reserved. -->
5 <head>
6 <title> SRPC Display Shared Memory Example </title>
7 <script type='application/x-javascript'>
8 <!--
9 var height;
10 var width;
11 var dpy;
12 var color;
13 var plugin;
14 var al_elt;
15 var rd_elt;
16 var gr_elt;
17 var bl_elt;
19 // The page begins by saving the display shared memory object.
20 var Init = function() {
21 // Get the plugin element.
22 plugin = document.getElementById('nacl');
23 // Save the geometry parameters.
24 height = plugin.height;
25 width = plugin.width;
26 al_elt = document.getElementById('al');
27 rd_elt = document.getElementById('rd');
28 gr_elt = document.getElementById('gr');
29 bl_elt = document.getElementById('bl');
30 // Get the plugin's display shared memory object.
31 dpy = plugin.__displayShm;
32 // Redraw the plugin.
33 plugin.__redraw();
34 // set the default color.
35 color = 0;
38 var setColor = function(str) {
39 var i;
40 var pixmap_size = height * width;
41 var pixmap = '';
42 for (i = 0; i < pixmap_size; i++) {
43 pixmap += str;
45 dpy.write(0, pixmap_size * 4, pixmap);
46 plugin.__redraw();
49 var changeColor = function() {
50 var alpha = parseInt(al_elt.value);
51 var red = parseInt(rd_elt.value);
52 var green = parseInt(gr_elt.value);
53 var blue = parseInt(bl_elt.value);
54 var color = String.fromCharCode(blue, green, red, alpha);
55 setColor(color);
57 -->
58 </script>
59 </head>
60 <body onload="Init();">
61 <h1> SRPC Display Shared Memory Example </h1>
62 <table summary="A colored box with ARGB inputs">
63 <tr>
64 <td>
65 <embed height=256 width=256 type="application/x-nacl-srpc"
66 id="nacl" />
67 </td>
68 <td>
69 <table summary="ARGB settings for controlling the color of the box">
70 <tr>
71 <td align=right> Alpha </td>
72 <td>
73 <input type="text" id="al" />
74 </td>
75 </tr>
76 <tr>
77 <td align=right> Red </td>
78 <td>
79 <input type="text" id="rd" />
80 </td>
81 </tr>
82 <tr>
83 <td align=right> Green </td>
84 <td>
85 <input type="text" id="gr" />
86 </td>
87 </tr>
88 <tr>
89 <td align=right> Blue </td>
90 <td>
91 <input type="text" id="bl" />
92 </td>
93 </tr>
94 </table>
95 </td>
96 </tr>
97 <tr>
98 <td>
99 <button type="button" onclick="changeColor()">
100 Change Color
101 </button>
102 </td>
103 </tr>
104 </table>
105 </body>
106 </html>