summaryrefslogtreecommitdiffstats
path: root/native_client_sdk/src/examples/geturl/index.html
blob: f47522b34d3c774afbf85bb29dc0f539f53cee0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html>
<html>
  <!--
  Copyright (c) 2012 The Chromium Authors. All rights reserved.
  Use of this source code is governed by a BSD-style license that can be
  found in the LICENSE file.
  -->
<head>
  <meta http-equiv="Pragma" content="no-cache" />
  <meta http-equiv="Expires" content="-1" />
  <title><TITLE></title>
  <script type="text/javascript" src="common.js"></script>
  <script type="text/javascript" >
    function loadUrl() {
      naclModule.postMessage('getUrl:geturl_success.html');
    }

    function handleMessage(message_event) {
      var logElt = document.getElementById('general_output');
      // Find the first line break.  This separates the URL data from the
      // result text.  Note that the result text can contain any number of
      // '\n' characters, so split() won't work here.
      var url = message_event.data;
      var result = '';
      var eol_pos = message_event.data.indexOf("\n");
      if (eol_pos != -1) {
        url = message_event.data.substring(0, eol_pos);
        if (eol_pos < message_event.data.length - 1) {
          result = message_event.data.substring(eol_pos + 1);
        }
      }
      logElt.textContent += 'FULLY QUALIFIED URL: ' + url + '\n';
      logElt.textContent += 'RESULT:\n' + result + '\n';
    }
  </script>
</head>
<body onload="pageDidLoad('<NAME>', '<tc>')">

<h1><TITLE></h1>
<h2>Status: <code id="statusField">NO-STATUS</code></h2>
<p>
<table border=5 cellpadding=5% summary="A title and a result log">
  <tr>
    <td valign=top><pre id='general_output' class='notrun'></pre></td>
  </tr>
</table>
<form name="geturl_form" action="" method="get">
  <input type="button" value="Get URL" onclick="loadUrl()"/>
</form>
  <!-- The <EMBED> element is wrapped inside a <DIV>, which has both a 'load'
  and a 'message' event listener attached.  This wrapping method is used
  instead of attaching the event listeners directly to the <EMBED> element to
  ensure that the listeners are active before the NaCl module 'load' event
  fires.  This also allows you to use PPB_Messaging.PostMessage() (in C) or
  pp::Instance.PostMessage() (in C++) from within the initialization code in
  your NaCl module. 
  
  The src points to a manifest file, which provides the Native Client plug-in
  a mapping between architecture and NaCl Executable (NEXE). 
  
  We use a non-zero sized embed to give Chrome space to place the bad plug-in
  graphic, if there is a problem.
  -->
  <div id="listener">
    <script type="text/javascript">
      var listener = document.getElementById('listener')
      listener.addEventListener('load', moduleDidLoad, true);
      listener.addEventListener('message', handleMessage, true);
    </script>
  </div>
</body>
</html>