Akshit Tripathi 11 years ago
parent
commit
ddc9f46fac
3 changed files with 37 additions and 6 deletions
  1. 20 5
      input.html
  2. 15 0
      js/script.js
  3. 2 1
      style.css

+ 20 - 5
input.html

@@ -6,21 +6,36 @@
 <head>
 	<meta charset="utf-8" script=>
 	<link rel="stylesheet" type="text/css" href="./style.css">
+	<script language="JavaScript" type="text/javascript">
+	$("textarea").keydown(function(e){
+		var $this, end, start, v;
+		if (e.keyCode === 9){
+			start = this.selectionStart;
+			end = this.selectionEnd;
+			$this = $(this);
+			v = $this.val();
+
+			$this.val(v.substring(0,start) 
+					+ "\t"
+					+ v.substring(end));
+			this.selectionStart = this.selectionEnd = start + 1;
+			e.preventDefault();
+            }
+        });
+	</script>
 </head>
 <body>
 	<form name="form1" method="post" target="output" action="output.php?saving=1">
 		<br/><br/>
-		<textarea name="data" cols="80" rows="10" placeholder="Write your program here" spellcheck="false"></textarea>
+		<textarea name="textarea" cols="80" rows="10" placeholder="Write your program here" spellcheck="false"></textarea>
 		<br/><br/><br/>
 		<input type="text" name="stdin" autocomplete="on" placeholder="Standard input" wrap="hard">
 		<br/><br/>
 		<input type="text" name="args" autocomplete="on" placeholder="Command-line arguments">
 		<br/><hr/><br/>
 		<button type="submit"> &#9654; Run</button>
-		<div style="padding:30px;"><a href="#" class="button">&#9654; Run</a></div>
 	</form>
-	<br/>
-	<br/>
-	<a href="textinput.php" target="output">Click here to submit text file input</a>
+	<button href="textinput.php" target="output">Submit text file</button>
+		<!--<div style="padding:30px;"><a href="#" class="button">&#9654; Run</a></div>-->
 </body>
 </html>

+ 15 - 0
js/script.js

@@ -0,0 +1,15 @@
+$("textarea").keydown(function(e)){
+            var $this, end, start, v;
+            if (e.keyCode === 9){
+                start = this.selectionStart;
+                end = this.selectionEnd;
+                $this = $(this);
+                v = $this.val();
+                
+                $this.val(v.substring(0,start) 
+                          + "\t"
+                          + v.substring(end));
+                this.selectionStart = this.selectionEnd = start + 1;
+                e.preventDefault();
+            }
+        });

+ 2 - 1
style.css

@@ -20,6 +20,7 @@ textarea {
 	resize: none;
 	border: solid;
 	border-width: 1px;
+	margin-left: 3px;
 }
 
 p {
@@ -70,7 +71,7 @@ input[type=text]:focus, textarea:focus {
 }
 
 button:hover {
-	padding: 13px 72px;
+	padding: 12px 48px;
 	font-family: "Alegreya Sans SC", sans-serif;
 	background: linear-gradient (to bottom, #EDEDED 70%, #DEDEDE 30%);
 	color: rgb(0, 0, 0);