Show More
@@ -5,10 +5,10 b' define([' | |||||
5 | 'base/js/namespace', |
|
5 | 'base/js/namespace', | |
6 | 'jquery', |
|
6 | 'jquery', | |
7 | 'base/js/utils', |
|
7 | 'base/js/utils', | |
8 | 'services/kernels/js/comm', |
|
8 | './comm', | |
9 | 'widgets/js/init', |
|
9 | './serialize', | |
10 | './serialize' |
|
10 | 'widgets/js/init' | |
11 |
], function(IPython, $, utils, comm, |
|
11 | ], function(IPython, $, utils, comm, serialize, widgetmanager) { | |
12 | "use strict"; |
|
12 | "use strict"; | |
13 |
|
13 | |||
14 | /** |
|
14 | /** |
@@ -3,7 +3,6 b'' | |||||
3 |
|
3 | |||
4 | define([ |
|
4 | define([ | |
5 | 'jquery', |
|
5 | 'jquery', | |
6 | 'components/utf8/utf8' |
|
|||
7 | ], function ($, utf8) { |
|
6 | ], function ($, utf8) { | |
8 | "use strict"; |
|
7 | "use strict"; | |
9 |
|
8 | |||
@@ -16,14 +15,9 b' define([' | |||||
16 | for (i = 1; i <= nbufs; i++) { |
|
15 | for (i = 1; i <= nbufs; i++) { | |
17 | offsets.push(data.getInt32(i * 4)); |
|
16 | offsets.push(data.getInt32(i * 4)); | |
18 | } |
|
17 | } | |
19 | // have to convert array to string for utf8.js |
|
18 | var json_bytes = new Uint8Array(buf.slice(offsets[0], offsets[1])); | |
20 | var bytestring = String.fromCharCode.apply(null, |
|
|||
21 | new Uint8Array(buf.slice(offsets[0], offsets[1])) |
|
|||
22 | ); |
|
|||
23 | var msg = $.parseJSON( |
|
19 | var msg = $.parseJSON( | |
24 | utf8.decode( |
|
20 | (new TextDecoder('utf8')).decode(json_bytes) | |
25 | bytestring |
|
|||
26 | ) |
|
|||
27 | ); |
|
21 | ); | |
28 | // the remaining chunks are stored as DataViews in msg.buffers |
|
22 | // the remaining chunks are stored as DataViews in msg.buffers | |
29 | msg.buffers = []; |
|
23 | msg.buffers = []; | |
@@ -66,16 +60,6 b' define([' | |||||
66 | } |
|
60 | } | |
67 | }; |
|
61 | }; | |
68 |
|
62 | |||
69 | var _bytes2buf = function (bytestring) { |
|
|||
70 | // convert bytestring to UInt8Array |
|
|||
71 | var nbytes = bytestring.length; |
|
|||
72 | var buf = new Uint8Array(nbytes); |
|
|||
73 | for (var i = 0; i < nbytes; i++) { |
|
|||
74 | buf[i] = bytestring.charCodeAt(i); |
|
|||
75 | } |
|
|||
76 | return buf; |
|
|||
77 | }; |
|
|||
78 |
|
||||
79 | var _serialize_binary = function (msg) { |
|
63 | var _serialize_binary = function (msg) { | |
80 | // implement the binary serialization protocol |
|
64 | // implement the binary serialization protocol | |
81 | // serializes JSON message to ArrayBuffer |
|
65 | // serializes JSON message to ArrayBuffer | |
@@ -83,7 +67,7 b' define([' | |||||
83 | var offsets = []; |
|
67 | var offsets = []; | |
84 | var buffers = msg.buffers; |
|
68 | var buffers = msg.buffers; | |
85 | delete msg.buffers; |
|
69 | delete msg.buffers; | |
86 |
var json_utf8 = |
|
70 | var json_utf8 = (new TextEncoder('utf8')).encode(JSON.stringify(msg)); | |
87 | buffers.unshift(json_utf8); |
|
71 | buffers.unshift(json_utf8); | |
88 | var nbufs = buffers.length; |
|
72 | var nbufs = buffers.length; | |
89 | offsets.push(4 * (nbufs + 1)); |
|
73 | offsets.push(4 * (nbufs + 1)); | |
@@ -112,7 +96,6 b' define([' | |||||
112 | }; |
|
96 | }; | |
113 |
|
97 | |||
114 | var serialize = function (msg) { |
|
98 | var serialize = function (msg) { | |
115 | console.log(msg.buffers, msg.buffers.length); |
|
|||
116 | if (msg.buffers && msg.buffers.length) { |
|
99 | if (msg.buffers && msg.buffers.length) { | |
117 | return _serialize_binary(msg); |
|
100 | return _serialize_binary(msg); | |
118 | } else { |
|
101 | } else { |
@@ -311,6 +311,7 b' class="notebook_app"' | |||||
311 | {% block script %} |
|
311 | {% block script %} | |
312 | {{super()}} |
|
312 | {{super()}} | |
313 |
|
313 | |||
|
314 | <script src="{{ static_url("components/text-encoding/lib/encoding.js") }}" charset="utf-8"></script> | |||
314 |
|
315 | |||
315 | <script src="{{ static_url("notebook/js/main.js") }}" charset="utf-8"></script> |
|
316 | <script src="{{ static_url("notebook/js/main.js") }}" charset="utf-8"></script> | |
316 |
|
317 |
General Comments 0
You need to be logged in to leave comments.
Login now