Home | History | Annotate | Download | only in resources
      1 <!DOCTYPE HTML>
      2 <html i18n-values='dir:textdirection;'>
      3 <style>
      4 
      5 html, body {
      6   margin: 0;
      7   overflow: hidden;
      8 }
      9 
     10 input {
     11   bottom: 0;
     12   left: 0;
     13   margin: 0;
     14   position: absolute;
     15   right: 0;
     16   top: 0;
     17 }
     18 
     19 </style>
     20 
     21 <body>
     22   <input>
     23 </body>
     24 
     25 <script>
     26 
     27 var textfield = document.querySelector('input');
     28 textfield.addEventListener('input', sendTextfieldValueToBrowser);
     29 
     30 /**
     31  * Sends the textfield value to the browser. Called whenever the user presses a
     32  * key. We first check if the key-press has really changed the text, then send
     33  * the new value to the browser if so.
     34  */
     35 function sendTextfieldValueToBrowser() {
     36   chrome.send('textfieldValue', [textfield.value]);
     37 }
     38 
     39 /**
     40  * Sets textfield value
     41  * @param {string} value
     42  */
     43 function setTextfieldValue(value) {
     44   textfield.value = value;
     45   sendTextfieldValueToBrowser();
     46 }
     47 
     48 </script>
     49 </html>
     50