1
0

input.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <!-- Code by Sunit Kumar Nandi -->
  2. <<<<<<< HEAD
  3. <!DOCTYPE html>
  4. <html lang="en">
  5. <head>
  6. <meta charset="utf-8" script=>
  7. <link rel="stylesheet" type="text/css" href="./style.css">
  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. =======
  28. <head>
  29. <!-- Inserting CodeMirror text editor -->
  30. <!-- Credit for the idea goes to Aditya Rajan -->
  31. <link rel="stylesheet" href="assets/codemirror.css">
  32. <script src="assets/codemirror.js"></script>
  33. <script src="assets/matchbrackets.js"></script>
  34. <script src="assets/clike.js"></script>
  35. <style>.CodeMirror {border: 1px solid #ccc; width:500px; }</style>
  36. </head>
  37. <body>
  38. <!-- Specifying how the form data should be processed -->
  39. <form name="form1" method="post" target="output" action="output.php?saving=1">
  40. Write your program here:
  41. <br>
  42. <!-- Accepting program code -->
  43. <textarea id="code" name="data" cols="80" rows="10">
  44. #include<iostream>
  45. using namespace std;
  46. int main()
  47. {
  48. cout << "Hello world!";
  49. return 0;
  50. }
  51. </textarea>
  52. <br><br>
  53. <!-- Accepting standard input -->
  54. Standard input:<br>
  55. <textarea name="stdin" cols="60" rows="10">
  56. </textarea>
  57. <br><br>
  58. <!-- Accepting command-line agruments -->
  59. Command line arguments: <input type="text" name="args">
  60. <br><br>
  61. <!-- Submit button goes here -->
  62. <input type="submit" value="Run">
  63. </form>
  64. <br>
  65. <!-- Provide a link to text input option -->
  66. <a href="textinput.php" target="output">Click here to submit text file input</a>
  67. <script>
  68. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  69. lineNumbers: true,
  70. matchBrackets: true,
  71. lineWrapping: true,
  72. tabMode: "indent",
  73. indentUnit: 4,
  74. mode: "text/x-c++src"
  75. });
  76. </script>
  77. </body>
  78. >>>>>>> 993de84b2fbccdce0b2c1c76291839d38519b9cf
  79. //http://alexking.org/blog/2003/06/02/inserting-at-the-cursor-using-javascript#comment-3817
  80. function insertAtCursor(myField, myValue) {
  81. //IE support
  82. if (document.selection) {
  83. var temp;
  84. myField.focus();
  85. sel = document.selection.createRange();
  86. temp = sel.text.length;
  87. sel.text = myValue;
  88. if (myValue.length == 0) {
  89. sel.moveStart('character', myValue.length);
  90. sel.moveEnd('character', myValue.length);
  91. } else {
  92. sel.moveStart('character', -myValue.length + temp);
  93. }
  94. sel.select();
  95. }
  96. //MOZILLA/NETSCAPE support
  97. else if (myField.selectionStart || myField.selectionStart == '0') {
  98. var startPos = myField.selectionStart;
  99. var endPos = myField.selectionEnd;
  100. myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
  101. myField.selectionStart = startPos + myValue.length;
  102. myField.selectionEnd = startPos + myValue.length;
  103. } else {
  104. myField.value += myValue;
  105. }
  106. }
  107. </script>
  108. <br/><br/><br/>
  109. <input type="text" name="stdin" autocomplete="on" placeholder="Standard input" wrap="hard">
  110. <br/><br/>
  111. <input type="text" name="args" autocomplete="on" placeholder="Command-line arguments">
  112. <br/><hr/><br/>
  113. <button type="submit"> &#9654; Run</button>
  114. </form>
  115. <button href="textinput.php" target="output">Submit text file</button>
  116. <!--<div style="padding:30px;"><a href="#" class="button">&#9654; Run</a></div>-->
  117. </body>
  118. </html>