Commit c3da8848 authored by Andrew Gibiansky's avatar Andrew Gibiansky

now actually works

parent 670ccde9
...@@ -7,6 +7,8 @@ if (initialized && window.parsecWidgetRegistered === undefined) { ...@@ -7,6 +7,8 @@ if (initialized && window.parsecWidgetRegistered === undefined) {
// Do not load this script again. // Do not load this script again.
window.parsecWidgetRegistered = true; window.parsecWidgetRegistered = true;
var parsecWidgetCounter = 0;
// Register the comm target. // Register the comm target.
var ParsecWidget = function (comm) { var ParsecWidget = function (comm) {
this.comm = comm; this.comm = comm;
...@@ -47,6 +49,10 @@ var ParsecWidget = function (comm) { ...@@ -47,6 +49,10 @@ var ParsecWidget = function (comm) {
var out = this.cell.output_area.element; var out = this.cell.output_area.element;
this.textarea = out.find("#parsec-editor")[0]; this.textarea = out.find("#parsec-editor")[0];
this.output = out.find("#parsec-output")[0]; this.output = out.find("#parsec-output")[0];
// Give the elements a different name.
this.textarea.id += parsecWidgetCounter;
this.output.id += parsecWidgetCounter;
parsecWidgetCounter++;
var editor = CodeMirror.fromTextArea(this.textarea, options); var editor = CodeMirror.fromTextArea(this.textarea, options);
var editor = editor; var editor = editor;
...@@ -61,14 +67,13 @@ var ParsecWidget = function (comm) { ...@@ -61,14 +67,13 @@ var ParsecWidget = function (comm) {
ParsecWidget.prototype.handler = function(msg) { ParsecWidget.prototype.handler = function(msg) {
var data = msg.content.data; var data = msg.content.data;
this.hasError = data["status"] == "error"; this.hasError = data["status"] == "error";
console.log('handler', msg);
if (this.hasError) { if (this.hasError) {
out = data["msg"]; this.output.innerHTML = data["msg"];
this.error = data; this.error = data;
} else { } else {
out = data["result"]; this.output.innerHTML = data["result"];
} }
// Update viewed output.
this.output.innerHTML = out;
}; };
// Register this widget. // Register this widget.
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"celltoolbar": "Hiding", "celltoolbar": "Hiding",
"language": "haskell", "language": "haskell",
"name": "", "name": "",
"signature": "sha256:444705f910fcdf32804f8966333f9306a779ea3b3a6123eff79873d78e4c6f56" "signature": "sha256:804b433cf50ca6157f3f59dbddeffdb20dda07eee3e4701830f71f5eee0fbfd3"
}, },
"nbformat": 3, "nbformat": 3,
"nbformat_minor": 0, "nbformat_minor": 0,
...@@ -36,16 +36,22 @@ ...@@ -36,16 +36,22 @@
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"Slider" "1+1"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {
"hidden": false
},
"outputs": [ "outputs": [
{ {
"metadata": {}, "metadata": {},
"output_type": "display_data" "output_type": "display_data",
"text": [
"2"
]
} }
] ],
"prompt_number": 1
}, },
{ {
"cell_type": "code", "cell_type": "code",
...@@ -104,6 +110,8 @@ ...@@ -104,6 +110,8 @@
"// Do not load this script again.\n", "// Do not load this script again.\n",
"window.parsecWidgetRegistered = true;\n", "window.parsecWidgetRegistered = true;\n",
"\n", "\n",
"var parsecWidgetCounter = 0;\n",
"\n",
"// Register the comm target.\n", "// Register the comm target.\n",
"var ParsecWidget = function (comm) {\n", "var ParsecWidget = function (comm) {\n",
" this.comm = comm;\n", " this.comm = comm;\n",
...@@ -144,6 +152,10 @@ ...@@ -144,6 +152,10 @@
" var out = this.cell.output_area.element;\n", " var out = this.cell.output_area.element;\n",
" this.textarea = out.find(\"#parsec-editor\")[0];\n", " this.textarea = out.find(\"#parsec-editor\")[0];\n",
" this.output = out.find(\"#parsec-output\")[0];\n", " this.output = out.find(\"#parsec-output\")[0];\n",
" // Give the elements a different name.\n",
" this.textarea.id += parsecWidgetCounter;\n",
" this.output.id += parsecWidgetCounter;\n",
" parsecWidgetCounter++;\n",
"\n", "\n",
" var editor = CodeMirror.fromTextArea(this.textarea, options);\n", " var editor = CodeMirror.fromTextArea(this.textarea, options);\n",
" var editor = editor;\n", " var editor = editor;\n",
...@@ -158,14 +170,13 @@ ...@@ -158,14 +170,13 @@
"ParsecWidget.prototype.handler = function(msg) {\n", "ParsecWidget.prototype.handler = function(msg) {\n",
" var data = msg.content.data;\n", " var data = msg.content.data;\n",
" this.hasError = data[\"status\"] == \"error\";\n", " this.hasError = data[\"status\"] == \"error\";\n",
" console.log('handler', msg);\n",
" if (this.hasError) {\n", " if (this.hasError) {\n",
" out = data[\"msg\"];\n", " this.output.innerHTML = data[\"msg\"];\n",
" this.error = data;\n", " this.error = data;\n",
" } else {\n", " } else {\n",
" out = data[\"result\"];\n", " this.output.innerHTML = data[\"result\"];\n",
" }\n", " }\n",
" // Update viewed output.\n",
" this.output.innerHTML = out;\n",
"};\n", "};\n",
"\n", "\n",
"// Register this widget.\n", "// Register this widget.\n",
......
...@@ -56,14 +56,14 @@ lintIdent = "lintIdentAEjlkQeh" ...@@ -56,14 +56,14 @@ lintIdent = "lintIdentAEjlkQeh"
lint :: [Located CodeBlock] -> IO Display lint :: [Located CodeBlock] -> IO Display
lint blocks = do lint blocks = do
-- Initialize hlint settings -- Initialize hlint settings
initialized <- isEmptyMVar hlintSettings initialized <- not <$> isEmptyMVar hlintSettings
when (not initialized) $ autoSettings >>= putMVar hlintSettings when (not initialized) $ do
autoSettings >>= putMVar hlintSettings
-- Get hlint settings -- Get hlint settings
(flags, classify, hint) <- readMVar hlintSettings (flags, classify, hint) <- readMVar hlintSettings
let mode = hseFlags flags let mode = hseFlags flags
-- create 'suggestions' -- create 'suggestions'
let modules = mapMaybe (createModule mode) blocks let modules = mapMaybe (createModule mode) blocks
ideas = applyHints classify hint modules ideas = applyHints classify hint modules
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment