Advertisement
Guest User

Textbox Lines

a guest
Feb 6th, 2014
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.58 KB | None | 0 0
  1. <html>
  2. <head>
  3. <script>
  4. var box; var code;
  5.  
  6. function init(){
  7.  box = document.getElementById('html_text');
  8.  code = document.getElementById('html_code');
  9.  code.onkeyup = boxCheck;
  10. }
  11.  
  12. String.prototype.indexesOf = function(x){
  13.  var r = [];
  14.  for(var i=0;i<this.length;i++) if(this[i] == x) r.push(i);
  15. return r;
  16. }
  17.  
  18. function boxCheck(){
  19.    var endLines = code.value.indexesOf('\n');
  20.    box.style.display = '';
  21.    for(var i=0;i<2;i++){
  22.        if(endLines[i+1] == undefined && code.value.length - endLines[i] > 46){
  23.             box.style.display = 'none';
  24.             break;
  25.         }
  26.         if(endLines[i] - endLines[i+1] > 46){
  27.             box.style.display = 'none';
  28.             break;
  29.         }
  30.     }
  31.     if(endLines.length == 0 && code.value.length > 45)
  32.        box.style.display = 'none';
  33. }
  34. </script>
  35. </head>
  36. <body onload="init();">
  37. <div id="html_text"><h5 style="
  38. margin-top: 17px;
  39. margin-left: 400px;
  40. position: fixed;
  41. color: black;
  42. z-index: 1;
  43. font-family: Arial, Helvetica, sans-serif;
  44. border-style: solid;
  45. border-width: thin;
  46. padding-left: 5px;
  47. padding-right: 5px;
  48. padding-top: 5px;
  49. padding-bottom: 3px;
  50. -webkit-touch-callout: none;
  51. -webkit-user-select: none;
  52. -khtml-user-select: none;
  53. -moz-user-select: none;
  54. -ms-user-select: none;
  55. user-select: none;">HTML</h5></div>
  56.  
  57. <textarea rows="20" style="
  58. margin-left: 20px;
  59. font-family: 'Courier New', Courier, monospace;
  60. height: 280px;
  61. width: 460px;
  62. resize: none;
  63. overflow: scroll;
  64. overflow-x: hidden;
  65. position: absolute;
  66. z-index: 0;" id="html_code" spellcheck="false"></textarea>
  67. </body>
  68. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement