input.html 2.5 KB

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