1// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5// Called by the common.js module. 6function attachListeners() { 7 document.getElementById('playButton').addEventListener('click', playSound); 8 document.getElementById('stopButton').addEventListener('click', stopSound); 9 document.getElementById('frequencyField').addEventListener('change', 10 changeFrequency); 11} 12 13// Called by the common.js module. 14function moduleDidLoad() { 15 // The module is not hidden by default so we can easily see if the plugin 16 // failed to load. 17 common.hideModule(); 18} 19 20function getFrequencyElement() { 21 return document.getElementById('frequencyField'); 22} 23 24function playSound() { 25 common.naclModule.postMessage('setFrequency:' + getFrequencyElement().value); 26 common.naclModule.postMessage('playSound'); 27} 28 29function stopSound() { 30 common.naclModule.postMessage('stopSound'); 31} 32 33function changeFrequency() { 34 common.naclModule.postMessage('setFrequency:' + getFrequencyElement().value); 35} 36 37// Called by the common.js module. 38function handleMessage(e) { 39 getFrequencyElement().value = message_event.data; 40} 41