diff options
Diffstat (limited to 'chrome/browser/resources/textfields.html')
| -rw-r--r-- | chrome/browser/resources/textfields.html | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/chrome/browser/resources/textfields.html b/chrome/browser/resources/textfields.html new file mode 100644 index 0000000..b716006 --- /dev/null +++ b/chrome/browser/resources/textfields.html @@ -0,0 +1,49 @@ +<!DOCTYPE HTML> +<html i18n-values='dir:textdirection;'> +<style> + +html, body { + margin: 0; + overflow: hidden; +} + +input { + bottom: 0; + left: 0; + margin: 0; + position: absolute; + right: 0; + top: 0; +} + +</style> + +<body> + <input> +</body> + +<script> + +var textfield = document.querySelector('input'); +textfield.addEventListener('input', sendTextfieldValueToBrowser); + +/** + * Sends the textfield value to the browser. Called whenever the user presses a + * key. We first check if the key-press has really changed the text, then send + * the new value to the browser if so. + */ +function sendTextfieldValueToBrowser() { + chrome.send('textfieldValue', [textfield.value]); +} + +/** + * Sets textfield value + * @param {string} value + */ +function setTextfieldValue(value) { + textfield.value = value; + sendTextfieldValueToBrowser(); +} + +</script> +</html> |
