Source file src/cmd/vendor/github.com/google/pprof/internal/report/source_html.go

     1  // Copyright 2014 Google Inc. All Rights Reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package report
    16  
    17  import (
    18  	"html/template"
    19  )
    20  
    21  // AddSourceTemplates adds templates used by PrintWebList to t.
    22  func AddSourceTemplates(t *template.Template) {
    23  	template.Must(t.Parse(`{{define "weblistcss"}}` + weblistPageCSS + `{{end}}`))
    24  	template.Must(t.Parse(`{{define "weblistjs"}}` + weblistPageScript + `{{end}}`))
    25  }
    26  
    27  const weblistPageCSS = `<style type="text/css">
    28  body #content{
    29  font-family: sans-serif;
    30  }
    31  h1 {
    32    font-size: 1.5em;
    33  }
    34  .legend {
    35    font-size: 1.25em;
    36  }
    37  .line, .nop, .unimportant {
    38    color: #aaaaaa;
    39  }
    40  .inlinesrc {
    41    color: #000066;
    42  }
    43  .livesrc {
    44  cursor: pointer;
    45  }
    46  .livesrc:hover {
    47  background-color: #eeeeee;
    48  }
    49  .asm {
    50  color: #008800;
    51  display: none;
    52  }
    53  </style>`
    54  
    55  const weblistPageScript = `<script type="text/javascript">
    56  function pprof_toggle_asm(e) {
    57    var target;
    58    if (!e) e = window.event;
    59    if (e.target) target = e.target;
    60    else if (e.srcElement) target = e.srcElement;
    61  
    62    if (target) {
    63      var asm = target.nextSibling;
    64      if (asm && asm.className == "asm") {
    65        asm.style.display = (asm.style.display == "block" ? "" : "block");
    66        e.preventDefault();
    67        return false;
    68      }
    69    }
    70  }
    71  </script>`
    72  
    73  const weblistPageClosing = `
    74  </body>
    75  </html>`
    76  

View as plain text