| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <!-- | 3 <!-- |
| 4 Copyright (c) 2012 The Chromium Authors. All rights reserved. | 4 Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 5 Use of this source code is governed by a BSD-style license that can be | 5 Use of this source code is governed by a BSD-style license that can be |
| 6 found in the LICENSE file. | 6 found in the LICENSE file. |
| 7 --> | 7 --> |
| 8 <head> | 8 <head> |
| 9 <title>Enumerate Devices Example</title> | 9 <title>Enumerate Devices Example</title> |
| 10 <script type="text/javascript"> | 10 <script type="text/javascript"> |
| 11 var device_array = []; | 11 var device_array = []; |
| 12 var enumerating = false; | 12 var enumerating = false; |
| 13 | 13 |
| 14 function HandleMessage(message_event) { | 14 function HandleMessage(message_event) { |
| 15 if (message_event.data) { | 15 if (message_event.data) { |
| 16 var status = document.getElementById('status'); | 16 var status = document.getElementById('status'); |
| 17 if (message_event.data == 'EnumerationFailed') { | 17 if (message_event.data == 'EnumerationFailed') { |
| 18 status.innerText = 'Device enumeration failed!'; | 18 status.innerText = 'Device enumeration failed!'; |
| 19 } else { | 19 } else { |
| 20 devices_data = | 20 devices_data = |
| 21 message_event.data.substring('EnumerationSuccess'.length); | 21 message_event.data.substring('EnumerationSuccess'.length); |
| 22 if (devices_data.length > 0) | 22 if (devices_data.length > 0) |
| 23 device_array = devices_data.split('#__#'); | 23 device_array = devices_data.split('#__#'); |
| 24 else | 24 else |
| 25 devices_array = []; | 25 device_array = []; |
| 26 | 26 |
| 27 var list = document.getElementById('device_list'); | 27 var list = document.getElementById('device_list'); |
| 28 if (devices_array.length == 0) | 28 if (device_array.length == 0) |
| 29 list.innerHTML = 'No devices.'; | 29 list.innerHTML = 'No devices.'; |
| 30 for (var i = 0; i < device_array.length; ++i) { | 30 for (var i = 0; i < device_array.length; ++i) { |
| 31 var list_item = document.createElement('li'); | 31 var list_item = document.createElement('li'); |
| 32 var span = document.createElement('span'); | 32 var span = document.createElement('span'); |
| 33 span.innerText = device_array[i]; | 33 span.innerText = device_array[i]; |
| 34 list_item.appendChild(span); | 34 list_item.appendChild(span); |
| 35 list.appendChild(list_item); | 35 list.appendChild(list_item); |
| 36 } | 36 } |
| 37 status.innerText = 'Device enumeration success!'; | 37 status.innerText = 'Device enumeration success!'; |
| 38 } | 38 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 </div> | 78 </div> |
| 79 <div id="available_devices"> | 79 <div id="available_devices"> |
| 80 Available device(s): | 80 Available device(s): |
| 81 <ul id="device_list">No devices.</ul> | 81 <ul id="device_list">No devices.</ul> |
| 82 </div> | 82 </div> |
| 83 <div> | 83 <div> |
| 84 Status: <span id="status"></span> | 84 Status: <span id="status"></span> |
| 85 </div> | 85 </div> |
| 86 </body> | 86 </body> |
| 87 </html> | 87 </html> |
| OLD | NEW |