Adds a ChromeSamples.clearLog() method and updates the Bluetooth samples to use it
This commit is contained in:
Родитель
5f74c32e30
Коммит
43293a2577
|
@ -12,21 +12,21 @@ additional_head_content: <meta name="optional" value="optional">
|
|||
<p>Any content here, outside of a capture block, is included verbatim on the resulting page.</p>
|
||||
|
||||
{% capture initial_output_content %}
|
||||
<p>This can be used to set initial sample output.</p>
|
||||
<p>This optional capture/include can be used to set initial sample output.</p>
|
||||
{% endcapture %}
|
||||
{% include output_helper.html initial_output_content=initial_output_content %}
|
||||
|
||||
{% capture js %}
|
||||
/*
|
||||
Use this section for any JavaScript that shows off the feature's functionality.
|
||||
Use this optional capture/include for any JavaScript that shows off the feature's functionality.
|
||||
Do not surround it with <script> tags.
|
||||
If output_helper.html is included on this page, then ChromeSamples.log(),
|
||||
ChromeSamples.setStatus(), and ChromeSamples.setContent() can be used here.
|
||||
ChromeSamples.clearLog(), ChromeSamples.setStatus(), and ChromeSamples.setContent() can be used.
|
||||
*/
|
||||
{% endcapture %}
|
||||
{% include js_snippet.html js=js %}
|
||||
|
||||
{% capture css %}
|
||||
/* Use this section for CSS that shows off the feature's functionality. */
|
||||
/* Use this optional capture/include for CSS that shows off the feature's functionality. */
|
||||
{% endcapture %}
|
||||
{% include css_snippet.html css=css %}
|
||||
|
|
|
@ -8,6 +8,10 @@
|
|||
document.querySelector('#log').textContent += line + '\n';
|
||||
},
|
||||
|
||||
clearLog: function() {
|
||||
document.querySelector('#log').textContent = '';
|
||||
},
|
||||
|
||||
setStatus: function(status) {
|
||||
document.querySelector('#status').textContent = status;
|
||||
},
|
||||
|
|
|
@ -57,14 +57,14 @@ function onButtonClick() {
|
|||
{% include js_snippet.html js=js %}
|
||||
|
||||
<script>
|
||||
document.querySelector('button').addEventListener('click', function() {
|
||||
document.querySelector('#log').textContent = '';
|
||||
if (!navigator.bluetooth) {
|
||||
log('Web Bluetooth API is not available.');
|
||||
log('Please make sure you run Chrome OS M45 and the Web Bluetooth flag is enabled.');
|
||||
} else {
|
||||
onButtonClick();
|
||||
}
|
||||
});
|
||||
log = ChromeSamples.log;
|
||||
document.querySelector('button').addEventListener('click', function() {
|
||||
if (!navigator.bluetooth) {
|
||||
ChromeSamples.setStatus('Web Bluetooth API is not available.\n' +
|
||||
'Please make sure you run Chrome OS M45 and the Web Bluetooth flag is enabled.');
|
||||
} else {
|
||||
ChromeSamples.clearLog();
|
||||
onButtonClick();
|
||||
}
|
||||
});
|
||||
log = ChromeSamples.log;
|
||||
</script>
|
||||
|
|
|
@ -34,14 +34,14 @@ function onButtonClick() {
|
|||
{% include js_snippet.html js=js %}
|
||||
|
||||
<script>
|
||||
document.querySelector('button').addEventListener('click', function() {
|
||||
document.querySelector('#log').textContent = '';
|
||||
if (!navigator.bluetooth) {
|
||||
log('Web Bluetooth API is not available.');
|
||||
log('Please make sure you run Chrome OS M45 and the Web Bluetooth flag is enabled.');
|
||||
} else {
|
||||
onButtonClick();
|
||||
}
|
||||
});
|
||||
log = ChromeSamples.log;
|
||||
document.querySelector('button').addEventListener('click', function() {
|
||||
if (!navigator.bluetooth) {
|
||||
ChromeSamples.setStatus('Web Bluetooth API is not available.\n' +
|
||||
'Please make sure you run Chrome OS M45 and the Web Bluetooth flag is enabled.');
|
||||
} else {
|
||||
ChromeSamples.clearLog();
|
||||
onButtonClick();
|
||||
}
|
||||
});
|
||||
log = ChromeSamples.log;
|
||||
</script>
|
||||
|
|
|
@ -58,14 +58,14 @@ function onButtonClick() {
|
|||
{% include js_snippet.html js=js %}
|
||||
|
||||
<script>
|
||||
document.querySelector('button').addEventListener('click', function() {
|
||||
document.querySelector('#log').textContent = '';
|
||||
if (!navigator.bluetooth) {
|
||||
log('Web Bluetooth API is not available.');
|
||||
log('Please make sure you run Chrome OS M45 and the Web Bluetooth flag is enabled.');
|
||||
} else {
|
||||
onButtonClick();
|
||||
}
|
||||
});
|
||||
log = ChromeSamples.log;
|
||||
document.querySelector('button').addEventListener('click', function() {
|
||||
if (!navigator.bluetooth) {
|
||||
ChromeSamples.setStatus('Web Bluetooth API is not available.\n' +
|
||||
'Please make sure you run Chrome OS M45 and the Web Bluetooth flag is enabled.');
|
||||
} else {
|
||||
ChromeSamples.clearLog();
|
||||
onButtonClick();
|
||||
}
|
||||
});
|
||||
log = ChromeSamples.log;
|
||||
</script>
|
||||
|
|
Загрузка…
Ссылка в новой задаче