Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-74502

[mentor-questa-vrm] Extract inline script block in com/mentor/questa/vrm/jenkins/QuestaVrmHostAction/summarytable.jelly

      Problem

      == Inline Script Block
      Line: 45
      ----
      <script type="text/javascript">
          var summary = <st:bind value="${it}"/>
          var mode = "${mode}" =="true";
          function getLinkedCell(rowOutput, value, link){
           var cellOutput = rowOutput.insertCell(-1)
           cellOutput.class="pane"
      
            var  a= document.createElement("a");
            a.href = link;
            a.class="model-link inside"
            var result = document.createTextNode(value);
            a.appendChild(result);
            cellOutput.appendChild(a);
      
          }
      
          function getNormalCell2(rowOutput, a , align){
         	var cellOutput = rowOutput.insertCell(-1)
         	cellOutput.class="pane"
         	cellOutput.style.textAlign = align
          	var result = document.createTextNode(a);
      	cellOutput.appendChild(result);
      
          }
          function getNormalCell(rowOutput, a) {
          	getNormalCell2(rowOutput, a, "center");
          }
          function getSummary(time){
          	document.getElementById("summary-table").style.display="";
          	document.getElementById("summary-table-header").style.display="";
      	var tbody = document.createElement("tbody");
      
         	 summary.getActions(time,function(t) {
         	 	var actions = t.responseObject();
         	 	var emptyCell= {content:"--", tooltip:""};
         	 	var table = document.getElementById("summary-table");
      
          		document.getElementById("summary-table-header").innerHTML="&lt;h2&gt;Summary at time "+actions[0]+"&lt;//h2&gt;";
         	 	for( i=1; i&lt; actions.length; i++) {
         	 		if(!mode &amp;&amp; !actions[i].hasOwnProperty('testname') )
         	 			continue;
      
      			var rowOutput = tbody.insertRow(-1);
         	 		var a = actions[i]
         	 		if (mode){
         	 			getLinkedCell(rowOutput,a['action'], a['url']);
         	 		}
      
         	 		if (a.hasOwnProperty('testname')){
      				rowOutput.class="test-row"
         	 			getLinkedCell(rowOutput,a['testname'], a['testurl']);
      			} else {
      
         	 			getNormalCell2(rowOutput,"--", "left");
      				rowOutput.class="action-row"
      			}
      
         	 		getNormalCell(rowOutput,a['status']);
         	 		getNormalCell(rowOutput,a['age']);
         	 		getNormalCell(rowOutput,a['duration']);
         	 		getNormalCell(rowOutput,a['host']);
         	 		}
         	 	table.replaceChild(tbody,table.tBodies[1] )
         	 });
      	 
          }
           </script>
      ----
      

      Solution

      https://www.jenkins.io/doc/developer/security/csp/#inline-javascript-blocks

          [JENKINS-74502] [mentor-questa-vrm] Extract inline script block in com/mentor/questa/vrm/jenkins/QuestaVrmHostAction/summarytable.jelly

          Basil Crow created issue -
          Basil Crow made changes -
          Assignee Original: Questa Vrm [ questa_vrm ]
          Basil Crow made changes -
          Description Original: h4. Problems

          {noformat}
          == Inline Script Block
          Line: 45
          ----
          <script type="text/javascript">
              var summary = <st:bind value="${it}"/>
              var mode = "${mode}" =="true";
              function getLinkedCell(rowOutput, value, link){
               var cellOutput = rowOutput.insertCell(-1)
               cellOutput.class="pane"

                var a= document.createElement("a");
                a.href = link;
                a.class="model-link inside"
                var result = document.createTextNode(value);
                a.appendChild(result);
                cellOutput.appendChild(a);

              }

              function getNormalCell2(rowOutput, a , align){
              var cellOutput = rowOutput.insertCell(-1)
              cellOutput.class="pane"
              cellOutput.style.textAlign = align
               var result = document.createTextNode(a);
          cellOutput.appendChild(result);

              }
              function getNormalCell(rowOutput, a) {
               getNormalCell2(rowOutput, a, "center");
              }
              function getSummary(time){
               document.getElementById("summary-table").style.display="";
               document.getElementById("summary-table-header").style.display="";
          var tbody = document.createElement("tbody");

              summary.getActions(time,function(t) {
              var actions = t.responseObject();
              var emptyCell= {content:"--", tooltip:""};
              var table = document.getElementById("summary-table");

               document.getElementById("summary-table-header").innerHTML="&lt;h2&gt;Summary at time "+actions[0]+"&lt;//h2&gt;";
              for( i=1; i&lt; actions.length; i++) {
              if(!mode &amp;&amp; !actions[i].hasOwnProperty('testname') )
              continue;

          var rowOutput = tbody.insertRow(-1);
              var a = actions[i]
              if (mode){
              getLinkedCell(rowOutput,a['action'], a['url']);
              }

              if (a.hasOwnProperty('testname')){
          rowOutput.class="test-row"
              getLinkedCell(rowOutput,a['testname'], a['testurl']);
          } else {

              getNormalCell2(rowOutput,"--", "left");
          rowOutput.class="action-row"
          }

              getNormalCell(rowOutput,a['status']);
              getNormalCell(rowOutput,a['age']);
              getNormalCell(rowOutput,a['duration']);
              getNormalCell(rowOutput,a['host']);
              }
              table.replaceChild(tbody,table.tBodies[1] )
              });

              }
               </script>
          ----

          == Inline Script Block
          Line: 45
          ----
          <script type="text/javascript">
              var summary = <st:bind value="${it}"/>
              var mode = "${mode}" =="true";
              function getLinkedCell(rowOutput, value, link){
               var cellOutput = rowOutput.insertCell(-1)
               cellOutput.class="pane"

                var a= document.createElement("a");
                a.href = link;
                a.class="model-link inside"
                var result = document.createTextNode(value);
                a.appendChild(result);
                cellOutput.appendChild(a);

              }

              function getNormalCell2(rowOutput, a , align){
              var cellOutput = rowOutput.insertCell(-1)
              cellOutput.class="pane"
              cellOutput.style.textAlign = align
               var result = document.createTextNode(a);
          cellOutput.appendChild(result);

              }
              function getNormalCell(rowOutput, a) {
               getNormalCell2(rowOutput, a, "center");
              }
              function getSummary(time){
               document.getElementById("summary-table").style.display="";
               document.getElementById("summary-table-header").style.display="";
          var tbody = document.createElement("tbody");

              summary.getActions(time,function(t) {
              var actions = t.responseObject();
              var emptyCell= {content:"--", tooltip:""};
              var table = document.getElementById("summary-table");

               document.getElementById("summary-table-header").innerHTML="&lt;h2&gt;Summary at time "+actions[0]+"&lt;//h2&gt;";
              for( i=1; i&lt; actions.length; i++) {
              if(!mode &amp;&amp; !actions[i].hasOwnProperty('testname') )
              continue;

          var rowOutput = tbody.insertRow(-1);
              var a = actions[i]
              if (mode){
              getLinkedCell(rowOutput,a['action'], a['url']);
              }

              if (a.hasOwnProperty('testname')){
          rowOutput.class="test-row"
              getLinkedCell(rowOutput,a['testname'], a['testurl']);
          } else {

              getNormalCell2(rowOutput,"--", "left");
          rowOutput.class="action-row"
          }

              getNormalCell(rowOutput,a['status']);
              getNormalCell(rowOutput,a['age']);
              getNormalCell(rowOutput,a['duration']);
              getNormalCell(rowOutput,a['host']);
              }
              table.replaceChild(tbody,table.tBodies[1] )
              });

              }
               </script>
          ----
          {noformat}

          h4. Solution

          [https://www.jenkins.io/doc/developer/security/csp/#inline-javascript-blocks]
          New: h4. Problem

          {noformat}
          == Inline Script Block
          Line: 45
          ----
          <script type="text/javascript">
              var summary = <st:bind value="${it}"/>
              var mode = "${mode}" =="true";
              function getLinkedCell(rowOutput, value, link){
               var cellOutput = rowOutput.insertCell(-1)
               cellOutput.class="pane"

                var a= document.createElement("a");
                a.href = link;
                a.class="model-link inside"
                var result = document.createTextNode(value);
                a.appendChild(result);
                cellOutput.appendChild(a);

              }

              function getNormalCell2(rowOutput, a , align){
              var cellOutput = rowOutput.insertCell(-1)
              cellOutput.class="pane"
              cellOutput.style.textAlign = align
               var result = document.createTextNode(a);
          cellOutput.appendChild(result);

              }
              function getNormalCell(rowOutput, a) {
               getNormalCell2(rowOutput, a, "center");
              }
              function getSummary(time){
               document.getElementById("summary-table").style.display="";
               document.getElementById("summary-table-header").style.display="";
          var tbody = document.createElement("tbody");

              summary.getActions(time,function(t) {
              var actions = t.responseObject();
              var emptyCell= {content:"--", tooltip:""};
              var table = document.getElementById("summary-table");

               document.getElementById("summary-table-header").innerHTML="&lt;h2&gt;Summary at time "+actions[0]+"&lt;//h2&gt;";
              for( i=1; i&lt; actions.length; i++) {
              if(!mode &amp;&amp; !actions[i].hasOwnProperty('testname') )
              continue;

          var rowOutput = tbody.insertRow(-1);
              var a = actions[i]
              if (mode){
              getLinkedCell(rowOutput,a['action'], a['url']);
              }

              if (a.hasOwnProperty('testname')){
          rowOutput.class="test-row"
              getLinkedCell(rowOutput,a['testname'], a['testurl']);
          } else {

              getNormalCell2(rowOutput,"--", "left");
          rowOutput.class="action-row"
          }

              getNormalCell(rowOutput,a['status']);
              getNormalCell(rowOutput,a['age']);
              getNormalCell(rowOutput,a['duration']);
              getNormalCell(rowOutput,a['host']);
              }
              table.replaceChild(tbody,table.tBodies[1] )
              });

              }
               </script>
          ----
          {noformat}

          h4. Solution

          [https://www.jenkins.io/doc/developer/security/csp/#inline-javascript-blocks]
          Summary Original: [mentor-questa-vrm] Extract inline script blocks in com/mentor/questa/vrm/jenkins/QuestaVrmHostAction/summarytable.jelly New: [mentor-questa-vrm] Extract inline script block in com/mentor/questa/vrm/jenkins/QuestaVrmHostAction/summarytable.jelly

            Unassigned Unassigned
            basil Basil Crow
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: