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

[svn-partial-release-mgr] Extract inline script block and event handlers in hudson/plugins/svn_partial_release_mgr/ui/ProjectReleaseAction/index.jelly

XMLWordPrintable

      Problems

      == Inline Script Block
      Line: 8
      ----
      <script>
                      //<![CDATA[
              function CA(form, checkboxName) {
                  var cb = form.elements[checkboxName];
                  for (var i = 0; i < form.elements.length; i++) {
                      if (!form.elements[i].type == "checkbox")
                          continue;
                      if (! ( form.elements[i].name == 'includeInPatch' || form.elements[i].name == 'issue'))
                          continue;
                      form.elements[i].checked = cb.checked;
                  }
              }
      
              function checkIssueRevisions(chBox, revisionIds) {
                  var revisionIdArray = revisionIds.split(',');
                  var isChecked = chBox.checked;
                  var f = chBox.form;
                  for (i = 0; i < f.elements.length; i++) {
                      if (f.elements[i].type == 'checkbox'
                              && f.elements[i].name == 'includeInPatch') {
                         if (isIncluded(f.elements[i].value,revisionIdArray)){
                             f.elements[i].checked = isChecked;
                         }
                      }
                  }
              }
      
              function isIncluded(chckValue,revisionIdArray){
                  for(var i=0; i < revisionIdArray.length; i++){
                      if( revisionIdArray[i] == chckValue ){
                          return true;
                      }
                  }
                  return false;
              }
      
      
               function validateForPatch(b)
               {
                  count = 0
                  f = b.form
                  for (i = 0 ; i < f.elements.length ; i++)
                  if (f.elements[i].type == 'checkbox' &&
                      f.elements[i].name == 'includeInPatch' &&
                      f.elements[i].checked)
                  {
                     count += 1
                  }
      
                  if (count < 1)
                  {
                  	alert("At least 1 revision is required to be checked.");
                  } else {
                  	f.submit();
                  }
               }
      
               function showHideImg(id , imgopen , imgclose ){
                  if (document.getElementById(id).style.display == 'table-row'){
                      document.getElementById(id).style.display = 'none';
                      document.getElementById(id + "_image").src = '${resURL}/plugin/svn-partial-release-mgr/images/'+imgopen;
                  }
                  else {
                     document.getElementById(id).style.display = 'table-row';
                     document.getElementById(id + "_image").src = '${resURL}/plugin/svn-partial-release-mgr/images/'+imgclose;
                  }
               }
               //]]>
                  </script>
      ----
      
      == Inline Event Handler
      Line: 92
      ----
      <input name="all_issues" type="checkbox"
                                                         checked="checked" style="border:0"
                                                          onClick="CA(this.form, 'all_issues');"/>
      ----
      
      == Inline Event Handler
      Line: 108
      ----
      <input type="checkbox" checked="checked" name="issue"
                                                                              onClick="checkIssueRevisions(this,'${i.revisionsArray}')"/>
      ----
      
      == Inline Event Handler
      Line: 125
      ----
      <input type="button"
                                         onClick="validateForPatch(this)" value="Release Version" class="compare-button"/>
      ----
      

      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: