From 4e26db9931950e3359c20ea09bd14f6e88c5db9d Mon Sep 17 00:00:00 2001 From: Berend-Jan Lange Date: Sun, 29 Mar 2020 21:27:52 +0200 Subject: [PATCH 01/10] duplicate_reduction --- notebook/static/notebook/js/outputarea.js | 53 +++++++---------------- 1 file changed, 16 insertions(+), 37 deletions(-) diff --git a/notebook/static/notebook/js/outputarea.js b/notebook/static/notebook/js/outputarea.js index da72caa5e..dd075e565 100644 --- a/notebook/static/notebook/js/outputarea.js +++ b/notebook/static/notebook/js/outputarea.js @@ -838,34 +838,16 @@ define([ } }; - var append_png = function (png, md, element, handle_inserted) { - var type = MIME_PNG; - var toinsert = this.create_output_subarea(md, "output_png", type); + OutputArea.prototype.append_img = function (src_type, md, element, handle_inserted, MIME, type_string) { + var type = MIME; + var toinsert = this.create_output_subarea(md, "output_" + type_string, type); var img = $(""); if (handle_inserted !== undefined) { img.on('load', function(){ handle_inserted(img); }); } - img[0].src = 'data:image/png;base64,'+ png; - set_width_height(img, md, type); - dblclick_to_reset_size(img); - toinsert.append(img); - element.append(toinsert); - return toinsert; - }; - - - var append_jpeg = function (jpeg, md, element, handle_inserted) { - var type = MIME_JPEG; - var toinsert = this.create_output_subarea(md, "output_jpeg", type); - var img = $(""); - if (handle_inserted !== undefined) { - img.on('load', function(){ - handle_inserted(img); - }); - } - img[0].src = 'data:image/jpeg;base64,'+ jpeg; + img[0].src = 'data:image/' + type_string + ';base64,'+ src_type; set_width_height(img, md, type); dblclick_to_reset_size(img); toinsert.append(img); @@ -873,24 +855,21 @@ define([ return toinsert; }; - var append_gif = function (gif, md, element, handle_inserted) { - var type = MIME_GIF; - var toinsert = this.create_output_subarea(md, "output_gif", type); - var img = $(""); - if (handle_inserted !== undefined) { - img.on('load', function(){ - handle_inserted(img); - }); - } - img[0].src = 'data:image/gif;base64,'+ gif; - set_width_height(img, md, type); - dblclick_to_reset_size(img); - toinsert.append(img); - element.append(toinsert); - return toinsert; + var append_png = function (png, md, element, handle_inserted) { + this.append_img(png, md, element, handle_inserted, MIME_PNG, "png"); }; + var append_jpeg = function (jpeg, md, element, handle_inserted) { + this.append_img(jpeg, md, element, handle_inserted, MIME_JPEG, "jpeg"); + }; + + var append_gif = function (gif, md, element, handle_inserted) { + this.append_img(gif, md, element, handle_inserted, MIME_GIF, "gif"); + }; + + + var append_pdf = function (pdf, md, element) { var type = MIME_PDF; var toinsert = this.create_output_subarea(md, "output_pdf", type); From 456421b6e5690ce71653b2c76015ae184b2f3eab Mon Sep 17 00:00:00 2001 From: Berend-Jan Lange Date: Sun, 29 Mar 2020 23:03:13 +0200 Subject: [PATCH 02/10] removed_prototyping --- notebook/static/notebook/js/outputarea.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/notebook/static/notebook/js/outputarea.js b/notebook/static/notebook/js/outputarea.js index dd075e565..61bfa1f47 100644 --- a/notebook/static/notebook/js/outputarea.js +++ b/notebook/static/notebook/js/outputarea.js @@ -838,9 +838,9 @@ define([ } }; - OutputArea.prototype.append_img = function (src_type, md, element, handle_inserted, MIME, type_string) { + var append_img = function (src_type, md, element, handle_inserted, MIME, type_string) { var type = MIME; - var toinsert = this.create_output_subarea(md, "output_" + type_string, type); + var toinsert = this.create_output_subarea(md, 'output_' + type_string, type); var img = $(""); if (handle_inserted !== undefined) { img.on('load', function(){ @@ -856,16 +856,16 @@ define([ }; var append_png = function (png, md, element, handle_inserted) { - this.append_img(png, md, element, handle_inserted, MIME_PNG, "png"); + append_img(png, md, element, handle_inserted, MIME_PNG, 'png'); }; var append_jpeg = function (jpeg, md, element, handle_inserted) { - this.append_img(jpeg, md, element, handle_inserted, MIME_JPEG, "jpeg"); + append_img(jpeg, md, element, handle_inserted, MIME_JPEG, 'jpeg'); }; var append_gif = function (gif, md, element, handle_inserted) { - this.append_img(gif, md, element, handle_inserted, MIME_GIF, "gif"); + append_img(gif, md, element, handle_inserted, MIME_GIF, 'gif'); }; From a9a5b1f1aa64c625382052b8dec4cf985b801caa Mon Sep 17 00:00:00 2001 From: Berend-Jan Lange Date: Mon, 30 Mar 2020 09:47:13 +0200 Subject: [PATCH 03/10] added return --- notebook/static/notebook/js/outputarea.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/notebook/static/notebook/js/outputarea.js b/notebook/static/notebook/js/outputarea.js index 61bfa1f47..137f68f6b 100644 --- a/notebook/static/notebook/js/outputarea.js +++ b/notebook/static/notebook/js/outputarea.js @@ -838,7 +838,7 @@ define([ } }; - var append_img = function (src_type, md, element, handle_inserted, MIME, type_string) { + _append_img = function (src_type, md, element, handle_inserted, MIME, type_string) { var type = MIME; var toinsert = this.create_output_subarea(md, 'output_' + type_string, type); var img = $(""); @@ -856,16 +856,16 @@ define([ }; var append_png = function (png, md, element, handle_inserted) { - append_img(png, md, element, handle_inserted, MIME_PNG, 'png'); + return _append_img(png, md, element, handle_inserted, MIME_PNG, 'png'); }; var append_jpeg = function (jpeg, md, element, handle_inserted) { - append_img(jpeg, md, element, handle_inserted, MIME_JPEG, 'jpeg'); + return _append_img(jpeg, md, element, handle_inserted, MIME_JPEG, 'jpeg'); }; var append_gif = function (gif, md, element, handle_inserted) { - append_img(gif, md, element, handle_inserted, MIME_GIF, 'gif'); + return _append_img(gif, md, element, handle_inserted, MIME_GIF, 'gif'); }; From aaf68538f0c5849f223494aaec1d5a75d1d3e3ba Mon Sep 17 00:00:00 2001 From: Berend-Jan Lange Date: Mon, 30 Mar 2020 21:37:21 +0200 Subject: [PATCH 04/10] passed_test --- notebook/static/notebook/js/outputarea.js | 1 - 1 file changed, 1 deletion(-) diff --git a/notebook/static/notebook/js/outputarea.js b/notebook/static/notebook/js/outputarea.js index 137f68f6b..bf826c596 100644 --- a/notebook/static/notebook/js/outputarea.js +++ b/notebook/static/notebook/js/outputarea.js @@ -859,7 +859,6 @@ define([ return _append_img(png, md, element, handle_inserted, MIME_PNG, 'png'); }; - var append_jpeg = function (jpeg, md, element, handle_inserted) { return _append_img(jpeg, md, element, handle_inserted, MIME_JPEG, 'jpeg'); }; From e6dea3364359ca63a1719537bb267c625f948889 Mon Sep 17 00:00:00 2001 From: Berend-Jan Lange Date: Mon, 30 Mar 2020 22:09:43 +0200 Subject: [PATCH 05/10] update --- notebook/static/notebook/js/outputarea.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/notebook/static/notebook/js/outputarea.js b/notebook/static/notebook/js/outputarea.js index bf826c596..da241b22e 100644 --- a/notebook/static/notebook/js/outputarea.js +++ b/notebook/static/notebook/js/outputarea.js @@ -867,8 +867,6 @@ define([ return _append_img(gif, md, element, handle_inserted, MIME_GIF, 'gif'); }; - - var append_pdf = function (pdf, md, element) { var type = MIME_PDF; var toinsert = this.create_output_subarea(md, "output_pdf", type); From 5907bf1e6cf1209d6f182d28d64e3f71425ac11c Mon Sep 17 00:00:00 2001 From: Berend-Jan Lange Date: Mon, 30 Mar 2020 22:49:18 +0200 Subject: [PATCH 06/10] update --- notebook/static/notebook/js/outputarea.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebook/static/notebook/js/outputarea.js b/notebook/static/notebook/js/outputarea.js index da241b22e..1cd1a1949 100644 --- a/notebook/static/notebook/js/outputarea.js +++ b/notebook/static/notebook/js/outputarea.js @@ -838,7 +838,7 @@ define([ } }; - _append_img = function (src_type, md, element, handle_inserted, MIME, type_string) { + var _append_img = function (src_type, md, element, handle_inserted, MIME, type_string) { var type = MIME; var toinsert = this.create_output_subarea(md, 'output_' + type_string, type); var img = $(""); From 1af2c0c27aded5488af61ccd6a85e78e65609533 Mon Sep 17 00:00:00 2001 From: Berend-Jan Lange Date: Wed, 8 Apr 2020 11:47:57 +0200 Subject: [PATCH 07/10] added prototype --- notebook/static/notebook/js/outputarea.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebook/static/notebook/js/outputarea.js b/notebook/static/notebook/js/outputarea.js index 1cd1a1949..51187ced6 100644 --- a/notebook/static/notebook/js/outputarea.js +++ b/notebook/static/notebook/js/outputarea.js @@ -838,7 +838,7 @@ define([ } }; - var _append_img = function (src_type, md, element, handle_inserted, MIME, type_string) { + OutputArea.prototype._append_img = function (src_type, md, element, handle_inserted, MIME, type_string) { var type = MIME; var toinsert = this.create_output_subarea(md, 'output_' + type_string, type); var img = $(""); From 39e7e0a280685178b0f7704044279d6b8ec39204 Mon Sep 17 00:00:00 2001 From: Berend-Jan Lange Date: Wed, 8 Apr 2020 12:12:17 +0200 Subject: [PATCH 08/10] added this. --- notebook/static/notebook/js/outputarea.js | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/notebook/static/notebook/js/outputarea.js b/notebook/static/notebook/js/outputarea.js index 51187ced6..db9ba389a 100644 --- a/notebook/static/notebook/js/outputarea.js +++ b/notebook/static/notebook/js/outputarea.js @@ -856,28 +856,17 @@ define([ }; var append_png = function (png, md, element, handle_inserted) { - return _append_img(png, md, element, handle_inserted, MIME_PNG, 'png'); + return this._append_img(png, md, element, handle_inserted, MIME_PNG, 'png'); }; var append_jpeg = function (jpeg, md, element, handle_inserted) { - return _append_img(jpeg, md, element, handle_inserted, MIME_JPEG, 'jpeg'); + return this._append_img(jpeg, md, element, handle_inserted, MIME_JPEG, 'jpeg'); }; var append_gif = function (gif, md, element, handle_inserted) { - return _append_img(gif, md, element, handle_inserted, MIME_GIF, 'gif'); + return this._append_img(gif, md, element, handle_inserted, MIME_GIF, 'gif'); }; - var append_pdf = function (pdf, md, element) { - var type = MIME_PDF; - var toinsert = this.create_output_subarea(md, "output_pdf", type); - var a = $('').attr('href', 'data:application/pdf;base64,'+pdf); - a.attr('target', '_blank'); - a.text('View PDF'); - toinsert.append(a); - element.append(toinsert); - return toinsert; - }; - var append_latex = function (latex, md, element) { /** * This method cannot do the typesetting because the latex first has to From def0dfc84b149ab4d51e90cf05059d05accdc502 Mon Sep 17 00:00:00 2001 From: Berend-Jan Lange Date: Wed, 8 Apr 2020 12:28:36 +0200 Subject: [PATCH 09/10] added_back_append_pdf --- notebook/i18n/nbjs.json | 3 ++- notebook/static/notebook/js/outputarea.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/notebook/i18n/nbjs.json b/notebook/i18n/nbjs.json index 8be7a8384..5174c0e32 100644 --- a/notebook/i18n/nbjs.json +++ b/notebook/i18n/nbjs.json @@ -2,7 +2,8 @@ "domain": "nbjs", "supported_languages": [ "fr-FR", - "zh-CN" + "zh-CN", + "nl-NL" ], "locale_data": { "nbjs": { diff --git a/notebook/static/notebook/js/outputarea.js b/notebook/static/notebook/js/outputarea.js index db9ba389a..74753a7c3 100644 --- a/notebook/static/notebook/js/outputarea.js +++ b/notebook/static/notebook/js/outputarea.js @@ -867,6 +867,17 @@ define([ return this._append_img(gif, md, element, handle_inserted, MIME_GIF, 'gif'); }; + var append_pdf = function (pdf, md, element) { + var type = MIME_PDF; + var toinsert = this.create_output_subarea(md, "output_pdf", type); + var a = $('').attr('href', 'data:application/pdf;base64,'+pdf); + a.attr('target', '_blank'); + a.text('View PDF'); + toinsert.append(a); + element.append(toinsert); + return toinsert; + }; + var append_latex = function (latex, md, element) { /** * This method cannot do the typesetting because the latex first has to From b7144259558e0d7ccf5c326d09fe620154da36a0 Mon Sep 17 00:00:00 2001 From: Berend-Jan Lange Date: Wed, 8 Apr 2020 12:30:21 +0200 Subject: [PATCH 10/10] removed_nl_NL --- notebook/i18n/nbjs.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/notebook/i18n/nbjs.json b/notebook/i18n/nbjs.json index 5174c0e32..8be7a8384 100644 --- a/notebook/i18n/nbjs.json +++ b/notebook/i18n/nbjs.json @@ -2,8 +2,7 @@ "domain": "nbjs", "supported_languages": [ "fr-FR", - "zh-CN", - "nl-NL" + "zh-CN" ], "locale_data": { "nbjs": {