aaltay commented on a change in pull request #11020: [BEAM-7926] Update Data 
Visualization
URL: https://github.com/apache/beam/pull/11020#discussion_r387360704
 
 

 ##########
 File path: 
sdks/python/apache_beam/runners/interactive/interactive_environment.py
 ##########
 @@ -43,6 +43,55 @@
 
 _LOGGER = logging.getLogger(__name__)
 
+# By `format(customized_script=xxx)`, the given `customized_script` is
+# guaranteed to be executed within access to a jquery with datatable plugin
+# configured which is useful so that any `customized_script` is resilient to
+# browser refresh. Inside `customized_script`, use `$` as jQuery.
+_JQUERY_WITH_DATATABLE_TEMPLATE = """
+        if (typeof window.jquery341 == 'undefined') {{
+          var jqueryScript = document.createElement('script');
+          jqueryScript.src = 
'https://code.jquery.com/jquery-3.4.1.slim.min.js';
+          jqueryScript.type = 'text/javascript';
+          jqueryScript.onload = function() {{
+            var datatableScript = document.createElement('script');
+            datatableScript.src = 
'https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js';
+            datatableScript.type = 'text/javascript';
+            datatableScript.onload = function() {{
+              window.jquery341 = jQuery.noConflict(true);
+              window.jquery341(document).ready(function($){{
+                {customized_script}
+              }});
+            }}
+            document.head.appendChild(datatableScript);
+          }};
+          document.head.appendChild(jqueryScript);
+        }} else {{
+          window.jquery341(document).ready(function($){{
+            {customized_script}
+          }});
+        }}"""
+
+_HTML_IMPORT_TEMPLATE = """
 
 Review comment:
   could you add comments related to this?
   
   Why is it no longer supported by chrome?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to