| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2013 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 function load() { | |
| 6 var checkPassphrase = function(event) { | |
| 7 chrome.send('checkPassphrase', [$('passphrase-entry').value]); | |
| 8 }; | |
| 9 var closeDialog = function(event) { | |
| 10 // TODO(akuegel): Replace by closeDialog. | |
| 11 chrome.send('DialogClose'); | |
| 12 }; | |
| 13 // Directly set the focus on the input box so the user can start typing right | |
| 14 // away. | |
| 15 $('passphrase-entry').focus(); | |
| 16 $('unlock-passphrase-button').onclick = checkPassphrase; | |
| 17 $('cancel-passphrase-button').onclick = closeDialog; | |
| 18 $('passphrase-entry').oninput = function(event) { | |
| 19 $('unlock-passphrase-button').disabled = $('passphrase-entry').value == ''; | |
| 20 $('incorrect-passphrase-warning').hidden = true; | |
| 21 }; | |
| 22 $('passphrase-entry').onkeypress = function(event) { | |
| 23 // Check if the user pressed enter. | |
| 24 if (event.keyCode == 13) | |
| 25 checkPassphrase(event); | |
| 26 }; | |
| 27 | |
| 28 // Pressing escape anywhere in the frame should work. | |
| 29 document.onkeyup = function(event) { | |
| 30 // Check if the user pressed escape. | |
| 31 if (event.keyCode == 27) | |
| 32 closeDialog(event); | |
| 33 }; | |
| 34 } | |
| 35 | |
| 36 function passphraseResult(passphraseCorrect) { | |
| 37 if (passphraseCorrect) { | |
| 38 chrome.send('DialogClose', ['true']); | |
| 39 } else { | |
| 40 $('incorrect-passphrase-warning').hidden = false; | |
| 41 $('passphrase-entry').focus(); | |
| 42 } | |
| 43 } | |
| 44 | |
| 45 window.addEventListener('DOMContentLoaded', load); | |
| OLD | NEW |