Permalink
Browse files

Some improved styling, added preliminary history support. Pity the ba…

…ckend breaks with history still...
  • Loading branch information...
1 parent 974e5d2 commit c5168d54d5df5b4e885ca23daafbcfdf0cc71913 @jamesgao committed Oct 19, 2010
@@ -1,4 +1,8 @@
-body { font-family:sans-serif; font-size:10pt;}
+body {
+ font-family:sans-serif;
+ font-size:10pt;
+ margin:5px;
+}
pre, p { margin:0px; }
.cblue { color: blue }
.ccyan { color: teal }
@@ -1,5 +1,33 @@
-#sidebar { float:right; width:20%; }
-#statusbar { margin:5px; }
+#messages *,#sidebar * {
+ border-radius:3px;
+ -moz-border-radius:3px;
+}
+#sidebar {
+ width:20%;
+ height:100%;
+ position:fixed;
+ right:5px;
+ background:white;
+}
+#history {
+ margin:6px;
+ padding:8px;
+ border:1px solid #CCC;
+ min-height:20px;
+}
+#history p{
+ margin:-18px 0px 0px 10px;
+ float:left;
+ background:white;
+}
+#statusbar {
+ position:absolute;
+ bottom:6px;
+ right:0px;
+ margin:6px;
+ padding:8px;
+ border:1px solid #CCC;
+}
#statusbar span { vertical-align:middle; }
#statusbar .bullet {
font-size:150%;
@@ -10,18 +38,20 @@
width:80%;
float:left;
}
-.active {
- border-color:#090;
-}
.message {
- padding:3px;
- border:1px solid #CCC;
- margin:5px;
+ border:1px solid #CCC;
+ border-radius:3px;
+ padding:8px;
+ margin:6px;
+ overflow:auto;
}
.message:hover {
border:1px solid red;
cursor:pointer;
}
+.active {
+ border:1px solid #090;
+}
.message .input_header {
color:blue;
float:left;
@@ -30,6 +60,7 @@
.message .input {
float:left;
width:90%;
+ margin-bottom:4px;
}
.message .output_header {
color:red;
@@ -55,6 +55,7 @@ function execute(code, msg) {
comet.start()
if (json != null) {
manager.process(json, msg)
+ //gethistory(1)
}
}
})
@@ -69,3 +70,12 @@ function tabcomplete(code, pos, func) {
}
})
}
+function gethistory(len) {
+ $.ajax({
+ type:"POST",
+ data:{type:"history", index:len},
+ success: function (json, status, request) {
+ kernhistory.append(json.content.history)
+ }
+ })
+}
@@ -7,6 +7,7 @@ $(document).ready(function() {
comet = new CometGetter()
manager = new Manager("messages")
statusbar = new StatusBar("statusbar")
+ kernhistory = new History("history")
//Startup POST, set some globals
$.ajax({
type: "POST",
@@ -17,6 +17,19 @@ StatusBar.prototype.set = function(status) {
this.text.text(status)
}
+function History(obj) {
+ this.obj = $(obj)
+// gethistory(-1)
+}
+History.prototype.append = function(hist) {
+ for (var i in hist) {
+ var obj = $(document.createElement("div"))
+ obj.addClass("history_element")
+ obj.html("["+i+"]: "+hist[i])
+ this.obj.append(obj)
+ }
+}
+
/***********************************************************************
* Manages the messages and their ordering
***********************************************************************/
@@ -104,6 +117,8 @@ Manager.prototype.process = function (json, origin) {
} else if (typeof(payload["text"]) != "undefined") {
msg.setOutput(fixConsole(payload["text"]))
}
+ } else {
+ msg.setOutput("")
}
//Open a new input object
manager.get().activate()
@@ -252,10 +267,13 @@ InputArea.prototype.complete = function (matches) {
this.replace(matches[0])
else if (matches.length > 1) {
//TODO:Implement a multi-selector!
+ var pos = this.text.getSelection().end
+
}
}
-InputArea.prototype.replace = function (match) {
- var pos = this.text.getSelection().end
+InputArea.prototype.replace = function (match, pos) {
+ if (typeof(pos) == "undefined")
+ pos = this.text.getSelection().end
var code = this.text.val()
var words = code.slice(0,pos).split(' ')
var end = code.slice(pos)
@@ -60,6 +60,15 @@ def complete(self, code, pos):
def inspect(self, oname):
self.kernel_manager.xreq_channel.object_info(oname)
return self.req_queue.get()
+
+ def history(self, index = None, raw = False, output=False):
+ if index == -1:
+ index = None
+ try:
+ self.kernel_manager.xreq_channel.history(index, raw, output)
+ return self.req_queue.get()
+ except:
+ return dict(msg_type="history_reply", content=dict(history=dict()))
def addreq(self, msg):
self.req_queue.put(msg)
@@ -123,6 +132,8 @@ def do_POST(self):
resp = manager.inspect(data['name'].value)
elif msg_type == "connect":
resp = manager.send("connect_request")
+ elif msg_type == "history":
+ resp = manager.history(data['index'].value)
json.dump(resp, self.wfile)
class IPyHttpServer(ThreadingMixIn, HTTPServer):
@@ -16,6 +16,12 @@
</head>
<body>
<div id="messages"></div>
- <div id="sidebar"><div id="statusbar"></div></div>
+ <div id="sidebar">
+ <div id="history">
+ <p>History</p>
+ <span>Backend history not supported</span>
+ </div>
+ <div id="statusbar"></div>
+ </div>
</body>
</html>

0 comments on commit c5168d5

Please sign in to comment.