1
0

input.html 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <!-- Code by Sunit Kumar Nandi -->
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <meta charset="utf-8" script=>
  6. <link rel="stylesheet" type="text/css" href="./style.css">
  7. </head>
  8. <body>
  9. <form name="form1" method="post" target="output" action="output.php?saving=1">
  10. <br/><br/>
  11. <textarea name="textarea" onfocus="script.js" id="text-area" cols="80" rows="10" placeholder="Write your program here" spellcheck="false"></textarea>
  12. <!-- Thanks to Emmet (http://stackoverflow.com/users/2749/emmett) for the tabbing js. -->
  13. <script type="text/javascript">
  14. document.getElementById("text-area").onkeydown = function(e) {
  15. if (!e && event.keyCode == 9)
  16. {
  17. event.returnValue = false;
  18. insertAtCursor(document.getElementById("text-area"), " ");
  19. }
  20. else if (e.keyCode == 9)
  21. {
  22. e.preventDefault();
  23. insertAtCursor(document.getElementById("text-area"), " ");
  24. }
  25. };
  26. //http://alexking.org/blog/2003/06/02/inserting-at-the-cursor-using-javascript#comment-3817
  27. function insertAtCursor(myField, myValue) {
  28. //IE support
  29. if (document.selection) {
  30. var temp;
  31. myField.focus();
  32. sel = document.selection.createRange();
  33. temp = sel.text.length;
  34. sel.text = myValue;
  35. if (myValue.length == 0) {
  36. sel.moveStart('character', myValue.length);
  37. sel.moveEnd('character', myValue.length);
  38. } else {
  39. sel.moveStart('character', -myValue.length + temp);
  40. }
  41. sel.select();
  42. }
  43. //MOZILLA/NETSCAPE support
  44. else if (myField.selectionStart || myField.selectionStart == '0') {
  45. var startPos = myField.selectionStart;
  46. var endPos = myField.selectionEnd;
  47. myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
  48. myField.selectionStart = startPos + myValue.length;
  49. myField.selectionEnd = startPos + myValue.length;
  50. } else {
  51. myField.value += myValue;
  52. }
  53. }
  54. </script>
  55. <br/><br/><br/>
  56. <input type="text" name="stdin" autocomplete="on" placeholder="Standard input" wrap="hard">
  57. <br/><br/>
  58. <input type="text" name="args" autocomplete="on" placeholder="Command-line arguments">
  59. <br/><hr/><br/>
  60. <button type="submit"> &#9654; Run</button>
  61. </form>
  62. <button href="textinput.php" target="output">Submit text file</button>
  63. <!--<div style="padding:30px;"><a href="#" class="button">&#9654; Run</a></div>-->
  64. </body>
  65. </html>