1// Copyright 2014 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 5var appWindow = chrome.app.window.current(); 6 7document.addEventListener('DOMContentLoaded', function() { 8 var flow = new Flow(); 9 flow.startFlow(); 10 11 // Make the close buttons close the app window. 12 var closeButtons = document.getElementsByClassName('close'); 13 for (var i = 0; i < closeButtons.length; ++i) { 14 var closeButton = closeButtons[i]; 15 closeButton.addEventListener('click', function(e) { 16 appWindow.close(); 17 e.stopPropagation(); 18 }); 19 } 20 21 $('ah-cancel-button').addEventListener('click', function(e) { 22 appWindow.close(); 23 e.stopPropagation(); 24 }); 25 26 $('hw-cancel-button').addEventListener('click', function(e) { 27 appWindow.close(); 28 e.stopPropagation(); 29 }); 30 31 $('st-cancel-button').addEventListener('click', function(e) { 32 appWindow.close(); 33 e.stopPropagation(); 34 }); 35 36 $('ah-agree-button').addEventListener('click', function(e) { 37 // TODO(kcarattini): Set the Audio History setting. 38 appWindow.close(); 39 e.stopPropagation(); 40 }); 41 42 $('hw-agree-button').addEventListener('click', function(e) { 43 flow.advanceStep(); 44 e.stopPropagation(); 45 }); 46 47 // TODO(kcarattini): Remove this once speech training is implemented. The 48 // way to get to the next page will be to complete the speech training. 49 $('training').addEventListener('click', function(e) { 50 if (chrome.hotwordPrivate.setAudioLoggingEnabled) 51 chrome.hotwordPrivate.setAudioLoggingEnabled(true, function() {}); 52 53 if (chrome.hotwordPrivate.setHotwordAlwaysOnSearchEnabled) { 54 chrome.hotwordPrivate.setHotwordAlwaysOnSearchEnabled(true, 55 flow.advanceStep.bind(flow)); 56 } 57 e.stopPropagation(); 58 }); 59 60 $('try-now-button').addEventListener('click', function(e) { 61 // TODO(kcarattini): Figure out what happens when you click this button. 62 appWindow.close(); 63 e.stopPropagation(); 64 }); 65}); 66