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

[mentor-questa-vrm] Extract inline script block and event handler in com/mentor/questa/vrm/jenkins/QuestaVrmRegressionProjectAction/table.jelly

XMLWordPrintable

      Problems

      == Inline Script Block
      Line: 63
      ----
      <script>
          var summary = <st:bind value="${it}"/>
      
          function getBuildCell(cellOutput, row){
           cellOutput.class="pane"
           cellOutput.title = row[0]['tooltip']
            var id= row[0]['content'];
      
            if(row.length>9) {
              var show = document.createElement("a");
              show.id= id+"-showlink";
              show.href = "javascript:showCoverageDetails(\'"+id+"\')";
              show.title = "Show Details";
              var icon =document.createElement("img");
              icon.src = "${imagesURL}/16x16/document_add.png";
      	icon.class="icon-document-add icon-sm";
      	icon.style="width: 16 px; height: 16px;"
      	show.appendChild(icon);
      	cellOutput.appendChild(show)
      
              var hide = document.createElement("a");
              hide.id= id+"-hidelink";
              hide.href = "javascript:hideCoverageDetails(\'"+id+"\')";
              hide.title = "Hide Details";
              hide.style.display = "none";
              icon =document.createElement("img");
              icon.src = "${imagesURL}/16x16/document_delete.png";
      	icon.class="icon-document-delete icon-sm";
      	icon.style="width: 16 px; height: 16px;"
      	hide.appendChild(icon);
      	cellOutput.appendChild(hide)
            }
      
            var  a= document.createElement("a");
            a.href = "${rootURL}/"+row[0]['url'].valueOf();
      
            var img = document.createElement("img");
            img.src = "${imagesURL}/16x16/"+row[0]['imgSrc'].valueOf();
            a.appendChild(img);
      
            var result = document.createTextNode(row[0]['content']);
            a.appendChild(result);
      
            cellOutput.appendChild(a);
      
          }
      
          function getNormalCell(cellOutput, r){
      
         	cellOutput.class="pane"
         	cellOutput.style.textAlign = "center"
         	cellOutput.title = r['tooltip']
          	var result = document.createTextNode(r['content']);
      	cellOutput.appendChild(result);
      
          }
          function getData(){
         	 summary.getJSONData(function(t) {
         	 	var rows = t.responseObject();
         	 	var emptyCell= {content:"--", tooltip:""};
         	 	var table = document.getElementById("coverageSum");
         	 	var tbody = document.createElement("tbody");
         	 	for( i=0; i&lt; rows.length; i++) {
            			var id= rows[i][0]['content']; 
         	 		var tbody = document.createElement("tbody");
         	 		tbody.class="pane"
         	 		tbody.style.display="";
         	 		var rowOutput = tbody.insertRow(-1);
         	 		var cellOutput = rowOutput.insertCell(-1)
         	 		getBuildCell(cellOutput, rows[i]);
      			var j = 1;
         	 		for (; j &lt; 9 ; j++) {
         	 			cellOutput = rowOutput.insertCell(-1);
         	 			getNormalCell(cellOutput, rows[i][j]);
         	 		}
         	 		table.appendChild(tbody);
      			if (rows[i].length &gt; 9) {
         	 			tbody = document.createElement("tbody");
      				tbody.class = "pane";
      				tbody.id = id;
      				tbody.style.display="none";
      
      				for (;j&lt; rows[i].length; j=j+8) {
         	 			  var rowOutput = tbody.insertRow(-1);
         	 			  cellOutput = rowOutput.insertCell(-1);
         	 			  getNormalCell(cellOutput, rows[i][j]);
         	 			  cellOutput.style= "text-align:right;";
      
         	 			  cellOutput = rowOutput.insertCell(-1);
      				  getNormalCell(cellOutput, emptyCell);
      				  for(k=1; k&lt; 8; k++){
         	 			    cellOutput = rowOutput.insertCell(-1);
      				    getNormalCell(cellOutput, rows[i][j+k]);
      				  }
      
         	 			}
         	 			table.appendChild(tbody);
      
      			}
         	 	}
      
         	 });
         	summary.hasMore(function(t) {
         	 	if( !t.responseObject()){
      			document.getElementById("more-link").style.display= "none";
      		}
      	});
      	 
          }
        </script>
      ----
      
      == Inline Event Handler
      Line: 59
      ----
      <a  onclick="getData()" href="javascript:void(0);">
      ----
      

      Solutions

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

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

              Created:
              Updated: