Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow payload to display text, partial support for object inspection.…

… I need to enable the full object_info_request before this is satisfying
  • Loading branch information...
commit 974e5d2c91f7d513ec85c8ad273ee91cdca801e7 1 parent e030733
@jamesgao authored
View
3  IPython/frontend/html/css/defaults.css
@@ -3,7 +3,8 @@ pre, p { margin:0px; }
.cblue { color: blue }
.ccyan { color: teal }
.cgreen { color: green }
-.cyellow { color: yellow }
+.cyellow { color: #990 }
+.cwhite { color: #777 }
.cred { color: red }
.cbold { font-weight:bold }
.hidden { display:none; }
View
15 IPython/frontend/html/js/notebook.js
@@ -21,12 +21,19 @@ $(document).ready(function() {
})
function xmlencode(string) {
- return string.replace(/\&/g,'&'+'amp;').replace(/</g,'&'+'lt;')
- .replace(/>/g,'&'+'gt;').replace(/\'/g,'&'+'apos;')
- .replace(/\"/g,'&'+'quot;');
+ return string.replace(/\&/g,'&'+'amp;')
+ .replace(/</g,'&'+'lt;')
+ .replace(/>/g,'&'+'gt;')
+ .replace(/\'/g,'&'+'apos;')
+ .replace(/\"/g,'&'+'quot;')
+ .replace(/`/g,'&'+'#96;')
}
-attrib = {"30":"cblack", "31":"cred","32":"cgreen", "34":"cblue", "36":"ccyan", "01":"cbold"}
+attrib = {
+ "30":"cblack", "31":"cred",
+ "32":"cgreen", "33":"cyellow",
+ "34":"cblue", "36":"ccyan",
+ "37":"cwhite", "01":"cbold"}
function fixConsole(txt) {
//Fixes escaped console commands, IE colors. Turns them into HTML
//Unfortunately, the "semantics" of html and console are very
View
33 IPython/frontend/html/js/ui.js
@@ -85,14 +85,25 @@ Manager.prototype.process = function (json, origin) {
if (type == "execute_reply") {
exec_count = json.content.execution_count
//If this reply has an SVG, let's add it
- if (json.content.payload.length > 0 &&
- json.content.payload[0]['format'] == "svg") {
- var data = json.content.payload[0]['data']
- //Remove the doctype from the top, otherwise no way to embed
- data = data.split("\n").slice(4).join("\n")
- var svg = document.createElement("div")
- svg.innerHTML = data
- msg.setOutput(svg)
+ if (json.content.payload.length > 0) {
+ var payload = json.content.payload[0]
+ if (typeof(payload['format']) != "undefined") {
+ var format = payload['format']
+ if (format == "svg") {
+ var data = payload['data']
+ //Remove the doctype from the top, otherwise no way to embed
+ data = data.split("\n").slice(4).join("\n")
+ var svg = document.createElement("div")
+ svg.innerHTML = data
+ msg.setOutput(svg)
+ } else if (format == "png") {
+ var png = document.createElement("img")
+ png.src = "data:image/png;"+payload['data']
+ msg.setOutput(png)
+ }
+ } else if (typeof(payload["text"]) != "undefined") {
+ msg.setOutput(fixConsole(payload["text"]))
+ }
}
//Open a new input object
manager.get().activate()
@@ -172,6 +183,7 @@ Message.prototype.activate = function () {
manager.deactivate(this)
this.outer.addClass("active")
this.text = new InputArea(this)
+ $.scrollTo(this.outer)
}
Message.prototype.deactivate = function () {
this.outer.removeClass("active")
@@ -224,10 +236,9 @@ InputArea.prototype.activate = function () {
thisObj.complete(matches)
})
} else {
- this.msg.code = this.text.val()
+ thisObj.msg.code = e.target.value
}
})
- $.scrollTo(this.text)
}
InputArea.prototype.submit = function (code) {
this.msg.code = code
@@ -240,7 +251,7 @@ InputArea.prototype.complete = function (matches) {
if (matches.length == 1)
this.replace(matches[0])
else if (matches.length > 1) {
- //TODO:Implement me!
+ //TODO:Implement a multi-selector!
}
}
InputArea.prototype.replace = function (match) {
Please sign in to comment.
Something went wrong with that request. Please try again.