Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

history added and cool colors

  • Loading branch information...
commit 822407431d92f142cb17d578ac4dc62717a68ed4 1 parent 62c3ae6
kanalj authored
Showing with 65 additions and 3 deletions.
  1. +3 −0  ghci.html
  2. +55 −2 haskell.hiji.js
  3. +7 −1 hiji.css
View
3  ghci.html
@@ -18,6 +18,9 @@
<link rel="stylesheet" type="text/css" href="hiji.css">
</head>
<body>
+
+ <h1>HIJi</h1>
+ <h2>Bringing you the power of GHCI to the interwebs</h2>
<div id="hiji" class="ghci-look"></div>
</body>
</html>
View
57 haskell.hiji.js
@@ -13,17 +13,39 @@
};
var makeInput = function(modules){
- return "<li class='input'>" + makeModules(modules) + "<input type='text'></li>";
+ return "<li class='input'>" + makeModules(modules) + "<input type='text' name='inputBox'></li>";
};
var makeOutput = function(output) {
console.log("%o", output);
return $("<li class='output'></li>").text(output.ast.toString());
};
+
$.fn.startHiji = function() {
var modules = new Array();
+ var hist = new Array();
+
+ // history
+ var hiss = new historry;
+
modules[0] = "Prelude";
modules[1] = "Control.Monad";
this.html("<ol>" + makeInput(modules) + "</ol>");
+
+
+ // pressing keyUP and keyDown
+ // history-related
+ document.onkeydown = function(e){
+ var input = $('input', this);
+ var line = input.attr("value");
+ // keyUp
+ if(e.keyCode=='38'){
+ input.attr("value", hiss.older());
+ }
+ if(e.keyCode=='40'){
+ input.attr("value", hiss.newer());
+ }
+ }
+
this.keypress(function(e){
if (e.keyCode=='13'){
var input = $('input', this);
@@ -33,7 +55,38 @@
var output = makeOutput(evaluateHaskell(line,{}));
$('.input', this).after(output).replaceWith(newLine);
$("ol",this).append(makeInput(modules));
+
+ hiss.addHistory(line);
}
});
};
-})(jQuery);
+})(jQuery);
+
+
+// historry-class with nice name
+// !!!WARNING!!! NICE NAME
+historry = function (){
+ this.pointer = 0;
+ this.history_array = new Array();
+ this.addHistory = function(input){
+ this.history_array.unshift(input);
+ this.pointer = -1;
+ };
+
+ this.older = function(){
+ this.pointer++;
+ if(this.pointer >= this.history_array.length){
+ this.pointer = this.history_array.length-1
+ }
+ return this.history_array[this.pointer];
+ };
+
+ this.newer = function(){
+ this.pointer--;
+ if(this.pointer < 0){
+ this.pointer = 0
+ return "";
+ }
+ return this.history_array[this.pointer];
+ };
+};
View
8 hiji.css
@@ -11,15 +11,21 @@
.ghci-look ol{
width:800px;
height:400px;
+ background-color: #000;
overflow-x:auto;
overflow-y:scroll;
list-style-type:none;
+
+ color: #fff;
}
.ghci-look .input input {
border:none;
display:inline-block;
margin-left:-1px;
+ background-color: #000;
+
+ color: #fff;
}
.ghci-look .modules {
@@ -38,4 +44,4 @@
.ghci-look .modules:after {
content:">";
padding-right:0.5em;
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.