You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/02/13 10:12:09 UTC

[GitHub] [airflow] mik-laj commented on a change in pull request #14215: Js linting and inline migration for simple scripts

mik-laj commented on a change in pull request #14215:
URL: https://github.com/apache/airflow/pull/14215#discussion_r575649112



##########
File path: airflow/www/templates/airflow/dag_code.html
##########
@@ -32,23 +32,8 @@
 {% block tail_js %}
   {{ super() }}
   <script>
-    function toggleWrap() {
-      $('.code pre').toggleClass('wrap')
-    };
-
-    // We blur task_ids in demo mode
-    $(document).ready(function() {
-      if ("{{ demo_mode }}" == "True") {
-        $("pre span.s").css({
-          'text-shadow': '0 0 10px red',
-          'color': 'transparent',
-        });
-      }
-    });
-
-    // pygments generates the HTML so set wrap toggle via js
-    if ("{{ wrapped }}" == "True") {
-      toggleWrap();
-    };
+    const isDemoMode = '{{ demo_mode }}' === 'True';

Review comment:
       Ideally, we should manage to delete all inline scripts. For this purpose, we can pass this data as the page metadata.
   ```javascript
   function getMetaValue(name) {
     const el = document.querySelector('meta[name="' + name + '"]')
     if (!el) {
       return
     }
     return el.getAttribute("content")
   }
   
   global.getMetaValue = getMetaValue
   ```
   ```
   <meta name="dag-timezone" content="{{ dag.timezone.name }}">
   ```
   ```
   var dag_timezone = gettMetaValue("dag-timezone")
   ```




----------------------------------------------------------------
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:
users@infra.apache.org