github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/dashboard/app/static/coverage.js (about)

     1  // Copyright 2024 syzkaller project authors. All rights reserved.
     2  // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  $(document).ready(initTogglers);
     5  $(document).ready(initUpdateForm);
     6  
     7  // Initializes the file tree onClick collapse logic.
     8  function initTogglers(){
     9    $(".caret").on("click", function() {
    10      $(this).toggleClass("caret-down");
    11      $(this).closest("li").find(".nested").first().toggleClass("active");
    12    });
    13  }
    14  
    15  function initUpdateForm(){
    16    $('#target-manager').change(function() {
    17      if ($(this).val() === '') { // selected "*"
    18        $("#unique-only").prop("checked", false);
    19        $('#unique-only').prop('disabled', true);
    20      } else {
    21        $('#unique-only').prop('disabled', false);
    22      }
    23    });
    24  
    25    var curUrlParams = new URLSearchParams(window.location.search);
    26    $('#target-period').val(curUrlParams.get('period'));
    27    if (curUrlParams.get('period_count') != null) {
    28      $('#target-period-count').val(curUrlParams.get('period_count'));
    29    }
    30    $('#target-subsystem').val(curUrlParams.get('subsystem'));
    31    $('#target-manager').val(curUrlParams.get('manager'));
    32    $("#unique-only").prop("checked", curUrlParams.get('unique-only') == "1");
    33    $('#unique-only').prop('disabled', $('#target-manager').val() == '');
    34  }
    35  
    36  // This handler is called when user clicks on the coverage percentage.
    37  // It downloads the kernel file coverage html block and adjust page to show it.
    38  // "#file-content-prev" and "#file-content-curr" are the file content <div>s.
    39  // "#file-details-prev" and "#file-details-curr" are the corresponding <div>s used to show per-file details.
    40  function onShowFileContent(url) {
    41    var curUrlParams = new URLSearchParams(window.location.search);
    42    url += '&subsystem=' + (curUrlParams.get('subsystem') || "")
    43    url += '&manager=' + (curUrlParams.get('manager') || "")
    44    url += '&unique-only=' + (curUrlParams.get('unique-only') || "")
    45  
    46    $.get(url, function(response) {
    47      $("#file-content-prev").html($("#file-content-curr").html());
    48      $("#file-content-curr").html(response);
    49  
    50      $("#file-details-prev").html($("#file-details-curr").html());
    51      // It looks hacky but costs nothing. Let's show all the url parameters as a source description.
    52      details = url.split("?")[1].split("&");
    53      $("#file-details-curr").html("Source information:\n" + details.join("\n"));
    54    });
    55  }