1 // Copyright 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 /** 6 * Queries the document for an element with a matching id. 7 * @param {string} id is a case-sensitive string representing the unique ID of 8 * the element being sought. 9 * @return {?Element} The element with that id. 10 */ 11 var $ = function(id) { 12 return document.getElementById(id); 13 } 14 15 function logIfError() { 16 if (chrome.runtime.lastError) { 17 console.log(chrome.runtime.lastError); 18 } 19 } 20 21 function insertText(text) { 22 chrome.virtualKeyboardPrivate.insertText(text, logIfError); 23 } 24 25 function MoveCursor(swipe_direction, swipe_flags) { 26 chrome.virtualKeyboardPrivate.moveCursor(swipe_direction, swipe_flags); 27 } 28 29 function sendKeyEvent(event) { 30 chrome.virtualKeyboardPrivate.sendKeyEvent(event, logIfError); 31 } 32 33 function hideKeyboard() { 34 chrome.virtualKeyboardPrivate.hideKeyboard(logIfError); 35 } 36 37 function keyboardLoaded() { 38 chrome.virtualKeyboardPrivate.keyboardLoaded(logIfError); 39 } 40 41 chrome.virtualKeyboardPrivate.onTextInputBoxFocused.addListener( 42 function (inputContext) { 43 $('keyboard').inputTypeValue = inputContext.type; 44 } 45 ); 46